Hero-defense with 2 switchable heroes - Focus bug

Level 8
Feb 27, 2019

I have a map of type Hero Defense. Each player can have 2 heroes, but control only once at a time. So when he uses F1 or F2, he switchs between his 2 heroes.

The unused hero is moved to a storage place, paused, made invulnerable.

My issue is the following:
- During boss fights, if the player attacked by the boss switches of hero, then the boss focus remains stuck. As a consequence, the boss moves away, ignoring all attackers, just trying to reach the unused hero (even if it is invulnerable, paused and out-of-range...).

Do you have an idea of how I can solve this focus-bug ?
Level 22
Feb 27, 2007
Store the current target of the boss in a variable. When a player switches, if the switched-out unit is the same as the boss target then also switch the boss target and re-issue its current order to the new target.