Make AI see Loaded Dice hold effect for multi hit moves that strike 5… (#4622)

* Make AI see Loaded Dice hold effect for multi hit moves that strike 5 times

* Update battle_ai_util.c
This commit is contained in:
Alex 2024-05-26 22:19:45 +02:00 committed by GitHub
parent c129423a69
commit 4f1df84acf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 5 deletions

View file

@ -552,9 +552,14 @@ s32 AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u8 *typeEffectivenes
dmg = gMovesInfo[move].argument * (aiData->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1);
break;
case EFFECT_MULTI_HIT:
dmg *= (aiData->abilities[battlerAtk] == ABILITY_SKILL_LINK
&& !(move == MOVE_WATER_SHURIKEN && gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH)
? 5 : 3);
if (move == MOVE_WATER_SHURIKEN && gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH)
dmg *= 3;
else if (aiData->abilities[battlerAtk] == ABILITY_SKILL_LINK)
dmg *= 5;
else if (aiData->holdEffects[battlerAtk] == HOLD_EFFECT_LOADED_DICE)
dmg *= 4;
else
dmg *= 3;
break;
case EFFECT_ENDEAVOR:
// If target has less HP than user, Endeavor does no damage
@ -3284,7 +3289,7 @@ s32 AI_CalcPartyMonDamage(u32 move, u32 battlerAtk, u32 battlerDef, struct Battl
s32 dmg;
u8 effectiveness;
struct BattlePokemon *savedBattleMons = AllocSaveBattleMons();
if (isPartyMonAttacker)
{
gBattleMons[battlerAtk] = switchinCandidate;
@ -3299,7 +3304,7 @@ s32 AI_CalcPartyMonDamage(u32 move, u32 battlerAtk, u32 battlerDef, struct Battl
SetBattlerData(battlerAtk); // set known opposing battler data
AI_THINKING_STRUCT->saved[battlerAtk].saved = FALSE;
}
dmg = AI_CalcDamage(move, battlerAtk, battlerDef, &effectiveness, FALSE, AI_GetWeather(AI_DATA));
// restores original gBattleMon struct
FreeRestoreBattleMons(savedBattleMons);

View file

@ -46,3 +46,16 @@ AI_SINGLE_BATTLE_TEST("AI will choose a priority move if it is slower then the t
MESSAGE("Foe Wobbuffet fainted!");
}
}
AI_SINGLE_BATTLE_TEST("AI sees Loaded Dice damage increase from multi hit moves")
{
GIVEN {
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
PLAYER(SPECIES_WOBBUFFET) { HP(44); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_LOADED_DICE); Moves(MOVE_SEED_BOMB, MOVE_BULLET_SEED); }
} WHEN {
TURN { EXPECT_MOVE(opponent, MOVE_BULLET_SEED); }
} SCENE {
MESSAGE("Wobbuffet fainted!");
}
}