From d3c8346a676cec0a0e18f0acb4a9b4c8b418dde6 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Fri, 17 Jun 2022 21:58:56 -0400 Subject: [PATCH] fix type, add bugfix --- src/battle_ai_switch_items.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 9c9bc4eef..c87271722 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -628,7 +628,11 @@ static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 u8 GetMostSuitableMonToSwitchInto(void) { u8 opposingBattler; +#ifdef BUGFIX + s32 bestDmg; +#else u8 bestDmg; // Note: should be changed to s32 since it is also used for the actual damage done later +#endif u8 bestMonId; u8 battlerIn1, battlerIn2; s32 firstId; @@ -684,8 +688,8 @@ u8 GetMostSuitableMonToSwitchInto(void) while (invalidMons != 0x3F) // All mons are invalid. { - bestDmg = ; - bestMonId = 6; + bestDmg = TYPE_MUL_NO_EFFECT; + bestMonId = PARTY_SIZE; // Find the mon whose type is the most suitable offensively. for (i = firstId; i < lastId; i++) { @@ -706,7 +710,7 @@ u8 GetMostSuitableMonToSwitchInto(void) /* Possible bug: this comparison gives the type that takes the most damage, when a "good" AI would want to select the type that takes the least damage. Unknown if this - is a legitimate mistake or if it's an intentional, if weird, design choice*/ + is a legitimate mistake or if it's an intentional, if weird, design choice */ if (bestDmg < typeDmg) { bestDmg = typeDmg;