From e6a374f2b6bd0edc44459e74e76ecd668998b2b3 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 6 Jul 2022 14:38:27 -0400 Subject: [PATCH 1/2] Rename faintifabilitynotdamp and jumpifattackandspecialattackcannotfall --- asm/macros/battle_script.inc | 4 ++-- data/battle_scripts_1.s | 18 ++++++++++-------- src/battle_script_commands.c | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 73b3beca0b..0a44f6075a 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -668,7 +668,7 @@ .byte 0x77 .endm - .macro faintifabilitynotdamp + .macro tryexplosion .byte 0x78 .endm @@ -1031,7 +1031,7 @@ .byte 0xc8 .endm - .macro jumpifattackandspecialattackcannotfall ptr:req + .macro trymemento ptr:req .byte 0xc9 .4byte \ptr .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e3408a3a78..8dd80c9158 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -374,7 +374,8 @@ BattleScript_EffectExplosion:: attackcanceler attackstring ppreduce - faintifabilitynotdamp +@ Below jumps to BattleScript_DampStopsExplosion if it fails (only way it can) + tryexplosion setatkhptozero waitstate jumpifbyte CMP_NO_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_MISSED, BattleScript_ExplosionDoAnimStartLoop @@ -2201,10 +2202,10 @@ BattleScript_AlreadyBurned:: BattleScript_EffectMemento:: attackcanceler - jumpifbyte CMP_EQUAL, cMISS_TYPE, B_MSG_PROTECTED, BattleScript_MementoFailProtect + jumpifbyte CMP_EQUAL, cMISS_TYPE, B_MSG_PROTECTED, BattleScript_MementoTargetProtect attackstring ppreduce - jumpifattackandspecialattackcannotfall BattleScript_ButItFailed + trymemento BattleScript_ButItFailed setatkhptozero attackanimation waitanimation @@ -2214,7 +2215,7 @@ BattleScript_EffectMemento:: playstatchangeanimation BS_TARGET, BIT_ATK, STAT_CHANGE_NEGATIVE | STAT_CHANGE_BY_TWO setstatchanger STAT_ATK, 2, TRUE statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_EffectMementoTrySpAtk - @ Greater than STAT_FELL is checking if the stat cannot decrease +@ Greater than B_MSG_DEFENDER_STAT_FELL is checking if the stat cannot decrease jumpifbyte CMP_GREATER_THAN, cMULTISTRING_CHOOSER, B_MSG_DEFENDER_STAT_FELL, BattleScript_EffectMementoTrySpAtk printfromtable gStatDownStringIds waitmessage B_WAIT_TIME_LONG @@ -2222,7 +2223,7 @@ BattleScript_EffectMementoTrySpAtk: playstatchangeanimation BS_TARGET, BIT_SPATK, STAT_CHANGE_NEGATIVE | STAT_CHANGE_BY_TWO setstatchanger STAT_SPATK, 2, TRUE statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_EffectMementoTryFaint - @ Greater than STAT_FELL is checking if the stat cannot decrease +@ Greater than B_MSG_DEFENDER_STAT_FELL is checking if the stat cannot decrease jumpifbyte CMP_GREATER_THAN, cMULTISTRING_CHOOSER, B_MSG_DEFENDER_STAT_FELL, BattleScript_EffectMementoTryFaint printfromtable gStatDownStringIds waitmessage B_WAIT_TIME_LONG @@ -2233,11 +2234,12 @@ BattleScript_EffectMementoPrintNoEffect: printstring STRINGID_BUTNOEFFECT waitmessage B_WAIT_TIME_LONG goto BattleScript_EffectMementoTryFaint -BattleScript_MementoFailProtect: +@ If the target is protected there's no need to check the target's stats or animate, the user will just faint +BattleScript_MementoTargetProtect: attackstring ppreduce - jumpifattackandspecialattackcannotfall BattleScript_MementoFailEnd -BattleScript_MementoFailEnd: + trymemento BattleScript_MementoTargetProtectEnd +BattleScript_MementoTargetProtectEnd: setatkhptozero pause B_WAIT_TIME_LONG effectivenesssound diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4f31f0f01c..560b139664 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -196,7 +196,7 @@ static void Cmd_hpthresholds2(void); static void Cmd_useitemonopponent(void); static void Cmd_various(void); static void Cmd_setprotectlike(void); -static void Cmd_faintifabilitynotdamp(void); +static void Cmd_tryexplosion(void); static void Cmd_setatkhptozero(void); static void Cmd_jumpifnexttargetvalid(void); static void Cmd_tryhealhalfhealth(void); @@ -277,7 +277,7 @@ static void Cmd_setsemiinvulnerablebit(void); static void Cmd_clearsemiinvulnerablebit(void); static void Cmd_setminimize(void); static void Cmd_sethail(void); -static void Cmd_jumpifattackandspecialattackcannotfall(void); +static void Cmd_trymemento(void); static void Cmd_setforcedtarget(void); static void Cmd_setcharge(void); static void Cmd_callterrainattack(void); @@ -448,7 +448,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_useitemonopponent, //0x75 Cmd_various, //0x76 Cmd_setprotectlike, //0x77 - Cmd_faintifabilitynotdamp, //0x78 + Cmd_tryexplosion, //0x78 Cmd_setatkhptozero, //0x79 Cmd_jumpifnexttargetvalid, //0x7A Cmd_tryhealhalfhealth, //0x7B @@ -529,7 +529,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_clearsemiinvulnerablebit, //0xC6 Cmd_setminimize, //0xC7 Cmd_sethail, //0xC8 - Cmd_jumpifattackandspecialattackcannotfall, //0xC9 + Cmd_trymemento, //0xC9 Cmd_setforcedtarget, //0xCA Cmd_setcharge, //0xCB Cmd_callterrainattack, //0xCC @@ -6489,11 +6489,12 @@ static void Cmd_setprotectlike(void) // protect and endure gBattlescriptCurrInstr++; } -static void Cmd_faintifabilitynotdamp(void) +static void Cmd_tryexplosion(void) { if (gBattleControllerExecFlags) return; + // Explosion can only fail if any battler has Damp for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { if (gBattleMons[gBattlerTarget].ability == ABILITY_DAMP) @@ -6502,12 +6503,14 @@ static void Cmd_faintifabilitynotdamp(void) if (gBattlerTarget == gBattlersCount) { + // Success, no battlers with Damp. Drop user's HP bar to 0 gActiveBattler = gBattlerAttacker; gBattleMoveDamage = gBattleMons[gActiveBattler].hp; BtlController_EmitHealthBarUpdate(BUFFER_A, INSTANT_HP_BAR_DROP); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr++; + // Mark Explosion user as absent for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { if (gBattlerTarget == gBattlerAttacker) @@ -6518,6 +6521,7 @@ static void Cmd_faintifabilitynotdamp(void) } else { + // Failed, a battler has Damp gLastUsedAbility = ABILITY_DAMP; RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability); gBattlescriptCurrInstr = BattleScript_DampStopsExplosion; @@ -8950,16 +8954,18 @@ static void Cmd_sethail(void) gBattlescriptCurrInstr++; } -static void Cmd_jumpifattackandspecialattackcannotfall(void) // memento +static void Cmd_trymemento(void) { if (gBattleMons[gBattlerTarget].statStages[STAT_ATK] == MIN_STAT_STAGE && gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == MIN_STAT_STAGE && gBattleCommunication[MISS_TYPE] != B_MSG_PROTECTED) { + // Failed, unprotected target already has minimum Attack and Special Attack. gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } else { + // Success, drop user's HP bar to 0 gActiveBattler = gBattlerAttacker; gBattleMoveDamage = gBattleMons[gActiveBattler].hp; BtlController_EmitHealthBarUpdate(BUFFER_A, INSTANT_HP_BAR_DROP); From 2c4c9497d2012a3568910a95e6161a2dcbe6a1a0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 6 Jul 2022 15:02:17 -0400 Subject: [PATCH 2/2] Fix comment --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 560b139664..be02ba34b9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6510,7 +6510,7 @@ static void Cmd_tryexplosion(void) MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr++; - // Mark Explosion user as absent + // Find first target for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { if (gBattlerTarget == gBattlerAttacker)