Skip to content

Commit

Permalink
Merge pull request #1701 from GriffinRichards/faint-cmd-name
Browse files Browse the repository at this point in the history
Rename faintifabilitynotdamp and jumpifattackandspecialattackcannotfall
  • Loading branch information
GriffinRichards authored Jul 16, 2022
2 parents 8898d84 + 2c4c949 commit 165f51a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
.byte 0x77
.endm

.macro faintifabilitynotdamp
.macro tryexplosion
.byte 0x78
.endm

Expand Down Expand Up @@ -1031,7 +1031,7 @@
.byte 0xc8
.endm

.macro jumpifattackandspecialattackcannotfall ptr:req
.macro trymemento ptr:req
.byte 0xc9
.4byte \ptr
.endm
Expand Down
18 changes: 10 additions & 8 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -2214,15 +2215,15 @@ 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
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
Expand All @@ -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
Expand Down
18 changes: 12 additions & 6 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -6497,11 +6497,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)
Expand All @@ -6510,12 +6511,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++;

// Find first target
for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++)
{
if (gBattlerTarget == gBattlerAttacker)
Expand All @@ -6526,6 +6529,7 @@ static void Cmd_faintifabilitynotdamp(void)
}
else
{
// Failed, a battler has Damp
gLastUsedAbility = ABILITY_DAMP;
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
gBattlescriptCurrInstr = BattleScript_DampStopsExplosion;
Expand Down Expand Up @@ -8961,16 +8965,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);
Expand Down

0 comments on commit 165f51a

Please sign in to comment.