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

Setting summoned units as variables

Status
Not open for further replies.
Level 2
Joined
Aug 22, 2020
Messages
18
Hello guys,

I know I am posting a lot, hope it's okay as I wasn't able to find the appropriate thread different than trigger basics.

Now to the trigger. I have a boss wolf Snowpaw who summons adds. Now when one of these adds dies, I want the boss acquire and use howl of terror ability. I'm struggling with the part of defining the summoned wolves.

Can anyone please help me? :psmile:

  • Snowpaw Engage
    • Events
      • Unit - |cffffcc00Snowpaw, the Alpha Wolf (Elite)|r 0067 <gen> Acquires a target
    • Conditions
    • Actions
      • Unit - Add Wolfpack to (Triggering unit)
      • Unit - Add Battle Roar 50 to (Triggering unit)
      • Unit - Order (Triggering unit) to Human Archmage - Summon Water Elemental
      • Set SnowpawAdd = (Summoned unit)
      • Wait 2.00 seconds
      • Unit - Order (Triggering unit) to Night Elf Druid Of The Claw - Roar
      • Trigger - Turn off (This trigger)
  • Snowpaw Add Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • SnowpawAdd Equal to (Dying unit)
    • Actions
      • Unit - Add Howl of Terror (Snowpaw) to |cffffcc00Snowpaw, the Alpha Wolf (Elite)|r 0067 <gen>
      • Unit - Order |cffffcc00Snowpaw, the Alpha Wolf (Elite)|r 0067 <gen> to Neutral Pit Lord - Howl Of Terror
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Is there a reason the wolves need to be tracked using a variable?

Can't you just do:
  • Events:
  • Unit - A unit Dies
  • Conditions:
  • Unit-type of (Dying unit) Equal to Snowpaw
  • Actions:
  • do stuff
^Snowpaw is the summoned wolf.

And to add to what Herly is saying, Events have Event Responses. An Event Response only exists when it's associated Event happens first (in that same trigger). So when you're trying to reference the Summoned unit in your trigger, it doesn't really make any sense. There was no "A unit Spawns a summoned unit" Event, therefore there is no "Summoned unit". There is the "Targeted unit" Event Response though, because that goes along with your "A Unit Acquires a target" Event.

Just for the sake of learning, here's how the Summoning trigger would look (like I said this is probably not even necessary):
  • Events:
  • Unit - A unit Spawns a summoned unit
  • Conditions:
  • (Summoning unit) Equal to |cffffcc00Snowpaw, the Alpha Wolf (Elite)|r 0067
  • Actions:
  • do stuff
And here's some examples of Events and their Event Responses.

Event: A unit dies
Event Response: Dying unit

Event: A unit enters region
Event Response: Entering unit

Event: A unit acquires an Item
Event Response: Hero manipulating item


An important thing to understand is that Event Responses almost always lose what they're referencing when a trigger ends or when you use the Wait action. They can also have their values changed to something else inside of the same trigger if you're not careful. This is because they act like Global Variables, and by that I mean that they can only have one value at a time. There can only be one "Dying unit", so even if two units died at the same time, only one of them will be stored as the "Dying unit".

Also, the most useful Event Response is Triggering Unit. It's usable in all of the Unit Events and doesn't suffer from losing it's reference even after a Wait action. In other words, it will reference the same exact unit throughout your entire trigger. If you know about Local/Global variables then you'll understand when I say that this acts like a Local variable. If you don't, then I recommend learning how local/global variables work, it'll help a lot.

Some Unit Events reference two units, for example, "A unit is attacked" has the Attacked unit and the Attacking unit. In this case the Attacked Unit will also be the Triggering Unit. This is where it gets a little tricky, because you can reference the Triggering Unit (attacked unit) even after using a Wait, but Attacking Unit will lose it's reference after doing so.

Long story short:
1) Use Triggering Unit whenever possible.
2) If you have Waits in your triggers then you'll need to use local/global variables if you don't want to lose your Event Responses. Triggering Unit is the one exception to this rule since it doesn't get lost.
3) Be careful about overwriting your Event Responses with new values. For example, if you had a trigger that used the "A unit dies" Event, and inside of that same trigger you Killed another unit, "Dying unit" will be set to that other unit. In these cases local/global variables can come in handy so that you can keep track of the correct unit(s).
4) Warcraft 3 uses an Event driven system. Just about everything that can happen in the game has an Event for it. Understanding and making use of these Events is extremely important if you want to master the Trigger Editor.
 
Last edited:
Level 2
Joined
Aug 22, 2020
Messages
18
Thank you both. I'm still doing very basics with the triggers and slowly picking it all up together by trial/error, so I appreciate your patience. Thanks for the extra info with Waits and how the coherency works!

  • events.gif
    Events:
  • unit.gif
    Unit - A unit Dies
  • cond.gif
    Conditions:
  • if.gif
    Unit-type of (Dying unit) Equal to Snowpaw
  • actions.gif
    Actions:
  • if.gif
    do stuff

@Uncle The problem with this is that the entrace to the Alpha wolf is guarded by three wolves of the same type he summons. And I didnt want to make two different types of wolves in object editor as I thought it is possible to make it via triggers, hence the variable. I suppose that with this trigger the Alpha wolf acquires and uses Howl of Terror skill before I get to him...
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
So use that second trigger I posted. When he spawns the summoned wolf you add the ability.

Also, you probably want to turn off that trigger BEFORE the 2.00 second Wait, this way it doesn't happen again. All of the actions will still execute even if it's turned off first.
 
Status
Not open for further replies.
Top