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

When to use Triggering Unit?

Status
Not open for further replies.
Level 10
Joined
Sep 25, 2013
Messages
521
Hi there, I have been told that using such references as casting unit, attacking unit, dying unit, etc in triggers is slow. Some people have said use triggering unit instead, but they also said you can't use it in all cases. I want to know in what cases is triggering unit good to use. Here are a few example triggers from my map.

Also, some other people have said to make a variable for the reference such as picked unit and then use that variable in those instances instead of individually selecting picked unit for every action.

If i fix these things, how much would this reduce map lag?

  • Siege Tower Unload
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
      • (Unit-type of (Transporting unit)) Equal to Siege Tower (All)(Immobile)
    • Actions
      • Set tempPoint = (Position of (Transporting unit))
      • Unit - Order (Transporting unit) to Unload All At (tempPoint offset by 500.00 towards (Facing of (Transporting unit)) degrees)
      • Animation - Play (Transporting unit)'s morph animation
      • Custom script: call RemoveLocation(udg_tempPoint)
  • Ent of Fangorn Writhing Roots
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Ent of Fangorn |c00FFFF00(Elite)|r (Elves)
    • Actions
      • Set EntanglingRoots = (Random integer number between 1 and 10)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • EntanglingRoots Equal to 1
              • (Distance between (Position of (Attacked unit)) and (Position of (Attacking unit))) Less than or equal to 350.00
              • ((Attacking unit) belongs to an enemy of (Owner of (Attacked unit))) Equal to True
              • ((Attacking unit) is A structure) Equal to False
              • ((Attacking unit) is Mechanical) Equal to False
              • ((Attacking unit) is A Hero) Equal to False
        • Then - Actions
          • Special Effect - Create a special effect attached to the origin of (Attacking unit) using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect attached to the origin of (Attacking unit) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set tempPoint = (Position of (Attacking unit))
          • Unit - Create 1 Elite Effect Unit for (Owner of (Attacked unit)) at tempPoint facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_tempPoint)
          • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Night Elf Keeper Of The Grove - Entangling Roots (Attacking unit)
        • Else - Actions
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
It's not about whether triggering unit is good or not.
If you can use triggering unit, you should.
Triggering unit refers to the unit that starts/fires the event.
So if you use "a unit dies" as an event, the dying unit is the triggering unit.
Triggering unit is always the fastest option when available, however..
It does not impact much at all. In fact you will not notice the difference since today's computers are pretty strong compared to 10 years ago when this game was new.
 
Level 10
Joined
Sep 25, 2013
Messages
521
I see, so it probably wouldn't be worth going back and using tirggering unit in all the instances that i used it. What about using a variable for the non triggering unit things? Like setting a variable at the beginning of a trigger for picked unit and then using that. Will that make any difference?

Thanks for the help :)
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Triggering unit can't replace picked unit since picked unit does not refer to any event.
But yes, it's generally not worthwhile to (go back and) change such a minor thing unless your trigger is really performance heavy otherwise.

While changing triggering unit alone wont do much, together with other minimal improvements you may have increased FPS etc.
 
Just as example, because you asked about variables.

If you use or (TriggeringUnit) or (PickedUnit) or what ever like these more often,
it can be stored into variables and then the varibale might be used.
It's standard in spells/systems here to do this, if you would refer like
around 3 or more times to the same unit.
 
Status
Not open for further replies.
Top