Auto-translated
I'm working on this combat script:
The idea is that, periodically during the battle, a random creature belonging to the player should be affected by the Blindness spell. The composition of the enemy army is unknown in advance.
Implementation: I tried to call UnitCastAimedSpell on behalf of enemy creatures during their turn. As it turned out, if the creature is not initially a spellcaster, this command will not execute. I tried a workaround: during the creature's turn (detected via a UnitMove trigger), I summon a spellcasting creature, say a Lich, onto the battlefield using SummonCreature or AddCreature commands, wait for it to appear using sleep commands, cast Blindness with it, and then delete it.
All functions are called in the main thread, but as a result, I get a desynchronization of the ATB scale with reality – you look at the properties of a creature on the battlefield, and it says, for example, "Blindness will last 0.5/1 turn." You look at the properties of the same creature through the icon on the ATB scale, and it shows something like "Blindness will last 0.8/1 turn." Because of this, the turn sometimes passes to a creature that is still displayed as blinded on the ATB scale.
Has anyone encountered this?