Refactor stockpile resets (#6810)

Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
This commit is contained in:
Alex 2025-05-10 20:09:38 +02:00 committed by GitHub
parent eee78ddfb9
commit 4342bfb91d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 18 deletions

View File

@ -764,6 +764,10 @@
.4byte \failInstr
.endm
.macro removestockpilecounters
callnative BS_RemoveStockpileCounters
.endm
.macro setdrainedhp
.byte 0x88
.endm

View File

@ -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

View File

@ -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,

View File

@ -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)
{