Fixes Stance Change, Sleep Talk interaction (#5909)

This commit is contained in:
Alex 2024-12-31 00:38:01 +01:00 committed by GitHub
parent 7e0c1f9323
commit 9d30299148
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 18 deletions

View file

@ -101,6 +101,7 @@ enum
{ {
CANCELLER_FLAGS, CANCELLER_FLAGS,
CANCELLER_SKY_DROP, CANCELLER_SKY_DROP,
CANCELLER_STANCE_CHANGE_1,
CANCELLER_ASLEEP, CANCELLER_ASLEEP,
CANCELLER_FROZEN, CANCELLER_FROZEN,
CANCELLER_OBEDIENCE, CANCELLER_OBEDIENCE,
@ -117,6 +118,7 @@ enum
CANCELLER_IN_LOVE, CANCELLER_IN_LOVE,
CANCELLER_BIDE, CANCELLER_BIDE,
CANCELLER_THAW, CANCELLER_THAW,
CANCELLER_STANCE_CHANGE_2,
CANCELLER_POWDER_MOVE, CANCELLER_POWDER_MOVE,
CANCELLER_POWDER_STATUS, CANCELLER_POWDER_STATUS,
CANCELLER_THROAT_CHOP, CANCELLER_THROAT_CHOP,

View file

@ -1125,19 +1125,6 @@ static bool32 NoTargetPresent(u8 battler, u32 move)
return FALSE; 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) bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType)
{ {
if ((ability == ABILITY_PROTEAN || ability == ABILITY_LIBERO) if ((ability == ABILITY_PROTEAN || ability == ABILITY_LIBERO)
@ -1206,8 +1193,6 @@ static void Cmd_attackcanceler(void)
gBattlescriptCurrInstr = BattleScript_MoveEnd; gBattlescriptCurrInstr = BattleScript_MoveEnd;
return; return;
} }
if (B_STANCE_CHANGE_FAIL < GEN_7 && TryFormChangeBeforeMove())
return;
if (AtkCanceller_UnableToUseMove(moveType)) if (AtkCanceller_UnableToUseMove(moveType))
return; return;
@ -1267,8 +1252,6 @@ static void Cmd_attackcanceler(void)
gMoveResultFlags |= MOVE_RESULT_MISSED; gMoveResultFlags |= MOVE_RESULT_MISSED;
return; return;
} }
if (B_STANCE_CHANGE_FAIL >= GEN_7 && TryFormChangeBeforeMove())
return;
gHitMarker &= ~HITMARKER_ALLOW_NO_PP; gHitMarker &= ~HITMARKER_ALLOW_NO_PP;

View file

@ -3209,6 +3209,19 @@ void SetAtkCancellerForCalledMove(void)
gBattleStruct->isAtkCancelerForCalledMove = TRUE; 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) u8 AtkCanceller_UnableToUseMove(u32 moveType)
{ {
u32 effect = 0; u32 effect = 0;
@ -3233,6 +3246,11 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
} }
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; 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 case CANCELLER_ASLEEP: // check being asleep
if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP)
{ {
@ -3573,6 +3591,11 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
} }
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case CANCELLER_STANCE_CHANGE_2:
if (B_STANCE_CHANGE_FAIL >= GEN_7 && TryFormChangeBeforeMove())
effect = 1;
gBattleStruct->atkCancellerTracker++;
break;
case CANCELLER_POWDER_MOVE: case CANCELLER_POWDER_MOVE:
if ((gMovesInfo[gCurrentMove].powderMove) && (gBattlerAttacker != gBattlerTarget)) if ((gMovesInfo[gCurrentMove].powderMove) && (gBattlerAttacker != gBattlerTarget))
{ {

View file

@ -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") 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 { GIVEN {
ASSUME(gMovesInfo[MOVE_SLEEP_TALK].effect == EFFECT_SLEEP_TALK); 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)); } PLAYER(SPECIES_AEGISLASH_BLADE) { Moves(MOVE_KINGS_SHIELD, MOVE_SLEEP_TALK); Status1(STATUS1_SLEEP_TURN(3)); }