Fix illusion not breaking properly when behind substitute (#8423)

Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
FosterProgramming 2025-12-04 00:35:38 +01:00 committed by GitHub
parent d47deb51a4
commit 142a5ef08c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 57 additions and 2 deletions

View File

@ -32134,6 +32134,16 @@ gBattleAnimGeneral_Swamp::
blendoff
end
gBattleAnimGeneral_SwapToSubstitute::
createvisualtask AnimTask_SwapMonSpriteToFromSubstitute, 2, FALSE
waitforvisualfinish
end
gBattleAnimGeneral_SwapFromSubstitute::
createvisualtask AnimTask_SwapMonSpriteToFromSubstitute, 2, TRUE
waitforvisualfinish
end
SnatchMoveTrySwapFromSubstitute:
createvisualtask AnimTask_IsAttackerBehindSubstitute, 2
jumprettrue SnatchMoveSwapSubstituteForMon

View File

@ -5951,8 +5951,10 @@ BattleScript_IllusionOffEnd3::
BattleScript_IllusionOff::
setspriteignore0hp TRUE
call BattleScript_SwapFromSubstitute
playanimation BS_SCRIPTING, B_ANIM_ILLUSION_OFF
waitanimation
call BattleScript_SwapToSubstitute
updatenick
waitstate
setspriteignore0hp FALSE
@ -8857,3 +8859,21 @@ BattleScript_NaturePowerAttackstring::
printstring STRINGID_NATUREPOWERTURNEDINTO
waitmessage B_WAIT_TIME_LONG
return
BattleScript_SwapFromSubstitute::
jumpifvolatile BS_SCRIPTING, VOLATILE_SUBSTITUTE, BattleScript_SwapFromSubstituteContinue
goto BattleScript_SwapFromSubstituteReturn
BattleScript_SwapFromSubstituteContinue:
playanimation BS_SCRIPTING, B_ANIM_SWAP_FROM_SUBSTITUTE
waitanimation
BattleScript_SwapFromSubstituteReturn:
return
BattleScript_SwapToSubstitute::
jumpifvolatile BS_SCRIPTING, VOLATILE_SUBSTITUTE, BattleScript_SwapToSubstituteContinue
goto BattleScript_SwapToSubstituteReturn
BattleScript_SwapToSubstituteContinue:
playanimation BS_SCRIPTING, B_ANIM_SWAP_TO_SUBSTITUTE
waitanimation
BattleScript_SwapToSubstituteReturn:
return

View File

@ -1005,6 +1005,8 @@ extern const u8 gBattleAnimGeneral_TeraCharge[];
extern const u8 gBattleAnimGeneral_TeraActivate[];
extern const u8 gBattleAnimGeneral_SimpleHeal[];
extern const u8 gBattleAnimGeneral_PowerConstruct[];
extern const u8 gBattleAnimGeneral_SwapToSubstitute[];
extern const u8 gBattleAnimGeneral_SwapFromSubstitute[];
// special animations
extern const u8 gBattleAnimSpecial_LevelUp[];

View File

@ -592,8 +592,9 @@
#define B_ANIM_TERA_ACTIVATE 51
#define B_ANIM_SIMPLE_HEAL 52
#define B_ANIM_POWER_CONSTRUCT 53
#define NUM_B_ANIMS_GENERAL 54
#define B_ANIM_SWAP_TO_SUBSTITUTE 54
#define B_ANIM_SWAP_FROM_SUBSTITUTE 55
#define NUM_B_ANIMS_GENERAL 56
// special animations table (sBattleAnims_Special)
#define B_ANIM_LVL_UP 0

View File

@ -255,6 +255,8 @@ static const u8* const sBattleAnims_General[NUM_B_ANIMS_GENERAL] =
[B_ANIM_TERA_ACTIVATE] = gBattleAnimGeneral_TeraActivate,
[B_ANIM_SIMPLE_HEAL] = gBattleAnimGeneral_SimpleHeal,
[B_ANIM_POWER_CONSTRUCT] = gBattleAnimGeneral_PowerConstruct,
[B_ANIM_SWAP_TO_SUBSTITUTE] = gBattleAnimGeneral_SwapToSubstitute,
[B_ANIM_SWAP_FROM_SUBSTITUTE] = gBattleAnimGeneral_SwapFromSubstitute,
};
static const u8* const sBattleAnims_Special[NUM_B_ANIMS_SPECIAL] =

View File

@ -546,6 +546,9 @@ static bool8 ShouldAnimBeDoneRegardlessOfSubstitute(u8 animId)
{
switch (animId)
{
case B_ANIM_ILLUSION_OFF:
case B_ANIM_SWAP_TO_SUBSTITUTE:
case B_ANIM_SWAP_FROM_SUBSTITUTE:
case B_ANIM_SUBSTITUTE_FADE:
case B_ANIM_RAIN_CONTINUES:
case B_ANIM_SUN_CONTINUES:

View File

@ -113,3 +113,20 @@ SINGLE_BATTLE_TEST("Illusion breaks if user loses Illusion due to Worry Seed")
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ILLUSION_OFF, player);
}
}
SINGLE_BATTLE_TEST("Illusion breaks when attacked behind a substitute")
{
GIVEN {
PLAYER(SPECIES_DRAGAPULT) {Ability(ABILITY_INFILTRATOR); Speed(1);};
OPPONENT(SPECIES_WOBBUFFET) {Speed(2);};
OPPONENT(SPECIES_ZOROARK) {Speed(2);};
OPPONENT(SPECIES_WYNAUT) {Speed(2);};
} WHEN {
TURN { MOVE(player, MOVE_TACKLE); MOVE(opponent, MOVE_SHED_TAIL); SEND_OUT(opponent, 1);}
} SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SWAP_FROM_SUBSTITUTE, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ILLUSION_OFF, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SWAP_TO_SUBSTITUTE, opponent);
MESSAGE("The opposing Zoroark's illusion wore off!");
}
}