mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 15:13:42 +01:00
match two functions
This commit is contained in:
parent
5162393c16
commit
305a4fa744
@ -92,6 +92,6 @@
|
||||
#define ATK48_STAT_NEGATIVE 0x1
|
||||
#define ATK48_STAT_BY_TWO 0x2
|
||||
#define ATK48_BIT_x4 0x4
|
||||
#define ATK48_LOWER_FAIL_CHECK 0x8
|
||||
#define ATK48_DONT_CHECK_LOWER 0x8
|
||||
|
||||
#endif // GUARD_CONSTANTS_BATTLE_SCRIPT_COMMANDS_H
|
||||
|
@ -346,7 +346,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
|
||||
}
|
||||
gBattleResources->AI_ScriptsStack->size = 0;
|
||||
sBattler_AI = gActiveBattler;
|
||||
// decide a random target bank in doubles
|
||||
// decide a random target battlerId in doubles
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
gBattlerTarget = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE);
|
||||
@ -620,32 +620,32 @@ static void RecordLastUsedMoveByTarget(void)
|
||||
}
|
||||
}
|
||||
|
||||
void ClearBattlerMoveHistory(u8 bank)
|
||||
void ClearBattlerMoveHistory(u8 battlerId)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
gBattleResources->battleHistory->usedMoves[bank].moves[i] = 0;
|
||||
gBattleResources->battleHistory->usedMoves[battlerId].moves[i] = 0;
|
||||
}
|
||||
|
||||
void RecordAbilityBattle(u8 bank, u8 abilityId)
|
||||
void RecordAbilityBattle(u8 battlerId, u8 abilityId)
|
||||
{
|
||||
gBattleResources->battleHistory->abilities[bank] = abilityId;
|
||||
gBattleResources->battleHistory->abilities[battlerId] = abilityId;
|
||||
}
|
||||
|
||||
void ClearBattlerAbilityHistory(u8 bank)
|
||||
void ClearBattlerAbilityHistory(u8 battlerId)
|
||||
{
|
||||
gBattleResources->battleHistory->abilities[bank] = 0;
|
||||
gBattleResources->battleHistory->abilities[battlerId] = 0;
|
||||
}
|
||||
|
||||
void RecordItemEffectBattle(u8 bank, u8 itemEffect)
|
||||
void RecordItemEffectBattle(u8 battlerId, u8 itemEffect)
|
||||
{
|
||||
gBattleResources->battleHistory->itemEffects[bank] = itemEffect;
|
||||
gBattleResources->battleHistory->itemEffects[battlerId] = itemEffect;
|
||||
}
|
||||
|
||||
void ClearBankItemEffectHistory(u8 bank)
|
||||
void ClearBankItemEffectHistory(u8 battlerId)
|
||||
{
|
||||
gBattleResources->battleHistory->itemEffects[bank] = 0;
|
||||
gBattleResources->battleHistory->itemEffects[battlerId] = 0;
|
||||
}
|
||||
|
||||
static void BattleAICmd_if_random_less_than(void)
|
||||
@ -700,14 +700,14 @@ static void BattleAICmd_score(void)
|
||||
|
||||
static void BattleAICmd_if_hp_less_than(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2])
|
||||
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) < gAIScriptPtr[2])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
else
|
||||
gAIScriptPtr += 7;
|
||||
@ -715,14 +715,14 @@ static void BattleAICmd_if_hp_less_than(void)
|
||||
|
||||
static void BattleAICmd_if_hp_more_than(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2])
|
||||
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) > gAIScriptPtr[2])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
else
|
||||
gAIScriptPtr += 7;
|
||||
@ -730,14 +730,14 @@ static void BattleAICmd_if_hp_more_than(void)
|
||||
|
||||
static void BattleAICmd_if_hp_equal(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2])
|
||||
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) == gAIScriptPtr[2])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
else
|
||||
gAIScriptPtr += 7;
|
||||
@ -745,14 +745,14 @@ static void BattleAICmd_if_hp_equal(void)
|
||||
|
||||
static void BattleAICmd_if_hp_not_equal(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2])
|
||||
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) != gAIScriptPtr[2])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
else
|
||||
gAIScriptPtr += 7;
|
||||
@ -760,17 +760,17 @@ static void BattleAICmd_if_hp_not_equal(void)
|
||||
|
||||
static void BattleAICmd_if_status(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
u32 status;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gBattleMons[bank].status1 & status) != 0)
|
||||
if ((gBattleMons[battlerId].status1 & status) != 0)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
|
||||
else
|
||||
gAIScriptPtr += 10;
|
||||
@ -778,17 +778,17 @@ static void BattleAICmd_if_status(void)
|
||||
|
||||
static void BattleAICmd_if_not_status(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
u32 status;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gBattleMons[bank].status1 & status) == 0)
|
||||
if ((gBattleMons[battlerId].status1 & status) == 0)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
|
||||
else
|
||||
gAIScriptPtr += 10;
|
||||
@ -796,17 +796,17 @@ static void BattleAICmd_if_not_status(void)
|
||||
|
||||
static void BattleAICmd_if_status2(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
u32 status;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gBattleMons[bank].status2 & status) != 0)
|
||||
if ((gBattleMons[battlerId].status2 & status) != 0)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
|
||||
else
|
||||
gAIScriptPtr += 10;
|
||||
@ -814,17 +814,17 @@ static void BattleAICmd_if_status2(void)
|
||||
|
||||
static void BattleAICmd_if_not_status2(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
u32 status;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gBattleMons[bank].status2 & status) == 0)
|
||||
if ((gBattleMons[battlerId].status2 & status) == 0)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
|
||||
else
|
||||
gAIScriptPtr += 10;
|
||||
@ -832,17 +832,17 @@ static void BattleAICmd_if_not_status2(void)
|
||||
|
||||
static void BattleAICmd_if_status3(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
u32 status;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gStatuses3[bank] & status) != 0)
|
||||
if ((gStatuses3[battlerId] & status) != 0)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
|
||||
else
|
||||
gAIScriptPtr += 10;
|
||||
@ -850,17 +850,17 @@ static void BattleAICmd_if_status3(void)
|
||||
|
||||
static void BattleAICmd_if_not_status3(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
u32 status;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gStatuses3[bank] & status) == 0)
|
||||
if ((gStatuses3[battlerId] & status) == 0)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
|
||||
else
|
||||
gAIScriptPtr += 10;
|
||||
@ -868,15 +868,15 @@ static void BattleAICmd_if_not_status3(void)
|
||||
|
||||
static void BattleAICmd_if_side_affecting(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
u32 side, status;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
side = GET_BATTLER_SIDE(bank);
|
||||
side = GET_BATTLER_SIDE(battlerId);
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gSideStatuses[side] & status) != 0)
|
||||
@ -887,15 +887,15 @@ static void BattleAICmd_if_side_affecting(void)
|
||||
|
||||
static void BattleAICmd_if_not_side_affecting(void)
|
||||
{
|
||||
u16 bank;
|
||||
u16 battlerId;
|
||||
u32 side, status;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
side = GET_BATTLER_SIDE(bank);
|
||||
side = GET_BATTLER_SIDE(battlerId);
|
||||
status = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
if ((gSideStatuses[side] & status) == 0)
|
||||
@ -1123,9 +1123,9 @@ static void BattleAICmd_get_type(void)
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
static u8 BattleAI_GetWantedBank(u8 bank)
|
||||
static u8 BattleAI_GetWantedBank(u8 battlerId)
|
||||
{
|
||||
switch (bank)
|
||||
switch (battlerId)
|
||||
{
|
||||
case AI_USER:
|
||||
return sBattler_AI;
|
||||
@ -1141,9 +1141,9 @@ static u8 BattleAI_GetWantedBank(u8 bank)
|
||||
|
||||
static void BattleAICmd_is_of_type(void)
|
||||
{
|
||||
u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
|
||||
u8 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
|
||||
|
||||
if(gBattleMons[bank].type1 == gAIScriptPtr[2] || gBattleMons[bank].type2 == gAIScriptPtr[2])
|
||||
if(gBattleMons[battlerId].type1 == gAIScriptPtr[2] || gBattleMons[battlerId].type2 == gAIScriptPtr[2])
|
||||
{
|
||||
AI_THINKING_STRUCT->funcResult = TRUE;
|
||||
}
|
||||
@ -1277,7 +1277,7 @@ static void BattleAICmd_nullsub_2B(void)
|
||||
|
||||
static void BattleAICmd_count_usable_party_mons(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
u8 bankOnField1, bankOnField2;
|
||||
struct Pokemon *party;
|
||||
int i;
|
||||
@ -1285,11 +1285,11 @@ static void BattleAICmd_count_usable_party_mons(void)
|
||||
AI_THINKING_STRUCT->funcResult = 0;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
|
||||
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
@ -1297,14 +1297,14 @@ static void BattleAICmd_count_usable_party_mons(void)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
u32 position;
|
||||
bankOnField1 = gBattlerPartyIndexes[bank];
|
||||
position = GetBattlerPosition(bank) ^ BIT_FLANK;
|
||||
bankOnField1 = gBattlerPartyIndexes[battlerId];
|
||||
position = GetBattlerPosition(battlerId) ^ BIT_FLANK;
|
||||
bankOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(position)];
|
||||
}
|
||||
else // in singles there's only one bank by side
|
||||
else // in singles there's only one battlerId by side
|
||||
{
|
||||
bankOnField1 = gBattlerPartyIndexes[bank];
|
||||
bankOnField2 = gBattlerPartyIndexes[bank];
|
||||
bankOnField1 = gBattlerPartyIndexes[battlerId];
|
||||
bankOnField2 = gBattlerPartyIndexes[battlerId];
|
||||
}
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
@ -1335,110 +1335,110 @@ static void BattleAICmd_get_considered_move_effect(void)
|
||||
|
||||
static void BattleAICmd_get_ability(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if (gActiveBattler != bank)
|
||||
if (gActiveBattler != battlerId)
|
||||
{
|
||||
if (BATTLE_HISTORY->abilities[bank] != 0)
|
||||
if (BATTLE_HISTORY->abilities[battlerId] != 0)
|
||||
{
|
||||
AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[bank];
|
||||
AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[battlerId];
|
||||
gAIScriptPtr += 2;
|
||||
return;
|
||||
}
|
||||
|
||||
// abilities that prevent fleeing.
|
||||
if (gBattleMons[bank].ability == ABILITY_SHADOW_TAG
|
||||
|| gBattleMons[bank].ability == ABILITY_MAGNET_PULL
|
||||
|| gBattleMons[bank].ability == ABILITY_ARENA_TRAP)
|
||||
if (gBattleMons[battlerId].ability == ABILITY_SHADOW_TAG
|
||||
|| gBattleMons[battlerId].ability == ABILITY_MAGNET_PULL
|
||||
|| gBattleMons[battlerId].ability == ABILITY_ARENA_TRAP)
|
||||
{
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[bank].ability;
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[battlerId].ability;
|
||||
gAIScriptPtr += 2;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gBaseStats[gBattleMons[bank].species].ability1 != ABILITY_NONE)
|
||||
if (gBaseStats[gBattleMons[battlerId].species].ability1 != ABILITY_NONE)
|
||||
{
|
||||
if (gBaseStats[gBattleMons[bank].species].ability2 != ABILITY_NONE)
|
||||
if (gBaseStats[gBattleMons[battlerId].species].ability2 != ABILITY_NONE)
|
||||
{
|
||||
// AI has no knowledge of opponent, so it guesses which ability.
|
||||
if (Random() & 1)
|
||||
{
|
||||
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability1;
|
||||
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability1;
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability2;
|
||||
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability1; // it's definitely ability 1.
|
||||
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability1; // it's definitely ability 1.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[bank].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
|
||||
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The AI knows its own ability.
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[bank].ability;
|
||||
AI_THINKING_STRUCT->funcResult = gBattleMons[battlerId].ability;
|
||||
}
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
static void BattleAICmd_check_ability(void)
|
||||
{
|
||||
u32 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
|
||||
u32 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
|
||||
u32 ability = gAIScriptPtr[2];
|
||||
|
||||
if (gAIScriptPtr[1] == AI_TARGET || gAIScriptPtr[1] == AI_TARGET_PARTNER)
|
||||
{
|
||||
if (BATTLE_HISTORY->abilities[bank] != 0)
|
||||
if (BATTLE_HISTORY->abilities[battlerId] != 0)
|
||||
{
|
||||
ability = BATTLE_HISTORY->abilities[bank];
|
||||
ability = BATTLE_HISTORY->abilities[battlerId];
|
||||
AI_THINKING_STRUCT->funcResult = ability;
|
||||
}
|
||||
// abilities that prevent fleeing.
|
||||
else if (gBattleMons[bank].ability == ABILITY_SHADOW_TAG
|
||||
|| gBattleMons[bank].ability == ABILITY_MAGNET_PULL
|
||||
|| gBattleMons[bank].ability == ABILITY_ARENA_TRAP)
|
||||
else if (gBattleMons[battlerId].ability == ABILITY_SHADOW_TAG
|
||||
|| gBattleMons[battlerId].ability == ABILITY_MAGNET_PULL
|
||||
|| gBattleMons[battlerId].ability == ABILITY_ARENA_TRAP)
|
||||
{
|
||||
ability = gBattleMons[bank].ability;
|
||||
ability = gBattleMons[battlerId].ability;
|
||||
}
|
||||
else if (gBaseStats[gBattleMons[bank].species].ability1 != ABILITY_NONE)
|
||||
else if (gBaseStats[gBattleMons[battlerId].species].ability1 != ABILITY_NONE)
|
||||
{
|
||||
if (gBaseStats[gBattleMons[bank].species].ability2 != ABILITY_NONE)
|
||||
if (gBaseStats[gBattleMons[battlerId].species].ability2 != ABILITY_NONE)
|
||||
{
|
||||
u8 abilityDummyVariable = ability; // needed to match
|
||||
if (gBaseStats[gBattleMons[bank].species].ability1 != abilityDummyVariable
|
||||
&& gBaseStats[gBattleMons[bank].species].ability2 != abilityDummyVariable)
|
||||
if (gBaseStats[gBattleMons[battlerId].species].ability1 != abilityDummyVariable
|
||||
&& gBaseStats[gBattleMons[battlerId].species].ability2 != abilityDummyVariable)
|
||||
{
|
||||
ability = gBaseStats[gBattleMons[bank].species].ability1;
|
||||
ability = gBaseStats[gBattleMons[battlerId].species].ability1;
|
||||
}
|
||||
else
|
||||
ability = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ability = gBaseStats[gBattleMons[bank].species].ability1;
|
||||
ability = gBaseStats[gBattleMons[battlerId].species].ability1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ability = gBaseStats[gBattleMons[bank].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
|
||||
ability = gBaseStats[gBattleMons[battlerId].species].ability2; // AI cant actually reach this part since every mon has at least 1 ability.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The AI knows its own or partner's ability.
|
||||
ability = gBattleMons[bank].ability;
|
||||
ability = gBattleMons[battlerId].ability;
|
||||
}
|
||||
if (ability == 0)
|
||||
{
|
||||
@ -1546,19 +1546,19 @@ static void BattleAICmd_if_status_in_party(void)
|
||||
struct Pokemon *party;
|
||||
int i;
|
||||
u32 statusToCompareTo;
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
switch(gAIScriptPtr[1])
|
||||
{
|
||||
case AI_USER:
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
break;
|
||||
default:
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
break;
|
||||
}
|
||||
|
||||
party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
|
||||
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@ -1583,19 +1583,19 @@ static void BattleAICmd_if_status_not_in_party(void)
|
||||
struct Pokemon *party;
|
||||
int i;
|
||||
u32 statusToCompareTo;
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
switch(gAIScriptPtr[1])
|
||||
{
|
||||
case 1:
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
break;
|
||||
default:
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
break;
|
||||
}
|
||||
|
||||
party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
|
||||
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
|
||||
|
||||
@ -1646,14 +1646,14 @@ static void BattleAICmd_if_not_effect(void)
|
||||
|
||||
static void BattleAICmd_if_stat_level_less_than(void)
|
||||
{
|
||||
u32 bank;
|
||||
u32 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
|
||||
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
|
||||
else
|
||||
gAIScriptPtr += 8;
|
||||
@ -1661,14 +1661,14 @@ static void BattleAICmd_if_stat_level_less_than(void)
|
||||
|
||||
static void BattleAICmd_if_stat_level_more_than(void)
|
||||
{
|
||||
u32 bank;
|
||||
u32 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
|
||||
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
|
||||
else
|
||||
gAIScriptPtr += 8;
|
||||
@ -1676,14 +1676,14 @@ static void BattleAICmd_if_stat_level_more_than(void)
|
||||
|
||||
static void BattleAICmd_if_stat_level_equal(void)
|
||||
{
|
||||
u32 bank;
|
||||
u32 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
|
||||
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
|
||||
else
|
||||
gAIScriptPtr += 8;
|
||||
@ -1691,14 +1691,14 @@ static void BattleAICmd_if_stat_level_equal(void)
|
||||
|
||||
static void BattleAICmd_if_stat_level_not_equal(void)
|
||||
{
|
||||
u32 bank;
|
||||
u32 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
|
||||
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
|
||||
else
|
||||
gAIScriptPtr += 8;
|
||||
@ -1940,16 +1940,16 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
|
||||
|
||||
static void BattleAICmd_if_any_move_disabled_or_encored(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if (gAIScriptPtr[2] == 0)
|
||||
{
|
||||
if (gDisableStructs[bank].disabledMove == 0)
|
||||
if (gDisableStructs[battlerId].disabledMove == 0)
|
||||
{
|
||||
gAIScriptPtr += 7;
|
||||
return;
|
||||
@ -1962,7 +1962,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
|
||||
gAIScriptPtr += 7;
|
||||
return;
|
||||
}
|
||||
else if (gDisableStructs[bank].encoredMove != 0)
|
||||
else if (gDisableStructs[battlerId].encoredMove != 0)
|
||||
{
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
|
||||
return;
|
||||
@ -2018,31 +2018,31 @@ static void BattleAICmd_watch(void)
|
||||
|
||||
static void BattleAICmd_get_hold_effect(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
if (gActiveBattler != bank)
|
||||
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]);
|
||||
if (gActiveBattler != battlerId)
|
||||
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[battlerId]);
|
||||
else
|
||||
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[bank].item);
|
||||
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[battlerId].item);
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
static void BattleAICmd_if_holds_item(void)
|
||||
{
|
||||
u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
|
||||
u8 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
|
||||
u16 item;
|
||||
u8 var1, var2;
|
||||
|
||||
if ((bank & BIT_SIDE) == (sBattler_AI & BIT_SIDE))
|
||||
item = gBattleMons[bank].item;
|
||||
if ((battlerId & BIT_SIDE) == (sBattler_AI & BIT_SIDE))
|
||||
item = gBattleMons[battlerId].item;
|
||||
else
|
||||
item = BATTLE_HISTORY->itemEffects[bank];
|
||||
item = BATTLE_HISTORY->itemEffects[battlerId];
|
||||
|
||||
// UB: doesn't properly read an unaligned u16
|
||||
var2 = gAIScriptPtr[2];
|
||||
@ -2056,42 +2056,42 @@ static void BattleAICmd_if_holds_item(void)
|
||||
|
||||
static void BattleAICmd_get_gender(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality);
|
||||
AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[battlerId].species, gBattleMons[battlerId].personality);
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
static void BattleAICmd_is_first_turn_for(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn;
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[battlerId].isFirstTurn;
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
static void BattleAICmd_get_stockpile_count(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter;
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[battlerId].stockpileCounter;
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
@ -2105,18 +2105,18 @@ static void BattleAICmd_is_double_battle(void)
|
||||
|
||||
static void BattleAICmd_get_used_held_item(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
// This is likely a leftover from Ruby's code and its ugly ewram access
|
||||
#ifdef NONMATCHING
|
||||
AI_THINKING_STRUCT->funcResult = gBattleStruct->usedHeldItems[bank];
|
||||
AI_THINKING_STRUCT->funcResult = gBattleStruct->usedHeldItems[battlerId];
|
||||
#else
|
||||
AI_THINKING_STRUCT->funcResult = *(u8*)((u8*)(gBattleStruct) + offsetof(struct BattleStruct, usedHeldItems) + (bank * 2));
|
||||
AI_THINKING_STRUCT->funcResult = *(u8*)((u8*)(gBattleStruct) + offsetof(struct BattleStruct, usedHeldItems) + (battlerId * 2));
|
||||
#endif // NONMATCHING
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
@ -2145,14 +2145,14 @@ static void BattleAICmd_get_move_effect_from_result(void)
|
||||
|
||||
static void BattleAICmd_get_protect_count(void)
|
||||
{
|
||||
u8 bank;
|
||||
u8 battlerId;
|
||||
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
bank = sBattler_AI;
|
||||
battlerId = sBattler_AI;
|
||||
else
|
||||
bank = gBattlerTarget;
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses;
|
||||
AI_THINKING_STRUCT->funcResult = gDisableStructs[battlerId].protectUses;
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
@ -2255,9 +2255,9 @@ static void BattleAICmd_if_target_is_ally(void)
|
||||
|
||||
static void BattleAICmd_if_flash_fired(void)
|
||||
{
|
||||
u8 bank = BattleAI_GetWantedBank(gAIScriptPtr[1]);
|
||||
u8 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
|
||||
|
||||
if (gBattleResources->flags->flags[bank] & UNKNOWN_FLAG_FLASH_FIRE)
|
||||
if (gBattleResources->flags->flags[battlerId] & UNKNOWN_FLAG_FLASH_FIRE)
|
||||
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
|
||||
else
|
||||
gAIScriptPtr += 6;
|
||||
|
@ -4436,31 +4436,34 @@ static void atk47_setgraphicalstatchangevalues(void)
|
||||
gBattlescriptCurrInstr++;
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
static void atk48_playstatchangeanimation(void)
|
||||
{
|
||||
u32 currStat = 0;
|
||||
s16 statAnimId = 0;
|
||||
s16 checkingStatAnimId = 0;
|
||||
s32 changeableStats = 0;
|
||||
u32 statsToCheck = 0;
|
||||
u16 statAnimId = 0;
|
||||
s32 changeableStatsCount = 0;
|
||||
u8 statsToCheck = 0;
|
||||
|
||||
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
|
||||
statsToCheck = gBattlescriptCurrInstr[2];
|
||||
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_STAT_NEGATIVE) // goes down
|
||||
{
|
||||
checkingStatAnimId = (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) ? 0x2D : 0x15;
|
||||
s16 startingStatAnimId;
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
|
||||
startingStatAnimId = 0x2D;
|
||||
else
|
||||
startingStatAnimId = 0x15;
|
||||
|
||||
while (statsToCheck != 0)
|
||||
{
|
||||
if (statsToCheck & 1)
|
||||
{
|
||||
if (!(gBattlescriptCurrInstr[3] & ATK48_LOWER_FAIL_CHECK))
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_DONT_CHECK_LOWER)
|
||||
{
|
||||
if (gBattleMons[gActiveBattler].statStages[currStat] > 0)
|
||||
{
|
||||
statAnimId = checkingStatAnimId;
|
||||
changeableStats++;
|
||||
statAnimId = startingStatAnimId + currStat;
|
||||
changeableStatsCount++;
|
||||
}
|
||||
}
|
||||
else if (!gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer
|
||||
@ -4471,15 +4474,15 @@ static void atk48_playstatchangeanimation(void)
|
||||
{
|
||||
if (gBattleMons[gActiveBattler].statStages[currStat] > 0)
|
||||
{
|
||||
statAnimId = checkingStatAnimId;
|
||||
changeableStats++;
|
||||
statAnimId = startingStatAnimId + currStat;
|
||||
changeableStatsCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
statsToCheck >>= 1, checkingStatAnimId++, currStat++;
|
||||
statsToCheck >>= 1, currStat++;
|
||||
}
|
||||
|
||||
if (changeableStats > 1) // more than one stat, so the color is gray
|
||||
if (changeableStatsCount > 1) // more than one stat, so the color is gray
|
||||
{
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
|
||||
statAnimId = 0x3A;
|
||||
@ -4489,18 +4492,23 @@ static void atk48_playstatchangeanimation(void)
|
||||
}
|
||||
else // goes up
|
||||
{
|
||||
checkingStatAnimId = (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) ? 0x26 : 0xE;
|
||||
s16 startingStatAnimId;
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
|
||||
startingStatAnimId = 0x26;
|
||||
else
|
||||
startingStatAnimId = 0xE;
|
||||
|
||||
while (statsToCheck != 0)
|
||||
{
|
||||
if (statsToCheck & 1 && gBattleMons[gActiveBattler].statStages[currStat] < 0xC)
|
||||
{
|
||||
statAnimId = checkingStatAnimId;
|
||||
changeableStats++;
|
||||
statAnimId = startingStatAnimId + currStat;
|
||||
changeableStatsCount++;
|
||||
}
|
||||
statsToCheck >>= 1, checkingStatAnimId += 1, currStat++;
|
||||
statsToCheck >>= 1, currStat++;
|
||||
}
|
||||
|
||||
if (changeableStats > 1) // more than one stat, so the color is gray
|
||||
if (changeableStatsCount > 1) // more than one stat, so the color is gray
|
||||
{
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO)
|
||||
statAnimId = 0x38;
|
||||
@ -4509,15 +4517,15 @@ static void atk48_playstatchangeanimation(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStats < 2)
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStatsCount < 2)
|
||||
{
|
||||
gBattlescriptCurrInstr += 4;
|
||||
}
|
||||
else if (changeableStats != 0 && gBattleScripting.field_1B == 0)
|
||||
else if (changeableStatsCount != 0 && gBattleScripting.field_1B == 0)
|
||||
{
|
||||
BtlController_EmitBattleAnimation(0, B_ANIM_STATS_CHANGE, statAnimId);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStats > 1)
|
||||
if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStatsCount > 1)
|
||||
gBattleScripting.field_1B = 1;
|
||||
gBattlescriptCurrInstr += 4;
|
||||
}
|
||||
@ -4526,261 +4534,6 @@ static void atk48_playstatchangeanimation(void)
|
||||
gBattlescriptCurrInstr += 4;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ASM_DIRECT
|
||||
static void atk48_playstatchangeanimation(void)
|
||||
{
|
||||
asm("\n\
|
||||
.syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
mov r7, r10\n\
|
||||
mov r6, r9\n\
|
||||
mov r5, r8\n\
|
||||
push {r5-r7}\n\
|
||||
sub sp, 0x4\n\
|
||||
movs r7, 0\n\
|
||||
movs r0, 0\n\
|
||||
mov r8, r0\n\
|
||||
movs r3, 0\n\
|
||||
ldr r5, =gBattlescriptCurrInstr\n\
|
||||
ldr r0, [r5]\n\
|
||||
ldrb r0, [r0, 0x1]\n\
|
||||
str r3, [sp]\n\
|
||||
bl GetBattlerForBattleScript\n\
|
||||
ldr r2, =gActiveBattler\n\
|
||||
strb r0, [r2]\n\
|
||||
ldr r0, [r5]\n\
|
||||
ldrb r4, [r0, 0x2]\n\
|
||||
ldrb r1, [r0, 0x3]\n\
|
||||
movs r0, 0x1\n\
|
||||
ands r0, r1\n\
|
||||
ldr r3, [sp]\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BAEC\n\
|
||||
movs r0, 0x2\n\
|
||||
ands r0, r1\n\
|
||||
movs r1, 0x15\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BA18\n\
|
||||
movs r1, 0x2D\n\
|
||||
_0804BA18:\n\
|
||||
cmp r4, 0\n\
|
||||
beq _0804BAC0\n\
|
||||
movs r0, 0x1\n\
|
||||
mov r10, r0\n\
|
||||
ldr r0, =gBattleMons + 0x18\n\
|
||||
mov r9, r0\n\
|
||||
lsls r5, r1, 16\n\
|
||||
_0804BA26:\n\
|
||||
adds r0, r4, 0\n\
|
||||
mov r1, r10\n\
|
||||
ands r0, r1\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BAB2\n\
|
||||
ldr r0, =gBattlescriptCurrInstr\n\
|
||||
ldr r0, [r0]\n\
|
||||
ldrb r1, [r0, 0x3]\n\
|
||||
movs r0, 0x8\n\
|
||||
ands r0, r1\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BA58\n\
|
||||
ldr r0, =gActiveBattler\n\
|
||||
ldrb r1, [r0]\n\
|
||||
movs r0, 0x58\n\
|
||||
muls r0, r1\n\
|
||||
adds r0, r7, r0\n\
|
||||
b _0804BAA0\n\
|
||||
.pool\n\
|
||||
_0804BA58:\n\
|
||||
ldr r6, =gActiveBattler\n\
|
||||
ldrb r0, [r6]\n\
|
||||
str r3, [sp]\n\
|
||||
bl GetBattlerPosition\n\
|
||||
mov r1, r10\n\
|
||||
ands r1, r0\n\
|
||||
lsls r0, r1, 1\n\
|
||||
adds r0, r1\n\
|
||||
lsls r0, 2\n\
|
||||
ldr r1, =gSideTimers\n\
|
||||
adds r0, r1\n\
|
||||
ldrb r0, [r0, 0x4]\n\
|
||||
ldr r3, [sp]\n\
|
||||
cmp r0, 0\n\
|
||||
bne _0804BAB2\n\
|
||||
ldr r0, =gBattleMons\n\
|
||||
ldrb r2, [r6]\n\
|
||||
movs r1, 0x58\n\
|
||||
muls r2, r1\n\
|
||||
adds r0, r2, r0\n\
|
||||
adds r0, 0x20\n\
|
||||
ldrb r0, [r0]\n\
|
||||
cmp r0, 0x1D\n\
|
||||
beq _0804BAB2\n\
|
||||
cmp r0, 0x49\n\
|
||||
beq _0804BAB2\n\
|
||||
cmp r0, 0x33\n\
|
||||
bne _0804BA96\n\
|
||||
cmp r7, 0x6\n\
|
||||
beq _0804BAB2\n\
|
||||
_0804BA96:\n\
|
||||
cmp r0, 0x34\n\
|
||||
bne _0804BA9E\n\
|
||||
cmp r7, 0x1\n\
|
||||
beq _0804BAB2\n\
|
||||
_0804BA9E:\n\
|
||||
adds r0, r7, r2\n\
|
||||
_0804BAA0:\n\
|
||||
add r0, r9\n\
|
||||
ldrb r0, [r0]\n\
|
||||
lsls r0, 24\n\
|
||||
asrs r0, 24\n\
|
||||
cmp r0, 0\n\
|
||||
ble _0804BAB2\n\
|
||||
lsrs r0, r5, 16\n\
|
||||
mov r8, r0\n\
|
||||
adds r3, 0x1\n\
|
||||
_0804BAB2:\n\
|
||||
lsrs r4, 1\n\
|
||||
movs r1, 0x80\n\
|
||||
lsls r1, 9\n\
|
||||
adds r5, r1\n\
|
||||
adds r7, 0x1\n\
|
||||
cmp r4, 0\n\
|
||||
bne _0804BA26\n\
|
||||
_0804BAC0:\n\
|
||||
ldr r0, =gBattlescriptCurrInstr\n\
|
||||
mov r9, r0\n\
|
||||
cmp r3, 0x1\n\
|
||||
ble _0804BB4E\n\
|
||||
ldr r0, [r0]\n\
|
||||
ldrb r1, [r0, 0x3]\n\
|
||||
movs r0, 0x2\n\
|
||||
ands r0, r1\n\
|
||||
movs r1, 0x39\n\
|
||||
mov r8, r1\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BB4E\n\
|
||||
movs r0, 0x3A\n\
|
||||
b _0804BB4C\n\
|
||||
.pool\n\
|
||||
_0804BAEC:\n\
|
||||
movs r0, 0x2\n\
|
||||
ands r0, r1\n\
|
||||
movs r1, 0xE\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BAF8\n\
|
||||
movs r1, 0x26\n\
|
||||
_0804BAF8:\n\
|
||||
mov r9, r5\n\
|
||||
cmp r4, 0\n\
|
||||
beq _0804BB34\n\
|
||||
ldr r6, =gBattleMons + 0x18\n\
|
||||
adds r5, r2, 0\n\
|
||||
lsls r2, r1, 16\n\
|
||||
_0804BB04:\n\
|
||||
movs r0, 0x1\n\
|
||||
ands r0, r4\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BB26\n\
|
||||
ldrb r1, [r5]\n\
|
||||
movs r0, 0x58\n\
|
||||
muls r0, r1\n\
|
||||
adds r0, r7, r0\n\
|
||||
adds r0, r6\n\
|
||||
ldrb r0, [r0]\n\
|
||||
lsls r0, 24\n\
|
||||
asrs r0, 24\n\
|
||||
cmp r0, 0xB\n\
|
||||
bgt _0804BB26\n\
|
||||
lsrs r1, r2, 16\n\
|
||||
mov r8, r1\n\
|
||||
adds r3, 0x1\n\
|
||||
_0804BB26:\n\
|
||||
lsrs r4, 1\n\
|
||||
movs r0, 0x80\n\
|
||||
lsls r0, 9\n\
|
||||
adds r2, r0\n\
|
||||
adds r7, 0x1\n\
|
||||
cmp r4, 0\n\
|
||||
bne _0804BB04\n\
|
||||
_0804BB34:\n\
|
||||
cmp r3, 0x1\n\
|
||||
ble _0804BB4E\n\
|
||||
mov r1, r9\n\
|
||||
ldr r0, [r1]\n\
|
||||
ldrb r1, [r0, 0x3]\n\
|
||||
movs r0, 0x2\n\
|
||||
ands r0, r1\n\
|
||||
movs r1, 0x37\n\
|
||||
mov r8, r1\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BB4E\n\
|
||||
movs r0, 0x38\n\
|
||||
_0804BB4C:\n\
|
||||
mov r8, r0\n\
|
||||
_0804BB4E:\n\
|
||||
mov r1, r9\n\
|
||||
ldr r2, [r1]\n\
|
||||
ldrb r1, [r2, 0x3]\n\
|
||||
movs r0, 0x4\n\
|
||||
ands r0, r1\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BB6C\n\
|
||||
cmp r3, 0x1\n\
|
||||
bgt _0804BB6C\n\
|
||||
adds r0, r2, 0x4\n\
|
||||
mov r1, r9\n\
|
||||
b _0804BBBA\n\
|
||||
.pool\n\
|
||||
_0804BB6C:\n\
|
||||
cmp r3, 0\n\
|
||||
beq _0804BBB4\n\
|
||||
ldr r4, =gBattleScripting\n\
|
||||
ldrb r0, [r4, 0x1B]\n\
|
||||
cmp r0, 0\n\
|
||||
bne _0804BBB4\n\
|
||||
movs r0, 0\n\
|
||||
movs r1, 0x1\n\
|
||||
mov r2, r8\n\
|
||||
str r3, [sp]\n\
|
||||
bl BtlController_EmitBattleAnimation\n\
|
||||
ldr r0, =gActiveBattler\n\
|
||||
ldrb r0, [r0]\n\
|
||||
bl MarkBattlerForControllerExec\n\
|
||||
ldr r0, =gBattlescriptCurrInstr\n\
|
||||
ldr r0, [r0]\n\
|
||||
ldrb r1, [r0, 0x3]\n\
|
||||
movs r0, 0x4\n\
|
||||
ands r0, r1\n\
|
||||
ldr r3, [sp]\n\
|
||||
cmp r0, 0\n\
|
||||
beq _0804BBA4\n\
|
||||
cmp r3, 0x1\n\
|
||||
ble _0804BBA4\n\
|
||||
movs r0, 0x1\n\
|
||||
strb r0, [r4, 0x1B]\n\
|
||||
_0804BBA4:\n\
|
||||
ldr r1, =gBattlescriptCurrInstr\n\
|
||||
b _0804BBB6\n\
|
||||
.pool\n\
|
||||
_0804BBB4:\n\
|
||||
mov r1, r9\n\
|
||||
_0804BBB6:\n\
|
||||
ldr r0, [r1]\n\
|
||||
adds r0, 0x4\n\
|
||||
_0804BBBA:\n\
|
||||
str r0, [r1]\n\
|
||||
add sp, 0x4\n\
|
||||
pop {r3-r5}\n\
|
||||
mov r8, r3\n\
|
||||
mov r9, r4\n\
|
||||
mov r10, r5\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n\
|
||||
.syntax divided");
|
||||
}
|
||||
#endif // NONMATCHING
|
||||
|
||||
#define ATK49_LAST_CASE 17
|
||||
|
||||
@ -5271,10 +5024,9 @@ static void atk4E_switchinanim(void)
|
||||
|
||||
static void atk4F_jumpifcantswitch(void)
|
||||
{
|
||||
s32 val = 0;
|
||||
s32 compareVar = 0;
|
||||
struct Pokemon *party = NULL;
|
||||
s32 r7 = 0;
|
||||
s32 i;
|
||||
s32 lastMonId;
|
||||
struct Pokemon *party;
|
||||
|
||||
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(ATK4F_DONT_CHECK_STATUSES));
|
||||
|
||||
@ -5294,20 +5046,20 @@ static void atk4F_jumpifcantswitch(void)
|
||||
else
|
||||
party = gPlayerParty;
|
||||
|
||||
val = 0;
|
||||
if (2 & gActiveBattler)
|
||||
val = 3;
|
||||
i = 0;
|
||||
if (gActiveBattler & 2)
|
||||
i = 3;
|
||||
|
||||
for (compareVar = val + 3; val < compareVar; val++)
|
||||
for (lastMonId = i + 3; i < lastMonId; i++)
|
||||
{
|
||||
if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[val], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&party[val], MON_DATA_HP) != 0
|
||||
&& gBattlerPartyIndexes[gActiveBattler] != val)
|
||||
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&party[i], MON_DATA_HP) != 0
|
||||
&& gBattlerPartyIndexes[gActiveBattler] != i)
|
||||
break;
|
||||
}
|
||||
|
||||
if (val == compareVar)
|
||||
if (i == lastMonId)
|
||||
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
|
||||
else
|
||||
gBattlescriptCurrInstr += 6;
|
||||
@ -5320,18 +5072,18 @@ static void atk4F_jumpifcantswitch(void)
|
||||
{
|
||||
party = gPlayerParty;
|
||||
|
||||
val = 0;
|
||||
i = 0;
|
||||
if (sub_806D82C(GetBattlerMultiplayerId(gActiveBattler)) == TRUE)
|
||||
val = 3;
|
||||
i = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
party = gEnemyParty;
|
||||
|
||||
if (gActiveBattler == 1)
|
||||
val = 0;
|
||||
i = 0;
|
||||
else
|
||||
val = 3;
|
||||
i = 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -5341,22 +5093,21 @@ static void atk4F_jumpifcantswitch(void)
|
||||
else
|
||||
party = gPlayerParty;
|
||||
|
||||
|
||||
val = 0;
|
||||
i = 0;
|
||||
if (sub_806D82C(GetBattlerMultiplayerId(gActiveBattler)) == TRUE)
|
||||
val = 3;
|
||||
i = 3;
|
||||
}
|
||||
|
||||
for (compareVar = val + 3; val < compareVar; val++)
|
||||
for (lastMonId = i + 3; i < lastMonId; i++)
|
||||
{
|
||||
if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[val], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&party[val], MON_DATA_HP) != 0
|
||||
&& gBattlerPartyIndexes[gActiveBattler] != val)
|
||||
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&party[i], MON_DATA_HP) != 0
|
||||
&& gBattlerPartyIndexes[gActiveBattler] != i)
|
||||
break;
|
||||
}
|
||||
|
||||
if (val == compareVar)
|
||||
if (i == lastMonId)
|
||||
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
|
||||
else
|
||||
gBattlescriptCurrInstr += 6;
|
||||
@ -5365,58 +5116,61 @@ static void atk4F_jumpifcantswitch(void)
|
||||
{
|
||||
party = gEnemyParty;
|
||||
|
||||
val = 0;
|
||||
if (gActiveBattler == 3)
|
||||
val = 3;
|
||||
i = 0;
|
||||
if (gActiveBattler == B_POSITION_OPPONENT_RIGHT)
|
||||
i = 3;
|
||||
|
||||
for (compareVar = val + 3; val < compareVar; val++)
|
||||
for (lastMonId = i + 3; i < lastMonId; i++)
|
||||
{
|
||||
if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[val], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&party[val], MON_DATA_HP) != 0
|
||||
&& gBattlerPartyIndexes[gActiveBattler] != val)
|
||||
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&party[i], MON_DATA_HP) != 0
|
||||
&& gBattlerPartyIndexes[gActiveBattler] != i)
|
||||
break;
|
||||
}
|
||||
|
||||
if (val == compareVar)
|
||||
if (i == lastMonId)
|
||||
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
|
||||
else
|
||||
gBattlescriptCurrInstr += 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 battlerIn1, battlerIn2;
|
||||
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT)
|
||||
{
|
||||
r7 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
compareVar = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
battlerIn2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
else
|
||||
compareVar = r7;
|
||||
battlerIn2 = battlerIn1;
|
||||
|
||||
party = gEnemyParty;
|
||||
}
|
||||
else
|
||||
{
|
||||
r7 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
battlerIn1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
compareVar = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
battlerIn2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
else
|
||||
compareVar = r7;
|
||||
battlerIn2 = battlerIn1;
|
||||
|
||||
party = gPlayerParty;
|
||||
}
|
||||
for (val = 0; val < 6; val++)
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (GetMonData(&party[val], MON_DATA_HP) != 0
|
||||
&& GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[val], MON_DATA_IS_EGG)
|
||||
&& val != gBattlerPartyIndexes[r7] && val != gBattlerPartyIndexes[compareVar])
|
||||
if (GetMonData(&party[i], MON_DATA_HP) != 0
|
||||
&& GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
|
||||
&& i != gBattlerPartyIndexes[battlerIn1] && i != gBattlerPartyIndexes[battlerIn2])
|
||||
break;
|
||||
}
|
||||
|
||||
if (val == 6)
|
||||
if (i == 6)
|
||||
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
|
||||
else
|
||||
gBattlescriptCurrInstr += 6;
|
||||
|
@ -606,7 +606,6 @@ u8 sub_818E06C(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
static u8 sub_818E13C(void)
|
||||
{
|
||||
u8 retval;
|
||||
@ -627,9 +626,11 @@ static u8 sub_818E13C(void)
|
||||
len = sub_818E258(gUnknown_0203CD68->playerName);
|
||||
if (len == sub_818E258(gSaveBlock2Ptr->playerName))
|
||||
{
|
||||
u8 *name = gUnknown_0203CD68->playerName;
|
||||
for (i = 0; i < len; i ++)
|
||||
{
|
||||
if (gUnknown_0203CD68->playerName[i] != gSaveBlock2Ptr->playerName[i])
|
||||
name = gUnknown_0203CD68->playerName;
|
||||
if (name[i] != gSaveBlock2Ptr->playerName[i])
|
||||
{
|
||||
retval = 2;
|
||||
break;
|
||||
@ -640,85 +641,6 @@ static u8 sub_818E13C(void)
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
#else
|
||||
ASM_DIRECT static u8 sub_818E13C(void)
|
||||
{
|
||||
asm_unified("\tpush {r4-r7,lr}\n"
|
||||
"\tmovs r7, 0x1\n"
|
||||
"\tldr r5, =gUnknown_0203CD68\n"
|
||||
"\tldr r0, =gSaveBlock1Ptr\n"
|
||||
"\tldr r1, [r0]\n"
|
||||
"\tldr r2, =0x00003b58\n"
|
||||
"\tadds r0, r1, r2\n"
|
||||
"\tstr r0, [r5]\n"
|
||||
"\tldrb r0, [r0, 0x18]\n"
|
||||
"\tcmp r0, 0xFF\n"
|
||||
"\tbne _0818E174\n"
|
||||
"\tldr r0, =gStringVar1\n"
|
||||
"\tldr r1, =gText_Lady2\n"
|
||||
"\tbl StringCopy7\n"
|
||||
"\tmovs r7, 0\n"
|
||||
"\tb _0818E1DC\n"
|
||||
"\t.pool\n"
|
||||
"_0818E174:\n"
|
||||
"\tldr r4, =gStringVar1\n"
|
||||
"\tldr r0, =0x00003b70\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tadds r0, r4, 0\n"
|
||||
"\tbl StringCopy7\n"
|
||||
"\tldr r0, [r5]\n"
|
||||
"\tadds r0, 0x2D\n"
|
||||
"\tldrb r1, [r0]\n"
|
||||
"\tadds r0, r4, 0\n"
|
||||
"\tbl ConvertInternationalString\n"
|
||||
"\tldr r0, [r5]\n"
|
||||
"\tadds r0, 0x18\n"
|
||||
"\tbl sub_818E258\n"
|
||||
"\tlsls r0, 24\n"
|
||||
"\tlsrs r4, r0, 24\n"
|
||||
"\tldr r6, =gSaveBlock2Ptr\n"
|
||||
"\tldr r0, [r6]\n"
|
||||
"\tbl sub_818E258\n"
|
||||
"\tlsls r0, 24\n"
|
||||
"\tlsrs r0, 24\n"
|
||||
"\tcmp r4, r0\n"
|
||||
"\tbne _0818E1DC\n"
|
||||
"\tldr r0, [r5]\n"
|
||||
"\tmovs r2, 0\n"
|
||||
"\tcmp r2, r4\n"
|
||||
"\tbcs _0818E1DC\n"
|
||||
"\tldr r1, [r6]\n"
|
||||
"\tldrb r0, [r0, 0x18]\n"
|
||||
"\tldrb r1, [r1]\n"
|
||||
"\tcmp r0, r1\n"
|
||||
"\tbne _0818E1DA\n"
|
||||
"_0818E1BA:\n"
|
||||
"\tadds r0, r2, 0x1\n"
|
||||
"\tlsls r0, 24\n"
|
||||
"\tlsrs r2, r0, 24\n"
|
||||
"\tcmp r2, r4\n"
|
||||
"\tbcs _0818E1DC\n"
|
||||
"\tldr r0, =gUnknown_0203CD68\n"
|
||||
"\tldr r1, [r0]\n"
|
||||
"\tadds r1, 0x18\n"
|
||||
"\tadds r1, r2\n"
|
||||
"\tldr r0, =gSaveBlock2Ptr\n"
|
||||
"\tldr r0, [r0]\n"
|
||||
"\tadds r0, r2\n"
|
||||
"\tldrb r1, [r1]\n"
|
||||
"\tldrb r0, [r0]\n"
|
||||
"\tcmp r1, r0\n"
|
||||
"\tbeq _0818E1BA\n"
|
||||
"_0818E1DA:\n"
|
||||
"\tmovs r7, 0x2\n"
|
||||
"_0818E1DC:\n"
|
||||
"\tadds r0, r7, 0\n"
|
||||
"\tpop {r4-r7}\n"
|
||||
"\tpop {r1}\n"
|
||||
"\tbx r1\n"
|
||||
"\t.pool");
|
||||
}
|
||||
#endif
|
||||
|
||||
static u8 sub_818E1F4(void)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user