How can I get if a unit successfully casted a spell?

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Maybe I'm not understanding but you know a spell is successful when this Event happens:
  • Unit - A unit Starts the effect of an ability
I don't think you can detect when the Targets Allowed failed, because that happens before Order/Spell Events.
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
Maybe I'm not understanding but you know a spell is successful when this Event happens:
  • Unit - A unit Starts the effect of an ability
I don't think you can detect when the Targets Allowed failed, because that happens before Order/Spell Events.
Thinking well, I could do something like:
1) Issues the order: set a boolean to false.
2) Spell Effect: set that boolean to true.
3) Spell Finish: check the value of the boolean.
But you just said that the fail happens before the Order/Spell Events, right?
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
The order onto unit function returns a boolean, which tells you if the order is going to be done (Mana, cooldown, valid target, silenced, ....).
Oh, really?
Maybe a better way to approach this is by figuring out a different path to what you want. What do you intend to do with this information if you had it?
I'm creating a system that when you press a button, a dummy caster cast a spell to the main selected unit, but I have to know that it happened because the button could be wasted in nothing, and need to know if there is a general way to achieve that.

If you are curious this thread is connected with these other 3:
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Then yes checking that the order issued to the dummy returned true will confirm that the unit was able to cast the spell at the time it was issued. If, say, the unit gets stunned between the order and when it is actually cast (and then reordered something else so the spell is never cast)… then the order would have returned true but the spell was never cast. That seems unlikely with dummy units but in principle it could happen with an immobile dummy unit and the target leaving vision before the cast goes off.
 
Status
Not open for further replies.
Top