• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Mana of caster after cast

Status
Not open for further replies.
Level 12
Joined
May 22, 2015
Messages
1,051
I have a spell that is supposed to replenish all the mana of the caster, but it costs 450 mana to cast. When you cast the spell, all the mana comes back and then 450 mana is taken away for the spell. It is triggering on "starts the effect of an ability". "Finishes casting an ability" seems to fail if you cancel the caster's cast animation, so I don't want to use that. Any ideas?

In general, a way to find out something after a trigger has happened would be good. Another case with a similar problem is on damage detection. I don't know how I can do things after a unit has taken damage (perhaps a heal but only after damage). I feel like I read somewhere a way to do this, but I don't remember where or how it worked.
 

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
Use Finishes casting. That you can interrupt the caster's cast animation is a desirable effect in general. You want people to cancel spells after all.

For damage detection, use one of the existing libraries from Hive. There's one for every flavour, even GUI. It's a common problem with a common solution.
 
Level 12
Joined
May 22, 2015
Messages
1,051
I think with "Finishes casting" it doesn't run the trigger if you end the animation early (like if you cancel the ending of Crystal Maiden's spells in Dota). I can just use a timer to delay it or something, I was just wondering if there is a more elegant solution.
 

EdgeOfChaos

E

EdgeOfChaos

Don't know if you think this is more or less elegant, but you could create a dummy unit and make him cast a mana restoring ability that has a small delay.
 
Level 12
Joined
May 22, 2015
Messages
1,051
That could work as well. I think I'd just go with a timer over that, though.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I recently had this exact same problem, unit finishes casting event doesn't working for the reason you mentioned.Easiest way seems a 0.00 seconds timer or wait.(I used wait because it didn't need to be precise)
 
Level 12
Joined
May 22, 2015
Messages
1,051
I used a 0 second timer. It works perfectly, so I'm happy with it. Thanks for the help, everyone.
 
Status
Not open for further replies.
Top