From 55b279ba0ab302be4fd0e61e7afeca6336d38af7 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sat, 13 Nov 2021 16:29:12 +1300 Subject: [PATCH] Fix several move effects Dragon Tail, Natural Gift, Spit Up all hit twice now. Could maybe use isparentalbondlaststrike instead of some of the other checks too. --- asm/macros/battle_script.inc | 5 +++++ data/battle_scripts_1.s | 4 ++++ include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 17 +++++++++++++---- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index df4a860dd9..a5ac603ed4 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1891,6 +1891,11 @@ various BS_ATTACKER, VARIOUS_SHELL_SIDE_ARM_CHECK .endm + .macro isparentalbondlaststrike ptr:req + various BS_ATTACKER, VARIOUS_IS_PARENTAL_BOND_LAST_STRIKE + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0353c91332..3677bc535e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1534,6 +1534,7 @@ BattleScript_EffectHitSwitchTarget: resultmessage waitmessage B_WAIT_TIME_LONG tryfaintmon BS_TARGET, FALSE, NULL + isparentalbondlaststrike BattleScript_EffectHitSwitchTargetMoveEnd jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut jumpifstatus3 BS_TARGET, STATUS3_ROOTED, BattleScript_PrintMonIsRooted tryhitswitchtarget BattleScript_EffectHitSwitchTargetMoveEnd @@ -2536,6 +2537,7 @@ BattleScript_EffectNaturalGift: waitmessage B_WAIT_TIME_LONG seteffectwithchance jumpifmovehadnoeffect BattleScript_EffectNaturalGiftEnd + isparentalbondlaststrike BattleScript_EffectNaturalGiftEnd removeitem BS_ATTACKER BattleScript_EffectNaturalGiftEnd: tryfaintmon BS_TARGET, FALSE, NULL @@ -4817,9 +4819,11 @@ BattleScript_EffectSpitUp:: stockpiletobasedamage BattleScript_SpitUpFail goto BattleScript_HitFromAtkAnimation BattleScript_SpitUpFail:: + isparentalbondlaststrike BattleScript_SpitUpEnd pause B_WAIT_TIME_SHORT printstring STRINGID_FAILEDTOSPITUP waitmessage B_WAIT_TIME_LONG +BattleScript_SpitUpEnd: goto BattleScript_MoveEnd BattleScript_SpitUpFailProtect:: diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 82a28f86a4..b3fa659c22 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -201,6 +201,7 @@ #define VARIOUS_TRY_TO_APPLY_MIMICRY 128 #define VARIOUS_PHOTON_GEYSER_CHECK 129 #define VARIOUS_SHELL_SIDE_ARM_CHECK 130 +#define VARIOUS_IS_PARENTAL_BOND_LAST_STRIKE 131 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 789c95bb00..d3cafeccae 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9275,6 +9275,12 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; return; } + case VARIOUS_IS_PARENTAL_BOND_LAST_STRIKE: + if (gSpecialStatuses[gBattlerAttacker].parentalBondOn == 2 && gBattleMons[gBattlerTarget].hp != 0) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; } gBattlescriptCurrInstr += 3; @@ -9743,10 +9749,13 @@ static void Cmd_stockpiletobasedamage(void) if (gBattleCommunication[MISS_TYPE] != B_MSG_PROTECTED) gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; - gDisableStructs[gBattlerAttacker].stockpileCounter = 0; - // Restore stat changes from stockpile. - gBattleMons[gBattlerAttacker].statStages[STAT_DEF] -= gDisableStructs[gBattlerAttacker].stockpileDef; - gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF] -= gDisableStructs[gBattlerAttacker].stockpileSpDef; + if (!(gSpecialStatuses[gBattlerAttacker].parentalBondOn == 2 && gBattleMons[gBattlerTarget].hp != 0)) + { + gDisableStructs[gBattlerAttacker].stockpileCounter = 0; + // Restore stat changes from stockpile. + gBattleMons[gBattlerAttacker].statStages[STAT_DEF] -= gDisableStructs[gBattlerAttacker].stockpileDef; + gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF] -= gDisableStructs[gBattlerAttacker].stockpileSpDef; + } gBattlescriptCurrInstr += 5; } }