• 🏆 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!

Unit Death on Cancel Spell

Status
Not open for further replies.
Level 3
Joined
May 10, 2014
Messages
41
Hello!

I make a spell, that locust unit cast on another unit.
When target unit dies, caster must die too.
But it just don't die.

Store caster and target unit can't solve the problem, because I need an unknown number of variables if I go that way.

When target unit dies, caster issue order 'stop' in game, as I know.
So I try to catch it.

1 Unit issue order with no target

2 If unit type of ordered unit equal to "type of caster"
3 If issued order equal to (Order(stop))

4 Kill ordered unit

That trigger don't give any results.
What I do wrong?

Or there is another way to solve that problem?

Thanks everybody for any information! :as:
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Use Hashtable.

Event: Unit start the effect....
Condition: Spell cast == Locust_unit's_ spell
Action: Save (handle of caster) as "Caster" of (handle of target) in Hashtable


Event: Unit dies
Action: unit_var = Load "Caster" of (handle of triggering unit) in Hashtable, kill unit_var
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Well... you can store values in dynamic variables.
That is called an array.
If you want to make it work with enormeous numbers as keys, you can use a Hashtable.

To make your spell work properly, you require to save the caster on the target.
When the target dies, you get the handle id of the target and you can retrieve the caster.

I have a system that can store additional data to a unit. That is my Effect Over Time System.
In this case (the case of just storing one variable), that solution is pretty slow compared to just make that variable but you don't have to create a new hashtable or even handle it by yourself.
 
Status
Not open for further replies.
Top