rename bank to battler
This commit is contained in:
@@ -45,17 +45,17 @@ AI scripts.
|
||||
*/
|
||||
|
||||
extern u32 gBattleTypeFlags;
|
||||
extern u8 gActiveBank;
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern u8 gActiveBattler;
|
||||
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
|
||||
extern u16 gCurrentMove;
|
||||
extern u8 gBankDefender;
|
||||
extern u8 gAbsentBankFlags;
|
||||
extern u16 gLastMoves[BATTLE_BANKS_COUNT];
|
||||
extern u8 gBattleDefender;
|
||||
extern u8 gAbsentBattlerFlags;
|
||||
extern u16 gLastMoves[MAX_BATTLERS_COUNT];
|
||||
extern u16 gTrainerBattleOpponent_A;
|
||||
extern u16 gTrainerBattleOpponent_B;
|
||||
extern u32 gStatuses3[BATTLE_BANKS_COUNT];
|
||||
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
|
||||
extern u16 gSideStatuses[2];
|
||||
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
|
||||
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT];
|
||||
extern u16 gDynamicBasePower;
|
||||
extern u8 gMoveResultFlags;
|
||||
extern s32 gBattleMoveDamage;
|
||||
@@ -352,7 +352,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
|
||||
defaultScoreMoves >>= 1;
|
||||
}
|
||||
|
||||
moveLimitations = CheckMoveLimitations(gActiveBank, 0, 0xFF);
|
||||
moveLimitations = CheckMoveLimitations(gActiveBattler, 0, 0xFF);
|
||||
|
||||
// ignore moves that aren't possible to use
|
||||
for (i = 0; i < 4; i++)
|
||||
@@ -363,18 +363,18 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
|
||||
AI_THINKING_STRUCT->simulatedRNG[i] = 100 - (Random() % 16);
|
||||
}
|
||||
gBattleResources->AI_ScriptsStack->size = 0;
|
||||
sBank_AI = gActiveBank;
|
||||
sBank_AI = gActiveBattler;
|
||||
// decide a random target bank in doubles
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
gBankDefender = (Random() & BIT_MON) + (GetBankSide(gActiveBank) ^ BIT_SIDE);
|
||||
if (gAbsentBankFlags & gBitTable[gBankDefender])
|
||||
gBankDefender ^= BIT_MON;
|
||||
gBattleDefender = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE);
|
||||
if (gAbsentBattlerFlags & gBitTable[gBattleDefender])
|
||||
gBattleDefender ^= BIT_FLANK;
|
||||
}
|
||||
// in singles there's only one choice
|
||||
else
|
||||
{
|
||||
gBankDefender = sBank_AI ^ BIT_SIDE;
|
||||
gBattleDefender = sBank_AI ^ BIT_SIDE;
|
||||
}
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
|
||||
@@ -491,7 +491,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
|
||||
else
|
||||
BattleAI_SetupAIData(0xF);
|
||||
|
||||
gBankDefender = i;
|
||||
gBattleDefender = i;
|
||||
|
||||
if ((i & BIT_SIDE) != (sBank_AI & BIT_SIDE))
|
||||
RecordLastUsedMoveByTarget();
|
||||
@@ -542,7 +542,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
|
||||
bestMovePointsForTarget[i] = mostViableMovesScores[0];
|
||||
|
||||
// don't use a move against ally if it has less than 100 pts
|
||||
if (i == (sBank_AI ^ BIT_MON) && bestMovePointsForTarget[i] < 100)
|
||||
if (i == (sBank_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100)
|
||||
{
|
||||
bestMovePointsForTarget[i] = -1;
|
||||
mostViableMovesScores[0] = mostViableMovesScores[0]; // needed to match
|
||||
@@ -573,8 +573,8 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
|
||||
}
|
||||
}
|
||||
|
||||
gBankDefender = mostViableTargetsArray[Random() % mostViableTargetsNo];
|
||||
return actionOrMoveIndex[gBankDefender];
|
||||
gBattleDefender = mostViableTargetsArray[Random() % mostViableTargetsNo];
|
||||
return actionOrMoveIndex[gBattleDefender];
|
||||
}
|
||||
|
||||
static void BattleAI_DoAIProcessing(void)
|
||||
@@ -627,12 +627,12 @@ static void RecordLastUsedMoveByTarget(void)
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] == gLastMoves[gBankDefender])
|
||||
if (gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] == gLastMoves[gBattleDefender])
|
||||
break;
|
||||
if (gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] != gLastMoves[gBankDefender] // HACK: This redundant condition is a hack to make the asm match.
|
||||
&& gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] == 0)
|
||||
if (gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] != gLastMoves[gBattleDefender] // HACK: This redundant condition is a hack to make the asm match.
|
||||
&& gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] == 0)
|
||||
{
|
||||
gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] = gLastMoves[gBankDefender];
|
||||
gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] = gLastMoves[gBattleDefender];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -723,7 +723,7 @@ static void BattleAICmd_if_hp_less_than(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
@@ -738,7 +738,7 @@ static void BattleAICmd_if_hp_more_than(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
@@ -753,7 +753,7 @@ static void BattleAICmd_if_hp_equal(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
@@ -768,7 +768,7 @@ static void BattleAICmd_if_hp_not_equal(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
@@ -784,7 +784,7 @@ static void BattleAICmd_if_status(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@@ -802,7 +802,7 @@ static void BattleAICmd_if_not_status(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@@ -820,7 +820,7 @@ static void BattleAICmd_if_status2(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@@ -838,7 +838,7 @@ static void BattleAICmd_if_not_status2(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@@ -856,7 +856,7 @@ static void BattleAICmd_if_status3(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@@ -874,7 +874,7 @@ static void BattleAICmd_if_not_status3(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@@ -892,9 +892,9 @@ static void BattleAICmd_if_side_affecting(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
side = GET_BANK_SIDE(bank);
|
||||
side = GET_BATTLER_SIDE(bank);
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gSideStatuses[side] & status) != 0)
|
||||
@@ -911,9 +911,9 @@ static void BattleAICmd_if_not_side_affecting(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
side = GET_BANK_SIDE(bank);
|
||||
side = GET_BATTLER_SIDE(bank);
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gSideStatuses[side] & status) == 0)
|
||||
@@ -1126,13 +1126,13 @@ static void BattleAICmd_get_type(void)
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1;
|
||||
break;
|
||||
case AI_TYPE1_TARGET: // target primary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBankDefender].type1;
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleDefender].type1;
|
||||
break;
|
||||
case AI_TYPE2_USER: // AI user secondary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2;
|
||||
break;
|
||||
case AI_TYPE2_TARGET: // target secondary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBankDefender].type2;
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleDefender].type2;
|
||||
break;
|
||||
case AI_TYPE_MOVE: // type of move being pointed to
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type;
|
||||
@@ -1149,11 +1149,11 @@ static u8 BattleAI_GetWantedBank(u8 bank)
|
||||
return sBank_AI;
|
||||
case AI_TARGET:
|
||||
default:
|
||||
return gBankDefender;
|
||||
return gBattleDefender;
|
||||
case AI_USER_PARTNER:
|
||||
return sBank_AI ^ BIT_MON;
|
||||
return sBank_AI ^ BIT_FLANK;
|
||||
case AI_TARGET_PARTNER:
|
||||
return gBankDefender ^ BIT_MON;
|
||||
return gBattleDefender ^ BIT_FLANK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1212,8 +1212,8 @@ static void BattleAICmd_get_how_powerful_move_is(void)
|
||||
&& gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].power > 1)
|
||||
{
|
||||
gCurrentMove = gBattleMons[sBank_AI].moves[checkedMove];
|
||||
AI_CalcDmg(sBank_AI, gBankDefender);
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBankDefender);
|
||||
AI_CalcDmg(sBank_AI, gBattleDefender);
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender);
|
||||
moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100;
|
||||
if (moveDmgs[checkedMove] == 0)
|
||||
moveDmgs[checkedMove] = 1;
|
||||
@@ -1248,7 +1248,7 @@ static void BattleAICmd_get_last_used_bank_move(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI];
|
||||
else
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[gBankDefender];
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[gBattleDefender];
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
@@ -1271,7 +1271,7 @@ static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
|
||||
|
||||
static void BattleAICmd_if_user_goes(void)
|
||||
{
|
||||
if (GetWhoStrikesFirst(sBank_AI, gBankDefender, TRUE) == gAIScriptPtr[1])
|
||||
if (GetWhoStrikesFirst(sBank_AI, gBattleDefender, TRUE) == gAIScriptPtr[1])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
|
||||
else
|
||||
gAIScriptPtr += 6;
|
||||
@@ -1279,7 +1279,7 @@ static void BattleAICmd_if_user_goes(void)
|
||||
|
||||
static void BattleAICmd_if_user_doesnt_go(void)
|
||||
{
|
||||
if (GetWhoStrikesFirst(sBank_AI, gBankDefender, TRUE) != gAIScriptPtr[1])
|
||||
if (GetWhoStrikesFirst(sBank_AI, gBattleDefender, TRUE) != gAIScriptPtr[1])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
|
||||
else
|
||||
gAIScriptPtr += 6;
|
||||
@@ -1305,9 +1305,9 @@ static void BattleAICmd_count_usable_party_mons(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if (GetBankSide(bank) == SIDE_PLAYER)
|
||||
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
@@ -1316,8 +1316,8 @@ static void BattleAICmd_count_usable_party_mons(void)
|
||||
{
|
||||
u32 position;
|
||||
bankOnField1 = gBattlePartyID[bank];
|
||||
position = GetBankPosition(bank) ^ BIT_MON;
|
||||
bankOnField2 = gBattlePartyID[GetBankByPosition(position)];
|
||||
position = GetBattlerPosition(bank) ^ BIT_FLANK;
|
||||
bankOnField2 = gBattlePartyID[GetBattlerAtPosition(position)];
|
||||
}
|
||||
else // in singles there's only one bank by side
|
||||
{
|
||||
@@ -1358,9 +1358,9 @@ static void BattleAICmd_get_ability(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if (gActiveBank != bank)
|
||||
if (gActiveBattler != bank)
|
||||
{
|
||||
if (BATTLE_HISTORY->abilities[bank] != 0)
|
||||
{
|
||||
@@ -1493,7 +1493,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void)
|
||||
|
||||
if (gCurrentMove)
|
||||
{
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBankDefender);
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender);
|
||||
|
||||
// reduce by 1/3.
|
||||
if (gBattleMoveDamage == 120)
|
||||
@@ -1528,7 +1528,7 @@ static void BattleAICmd_if_type_effectiveness(void)
|
||||
gBattleMoveDamage = AI_EFFECTIVENESS_x1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBankDefender);
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender);
|
||||
|
||||
if (gBattleMoveDamage == 120)
|
||||
gBattleMoveDamage = AI_EFFECTIVENESS_x2;
|
||||
@@ -1572,11 +1572,11 @@ static void BattleAICmd_if_status_in_party(void)
|
||||
bank = sBank_AI;
|
||||
break;
|
||||
default:
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
break;
|
||||
}
|
||||
|
||||
party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
|
||||
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@@ -1609,11 +1609,11 @@ static void BattleAICmd_if_status_not_in_party(void)
|
||||
bank = sBank_AI;
|
||||
break;
|
||||
default:
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
break;
|
||||
}
|
||||
|
||||
party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
|
||||
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@@ -1669,7 +1669,7 @@ static void BattleAICmd_if_stat_level_less_than(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
|
||||
@@ -1684,7 +1684,7 @@ static void BattleAICmd_if_stat_level_more_than(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
|
||||
@@ -1699,7 +1699,7 @@ static void BattleAICmd_if_stat_level_equal(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
|
||||
@@ -1714,7 +1714,7 @@ static void BattleAICmd_if_stat_level_not_equal(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
|
||||
@@ -1736,8 +1736,8 @@ static void BattleAICmd_if_can_faint(void)
|
||||
gMoveResultFlags = 0;
|
||||
gCritMultiplier = 1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
AI_CalcDmg(sBank_AI, gBankDefender);
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBankDefender);
|
||||
AI_CalcDmg(sBank_AI, gBattleDefender);
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender);
|
||||
|
||||
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
|
||||
|
||||
@@ -1745,7 +1745,7 @@ static void BattleAICmd_if_can_faint(void)
|
||||
if (gBattleMoveDamage == 0)
|
||||
gBattleMoveDamage = 1;
|
||||
|
||||
if (gBattleMons[gBankDefender].hp <= gBattleMoveDamage)
|
||||
if (gBattleMons[gBattleDefender].hp <= gBattleMoveDamage)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
@@ -1765,14 +1765,14 @@ static void BattleAICmd_if_cant_faint(void)
|
||||
gMoveResultFlags = 0;
|
||||
gCritMultiplier = 1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
AI_CalcDmg(sBank_AI, gBankDefender);
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBankDefender);
|
||||
AI_CalcDmg(sBank_AI, gBattleDefender);
|
||||
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender);
|
||||
|
||||
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
|
||||
|
||||
// this macro is missing the damage 0 = 1 assumption.
|
||||
|
||||
if (gBattleMons[gBankDefender].hp > gBattleMoveDamage)
|
||||
if (gBattleMons[gBattleDefender].hp > gBattleMoveDamage)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
@@ -1802,7 +1802,7 @@ static void BattleAICmd_if_has_move(void)
|
||||
return;
|
||||
}
|
||||
case AI_USER_PARTNER:
|
||||
if (gBattleMons[sBank_AI ^ BIT_MON].hp == 0)
|
||||
if (gBattleMons[sBank_AI ^ BIT_FLANK].hp == 0)
|
||||
{
|
||||
gAIScriptPtr += 8;
|
||||
return;
|
||||
@@ -1811,7 +1811,7 @@ static void BattleAICmd_if_has_move(void)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gBattleMons[sBank_AI ^ BIT_MON].moves[i] == *movePtr)
|
||||
if (gBattleMons[sBank_AI ^ BIT_FLANK].moves[i] == *movePtr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1829,7 +1829,7 @@ static void BattleAICmd_if_has_move(void)
|
||||
case AI_TARGET_PARTNER:
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (BATTLE_HISTORY->usedMoves[gBankDefender].moves[i] == *movePtr)
|
||||
if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] == *movePtr)
|
||||
break;
|
||||
}
|
||||
if (i == 4)
|
||||
@@ -1873,7 +1873,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
|
||||
case AI_TARGET_PARTNER:
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (BATTLE_HISTORY->usedMoves[gBankDefender].moves[i] == *movePtr)
|
||||
if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] == *movePtr)
|
||||
break;
|
||||
}
|
||||
if (i != 4)
|
||||
@@ -1911,8 +1911,8 @@ static void BattleAICmd_if_has_move_with_effect(void)
|
||||
case AI_TARGET_PARTNER:
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
// UB: checks sBank_AI instead of gBankDefender
|
||||
if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankDefender].moves[i]].effect == gAIScriptPtr[2])
|
||||
// UB: checks sBank_AI instead of gBattleDefender
|
||||
if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i]].effect == gAIScriptPtr[2])
|
||||
break;
|
||||
}
|
||||
if (i == 4)
|
||||
@@ -1945,7 +1945,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
|
||||
case AI_TARGET_PARTNER:
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (BATTLE_HISTORY->usedMoves[gBankDefender].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankDefender].moves[i]].effect == gAIScriptPtr[2])
|
||||
if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i]].effect == gAIScriptPtr[2])
|
||||
break;
|
||||
}
|
||||
if (i != 4)
|
||||
@@ -1963,7 +1963,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if (gAIScriptPtr[2] == 0)
|
||||
{
|
||||
@@ -1993,7 +1993,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void)
|
||||
switch (gAIScriptPtr[1])
|
||||
{
|
||||
case 0:
|
||||
if (gDisableStructs[gActiveBank].disabledMove == AI_THINKING_STRUCT->moveConsidered)
|
||||
if (gDisableStructs[gActiveBattler].disabledMove == AI_THINKING_STRUCT->moveConsidered)
|
||||
{
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -2001,7 +2001,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void)
|
||||
gAIScriptPtr += 6;
|
||||
return;
|
||||
case 1:
|
||||
if (gDisableStructs[gActiveBank].encoredMove == AI_THINKING_STRUCT->moveConsidered)
|
||||
if (gDisableStructs[gActiveBattler].encoredMove == AI_THINKING_STRUCT->moveConsidered)
|
||||
{
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -2041,9 +2041,9 @@ static void BattleAICmd_get_hold_effect(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
if (gActiveBank != bank)
|
||||
if (gActiveBattler != bank)
|
||||
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]);
|
||||
else
|
||||
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[bank].item);
|
||||
@@ -2079,7 +2079,7 @@ static void BattleAICmd_get_gender(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality);
|
||||
|
||||
@@ -2093,7 +2093,7 @@ static void BattleAICmd_is_first_turn_for(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn;
|
||||
|
||||
@@ -2107,7 +2107,7 @@ static void BattleAICmd_get_stockpile_count(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter;
|
||||
|
||||
@@ -2128,7 +2128,7 @@ static void BattleAICmd_get_used_held_item(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
// This is likely a leftover from Ruby's code and its ugly ewram access
|
||||
#ifdef NONMATCHING
|
||||
@@ -2168,7 +2168,7 @@ static void BattleAICmd_get_protect_count(void)
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBank_AI;
|
||||
else
|
||||
bank = gBankDefender;
|
||||
bank = gBattleDefender;
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses;
|
||||
|
||||
@@ -2221,7 +2221,7 @@ static void BattleAICmd_if_level_cond(void)
|
||||
switch (gAIScriptPtr[1])
|
||||
{
|
||||
case 0: // greater than
|
||||
if (gBattleMons[sBank_AI].level > gBattleMons[gBankDefender].level)
|
||||
if (gBattleMons[sBank_AI].level > gBattleMons[gBattleDefender].level)
|
||||
{
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -2229,7 +2229,7 @@ static void BattleAICmd_if_level_cond(void)
|
||||
gAIScriptPtr += 6;
|
||||
return;
|
||||
case 1: // less than
|
||||
if (gBattleMons[sBank_AI].level < gBattleMons[gBankDefender].level)
|
||||
if (gBattleMons[sBank_AI].level < gBattleMons[gBattleDefender].level)
|
||||
{
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -2237,7 +2237,7 @@ static void BattleAICmd_if_level_cond(void)
|
||||
gAIScriptPtr += 6;
|
||||
return;
|
||||
case 2: // equal
|
||||
if (gBattleMons[sBank_AI].level == gBattleMons[gBankDefender].level)
|
||||
if (gBattleMons[sBank_AI].level == gBattleMons[gBattleDefender].level)
|
||||
{
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -2249,7 +2249,7 @@ static void BattleAICmd_if_level_cond(void)
|
||||
|
||||
static void BattleAICmd_if_target_taunted(void)
|
||||
{
|
||||
if (gDisableStructs[gBankDefender].tauntTimer1 != 0)
|
||||
if (gDisableStructs[gBattleDefender].tauntTimer1 != 0)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
@@ -2257,7 +2257,7 @@ static void BattleAICmd_if_target_taunted(void)
|
||||
|
||||
static void BattleAICmd_if_target_not_taunted(void)
|
||||
{
|
||||
if (gDisableStructs[gBankDefender].tauntTimer1 == 0)
|
||||
if (gDisableStructs[gBattleDefender].tauntTimer1 == 0)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
@@ -2265,7 +2265,7 @@ static void BattleAICmd_if_target_not_taunted(void)
|
||||
|
||||
static void BattleAICmd_if_target_is_ally(void)
|
||||
{
|
||||
if ((sBank_AI & BIT_SIDE) == (gBankDefender & BIT_SIDE))
|
||||
if ((sBank_AI & BIT_SIDE) == (gBattleDefender & BIT_SIDE))
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
|
||||
Reference in New Issue
Block a user