Skip to content
#3932
Auto-translated

Thank you very much for the detailed comments from esteemed Dolgiy and esteemed Jack of Shadows.

The problem is that, as I understand it, if I return not nil in the UnitMove hook, the unit should not move further. However, for some reason, the unit casts a spell and makes its move, and it makes the move first. I rechecked Novik's documentation, and it also states that UnitMove should be called before each turn of the creature stack.

That is, the expected sequence of actions is:

1. The creature receives its turn.

2. The UnitMove hook is triggered.

3. In the hook, I apply blindness and return not nil.

4. The creature remains in its place, playing the spell animation.

The actual sequence of actions is:

1. The creature receives its turn.

2. The UnitMove hook is triggered.

3. The creature performs an action (moves forward or attacks if it can reach).

4. The action is passed to my handler, and the creature casts a spell.

5. not nil is returned.

Could you please advise me on where I might have made a mistake? I understand that the body of the hook should be executed first, and then the creature's action, and not the other way around.