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

How do I use "Trigger - Add New Event" properly? What works with it?

Status
Not open for further replies.
Level 8
Joined
Dec 9, 2005
Messages
523
There are several triggers I want to do and I want to know if it works with this function.

1. Does it work for Specific Unit events, for instance:
I create a set up trigger, set a variable to define a unit (let's say call it Zombie). Then in the set up trigger I create a "Trigger - Add New Event" function to another trigger, saying something like "if Zombie is attacked". Will that new trigger fire when Zombie unit is attacked?

2. Does it work for destructibles, for instance:
I set up a trigger with hashtables etc. Each time a unit casts a spell on a destructible, I save the handle of that destructible on a hashtable, then create a unit and save THAT unit's handle on the same hashtable (linking destructible with unit created)... then create a "Trigger - Add New Event" function for when the set up destructible is destroyed, the linked unit is destroyed as well. Will that fire the trigger and actually kill the unit?

What else does this function do (or does not do)?

Thanks all.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I use it a lot on map initialization. Works for chat commands events, as you can see. Works for turning on specific player-based triggers if they're in game, or adding specific player to certain event only if it's there. Also works for what you say: Adding specific unit events, that's how Damage Detection System works (sort of)

  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • Set ivar = (Integer A)
      • Set Player = (Player(ivar))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player slot status) Not equal to Is playing
        • Then - Actions
          • Trigger - Turn off Triggers[ivar]
        • Else - Actions
          • Trigger - Add to Player Left Game <gen> the event (Player - Player leaves the game)
          • Trigger - Add to Clear command <gen> the event (Player - Player types a chat message containing -clear as An exact match)
          • Trigger - Add to Clear command <gen> the event (Player - Player types a chat message containing -borrar as An exact match)
          • Trigger - Add to Camera info <gen> the event (Player - Player types a chat message containing -cam as An exact match)
          • Trigger - Add to Camera Set <gen> the event (Player - Player types a chat message containing -cam as A substring)
          • Set TPoint = (Player start location)
          • Unit - Create 1 Peasant for Player at TPoint facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_TPoint)
 
  • Example
    • Events
      • Time - Elapsed game time is 1.00 seconds
      • Time - Elapsed game time is 2.00 seconds
      • Time - Elapsed game time is 3.00 seconds
      • Time - Elapsed game time is 4.00 seconds
      • Time - Elapsed game time is 5.00 seconds
      • ...
      • Time - Elapsed game time is 9999.00 seconds
    • Conditions
    • Actions
  • Example
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 9999, do (Actions)
        • Loop - Actions
          • Trigger - Add to (This trigger) the event (Time - Elapsed game time is (Real((Integer A))) seconds)
Imagine that you need to add 100 different events for some units or 10 or more times simple chat commands for all players. Really annoying indeed, that's why we have this function that will allow us to setup trigger event dynamically and easily.

Should I mention that you can register unknown events as well. For example you can register unit selection for some unit group for example without even knowing how many and what units will be in same group.
 
Level 8
Joined
Dec 9, 2005
Messages
523
Thanks everyone for posting, this was a very informative thread. One thing about this:

to the first one o think so but you can just use any unit is attacked and filter out other units
That would mean every single attack made to every single unit will trigger the spell to check for condition, and that's not something I'd like to have since the map might be huge and basically every time a unit attacks the map needs to ask "is this unit A? Does it have this ability?"...

But I like this. This opens up a lot of potentials for me. Thanks. And keep posting instances where this function can be applied to, I want to know its limitations :D
 
Level 8
Joined
Dec 9, 2005
Messages
523
Limitations would be, you will be spamming events, and events cannot be cleared unless you destroy the trigger itself... so it can lead to event leaks... that's why I like it better to just use the Any unit events + filters unless I really need to use specific events and such (like for Unit is damaged event)...

So you're saying that a trigger that fires for every single time a unit is attacked is still better than a trigger that only fires when a specific unit is attacked? How does such an even leak?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Because when the specific unit dies, the event remains there taking up space... And since hundreds of units dies, you would have hundreds of event leaks.
 
Level 8
Joined
Dec 9, 2005
Messages
523
No, no, of course. You actually told me something I didn't know before, so of course it's a good input, Adikutz. I had always thought that any unit event does more "damage" but if that's wrong then it's good to know.

And Spartipilo I don't quite follow you. How about this: what if the specific unit is a revivable Hero unit, so even if it dies it will live again? Would that also leak?
 
Status
Not open for further replies.
Top