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

[General] Question about trigger

Status
Not open for further replies.
Level 3
Joined
Mar 26, 2019
Messages
54
Should I put all trigger that use the same event to one trigger like this:
  • Cast Skillbook
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Floating Text - Create floating text that reads (Name of (Ability being cast)) above (Casting unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 120.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to War Stomp
        • Then - Actions
          • Unit - Create 1 DummyChan for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
          • Unit - Add Ground Bass to (Last created unit)
          • Unit - Set level of Ground Bass for (Last created unit) to (Level of War Stomp for (Triggering unit))
          • Unit - Order (Last created unit) to Orc Tauren Chieftain - War Stomp
          • Unit Group - Pick every unit in (Units within 300.00 of (Position of (Triggering unit)) matching (((Owner of (Matching unit)) is an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
            • Loop - Actions
              • Unit - Cause (Triggering unit) to damage (Picked unit), dealing ((Real((Strength of (Triggering unit) (Include bonuses)))) x 4.50) damage of attack type Spells and damage type Normal
          • Unit Group - Remove all units from (Last created unit group)
          • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
          • Unit - Remove (Last created unit) from the game
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Absorbtion Hit
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Target unit of ability being cast)) Less than or equal to ((60.00 + (Real((Level of Absorbtion Hit for (Triggering unit))))) + (AbsorptionhitDamage[(Player number of (Owner of (Triggering unit)))] x 2.00))
            • Then - Actions
              • Set AbsorptionhitDamage[(Player number of (Owner of (Triggering unit)))] = (AbsorptionhitDamage[(Player number of (Owner of (Triggering unit)))] + ((Real((Level of (Ability being cast) for (Triggering unit)))) x 2.00))
            • Else - Actions
              • Do nothing
          • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing ((Real(((Level of (Ability being cast) for (Triggering unit)) x 60))) + AbsorptionhitDamage[(Player number of (Owner of (Triggering unit)))]) damage of attack type Spells and damage type Normal
          • Floating Text - Create floating text that reads (String((((Real((Level of (Ability being cast) for (Triggering unit)))) x 60.00) + (AbsorptionhitDamage[(Player number of (Owner of (Triggering unit)))] x 2.00)))) above (Target unit of ability being cast) with Z offset 0.00, using font size 10.00, color (100.00%, 20.00%, 20.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 120.00 towards 90.00 degrees
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
        • Else - Actions
          • Do nothing
Or i should split each spell on a individual trigger?
 
Last edited:
Level 12
Joined
Nov 3, 2013
Messages
989
If the event is a periodic event, in that case you actually do want to use the same trigger since if you create multiple triggers with periodic events the map will lag. Or at least as far as I'm aware...
 
Level 12
Joined
Nov 3, 2013
Messages
989
That's incredibly shortsighted and wrong, Death Adder. It's entirely dependent on what you are doing in your triggers and how efficient they are.
Well just as a random example [Solved] - World Edit/Trigger Editor - Lagging Problem - Skills based on Periodic Event

Isn't it worse to use 2 period events here for example? It's better for the clarity, but doesn't it affect the performance if there's multiple periodic events? Or has that no effect what so ever?


Now you did say "entirely dependent on..." and you didn't mention events, so maybe that's exactly what you just told me and me asking about it is being redundant, but I just want to make sure...


If the events themselves don't matter at all, then indeed I'm completely wrong and have been yet another person spreading misinformation...
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
From the thread you linked, the OP was trying to do this:
  • Blood Aura Periodic
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • -------- add and remove abilities based on a buff the unit might have --------
That's usually going to be a really bad way to do it because picking every unit in the map and filtering through all of them is a lot of additional code that realistically doesn't need to run. The solution for that OP was instead to put units affected by the aura into a group and then loop through units in the group and units near units that have the ability to add/remove hp bonus as necessary, which is a way less taxing way to accomplish the same thing. In that specific example, Tasyen's two periodic triggers could have been combined into one trigger for simplicity and ease-of-modification but neither of them is particularly taxing execution-wise (since the number of units looped over is massively reduced).

Periodic events that pick every unit in the map are my #1 example of what not to do if you want to avoid trigger-related lag. Another big culprit would be a periodic trigger that uses something like Player Number of (Owner of (Picked Unit)) in a bunch of different places; by recomputing that integer every time it needs to be used (instead of saving it into a variable and re-using that) you add a massive amount of extra function calls to your code. GUI is not efficient to begin with so nesting 2 function calls inside of a BJ wrapper function is a recipe for disaster. In general it's usually worth your while to use some variable to reduce unnecessary function calls because it makes your code easier to modify (things aren't hardcoded in ostensibly the same way in 3 different places) and easier to debug/troubleshoot. If you look at example code I post here on THW you'll notice that I often do things like this to reduce function call count and streamline the code:

  • Unit Group - Pick every unit in...
    • Loop - Actions
      • Set TempUnit = (Picked Unit)
      • Set TempInt = (Player Number of (Owner of TempUnit))
      • -------- do things with TempInt or TempUnit --------
However, that's not to say that it's never okay to pick all units on the map every second (or even ten times a second) or not use variables to reduce complexity. Imagine you have a 24p paintball map without neutral creeps where every player only has 1 hero and 0-2 other active units at any given time. In that scenario it is totally reasonable to pick every unit on the map very frequently since you know that there aren't more than maybe 100 units total. Context for what you're doing is important. Being efficient is important. Being intelligent about it is important. Avoiding periodic triggers is not important. To quote Tasyen in the thread you linked:
Tasyen said:
Perodic is not the problem. The problem is what you do perodic.
 
Status
Not open for further replies.
Top