• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Question with Leaks, bad triggers, and waits

Status
Not open for further replies.
Level 3
Joined
Jul 28, 2014
Messages
29
I can't seem to find the answers to certain questionable triggers in my map or any map for that matter.

1) Is this trigger bad, because there is a wait before it refers to triggering unit?
  • Untitled Trigger 001
    • Events
      • Unit - A unit enters Hero Spawn <gen>
    • Conditions
    • Actions
      • Wait 1.00 seconds
      • Unit - Kill (Triggering unit)
2) I heard this event causes desinc, are there any other events that do that?
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Camera - Pan camera for Player 1 (Red) to (Center of (Playable map area)) over 0.00 seconds
3) This trigger seems to cause lag. I don't think it leaks but when it's disabled there's no lag.
  • Mana Generator
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set TempUnitGroup[1] = (Units of type Mana Generator)
      • Unit Group - Pick every unit in TempUnitGroup[1] and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Set TempPointSpell = (Position of (Picked unit))
          • Set TempUnitGroup[2] = (Units within 150.00 of TempPointSpell matching (((Matching unit) is A structure) Equal to True))
          • Unit Group - Pick every unit in TempUnitGroup[2] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Percentage mana of (Picked unit)) Less than 100.00
                  • (Mana of TempUnit) Greater than 5.00
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Picked unit)) Equal to Mana Battery
                      • (Unit-type of (Picked unit)) Equal to Mana Cell
                      • (Unit-type of (Picked unit)) Equal to Tesla Coil
                      • (Unit-type of (Picked unit)) Equal to Mana Cell Array
                      • (Unit-type of (Picked unit)) Equal to Ultamite Tesla Coil
                • Then - Actions
                  • Special Effect - Create a special effect at TempPointSpell using Abilities\Spells\Undead\ReplenishMana\ReplenishManaCasterOverhead.mdl
                  • Unit - Set mana of TempUnit to ((Mana of TempUnit) - 5.00)
                  • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 5.00)
                  • Special Effect - Destroy (Last created special effect)
                • Else - Actions
                  • Do nothing
          • Set TempUnit = No unit
          • Custom script: call RemoveLocation(udg_TempPointSpell)
          • Custom script: call DestroyGroup(udg_TempUnitGroup[2])
      • Custom script: call DestroyGroup(udg_TempUnitGroup[1])
4) Are "do nothing" events bad to use? I swear awhile ago I read you need them in if/than/else triggers. But now I'm reading that they're unnecessary and slow down the game very slightly.
 
Last edited:
  1. The trigger is fine as it is.

  2. There won't be desync. "Pan Cam As Necessary" is the one that should not be used.

  3. Picking all units on map (which Pick All Units of Type is basically, too) is very resource consuming. Plus, for every picked unit there's again a range enumeration.
    Instead of periodcially defining "All units of type.." you can have a global group, or unit[array] which just alaways holds all such units of this type.
    You would need to make entry and exit points for when to add/remove units there. For example a unit of such type is build -> will be added to group/array.
    With this, you will loop through the already filled group/array instead of always picking all units of type x on map.

    By the way, maybe you might want to check for unit's mana if it has more than "5", before making the effect.
    And if tooo many effects would be created it maybe might lag a little, too. But the amounts you probably know best.

  4. "Do Nothing" action can be indeed removed. It won't change any logics in your trigger.
    Its sense was most likely only for the GUI "If Then Else" single-line operation, where you then can choose "Do Nothing" in the "Else" part, for example.
    But for these "Multiple Conditions If Then Else" (which is better/easier to ready) that you currently use, it is senseless.
 
Level 42
Joined
Feb 27, 2007
Messages
5,308
Re: point 1

Some event responses (things like Triggering/Casting/Attacked Unit, Expired Timer, Target Point of Ability Being Cast, etc.) don't work if you use them after a wait, which is one of two big reasons waits are not recommended. Triggering Unit is not one of these so it is safe to use after all waits, but if you find a problem where something like Attacked Unit doesn't actually give you a unit then it is probably because it's being used after a wait.
 
Level 3
Joined
Jul 28, 2014
Messages
29
Ok thanks,
Yeah googling around for these things I couldn't really find answers, just alot of info on leaks.
Ty this will help cause my map runs a bit buggy and I was seeing if I was creating any triggers wrong.
 
Status
Not open for further replies.
Top