diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 7875364f1..ff246955a 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1928,8 +1928,8 @@ .4byte \ptr .endm - .macro photongeysercheck - various BS_ATTACKER, VARIOUS_PHOTON_GEYSER_CHECK + .macro photongeysercheck battler:req + various \battler, VARIOUS_PHOTON_GEYSER_CHECK .endm .macro shellsidearmcheck diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 03ab6802c..4afb9c87e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -722,7 +722,7 @@ BattleScript_EffectPhotonGeyser: critcalc damagecalc adjustdamage - photongeysercheck + photongeysercheck BS_ATTACKER attackanimation waitanimation effectivenesssound diff --git a/include/battle.h b/include/battle.h index 185c509df..38e14b734 100644 --- a/include/battle.h +++ b/include/battle.h @@ -615,6 +615,7 @@ struct BattleStruct u8 quickClawBattlerId; struct StolenItem itemStolen[PARTY_SIZE]; // Player's team that had items stolen (two bytes per party member) u8 blunderPolicy:1; // should blunder policy activate + u8 swapDamageCategory:1; u8 ballSpriteIds[2]; // item gfx, window gfx u8 stickyWebUser; u8 appearedInBattle; // Bitfield to track which Pokemon appeared in battle. Used for Burmy's form change @@ -938,7 +939,6 @@ extern u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; extern u16 gLastThrownBall; -extern bool8 gSwapDamageCategory; // Photon Geyser, Shell Side Arm, Light That Burns the Sky extern u8 gPartyCriticalHits[PARTY_SIZE]; #endif // GUARD_BATTLE_H diff --git a/include/constants/z_move_effects.h b/include/constants/z_move_effects.h index 8b77596ef..ce4d5c4ad 100644 --- a/include/constants/z_move_effects.h +++ b/include/constants/z_move_effects.h @@ -35,4 +35,4 @@ #define Z_EFFECT_EVSN_UP_3 28 -#endif // GUARD_Z_MOVE_EFFECTS_H \ No newline at end of file +#endif // GUARD_Z_MOVE_EFFECTS_H diff --git a/src/battle_anim_new.c b/src/battle_anim_new.c index f737aee80..96faf23dd 100644 --- a/src/battle_anim_new.c +++ b/src/battle_anim_new.c @@ -7867,7 +7867,7 @@ void AnimTask_PrimalReversion(u8 taskId) void AnimTask_ShellSideArm(u8 taskId) { - if (gSwapDamageCategory) + if (gBattleStruct->swapDamageCategory) gBattleAnimArgs[0] = TRUE; else gBattleAnimArgs[0] = FALSE; diff --git a/src/battle_main.c b/src/battle_main.c index 0d001d6f6..ff8b6a58d 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -239,7 +239,6 @@ EWRAM_DATA struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA bool8 gHasFetchedBall = FALSE; EWRAM_DATA u8 gLastUsedBall = 0; EWRAM_DATA u16 gLastThrownBall = 0; -EWRAM_DATA bool8 gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky EWRAM_DATA u8 gPartyCriticalHits[PARTY_SIZE] = {0}; EWRAM_DATA static u8 sTriedEvolving = 0; @@ -3007,7 +3006,7 @@ static void BattleStartClearSetData(void) gPartyCriticalHits[i] = 0; } - gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky + gBattleStruct->swapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky } void SwitchInClearSetData(void) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0de1725e8..eb3f32269 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9404,24 +9404,8 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 9; return; case VARIOUS_PHOTON_GEYSER_CHECK: - { - u32 attackerAtkStat = gBattleMons[gBattlerAttacker].attack; - u8 attackerAtkStage = gBattleMons[gBattlerAttacker].statStages[STAT_ATK]; - u32 attackerSpAtkStat = gBattleMons[gBattlerAttacker].spAttack; - - gSwapDamageCategory = FALSE; - - attackerAtkStat *= gStatStageRatios[attackerAtkStage][0]; - attackerAtkStat /= gStatStageRatios[attackerAtkStage][1]; - - attackerAtkStage = gBattleMons[gBattlerAttacker].statStages[STAT_SPATK]; - attackerSpAtkStat *= gStatStageRatios[attackerAtkStage][0]; - attackerSpAtkStat /= gStatStageRatios[attackerAtkStage][1]; - - if (attackerAtkStat > attackerSpAtkStat) - gSwapDamageCategory = TRUE; + gBattleStruct->swapDamageCategory = (GetSplitBasedOnStats(gActiveBattler) == SPLIT_SPECIAL); break; - } case VARIOUS_SHELL_SIDE_ARM_CHECK: // 0% chance GameFreak actually checks this way according to DaWobblefet, but this is the only functional explanation at the moment { u32 attackerAtkStat = gBattleMons[gBattlerAttacker].attack; @@ -9432,7 +9416,7 @@ static void Cmd_various(void) u32 physical; u32 special; - gSwapDamageCategory = FALSE; + gBattleStruct->swapDamageCategory = FALSE; statStage = gBattleMons[gBattlerAttacker].statStages[STAT_ATK]; attackerAtkStat *= gStatStageRatios[statStage][0]; @@ -9455,7 +9439,7 @@ static void Cmd_various(void) special = ((((2 * gBattleMons[gBattlerAttacker].level / 5 + 2) * gBattleMoves[gCurrentMove].power * attackerSpAtkStat) / targetSpDefStat) / 50); if (((physical > special) || (physical == special && (Random() % 2) == 0))) - gSwapDamageCategory = TRUE; + gBattleStruct->swapDamageCategory = TRUE; break; } case VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED: diff --git a/src/battle_util.c b/src/battle_util.c index 044e36adb..bfbfb8993 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7740,7 +7740,7 @@ bool32 IsMoveMakingContact(u16 move, u8 battlerAtk) { if (!(gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) { - if (gBattleMoves[move].effect == EFFECT_SHELL_SIDE_ARM && gSwapDamageCategory) + if (gBattleMoves[move].effect == EFFECT_SHELL_SIDE_ARM && gBattleStruct->swapDamageCategory) return TRUE; else return FALSE; @@ -7773,7 +7773,7 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) // Protective Pads doesn't stop Unseen Fist from bypassing Protect effects, so IsMoveMakingContact() isn't used here. // This means extra logic is needed to handle Shell Side Arm. if (GetBattlerAbility(gBattlerAttacker) == ABILITY_UNSEEN_FIST - && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT || (gBattleMoves[move].effect == EFFECT_SHELL_SIDE_ARM && gSwapDamageCategory))) + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT || (gBattleMoves[move].effect == EFFECT_SHELL_SIDE_ARM && gBattleStruct->swapDamageCategory))) return FALSE; else if (!(gBattleMoves[move].flags & FLAG_PROTECT_AFFECTED)) return FALSE; @@ -9685,7 +9685,7 @@ u8 GetBattleMoveSplit(u32 moveId) { if (gBattleStruct != NULL && gBattleStruct->zmove.active && !IS_MOVE_STATUS(moveId)) return gBattleStruct->zmove.activeSplit; - if (gSwapDamageCategory) // Photon Geyser, Shell Side Arm, Light That Burns the Sky + if (gBattleStruct != NULL && gBattleStruct->swapDamageCategory) // Photon Geyser, Shell Side Arm, Light That Burns the Sky return SPLIT_PHYSICAL; else if (IS_MOVE_STATUS(moveId) || B_PHYSICAL_SPECIAL_SPLIT >= GEN_4) return gBattleMoves[moveId].split;