Skip to content

Commit

Permalink
Fixes Stance Change, Sleep Talk interaction (#5909)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored Dec 30, 2024
1 parent 7e0c1f9 commit 9d30299
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
2 changes: 2 additions & 0 deletions include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ enum
{
CANCELLER_FLAGS,
CANCELLER_SKY_DROP,
CANCELLER_STANCE_CHANGE_1,
CANCELLER_ASLEEP,
CANCELLER_FROZEN,
CANCELLER_OBEDIENCE,
Expand All @@ -117,6 +118,7 @@ enum
CANCELLER_IN_LOVE,
CANCELLER_BIDE,
CANCELLER_THAW,
CANCELLER_STANCE_CHANGE_2,
CANCELLER_POWDER_MOVE,
CANCELLER_POWDER_STATUS,
CANCELLER_THROAT_CHOP,
Expand Down
17 changes: 0 additions & 17 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,19 +1125,6 @@ static bool32 NoTargetPresent(u8 battler, u32 move)
return FALSE;
}

static bool32 TryFormChangeBeforeMove(void)
{
bool32 result = TryBattleFormChange(gBattlerAttacker, FORM_CHANGE_BATTLE_BEFORE_MOVE);
if (!result)
result = TryBattleFormChange(gBattlerAttacker, FORM_CHANGE_BATTLE_BEFORE_MOVE_CATEGORY);
if (!result)
return FALSE;

BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_AttackerFormChange;
return TRUE;
}

bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType)
{
if ((ability == ABILITY_PROTEAN || ability == ABILITY_LIBERO)
Expand Down Expand Up @@ -1206,8 +1193,6 @@ static void Cmd_attackcanceler(void)
gBattlescriptCurrInstr = BattleScript_MoveEnd;
return;
}
if (B_STANCE_CHANGE_FAIL < GEN_7 && TryFormChangeBeforeMove())
return;
if (AtkCanceller_UnableToUseMove(moveType))
return;

Expand Down Expand Up @@ -1267,8 +1252,6 @@ static void Cmd_attackcanceler(void)
gMoveResultFlags |= MOVE_RESULT_MISSED;
return;
}
if (B_STANCE_CHANGE_FAIL >= GEN_7 && TryFormChangeBeforeMove())
return;

gHitMarker &= ~HITMARKER_ALLOW_NO_PP;

Expand Down
23 changes: 23 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3209,6 +3209,19 @@ void SetAtkCancellerForCalledMove(void)
gBattleStruct->isAtkCancelerForCalledMove = TRUE;
}

static inline bool32 TryFormChangeBeforeMove(void)
{
bool32 result = TryBattleFormChange(gBattlerAttacker, FORM_CHANGE_BATTLE_BEFORE_MOVE);
if (!result)
result = TryBattleFormChange(gBattlerAttacker, FORM_CHANGE_BATTLE_BEFORE_MOVE_CATEGORY);
if (!result)
return FALSE;

BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_AttackerFormChange;
return TRUE;
}

u8 AtkCanceller_UnableToUseMove(u32 moveType)
{
u32 effect = 0;
Expand All @@ -3233,6 +3246,11 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
}
gBattleStruct->atkCancellerTracker++;
break;
case CANCELLER_STANCE_CHANGE_1:
if (B_STANCE_CHANGE_FAIL < GEN_7 && TryFormChangeBeforeMove())
effect = 1;
gBattleStruct->atkCancellerTracker++;
break;
case CANCELLER_ASLEEP: // check being asleep
if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP)
{
Expand Down Expand Up @@ -3573,6 +3591,11 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
}
gBattleStruct->atkCancellerTracker++;
break;
case CANCELLER_STANCE_CHANGE_2:
if (B_STANCE_CHANGE_FAIL >= GEN_7 && TryFormChangeBeforeMove())
effect = 1;
gBattleStruct->atkCancellerTracker++;
break;
case CANCELLER_POWDER_MOVE:
if ((gMovesInfo[gCurrentMove].powderMove) && (gBattlerAttacker != gBattlerTarget))
{
Expand Down
1 change: 0 additions & 1 deletion test/battle/ability/stance_change.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ SINGLE_BATTLE_TEST("Stance Change changes Aegislash from Blade to Shield when us

SINGLE_BATTLE_TEST("Stance Change doesn't change Aegislash to Shield if King's Shield is called by a different move - Sleep Talk")
{
KNOWN_FAILING; // Currently does change form
GIVEN {
ASSUME(gMovesInfo[MOVE_SLEEP_TALK].effect == EFFECT_SLEEP_TALK);
PLAYER(SPECIES_AEGISLASH_BLADE) { Moves(MOVE_KINGS_SHIELD, MOVE_SLEEP_TALK); Status1(STATUS1_SLEEP_TURN(3)); }
Expand Down

0 comments on commit 9d30299

Please sign in to comment.