HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unit death - spell related trigger, need help

06-13-2004, 01:26 PM#1
SoemaWaKaa
Ok, it sounds simple but I have problems for creating a trigger that reacts when a unit dies by a spell. So an example: My hero unit kills a unit with a spell (say Stormbolt). I want my trigger be triggered by this event.
I've tried it beginning with "A unit dies" as the event, and "A unit begins casting an ability" event, but with both I end up to be stuck with nothing. Can someone plz help?
06-13-2004, 03:33 PM#2
SirSalute
perhap you should make two trigger, one that react when a storm bolt is cast and it activate the 2nd trigger for 2 sec, then the 2nd trigger reacts to when a unit dies. the unit target have to be store as a variable though. Hope you get the idea.
06-13-2004, 05:17 PM#3
SoemaWaKaa
Thanks, I got the idea and it worked. But now I have the problem that this trigger only can be used one time.... is there any way that I can "refresh" the target variable? Now I have 1 trigger to create the target variable, and 1 trigger that detects the casting of Stormbolt and compares that target to the unit that dies (stored in the variable). But if I use Stormbolt again, it won't refrsh the variable with the new target, resulting in that the dying unit is not equal to the targeted unit. Somebody helps me on this one?
06-13-2004, 05:51 PM#4
Anitarf
Just use an action "set variable". It's in the "general" section somewhere. Then just do "set myvariable = target unit of ability being cast" and then in the other trigger have "if dying unit equal to myvariable then...".

However, it is not guaranteed that then the dying unit will have died from stormbolt. These triggers only tell you that a unit died somewhere around the time a stormbolt was cast on it. To be more sure, make a unit-type comparison in the "unit dies"-trigger to see if the "killing unit" was indeed of the type that can cast storm bolt. Even THEN it won't be 100%, the unit could be nearly killed by storm bolt and then in those two seconds finished off by a normal attack from the unit that casts storm bolt.

To get around all this, the only solution I see is to trigger the stormbolt spell; give your hero a spell that does nothing but targeting a unit (for example, cripple with no speed decrease and almost no duration); give it all the tooltips of stormbolt. Then, when your hero casts it, create a "dummy caster", a unit with no model, no shadow, and "locust" ability which makes it untergetable and unselectable, give that unit the storm bolt ability and then order it to cast it on the target of the hero's spell. That way, if the "killing unit" is your "dummy caster", you can be sure that the unit was killed by storm bolt, because that's the only way a "dummy caster" can kill a unit, because it has no attack.
06-14-2004, 07:20 AM#5
SoemaWaKaa
Thanks man, it works perfectly... for one time. If I cast Stormbolt for the second time, and it kills someone, the trigger won't run for an unknown reason to me... maybe the Set variable won't react (or overwrite the first value) for the 2nd time?
06-14-2004, 09:30 AM#6
Anitarf
I'm not sure how your triggers work, but this should work all right:
Code:
Stormbolt cast
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Storm Bolt
    Actions
        Set UnitVariableForStormBolt = (Target unit of ability being cast)
        Wait 2.00 game-time seconds
        Set UnitVariableForStormBolt = No unit

Stormbolt kill
    Events
        Unit - A unit Dies
    Conditions
        (Dying unit) Equal to UnitVariableForStormBolt
        (Unit-type of (Killing unit)) Equal to Mountain King
    Actions
        -------- Do what you want to do here --------
Of course, these are the simple triggers, which aren't comepletely accurate, and will run even if the mountain king kills the target with a normal attack in those two seconds when he casts storm bolt. Also, this trigger may function inproperly if there are two mountain kings in the map and they both cast the spell at the same time; in such a case, it would work only for one of them, even if both storm bolts were to kill the target.

The triggers could be made to work 100% in any case, but they would be slightly more complex. I can help you with them if you wish to make them that way.
06-14-2004, 12:02 PM#7
SoemaWaKaa
Thanks man, got the trigger fully working, never knew that you could erase the value of the variable :)
I've perfected the trigger a bit, and I must say, it works flawlessly for me. I'm lucky that I have no 2 heroes with the same ability in the game, cause would've been indeed really hard to bypass.