Reduces AI_WhoStrikesFirst to the most essential parts (#4978)
* Reduces AI_WhoStrikesFirst to the most essential parts * abgcc * add stall check + minor clean up * add comment
This commit is contained in:
parent
684e8af181
commit
0d0100d8f8
@ -1036,27 +1036,55 @@ static u32 AI_GetEffectiveness(uq4_12_t multiplier)
|
||||
}
|
||||
|
||||
/* Checks to see if AI will move ahead of another battler
|
||||
* The function uses a stripped down version of the checks from GetWhichBattlerFasterArgs
|
||||
* Output:
|
||||
* AI_IS_FASTER: is user(ai) faster
|
||||
* AI_IS_SLOWER: is target faster
|
||||
*/
|
||||
s32 AI_WhoStrikesFirst(u32 battlerAI, u32 battler2, u32 moveConsidered)
|
||||
s32 AI_WhoStrikesFirst(u32 battlerAI, u32 battler, u32 moveConsidered)
|
||||
{
|
||||
s8 prioAI = 0;
|
||||
s8 prioBattler2 = 0;
|
||||
prioAI = GetMovePriority(battlerAI, moveConsidered);
|
||||
u32 speedBattlerAI, speedBattler;
|
||||
u32 holdEffectAI = AI_DATA->holdEffects[battlerAI];
|
||||
u32 holdEffectPlayer = AI_DATA->holdEffects[battler];
|
||||
u32 abilityAI = AI_DATA->abilities[battlerAI];
|
||||
u32 abilityPlayer = AI_DATA->abilities[battler];
|
||||
|
||||
if (prioAI > prioBattler2)
|
||||
if (GetMovePriority(battlerAI, moveConsidered) > 0)
|
||||
return AI_IS_FASTER;
|
||||
|
||||
if (GetWhichBattlerFasterArgs(battlerAI, battler2, TRUE,
|
||||
AI_DATA->abilities[battlerAI], AI_DATA->abilities[battler2],
|
||||
AI_DATA->holdEffects[battlerAI], AI_DATA->holdEffects[battler2],
|
||||
AI_DATA->speedStats[battlerAI], AI_DATA->speedStats[battler2],
|
||||
prioAI, prioBattler2) == 1)
|
||||
return AI_IS_FASTER;
|
||||
else
|
||||
speedBattlerAI = GetBattlerTotalSpeedStatArgs(battlerAI, abilityAI, holdEffectAI);
|
||||
speedBattler = GetBattlerTotalSpeedStatArgs(battler, abilityPlayer, holdEffectPlayer);
|
||||
|
||||
if (holdEffectAI == HOLD_EFFECT_LAGGING_TAIL && holdEffectPlayer != HOLD_EFFECT_LAGGING_TAIL)
|
||||
return AI_IS_SLOWER;
|
||||
else if (holdEffectAI != HOLD_EFFECT_LAGGING_TAIL && holdEffectPlayer == HOLD_EFFECT_LAGGING_TAIL)
|
||||
return AI_IS_FASTER;
|
||||
|
||||
if (abilityAI == ABILITY_STALL && abilityPlayer != ABILITY_STALL)
|
||||
return AI_IS_SLOWER;
|
||||
else if (abilityAI != ABILITY_STALL && abilityPlayer == ABILITY_STALL)
|
||||
return AI_IS_FASTER;
|
||||
|
||||
if (speedBattlerAI > speedBattler)
|
||||
{
|
||||
if (gFieldStatuses & STATUS_FIELD_TRICK_ROOM)
|
||||
return AI_IS_SLOWER;
|
||||
else
|
||||
return AI_IS_FASTER;
|
||||
}
|
||||
else if (speedBattlerAI == speedBattler)
|
||||
{
|
||||
return AI_IS_FASTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gFieldStatuses & STATUS_FIELD_TRICK_ROOM)
|
||||
return AI_IS_FASTER;
|
||||
else
|
||||
return AI_IS_SLOWER;
|
||||
}
|
||||
|
||||
return AI_IS_SLOWER;
|
||||
}
|
||||
|
||||
// Check if target has means to faint ai mon.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user