Skip to content

Commit

Permalink
Fixes: Glaive Rush status is removed until users next turn
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine committed Oct 29, 2023
1 parent c0793cd commit f8b3fdf
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 11 deletions.
4 changes: 3 additions & 1 deletion data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,10 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectGlaiveRush @ EFFECT_GLAIVE_RUSH

BattleScript_EffectGlaiveRush::
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
setglaiverush
goto BattleScript_EffectHit
goto BattleScript_HitFromAtkString

BattleScript_EffectSyrupBomb::
setmoveeffect MOVE_EFFECT_SYRUP_BOMB
Expand Down
1 change: 1 addition & 0 deletions data/scripts/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Debug_CheatStart::
setflag FLAG_RESCUED_BIRCH
setflag FLAG_HIDE_ROUTE_101_BIRCH_ZIGZAGOON_BATTLE
setflag FLAG_ADVENTURE_STARTED
setflag FLAG_BADGE08_GET
clearflag FLAG_HIDE_LITTLEROOT_TOWN_BIRCHS_LAB_BIRCH
setflag FLAG_HIDE_ROUTE_101_BIRCH_STARTERS_BAG
setvar VAR_BIRCH_LAB_STATE, 2
Expand Down
2 changes: 1 addition & 1 deletion include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ bool32 CanBattlerEscape(u32 battler); // no ability check
void BattleScriptExecute(const u8 *BS_ptr);
void BattleScriptPushCursorAndCallback(const u8 *BS_ptr);
u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u32 battler);
void ClearVariousBattlerFlags(u32 battler);
void HandleAction_RunBattleScript(void);
u32 SetRandomTarget(u32 battler);
u32 GetMoveTarget(u16 move, u8 setTarget);
Expand Down
2 changes: 1 addition & 1 deletion include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
#define STATUS4_INFINITE_CONFUSION (1 << 4) // Used for Berserk Gene
#define STATUS4_SALT_CURE (1 << 5)
#define STATUS4_SYRUP_BOMB (1 << 6)
#define STATUS4_GLEIVE_RUSH (1 << 7)
#define STATUS4_GLAIVE_RUSH (1 << 7)

#define HITMARKER_WAKE_UP_CLEAR (1 << 4) // Cleared when waking up. Never set or checked.
#define HITMARKER_SKIP_DMG_TRACK (1 << 5)
Expand Down
1 change: 0 additions & 1 deletion src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4975,7 +4975,6 @@ static void TurnValuesCleanUp(bool8 var0)
gBattleMons[i].status2 &= ~STATUS2_SUBSTITUTE;

gSpecialStatuses[i].parentalBondState = PARENTAL_BOND_OFF;
gStatuses4[i] &= ~STATUS4_GLEIVE_RUSH;
}

gSideStatuses[B_SIDE_PLAYER] &= ~(SIDE_STATUS_QUICK_GUARD | SIDE_STATUS_WIDE_GUARD | SIDE_STATUS_CRAFTY_SHIELD | SIDE_STATUS_MAT_BLOCK);
Expand Down
4 changes: 2 additions & 2 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ static bool32 AccuracyCalcHelper(u16 move)
{
if ((gStatuses3[gBattlerTarget] & STATUS3_ALWAYS_HITS && gDisableStructs[gBattlerTarget].battlerWithSureHit == gBattlerAttacker)
|| (B_TOXIC_NEVER_MISS >= GEN_6 && gBattleMoves[move].effect == EFFECT_TOXIC && IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_POISON))
|| gStatuses4[gBattlerTarget] & STATUS4_GLEIVE_RUSH)
|| gStatuses4[gBattlerTarget] & STATUS4_GLAIVE_RUSH)
{
JumpIfMoveFailed(7, move);
return TRUE;
Expand Down Expand Up @@ -16281,6 +16281,6 @@ void BS_SetGlaiveRush(void)
{
NATIVE_ARGS();

gStatuses4[gBattlerAttacker] |= STATUS4_GLEIVE_RUSH;
gStatuses4[gBattlerAttacker] |= STATUS4_GLAIVE_RUSH;
gBattlescriptCurrInstr = cmd->nextInstr;
}
11 changes: 7 additions & 4 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ void HandleAction_UseItem(void)
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber];
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
ClearFuryCutterDestinyBondGrudge(gBattlerAttacker);
ClearVariousBattlerFlags(gBattlerAttacker);

gLastUsedItem = gBattleResources->bufferB[gBattlerAttacker][1] | (gBattleResources->bufferB[gBattlerAttacker][2] << 8);
gBattlescriptCurrInstr = gBattlescriptsForUsingItem[ItemId_GetBattleUsage(gLastUsedItem) - 1];
Expand Down Expand Up @@ -680,7 +680,7 @@ void HandleAction_Run(void)
{
if (!TryRunFromBattle(gBattlerAttacker)) // failed to run away
{
ClearFuryCutterDestinyBondGrudge(gBattlerAttacker);
ClearVariousBattlerFlags(gBattlerAttacker);
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_ESCAPE_2;
gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString;
gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT;
Expand Down Expand Up @@ -1333,6 +1333,7 @@ const u8* CancelMultiTurnMoves(u32 battler)

gDisableStructs[battler].rolloutTimer = 0;
gDisableStructs[battler].furyCutterCounter = 0;

return result;
}

Expand Down Expand Up @@ -3313,6 +3314,7 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
case CANCELLER_FLAGS: // flags clear
gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_DESTINY_BOND;
gStatuses3[gBattlerAttacker] &= ~STATUS3_GRUDGE;
gStatuses4[gBattlerAttacker] &= ~ STATUS4_GLAIVE_RUSH;
gBattleScripting.tripleKickPower = 0;
gBattleStruct->atkCancellerTracker++;
break;
Expand Down Expand Up @@ -7865,11 +7867,12 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
return effect;
}

void ClearFuryCutterDestinyBondGrudge(u32 battler)
void ClearVariousBattlerFlags(u32 battler)
{
gDisableStructs[battler].furyCutterCounter = 0;
gBattleMons[battler].status2 &= ~STATUS2_DESTINY_BOND;
gStatuses3[battler] &= ~STATUS3_GRUDGE;
gStatuses4[battler] &= ~ STATUS4_GLAIVE_RUSH;
}

void HandleAction_RunBattleScript(void) // identical to RunBattleScriptCommands
Expand Down Expand Up @@ -9513,7 +9516,7 @@ static inline uq4_12_t GetCriticalModifier(bool32 isCrit)

static inline uq4_12_t GetGlaiveRushModifier(u32 battlerDef)
{
if (gStatuses4[battlerDef] & STATUS4_GLEIVE_RUSH)
if (gStatuses4[battlerDef] & STATUS4_GLAIVE_RUSH)
return UQ_4_12(2.0);
return UQ_4_12(1.0);
}
Expand Down
25 changes: 24 additions & 1 deletion test/battle/move_effect/glaive_rush.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,30 @@ SINGLE_BATTLE_TEST("If Glaive Rush is successful, moves targeted at the user dea
}
}

SINGLE_BATTLE_TEST("Glaive Rush status last until the next turn")
SINGLE_BATTLE_TEST("If Glaive Rush is successful, moves targeted at the user deal double damage until the user moves again")
{
s16 glaiveRushEffectedDmg;
s16 normalDmg;

GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); MOVE(player, MOVE_GLAIVE_RUSH); }
TURN { MOVE(opponent, MOVE_TACKLE); MOVE(player, MOVE_CELEBRATE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
HP_BAR(player, captureDamage: &normalDmg);
ANIMATION(ANIM_TYPE_MOVE, MOVE_GLAIVE_RUSH, player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
HP_BAR(player, captureDamage: &glaiveRushEffectedDmg);
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
} THEN {
EXPECT_MUL_EQ(normalDmg, Q_4_12(2.0), glaiveRushEffectedDmg);
}
}

SINGLE_BATTLE_TEST("Glaive Rush status last until the the user's next turn")
{
s16 normalDmgFristHit;
s16 normalDmgSecondHit;
Expand Down

0 comments on commit f8b3fdf

Please sign in to comment.