ported battle_controllers from pokeem
This commit is contained in:
@@ -249,7 +249,7 @@ static const u16 sDiscouragedPowerfulMoveEffects[] =
|
||||
};
|
||||
|
||||
// TODO: move these
|
||||
extern u8 sBattler_AI;
|
||||
extern u8 gBattlerAttacker;
|
||||
extern const u32 gBitTable[]; // util.h
|
||||
extern u32 gStatuses3[]; // battle_2.h
|
||||
extern u16 gSideAffecting[2];
|
||||
@@ -318,7 +318,7 @@ void BattleAI_SetupAIData(void)
|
||||
}
|
||||
|
||||
gBattleResources->AI_ScriptsStack->size = 0;
|
||||
sBattler_AI = gActiveBattler;
|
||||
gBattlerAttacker = gActiveBattler;
|
||||
|
||||
// Decide a random target battlerId in doubles.
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
@@ -331,7 +331,7 @@ void BattleAI_SetupAIData(void)
|
||||
// There's only one choice in single battles.
|
||||
else
|
||||
{
|
||||
gBattlerTarget = sBattler_AI ^ BIT_SIDE;
|
||||
gBattlerTarget = gBattlerAttacker ^ BIT_SIDE;
|
||||
}
|
||||
|
||||
// Choose proper trainer ai scripts.
|
||||
@@ -425,13 +425,13 @@ void BattleAI_DoAIProcessing(void)
|
||||
break;
|
||||
case AIState_SettingUp:
|
||||
gAIScriptPtr = BattleAIs[AI_THINKING_STRUCT->aiLogicId]; // set the AI ptr.
|
||||
if (gBattleMons[sBattler_AI].pp[AI_THINKING_STRUCT->movesetIndex] == 0)
|
||||
if (gBattleMons[gBattlerAttacker].pp[AI_THINKING_STRUCT->movesetIndex] == 0)
|
||||
{
|
||||
AI_THINKING_STRUCT->moveConsidered = 0; // don't consider a move you have 0 PP for, idiot.
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_THINKING_STRUCT->moveConsidered = gBattleMons[sBattler_AI].moves[AI_THINKING_STRUCT->movesetIndex];
|
||||
AI_THINKING_STRUCT->moveConsidered = gBattleMons[gBattlerAttacker].moves[AI_THINKING_STRUCT->movesetIndex];
|
||||
}
|
||||
AI_THINKING_STRUCT->aiState++;
|
||||
break;
|
||||
@@ -544,7 +544,7 @@ static void BattleAICmd_if_hp_less_than(void)
|
||||
u16 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -559,7 +559,7 @@ static void BattleAICmd_if_hp_more_than(void)
|
||||
u16 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -574,7 +574,7 @@ static void BattleAICmd_if_hp_equal(void)
|
||||
u16 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -589,7 +589,7 @@ static void BattleAICmd_if_hp_not_equal(void)
|
||||
u16 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -605,7 +605,7 @@ static void BattleAICmd_if_status(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -623,7 +623,7 @@ static void BattleAICmd_if_not_status(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -641,7 +641,7 @@ static void BattleAICmd_if_status2(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -659,7 +659,7 @@ static void BattleAICmd_if_not_status2(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -677,7 +677,7 @@ static void BattleAICmd_if_status3(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -695,7 +695,7 @@ static void BattleAICmd_if_not_status3(void)
|
||||
u32 arg;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -713,7 +713,7 @@ static void BattleAICmd_if_status4(void)
|
||||
u32 arg1, arg2;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -732,7 +732,7 @@ static void BattleAICmd_if_not_status4(void)
|
||||
u32 arg1, arg2;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -907,8 +907,8 @@ static void BattleAICmd_if_user_can_damage(void)
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0
|
||||
&& gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0)
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0
|
||||
&& gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].power != 0)
|
||||
break;
|
||||
}
|
||||
if (i == MAX_MON_MOVES)
|
||||
@@ -923,8 +923,8 @@ static void BattleAICmd_if_user_cant_damage(void)
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0
|
||||
&& gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0)
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0
|
||||
&& gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].power != 0)
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -944,13 +944,13 @@ static void BattleAICmd_get_type(void)
|
||||
switch (gAIScriptPtr[1])
|
||||
{
|
||||
case 1: // player primary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type1;
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerAttacker].type1;
|
||||
break;
|
||||
case 0: // enemy primary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type1;
|
||||
break;
|
||||
case 3: // player secondary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type2;
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerAttacker].type2;
|
||||
break;
|
||||
case 2: // enemy secondary type
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type2;
|
||||
@@ -992,17 +992,17 @@ static void BattleAICmd_is_most_powerful_move(void)
|
||||
{
|
||||
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++)
|
||||
{
|
||||
if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
|
||||
if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
|
||||
break;
|
||||
}
|
||||
|
||||
if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE
|
||||
if (gBattleMons[gBattlerAttacker].moves[checkedMove] != MOVE_NONE
|
||||
&& sDiscouragedPowerfulMoveEffects[i] == 0xFFFF
|
||||
&& gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1)
|
||||
&& gBattleMoves[gBattleMons[gBattlerAttacker].moves[checkedMove]].power > 1)
|
||||
{
|
||||
gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove];
|
||||
AI_CalcDmg(sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
gCurrentMove = gBattleMons[gBattlerAttacker].moves[checkedMove];
|
||||
AI_CalcDmg(gBattlerAttacker, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100;
|
||||
if (moveDmgs[checkedMove] == 0)
|
||||
moveDmgs[checkedMove] = 1;
|
||||
@@ -1035,7 +1035,7 @@ static void BattleAICmd_is_most_powerful_move(void)
|
||||
static void BattleAICmd_get_move(void)
|
||||
{
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMove[sBattler_AI];
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMove[gBattlerAttacker];
|
||||
else
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMove[gBattlerTarget];
|
||||
|
||||
@@ -1060,7 +1060,7 @@ static void BattleAICmd_if_arg_not_equal(void)
|
||||
|
||||
static void BattleAICmd_if_would_go_first(void)
|
||||
{
|
||||
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) == gAIScriptPtr[1])
|
||||
if (GetWhoStrikesFirst(gBattlerAttacker, gBattlerTarget, TRUE) == gAIScriptPtr[1])
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
else
|
||||
gAIScriptPtr += 6;
|
||||
@@ -1068,7 +1068,7 @@ static void BattleAICmd_if_would_go_first(void)
|
||||
|
||||
static void BattleAICmd_if_would_not_go_first(void)
|
||||
{
|
||||
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) != gAIScriptPtr[1])
|
||||
if (GetWhoStrikesFirst(gBattlerAttacker, gBattlerTarget, TRUE) != gAIScriptPtr[1])
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
else
|
||||
gAIScriptPtr += 6;
|
||||
@@ -1092,7 +1092,7 @@ static void BattleAICmd_count_alive_pokemon(void)
|
||||
AI_THINKING_STRUCT->funcResult = 0;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1145,7 +1145,7 @@ static void BattleAICmd_get_ability(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1218,11 +1218,11 @@ static void BattleAICmd_get_highest_possible_damage(void)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
gBattleMoveDamage = 40;
|
||||
gCurrentMove = gBattleMons[sBattler_AI].moves[i];
|
||||
gCurrentMove = gBattleMons[gBattlerAttacker].moves[i];
|
||||
|
||||
if (gCurrentMove != 0)
|
||||
{
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
if (gBattleMoveDamage == 120) // Super effective STAB.
|
||||
gBattleMoveDamage = AI_EFFECTIVENESS_x2;
|
||||
@@ -1257,7 +1257,7 @@ static void BattleAICmd_if_type_effectiveness(void)
|
||||
gBattleMoveDamage = AI_EFFECTIVENESS_x1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
if (gBattleMoveDamage == 120) // Super effective STAB.
|
||||
gBattleMoveDamage = AI_EFFECTIVENESS_x2;
|
||||
@@ -1402,7 +1402,7 @@ static void BattleAICmd_if_stat_level_less_than(void)
|
||||
u32 party;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
party = sBattler_AI;
|
||||
party = gBattlerAttacker;
|
||||
else
|
||||
party = gBattlerTarget;
|
||||
|
||||
@@ -1417,7 +1417,7 @@ static void BattleAICmd_if_stat_level_more_than(void)
|
||||
u32 party;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
party = sBattler_AI;
|
||||
party = gBattlerAttacker;
|
||||
else
|
||||
party = gBattlerTarget;
|
||||
|
||||
@@ -1432,7 +1432,7 @@ static void BattleAICmd_if_stat_level_equal(void)
|
||||
u32 party;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
party = sBattler_AI;
|
||||
party = gBattlerAttacker;
|
||||
else
|
||||
party = gBattlerTarget;
|
||||
|
||||
@@ -1447,7 +1447,7 @@ static void BattleAICmd_if_stat_level_not_equal(void)
|
||||
u32 party;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
party = sBattler_AI;
|
||||
party = gBattlerAttacker;
|
||||
else
|
||||
party = gBattlerTarget;
|
||||
|
||||
@@ -1471,8 +1471,8 @@ static void BattleAICmd_if_can_faint(void)
|
||||
gMoveResultFlags = 0;
|
||||
gCritMultiplier = 1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
AI_CalcDmg(sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
AI_CalcDmg(gBattlerAttacker, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
|
||||
|
||||
@@ -1500,8 +1500,8 @@ static void BattleAICmd_if_cant_faint(void)
|
||||
gMoveResultFlags = 0;
|
||||
gCritMultiplier = 1;
|
||||
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
|
||||
AI_CalcDmg(sBattler_AI, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
|
||||
AI_CalcDmg(gBattlerAttacker, gBattlerTarget);
|
||||
TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
|
||||
|
||||
@@ -1524,7 +1524,7 @@ static void BattleAICmd_if_has_move(void)
|
||||
case 3:
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] == *temp_ptr)
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] == *temp_ptr)
|
||||
break;
|
||||
}
|
||||
if (i == MAX_MON_MOVES)
|
||||
@@ -1558,7 +1558,7 @@ static void BattleAICmd_if_dont_have_move(void)
|
||||
case 3:
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] == *temp_ptr)
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] == *temp_ptr)
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -1591,7 +1591,7 @@ static void BattleAICmd_if_move_effect(void)
|
||||
case 3:
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2])
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0 && gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].effect == gAIScriptPtr[2])
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -1603,7 +1603,7 @@ static void BattleAICmd_if_move_effect(void)
|
||||
case 2:
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i]].effect == gAIScriptPtr[2])
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i]].effect == gAIScriptPtr[2])
|
||||
break;
|
||||
}
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
|
||||
@@ -1620,7 +1620,7 @@ static void BattleAICmd_if_not_move_effect(void)
|
||||
case 3:
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2])
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != 0 && gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].effect == gAIScriptPtr[2])
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -1644,7 +1644,7 @@ static void BattleAICmd_if_last_move_did_damage(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1739,7 +1739,7 @@ static void BattleAICmd_get_hold_effect(void)
|
||||
u16 side;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1759,7 +1759,7 @@ static void BattleAICmd_get_gender(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1773,7 +1773,7 @@ static void BattleAICmd_is_first_turn(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1787,7 +1787,7 @@ static void BattleAICmd_get_stockpile_count(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1808,7 +1808,7 @@ static void BattleAICmd_get_used_held_item(void)
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
battlerId = sBattler_AI;
|
||||
battlerId = gBattlerAttacker;
|
||||
else
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
@@ -1848,7 +1848,7 @@ static void BattleAICmd_get_protect_count(void)
|
||||
u8 index;
|
||||
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
index = sBattler_AI;
|
||||
index = gBattlerAttacker;
|
||||
else
|
||||
index = gBattlerTarget;
|
||||
|
||||
@@ -1903,7 +1903,7 @@ static void BattleAICmd_if_level_compare(void)
|
||||
switch (gAIScriptPtr[1])
|
||||
{
|
||||
case 0: // greater than
|
||||
if (gBattleMons[sBattler_AI].level > gBattleMons[gBattlerTarget].level)
|
||||
if (gBattleMons[gBattlerAttacker].level > gBattleMons[gBattlerTarget].level)
|
||||
{
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -1911,7 +1911,7 @@ static void BattleAICmd_if_level_compare(void)
|
||||
gAIScriptPtr += 6;
|
||||
return;
|
||||
case 1: // less than
|
||||
if (gBattleMons[sBattler_AI].level < gBattleMons[gBattlerTarget].level)
|
||||
if (gBattleMons[gBattlerAttacker].level < gBattleMons[gBattlerTarget].level)
|
||||
{
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
return;
|
||||
@@ -1919,7 +1919,7 @@ static void BattleAICmd_if_level_compare(void)
|
||||
gAIScriptPtr += 6;
|
||||
return;
|
||||
case 2: // equal
|
||||
if (gBattleMons[sBattler_AI].level == gBattleMons[gBattlerTarget].level)
|
||||
if (gBattleMons[gBattlerAttacker].level == gBattleMons[gBattlerTarget].level)
|
||||
{
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
|
||||
return;
|
||||
|
||||
@@ -176,16 +176,16 @@ static void HandleInputChooseAction(void)
|
||||
switch (gActionSelectionCursor[gActiveBattler])
|
||||
{
|
||||
case 0:
|
||||
EmitTwoReturnValues(1, B_ACTION_SAFARI_BALL, 0);
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_BALL, 0);
|
||||
break;
|
||||
case 1:
|
||||
EmitTwoReturnValues(1, B_ACTION_SAFARI_POKEBLOCK, 0);
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_POKEBLOCK, 0);
|
||||
break;
|
||||
case 2:
|
||||
EmitTwoReturnValues(1, B_ACTION_SAFARI_GO_NEAR, 0);
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_GO_NEAR, 0);
|
||||
break;
|
||||
case 3:
|
||||
EmitTwoReturnValues(1, B_ACTION_SAFARI_RUN, 0);
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_RUN, 0);
|
||||
break;
|
||||
}
|
||||
SafariBufferExecCompleted();
|
||||
@@ -276,7 +276,7 @@ static void CompleteWhenChosePokeblock(void)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
EmitOneReturnValue(1, gSpecialVar_ItemId);
|
||||
BtlController_EmitOneReturnValue(1, gSpecialVar_ItemId);
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -758,6 +758,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, u8 notTransform)
|
||||
void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite)
|
||||
{
|
||||
u8 position;
|
||||
// variable i is actually u8, but needs to be 32-bit to make the inline ASM match.
|
||||
s32 i;
|
||||
u32 palOffset;
|
||||
const void *substitutePal;
|
||||
|
||||
+4
-4
@@ -134,7 +134,7 @@ static void ResetTTDataBuffer(void)
|
||||
{
|
||||
memset(gDecompressionBuffer, 0, 0x2000);
|
||||
gLinkType = 0x5502;
|
||||
sub_8009804();
|
||||
OpenLink();
|
||||
SetSuppressLinkErrorMessage(TRUE);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ bool32 sub_81436EC(void)
|
||||
|
||||
static bool32 IsEReaderConnectionSane(void)
|
||||
{
|
||||
if (sub_800AA48() && GetLinkPlayerCount_2() == 2)
|
||||
if (IsLinkMaster() && GetLinkPlayerCount_2() == 2)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ u32 sub_8143770(u8 * r4, u16 * r5)
|
||||
switch (*r4)
|
||||
{
|
||||
case 0:
|
||||
if (sub_800AA48() && GetLinkPlayerCount_2() > 1)
|
||||
if (IsLinkMaster() && GetLinkPlayerCount_2() > 1)
|
||||
{
|
||||
*r4 = 1;
|
||||
;
|
||||
@@ -193,7 +193,7 @@ u32 sub_8143770(u8 * r4, u16 * r5)
|
||||
if (GetLinkPlayerCount_2() == 2)
|
||||
{
|
||||
PlaySE(SE_TOY_G);
|
||||
sub_800A5BC();
|
||||
CheckShouldAdvanceLinkState();
|
||||
*r5 = 0;
|
||||
*r4 = 3;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ static bool32 mevent_send_func(struct mevent_srv_sub * svr)
|
||||
switch (svr->seqno)
|
||||
{
|
||||
case 0:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
header.ident = svr->sendIdent;
|
||||
header.size = svr->sendSize;
|
||||
@@ -167,7 +167,7 @@ static bool32 mevent_send_func(struct mevent_srv_sub * svr)
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
if (mevent_has_received(svr->sendPlayerNo))
|
||||
{
|
||||
@@ -189,7 +189,7 @@ static bool32 mevent_send_func(struct mevent_srv_sub * svr)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
if (CalcCRC16WithTable(svr->sendBfr, svr->sendSize) != svr->sendCRC)
|
||||
sub_80FA190();
|
||||
|
||||
+5
-12
@@ -19,7 +19,6 @@
|
||||
#include "evolution_scene.h"
|
||||
#include "battle_message.h"
|
||||
#include "battle_util.h"
|
||||
#include "battle_ai_script_commands.h"
|
||||
#include "link.h"
|
||||
#include "m4a.h"
|
||||
#include "sound.h"
|
||||
@@ -2592,7 +2591,7 @@ u8 CountAliveMonsInBattle(u8 caseId)
|
||||
case BATTLE_ALIVE_ATK_SIDE:
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (GetBattlerSide(i) == GetBattlerSide(sBattler_AI) && !(gAbsentBattlerFlags & gBitTable[i]))
|
||||
if (GetBattlerSide(i) == GetBattlerSide(gBattlerAttacker) && !(gAbsentBattlerFlags & gBitTable[i]))
|
||||
retVal++;
|
||||
}
|
||||
break;
|
||||
@@ -6106,7 +6105,7 @@ const u8 *Battle_PrintStatBoosterEffectMessage(u16 itemId)
|
||||
}
|
||||
else
|
||||
{
|
||||
sBattler_AI = gBattlerInMenuId;
|
||||
gBattlerAttacker = gBattlerInMenuId;
|
||||
BattleStringExpandPlaceholdersToDisplayedString(BattleText_GetPumped);
|
||||
}
|
||||
}
|
||||
@@ -6114,7 +6113,7 @@ const u8 *Battle_PrintStatBoosterEffectMessage(u16 itemId)
|
||||
|
||||
if (itemEffect[3] & 0x80)
|
||||
{
|
||||
sBattler_AI = gBattlerInMenuId;
|
||||
gBattlerAttacker = gBattlerInMenuId;
|
||||
BattleStringExpandPlaceholdersToDisplayedString(BattleText_MistShroud);
|
||||
}
|
||||
|
||||
@@ -7075,15 +7074,9 @@ void BoxMonRestorePP(struct BoxPokemon *boxMon)
|
||||
}
|
||||
}
|
||||
|
||||
// SetMonPreventsSwitchingString
|
||||
void sub_8044348(void)
|
||||
void SetMonPreventsSwitchingString(void)
|
||||
{
|
||||
#ifdef NONMATCHING
|
||||
gLastUsedAbility = gBattleStruct -> abilityPreventingSwitchout; // fixed from the original
|
||||
#else
|
||||
gLastUsedAbility = ((u8 *) gBattleStruct)[0xac]; // huh? why is this wrong?
|
||||
#endif
|
||||
|
||||
gLastUsedAbility = gBattleStruct -> abilityPreventingSwitchout;
|
||||
gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN;
|
||||
gBattleTextBuff1[1] = B_BUFF_MON_NICK_WITH_PREFIX;
|
||||
gBattleTextBuff1[2] = gBattleStruct->battlerPreventingSwitchout;
|
||||
|
||||
@@ -26,7 +26,7 @@ void sub_812C334(s32 *, s32 *);
|
||||
|
||||
void sub_812BFDC(void)
|
||||
{
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_POKEDUDE)) && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT))
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_OLDMAN_TUTORIAL | BATTLE_TYPE_POKEDUDE)) && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT))
|
||||
{
|
||||
struct QuestLogStruct_TrainerBattleRecord * questLogTrainerBattleRecord = Alloc(sizeof(struct QuestLogStruct_TrainerBattleRecord));
|
||||
struct QuestLogStruct_WildBattleRecord * questLogWildBattleRecord = Alloc(sizeof(struct QuestLogStruct_WildBattleRecord));
|
||||
|
||||
+4
-4
@@ -68,7 +68,7 @@ const struct SaveSectionOffsets gSaveSectionOffsets[] =
|
||||
|
||||
extern void DoSaveFailedScreen(u8 saveType); // save_failed_screen
|
||||
extern void sub_800AB9C(void); // link
|
||||
extern bool8 sub_800A4BC(void); // link
|
||||
extern bool8 IsLinkTaskFinished(void); // link
|
||||
extern void save_serialize_map(void); // fieldmap
|
||||
extern void sub_804C1C0(void); // load_save
|
||||
extern void sav2_gender2_inplace_and_xFE(void); // load_save
|
||||
@@ -865,7 +865,7 @@ void sub_80DA634(u8 taskId)
|
||||
gTasks[taskId].data[0] = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
save_serialize_map();
|
||||
gTasks[taskId].data[0] = 3;
|
||||
@@ -899,7 +899,7 @@ void sub_80DA634(u8 taskId)
|
||||
gTasks[taskId].data[0] = 8;
|
||||
break;
|
||||
case 8:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
sub_80DA434();
|
||||
gTasks[taskId].data[0] = 9;
|
||||
@@ -910,7 +910,7 @@ void sub_80DA634(u8 taskId)
|
||||
gTasks[taskId].data[0] = 10;
|
||||
break;
|
||||
case 10:
|
||||
if (sub_800A4BC())
|
||||
if (IsLinkTaskFinished())
|
||||
gTasks[taskId].data[0]++;
|
||||
break;
|
||||
case 11:
|
||||
|
||||
Reference in New Issue
Block a user