From 632ec92475009bb0e9f376f4a1c7ce88563ca032 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Wed, 21 Dec 2022 13:48:19 +0000 Subject: [PATCH] Minor Roost changes - Fix 'mon with Flying in type3 but not type1 or type2 is set to uninitialized roostTypes. - Remove unread third roostTypes element. - Option for Gen IV pure-Flying behavior. --- include/battle.h | 2 +- include/config/battle.h | 1 + src/battle_script_commands.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/battle.h b/include/battle.h index 72ec1b41f250..a38c28db87c5 100644 --- a/include/battle.h +++ b/include/battle.h @@ -611,7 +611,7 @@ struct BattleStruct u8 debugBattler; u8 magnitudeBasePower; u8 presentBasePower; - u8 roostTypes[MAX_BATTLERS_COUNT][3]; + u8 roostTypes[MAX_BATTLERS_COUNT][2]; u8 savedBattlerTarget; bool8 ateBoost[MAX_BATTLERS_COUNT]; u8 activeAbilityPopUps; // as bits for each battler diff --git a/include/config/battle.h b/include/config/battle.h index 644f9955c128..47a2acee478f 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -38,6 +38,7 @@ #define B_STEEL_RESISTANCES GEN_LATEST // In Gen6+, Steel-type Pokémon are no longer resistant to Dark-type and Ghost-type moves. #define B_PRANKSTER_DARK_TYPES GEN_LATEST // In Gen7+, Prankster-elevated status moves do not affect Dark type Pokémon. #define B_SHEER_COLD_IMMUNITY GEN_LATEST // In Gen7+, Ice-types are immune to Sheer Cold +#define B_ROOST_PURE_FLYING GEN_LATEST // In Gen5+, Roost makes pure Flying-types into Normal-type. // Turn settings #define B_BINDING_TURNS GEN_LATEST // In Gen5+, binding moves last for 4-5 turns instead of 2-5 turns. (With Grip Claw, 7 and 5 turns respectively.) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 055a100b653a..6ab5667df2ce 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4802,22 +4802,24 @@ static void Cmd_setroost(void) { gBattleStruct->roostTypes[gBattlerAttacker][0] = TYPE_FLYING; gBattleStruct->roostTypes[gBattlerAttacker][1] = TYPE_FLYING; - gBattleStruct->roostTypes[gBattlerAttacker][2] = TYPE_FLYING; +#if B_ROOST_PURE_FLYING >= GEN_5 SET_BATTLER_TYPE(gBattlerAttacker, TYPE_NORMAL); +#else + SET_BATTLER_TYPE(gBattlerAttacker, TYPE_MYSTERY); +#endif } - // Dual Type with Flying Type. - else if ((gBattleMons[gBattlerAttacker].type1 == TYPE_FLYING && gBattleMons[gBattlerAttacker].type2 != TYPE_FLYING) - ||(gBattleMons[gBattlerAttacker].type2 == TYPE_FLYING && gBattleMons[gBattlerAttacker].type1 != TYPE_FLYING)) + // Dual type with flying type. + else if (gBattleMons[gBattlerAttacker].type1 == TYPE_FLYING || gBattleMons[gBattlerAttacker].type2 == TYPE_FLYING) { gBattleStruct->roostTypes[gBattlerAttacker][0] = gBattleMons[gBattlerAttacker].type1; gBattleStruct->roostTypes[gBattlerAttacker][1] = gBattleMons[gBattlerAttacker].type2; if (gBattleMons[gBattlerAttacker].type1 == TYPE_FLYING) gBattleMons[gBattlerAttacker].type1 = TYPE_MYSTERY; - if (gBattleMons[gBattlerAttacker].type2 == TYPE_FLYING) + else if (gBattleMons[gBattlerAttacker].type2 == TYPE_FLYING) gBattleMons[gBattlerAttacker].type2 = TYPE_MYSTERY; } // Non-flying type. - else if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_FLYING)) + else { gBattleStruct->roostTypes[gBattlerAttacker][0] = gBattleMons[gBattlerAttacker].type1; gBattleStruct->roostTypes[gBattlerAttacker][1] = gBattleMons[gBattlerAttacker].type2;