Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two turn moves tweaks #4150

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1061,13 +1061,21 @@
setsemiinvulnerablebit TRUE
.endm

.macro jumpifweathercheckchargeeffects battler:req, checkChargeTurnEffects:req, jumpInstr:req
.macro tryfiretwoturnmovenowcheckeffects battler:req, checkChargeTurnEffects:req, jumpInstr:req
cfmnephrite marked this conversation as resolved.
Show resolved Hide resolved
.byte 0xc6
.byte \battler
.byte \checkChargeTurnEffects
.4byte \jumpInstr
.endm

.macro tryfiretwoturnmovewithoutcharging battler:req, jumpInstr:req
tryfiretwoturnmovenowcheckeffects \battler, TRUE, \jumpInstr
.endm

.macro tryfiretwoturnmoveaftercharging battler:req, jumpInstr:req
tryfiretwoturnmovenowcheckeffects \battler, FALSE, \jumpInstr
.endm

.macro setminimize
.byte 0xc7
.endm
Expand Down
10 changes: 6 additions & 4 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -3718,9 +3718,9 @@ BattleScript_PowerHerbActivation:
BattleScript_EffectTwoTurnsAttack::
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn
jumpifweathercheckchargeeffects BS_ATTACKER, TRUE, BattleScript_EffectHit
tryfiretwoturnmovewithoutcharging BS_ATTACKER, BattleScript_EffectHit @ e.g. Solar Beam
call BattleScript_FirstChargingTurn
jumpifweathercheckchargeeffects BS_ATTACKER, FALSE, BattleScript_TwoTurnMovesSecondTurn
tryfiretwoturnmoveaftercharging BS_ATTACKER, BattleScript_TwoTurnMovesSecondTurn @ e.g. Electro Shot
jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_POWER_HERB, BattleScript_TwoTurnMovesSecondPowerHerbActivates
goto BattleScript_MoveEnd

Expand Down Expand Up @@ -3766,7 +3766,8 @@ BattleScript_GeomancyEnd::

BattleScript_FirstChargingTurn::
attackcanceler
.if B_UPDATED_MOVE_DATA >= GEN_5 @ before Gen 5, charge moves did not print an attack string on the charge turn
@ before Gen 5, charge moves did not print an attack string on the charge turn
.if B_UPDATED_MOVE_DATA >= GEN_5
flushtextbox
attackstring
waitmessage B_WAIT_TIME_LONG
Expand All @@ -3784,7 +3785,8 @@ BattleScript_TwoTurnMovesSecondPowerHerbActivates:
call BattleScript_PowerHerbActivation
call BattleScript_TwoTurnMovesSecondTurnRet
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
.if B_UPDATED_MOVE_DATA < GEN_5 @ before Gen 5, charge moves did not print an attack string on the charge turn
@ before Gen 5, charge moves did not print an attack string on the charge turn
.if B_UPDATED_MOVE_DATA < GEN_5
attackstring
.endif
goto BattleScript_HitFromCritCalc
Expand Down
33 changes: 24 additions & 9 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ static void Cmd_selectfirstvalidtarget(void);
static void Cmd_trysetfutureattack(void);
static void Cmd_trydobeatup(void);
static void Cmd_setsemiinvulnerablebit(void);
static void Cmd_jumpifweathercheckchargeeffects(void);
static void Cmd_tryfiretwoturnmovenowcheckeffects(void);
static void Cmd_setminimize(void);
static void Cmd_sethail(void);
static void Cmd_trymemento(void);
Expand Down Expand Up @@ -815,7 +815,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_trysetfutureattack, //0xC3
Cmd_trydobeatup, //0xC4
Cmd_setsemiinvulnerablebit, //0xC5
Cmd_jumpifweathercheckchargeeffects, //0xC6
Cmd_tryfiretwoturnmovenowcheckeffects, //0xC6
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
Cmd_setminimize, //0xC7
Cmd_sethail, //0xC8
Cmd_trymemento, //0xC9
Expand Down Expand Up @@ -13668,16 +13668,31 @@ static void Cmd_setsemiinvulnerablebit(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}

static void Cmd_jumpifweathercheckchargeeffects(void)
static bool32 CheckIfCanFireTwoTurnMoveNow(u8 battler, bool8 checkChargeTurnEffects)
{
// Semi-invulnerable moves cannot skip their charge turn (except with Power Herb)
if (gBattleMoveEffects[gMovesInfo[gCurrentMove].effect].semiInvulnerableEffect == TRUE)
return FALSE;

// If this move has charge turn effects, it must charge, activate them, then try to fire
if (checkChargeTurnEffects && MoveHasChargeTurnMoveEffect(gCurrentMove))
return FALSE;

// Insert custom conditions here

// Certain two-turn moves may fire on the first turn in the right weather (Solar Beam, Electro Shot)
// By default, all two-turn moves have the option of adding weather to their argument
if (IsBattlerWeatherAffected(battler, HIHALF(gMovesInfo[gCurrentMove].argument)))
return TRUE;

return FALSE;
}

static void Cmd_tryfiretwoturnmovenowcheckeffects(void)
{
CMD_ARGS(u8 battler, bool8 checkChargeTurnEffects, const u8 *jumpInstr);

/* If this is NOT semi-invulnerable move and we don't have charge turn effects
yet to fire, we can fire the move right away so long as the weather matches
the argument and the battler is affected by it (not blocked by Cloud Nine etc) */
if (gBattleMoveEffects[gMovesInfo[gCurrentMove].effect].semiInvulnerableEffect == FALSE
&& !(cmd->checkChargeTurnEffects && MoveHasChargeTurnMoveEffect(gCurrentMove))
&& IsBattlerWeatherAffected(cmd->battler, HIHALF(gMovesInfo[gCurrentMove].argument)))
if (CheckIfCanFireTwoTurnMoveNow(cmd->battler, cmd->checkChargeTurnEffects) == TRUE)
{
gBattleScripting.animTurn = 1;
gBattlescriptCurrInstr = cmd->jumpInstr;
Expand Down