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

Creating a trigger around a unit that does not exist

Status
Not open for further replies.
Level 1
Joined
Jul 15, 2012
Messages
4
I'm fairly new to this, so sorry if I am asking a dumb question.

I am making a map that has alot of triggers based around the death's of certain heroes. When one of my heroes dies, a totally new hero takes its place. I want to make triggers around these new heroes, however I can't seem to find out how. When I try to make an event around said unit, since that unit is not placed at the start and only appears because of a trigger, I can't select it. Any help?
 
Level 1
Joined
Jul 15, 2012
Messages
4
You should use a unit variable in your trigger.
Make a trigger that sets the unit variable to the newly created hero.

Okay. So in the trigger that the hero is created, I made a action that would make the newest created unit = to the unit variable I have already made.

However, now, when I go to make a trigger based on that unit, it won't let me choose that variable. The new trigger is based on the unit's death, and the only variables available to choose from are units I have used in the past as variables.

EDIT: To the person above me: how do I do that?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Events work by value and not by reference. Changing the variable you passed to an event generator after calling that generator makes no change to the produced event from that generator.

You have 3 choices.
1. Player unit death event and then check for the dying unit matching the unit in a variable. This adds a processor overhead to every unit dying owned by that player and so should be avoided when possible.

2. Create a new event for the new unit by calling the event constructor after creating the new unit. Efficient processor wise as it avoids unnecessary trigger evaluations but can waste memory with event leaks.

3. Create a new trigger with a new event for the new unit after creating the new unit while destroying the old trigger and old events for the dead unit. Theoretically the best approach as it keeps resource load at a minimal at all times however due to bugs in the WarCraft III game engine this method can be prone to crashes or leaks.
 
Level 1
Joined
Jul 15, 2012
Messages
4
Events work by value and not by reference. Changing the variable you passed to an event generator after calling that generator makes no change to the produced event from that generator.

You have 3 choices.
1. Player unit death event and then check for the dying unit matching the unit in a variable. This adds a processor overhead to every unit dying owned by that player and so should be avoided when possible.

2. Create a new event for the new unit by calling the event constructor after creating the new unit. Efficient processor wise as it avoids unnecessary trigger evaluations but can waste memory with event leaks.

3. Create a new trigger with a new event for the new unit after creating the new unit while destroying the old trigger and old events for the dead unit. Theoretically the best approach as it keeps resource load at a minimal at all times however due to bugs in the WarCraft III game engine this method can be prone to crashes or leaks.

The only problem is that I have no idea to do any of those. Is it possible you could go in detail on how to do one of your suggestions?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
If you know how to create a trigger in JASS you will know how to do 2 and 3.

1 is just the generic unit death event with a condition to test if the dying unit is the same as the unit in the variable. The variable contains no unit until your unit is created. The trigger is off until your unit is created. You assign both the unit variable and turn the trigger on when creating the new unit. The unit variable has to be a global. Try and proceduraize it so the same trigger can be used for many units.
 
Status
Not open for further replies.
Top