From 4342bfb91d91618d47aa8fb47d86c6523cf4f21c Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Sat, 10 May 2025 20:09:38 +0200 Subject: [PATCH] Refactor stockpile resets (#6810) Co-authored-by: Bassoonian --- asm/macros/battle_script.inc | 4 ++++ data/battle_scripts_1.s | 16 ++++++++++++++-- include/constants/battle.h | 1 - src/battle_script_commands.c | 33 ++++++++++++++++++--------------- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 996ed24d3b..adc9fcc195 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -764,6 +764,10 @@ .4byte \failInstr .endm + .macro removestockpilecounters + callnative BS_RemoveStockpileCounters + .endm + .macro setdrainedhp .byte 0x88 .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 772f6aa404..9e44459200 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4598,7 +4598,10 @@ BattleScript_EffectSpitUp:: damagecalc adjustdamage stockpiletobasedamage BattleScript_SpitUpFail - goto BattleScript_HitFromAtkAnimation + call BattleScript_Hit_RetFromAtkAnimation + tryfaintmon BS_TARGET + removestockpilecounters + goto BattleScript_SpitUpEnd BattleScript_SpitUpFail:: checkparentalbondcounter 2, BattleScript_SpitUpEnd pause B_WAIT_TIME_SHORT @@ -4621,7 +4624,16 @@ BattleScript_EffectSwallow:: attackstring ppreduce stockpiletohpheal BattleScript_SwallowFail - goto BattleScript_PresentHealTarget + attackanimation + waitanimation + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + printstring STRINGID_PKMNREGAINEDHEALTH + waitmessage B_WAIT_TIME_LONG + removestockpilecounters + goto BattleScript_MoveEnd + BattleScript_SwallowFail:: pause B_WAIT_TIME_SHORT diff --git a/include/constants/battle.h b/include/constants/battle.h index bd8c56c2a0..09ff9b621b 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -389,7 +389,6 @@ enum MoveEffects MOVE_EFFECT_RECOIL_HP_25, MOVE_EFFECT_TRAP_BOTH, MOVE_EFFECT_ROUND, - MOVE_EFFECT_STOCKPILE_WORE_OFF, MOVE_EFFECT_DIRE_CLAW, MOVE_EFFECT_STEALTH_ROCK, MOVE_EFFECT_SPIKES, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b837544541..067b06afb4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3279,7 +3279,6 @@ void SetMoveEffect(bool32 primary, bool32 certain) case MOVE_EFFECT_KNOCK_OFF: case MOVE_EFFECT_SMACK_DOWN: case MOVE_EFFECT_REMOVE_STATUS: - case MOVE_EFFECT_STOCKPILE_WORE_OFF: gBattleStruct->moveEffect2 = gBattleScripting.moveEffect; gBattlescriptCurrInstr++; return; @@ -6516,15 +6515,6 @@ static void Cmd_moveend(void) effect = TryKnockOffBattleScript(gBattlerTarget); } break; - case MOVE_EFFECT_STOCKPILE_WORE_OFF: - if (gDisableStructs[gBattlerAttacker].stockpileCounter != 0) - { - gDisableStructs[gBattlerAttacker].stockpileCounter = 0; - effect = TRUE; - BattleScriptPush(gBattlescriptCurrInstr); - gBattlescriptCurrInstr = BattleScript_MoveEffectStockpileWoreOff; - } - break; case MOVE_EFFECT_SMACK_DOWN: if (!IsBattlerGrounded(gBattlerTarget) && IsBattlerAlive(gBattlerTarget) @@ -12054,10 +12044,6 @@ static void Cmd_stockpiletobasedamage(void) if (gBattleCommunication[MISS_TYPE] != B_MSG_PROTECTED) gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; - if (!(gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT && IsBattlerAlive(gBattlerTarget))) - { - gBattleStruct->moveEffect2 = MOVE_EFFECT_STOCKPILE_WORE_OFF; - } gBattlescriptCurrInstr = cmd->nextInstr; } } @@ -12088,7 +12074,6 @@ static void Cmd_stockpiletohpheal(void) { gBattleStruct->moveDamage[gBattlerAttacker] = GetNonDynamaxMaxHP(gBattlerAttacker) / (1 << (3 - gDisableStructs[gBattlerAttacker].stockpileCounter)); gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; - gBattleStruct->moveEffect2 = MOVE_EFFECT_STOCKPILE_WORE_OFF; } else // Snatched move { @@ -12106,6 +12091,24 @@ static void Cmd_stockpiletohpheal(void) } } +void BS_RemoveStockpileCounters(void) +{ + NATIVE_ARGS(); + + if (GetMoveEffect(gCurrentMove) == EFFECT_SWALLOW + && gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT + && IsBattlerAlive(gBattlerTarget)) + { + gBattlescriptCurrInstr = cmd->nextInstr; + } + else + { + gDisableStructs[gBattlerAttacker].stockpileCounter = 0; + BattleScriptPush(cmd->nextInstr); + gBattlescriptCurrInstr = BattleScript_MoveEffectStockpileWoreOff; + } +} + // Sign change for drained HP handled in GetDrainedBigRootHp static void Cmd_setdrainedhp(void) {