rh-hideout / pokeemerald-expansion

Feature branche for the pokeemerald decompilation. See the wiki for more info.
326 stars 953 forks source link

Illusion breaking behind a Substitute doesn't reveal the real Pokemon #4526

Open hedara90 opened 3 months ago

hedara90 commented 3 months ago

Description

If Illusion break while the user is behind a substitute, the ability popup will appear and say that the Illusion broke, but neither the name nor the sprite is changed to the Illusion user.

https://github.com/rh-hideout/pokeemerald-expansion/assets/149414898/f202cb05-d511-45f7-a433-5869c8ab9072

Version

1.8.3 (Latest release)

Upcoming/master Version

No response

Discord contact info

hedara

hedara90 commented 3 months ago

The problem is that the Illusion user is behind the Substitute when Illusion gets broken. The proper behavior is that the Illusion user swaps places with its Substitute, then performs the Illusion breaking animation and lastly swaps back behind the Substitute. The normal way of showing/hiding mons behind the substitute is done as part of Controller_DoMoveAnimation in battle_util.c, which is run through gBattlerControllerFuncs which is run in BattleMainCB1 in battle_main.c which is run by gMain.callback1 in the main loop. The mon must be switched with the Substitute before AbilityBattleEffects is run for the damage taken if I understand the code correctly.