mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-03-28 16:38:57 +01:00
Fix Protean / Libero when AI calculates Damage (#2714)
* Fix Protean / Libero when AI calculates Damage * fix ai changing types when calculating dmg
This commit is contained in:
parent
a04046dbb6
commit
e055456b7e
@ -44,6 +44,7 @@ u16 GetSecretPowerMoveEffect(void);
|
|||||||
void StealTargetItem(u8 battlerStealer, u8 battlerItem);
|
void StealTargetItem(u8 battlerStealer, u8 battlerItem);
|
||||||
u8 GetCatchingBattler(void);
|
u8 GetCatchingBattler(void);
|
||||||
u32 GetHighestStatId(u32 battlerId);
|
u32 GetHighestStatId(u32 battlerId);
|
||||||
|
bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType);
|
||||||
bool32 DoSwitchInAbilitiesItems(u32 battlerId);
|
bool32 DoSwitchInAbilitiesItems(u32 battlerId);
|
||||||
|
|
||||||
extern void (* const gBattleScriptingCommandsTable[])(void);
|
extern void (* const gBattleScriptingCommandsTable[])(void);
|
||||||
|
@ -538,9 +538,10 @@ void SaveBattlerData(u8 battlerId)
|
|||||||
AI_THINKING_STRUCT->saved[battlerId].species = gBattleMons[battlerId].species;
|
AI_THINKING_STRUCT->saved[battlerId].species = gBattleMons[battlerId].species;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
AI_THINKING_STRUCT->saved[battlerId].moves[i] = gBattleMons[battlerId].moves[i];
|
AI_THINKING_STRUCT->saved[battlerId].moves[i] = gBattleMons[battlerId].moves[i];
|
||||||
AI_THINKING_STRUCT->saved[battlerId].types[0] = gBattleMons[battlerId].type1;
|
|
||||||
AI_THINKING_STRUCT->saved[battlerId].types[1] = gBattleMons[battlerId].type2;
|
|
||||||
}
|
}
|
||||||
|
// Save and restore types even for AI controlled battlers in case it gets changed during move evaluation process.
|
||||||
|
AI_THINKING_STRUCT->saved[battlerId].types[0] = gBattleMons[battlerId].type1;
|
||||||
|
AI_THINKING_STRUCT->saved[battlerId].types[1] = gBattleMons[battlerId].type2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool32 ShouldFailForIllusion(u16 illusionSpecies, u32 battlerId)
|
static bool32 ShouldFailForIllusion(u16 illusionSpecies, u32 battlerId)
|
||||||
@ -631,9 +632,9 @@ void RestoreBattlerData(u8 battlerId)
|
|||||||
gBattleMons[battlerId].species = AI_THINKING_STRUCT->saved[battlerId].species;
|
gBattleMons[battlerId].species = AI_THINKING_STRUCT->saved[battlerId].species;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
gBattleMons[battlerId].moves[i] = AI_THINKING_STRUCT->saved[battlerId].moves[i];
|
gBattleMons[battlerId].moves[i] = AI_THINKING_STRUCT->saved[battlerId].moves[i];
|
||||||
gBattleMons[battlerId].type1 = AI_THINKING_STRUCT->saved[battlerId].types[0];
|
|
||||||
gBattleMons[battlerId].type2 = AI_THINKING_STRUCT->saved[battlerId].types[1];
|
|
||||||
}
|
}
|
||||||
|
gBattleMons[battlerId].type1 = AI_THINKING_STRUCT->saved[battlerId].types[0];
|
||||||
|
gBattleMons[battlerId].type2 = AI_THINKING_STRUCT->saved[battlerId].types[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetHealthPercentage(u8 battlerId)
|
u32 GetHealthPercentage(u8 battlerId)
|
||||||
@ -801,6 +802,7 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 *typeEffectiveness,
|
|||||||
|
|
||||||
if (gBattleMoves[move].power)
|
if (gBattleMoves[move].power)
|
||||||
{
|
{
|
||||||
|
ProteanTryChangeType(battlerAtk, AI_DATA->abilities[battlerAtk], move, moveType);
|
||||||
critChance = GetInverseCritChance(battlerAtk, battlerDef, move);
|
critChance = GetInverseCritChance(battlerAtk, battlerDef, move);
|
||||||
normalDmg = CalculateMoveDamageAndEffectiveness(move, battlerAtk, battlerDef, moveType, &effectivenessMultiplier);
|
normalDmg = CalculateMoveDamageAndEffectiveness(move, battlerAtk, battlerDef, moveType, &effectivenessMultiplier);
|
||||||
critDmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, TRUE, FALSE, FALSE);
|
critDmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, TRUE, FALSE, FALSE);
|
||||||
|
@ -1443,6 +1443,19 @@ static bool32 TryAegiFormChange(void)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType)
|
||||||
|
{
|
||||||
|
if ((ability == ABILITY_PROTEAN || ability == ABILITY_LIBERO)
|
||||||
|
&& (gBattleMons[battler].type1 != moveType || gBattleMons[battler].type2 != moveType
|
||||||
|
|| (gBattleMons[battler].type3 != moveType && gBattleMons[battler].type3 != TYPE_MYSTERY))
|
||||||
|
&& move != MOVE_STRUGGLE)
|
||||||
|
{
|
||||||
|
SET_BATTLER_TYPE(gBattlerAttacker, moveType);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void Cmd_attackcanceler(void)
|
static void Cmd_attackcanceler(void)
|
||||||
{
|
{
|
||||||
CMD_ARGS();
|
CMD_ARGS();
|
||||||
@ -1499,13 +1512,9 @@ static void Cmd_attackcanceler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check Protean activation.
|
// Check Protean activation.
|
||||||
if ((attackerAbility == ABILITY_PROTEAN || attackerAbility == ABILITY_LIBERO)
|
if (ProteanTryChangeType(gBattlerAttacker, attackerAbility, gCurrentMove, moveType))
|
||||||
&& (gBattleMons[gBattlerAttacker].type1 != moveType || gBattleMons[gBattlerAttacker].type2 != moveType ||
|
|
||||||
(gBattleMons[gBattlerAttacker].type3 != moveType && gBattleMons[gBattlerAttacker].type3 != TYPE_MYSTERY))
|
|
||||||
&& gCurrentMove != MOVE_STRUGGLE)
|
|
||||||
{
|
{
|
||||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType);
|
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType);
|
||||||
SET_BATTLER_TYPE(gBattlerAttacker, moveType);
|
|
||||||
gBattlerAbility = gBattlerAttacker;
|
gBattlerAbility = gBattlerAttacker;
|
||||||
BattleScriptPushCursor();
|
BattleScriptPushCursor();
|
||||||
PrepareStringBattle(STRINGID_EMPTYSTRING3, gBattlerAttacker);
|
PrepareStringBattle(STRINGID_EMPTYSTRING3, gBattlerAttacker);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user