From f30a9542eebb2db4fb7245b324fea649787b8352 Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Thu, 27 May 2021 22:21:55 -0700 Subject: [PATCH] Problem: Photon Geyser is calculating as Shell Side Arm?? Needs: Poison effect, contact move for Shell Side Arm --- asm/macros/battle_script.inc | 8 ++++ data/battle_scripts_1.s | 8 ++++ include/battle.h | 2 + include/constants/battle_move_effects.h | 4 +- include/constants/battle_script_commands.h | 2 + src/battle_main.c | 3 ++ src/battle_script_commands.c | 49 ++++++++++++++++++++++ src/battle_util.c | 7 +++- src/data/battle_moves.h | 10 ++--- 9 files changed, 85 insertions(+), 8 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9fa3fe0c3..b5d21abc4 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1726,6 +1726,14 @@ .4byte \ptr .endm + .macro photongeysercheck + various BS_ATTACKER, VARIOUS_PHOTON_GEYSER_CHECK + .endm + + .macro shellsidearmcheck + various BS_ATTACKER, VARIOUS_SHELL_SIDE_ARM_CHECK + .endm + .macro trysetfairylock ptr:req various BS_ATTACKER, VARIOUS_TRY_FAIRY_LOCK .4byte \ptr diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 77eddc8ab..544583961 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -367,6 +367,14 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectFairyLock .4byte BattleScript_EffectAllySwitch .4byte BattleScript_EffectSleepHit + .4byte BattleScript_EffectPhotonGeyser + .4byte BattleScript_EffectShellSideArm + +BattleScript_EffectShellSideArm: + shellsidearmcheck + +BattleScript_EffectPhotonGeyser: + photongeysercheck BattleScript_EffectSleepHit: setmoveeffect MOVE_EFFECT_SLEEP diff --git a/include/battle.h b/include/battle.h index 82a917538..2195e0a21 100644 --- a/include/battle.h +++ b/include/battle.h @@ -858,4 +858,6 @@ extern u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; +extern bool8 gSwapDamageCategory; // Photon Geyser, Shell Side Arm, Light That Burns the Sky + #endif // GUARD_BATTLE_H diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 74418d2c7..b9cf92854 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -351,7 +351,9 @@ #define EFFECT_FAIRY_LOCK 345 #define EFFECT_ALLY_SWITCH 346 #define EFFECT_SLEEP_HIT 347 // Relic Song +#define EFFECT_PHOTON_GEYSER 348 +#define EFFECT_SHELL_SIDE_ARM 349 -#define NUM_BATTLE_MOVE_EFFECTS 348 +#define NUM_BATTLE_MOVE_EFFECTS 350 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index faaf8f17e..28ba1a5d4 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -173,6 +173,8 @@ #define VARIOUS_DESTROY_ABILITY_POPUP 102 #define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 +#define VARIOUS_PHOTON_GEYSER_CHECK 105 +#define VARIOUS_SHELL_SIDE_ARM_CHECK 106 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_main.c b/src/battle_main.c index 77470246f..739d33a3e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -229,6 +229,7 @@ EWRAM_DATA u16 gPartnerSpriteId = 0; EWRAM_DATA struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA bool8 gHasFetchedBall = FALSE; EWRAM_DATA u8 gLastUsedBall = 0; +EWRAM_DATA bool8 gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky // IWRAM common vars void (*gPreBattleCallback1)(void); @@ -2928,6 +2929,8 @@ static void BattleStartClearSetData(void) gBattleStruct->arenaLostOpponentMons = 0; gBattleStruct->mega.triggerSpriteId = 0xFF; + + gSwapDamageCategory = 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 fc0eedcbc..2a761e5c6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7126,6 +7126,55 @@ static void Cmd_various(void) switch (gBattlescriptCurrInstr[2]) { + case VARIOUS_PHOTON_GEYSER_CHECK: + { + u32 attStat = gBattleMons[gActiveBattler].attack; + u8 atkStage = gBattleMons[gActiveBattler].statStages[STAT_ATK]; + u32 spaStat = gBattleMons[gActiveBattler].spAttack; + + attStat *= gStatStageRatios[atkStage][0]; + attStat /= gStatStageRatios[atkStage][1]; + + atkStage = gBattleMons[gActiveBattler].statStages[STAT_SPATK]; + spaStat *= gStatStageRatios[atkStage][0]; + spaStat /= gStatStageRatios[atkStage][1]; + + if (attStat > spaStat) + gSwapDamageCategory = TRUE; + } + case VARIOUS_SHELL_SIDE_ARM_CHECK: // according to DaWoblefet, 0% chance GameFreak actually checks this way, but this is the only functional explanation at the moment + { + u32 attStat = gBattleMons[gBattlerAttacker].attack; + u8 atkStage = gBattleMons[gBattlerAttacker].statStages[STAT_ATK]; + u32 attStatDef = gBattleMons[gBattlerTarget].attack; + u32 physical; + + u32 spaStat = gBattleMons[gBattlerAttacker].spAttack; + u32 spaStatDef = gBattleMons[gBattlerTarget].spAttack; + u32 special; + + attStat *= gStatStageRatios[atkStage][0]; + attStat /= gStatStageRatios[atkStage][1]; + + atkStage = gBattleMons[gBattlerTarget].statStages[STAT_ATK]; + attStatDef *= gStatStageRatios[atkStage][0]; + attStatDef /= gStatStageRatios[atkStage][1]; + + physical = ((((2 * gBattleMons[gBattlerAttacker].level / 5 + 2) * 90 * attStat) / attStatDef) / 50); + + atkStage = gBattleMons[gBattlerAttacker].statStages[STAT_SPATK]; + spaStat *= gStatStageRatios[atkStage][0]; + spaStat /= gStatStageRatios[atkStage][1]; + + atkStage = gBattleMons[gBattlerTarget].statStages[STAT_SPATK]; + spaStatDef *= gStatStageRatios[atkStage][0]; + spaStatDef /= gStatStageRatios[atkStage][1]; + + special = ((((2 * gBattleMons[gBattlerAttacker].level / 5 + 2) * 90 * spaStat) / spaStatDef) / 50); + + if (((physical > special) || (physical == special && (Random() % 2) == 0))) + gSwapDamageCategory = TRUE; + } // Roar will fail in a double wild battle when used by the player against one of the two alive wild mons. // Also when an opposing wild mon uses it againt its partner. case VARIOUS_JUMP_IF_ROAR_FAILS: diff --git a/src/battle_util.c b/src/battle_util.c index 07c150066..e657a4e96 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8367,8 +8367,11 @@ bool8 ShouldGetStatBadgeBoost(u16 badgeFlag, u8 battlerId) u8 GetBattleMoveSplit(u32 moveId) { if (IS_MOVE_STATUS(moveId) || B_PHYSICAL_SPECIAL_SPLIT >= GEN_4) - return gBattleMoves[moveId].split; - else if (gBattleMoves[moveId].type < TYPE_MYSTERY) + if (gSwapDamageCategory == TRUE) // Photon Geyser, Shell Side Arm, Light That Burns the Sky + return SPLIT_PHYSICAL; + else + return gBattleMoves[moveId].split; + else if (gBattleMoves[moveId].type < TYPE_MYSTERY || gSwapDamageCategory == TRUE) // Photon Geyser, Shell Side Arm, Light That Burns the Sky return SPLIT_PHYSICAL; else return SPLIT_SPECIAL; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 61050e44f..0e27bb588 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10343,15 +10343,15 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_PHOTON_GEYSER] = { - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_PHOTON_GEYSER, .power = 100, .type = TYPE_PSYCHIC, .accuracy = 100, .pp = 5, - .secondaryEffectChance = 0, + .secondaryEffectChance = 100, .target = MOVE_TARGET_FOES_AND_ALLY, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TARGET_ABILITY_IGNORED, .split = SPLIT_SPECIAL, }, @@ -11178,12 +11178,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_SHELL_SIDE_ARM] = { - .effect = EFFECT_PLACEHOLDER, //TODO + .effect = EFFECT_SHELL_SIDE_ARM, .power = 90, .type = TYPE_POISON, .accuracy = 100, .pp = 10, - .secondaryEffectChance = 0, + .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED,