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

[Trigger] This trigger leak?

Status
Not open for further replies.
Level 6
Joined
Jan 27, 2007
Messages
208
I learn Hashtable and now I often to using it. But when i tested it in LAN, i got lag when i use this spell. This spell is shooting a bullet to line and deals some damage to every enemy units in line and works fine. I use 2 trigger for the spell. Here it goes.

  • Piercing Shot
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Piercing Shot [Rogue]
    • Actions
      • Set temp_Point = (Target point of ability being cast)
      • Set PiercingShotAngle = (Angle from (Position of (Triggering unit)) to temp_Point)
      • Set PiercingShotDistance = 35.00
      • Set PiercingShotTime = 5.50
      • Set PiercingShotPoint = (Position of (Triggering unit))
      • Unit - Create 1 DummyUnitPiercingShot for (Owner of (Triggering unit)) at PiercingShotPoint facing Default building facing degrees
      • Set PiercingDummyUnit = (Last created unit)
      • Hashtable - Save PiercingShotAngle as 0 of (Key (Last created unit)) in PiercingShotTable
      • Hashtable - Save PiercingShotDistance as 1 of (Key (Last created unit)) in PiercingShotTable
      • Hashtable - Save PiercingShotTime as 2 of (Key (Last created unit)) in PiercingShotTable
      • Hashtable - Save Handle OfPiercingDummyUnit as 3 of (Key (Last created unit)) in PiercingShotTable
      • Unit Group - Add (Last created unit) to PiercingGroup
      • Custom script: call RemoveLocation(udg_PiercingShotPoint)
      • Custom script: call RemoveLocation(udg_temp_Point)
And next,

  • Activate Piercing Shot
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PiercingGroup and do (Actions)
        • Loop - Actions
          • Set PiercingShotAngle = (Load 0 of (Key (Picked unit)) from PiercingShotTable)
          • Set PiercingShotDistance = (Load 1 of (Key (Picked unit)) from PiercingShotTable)
          • Set PiercingShotTime = (Load 2 of (Key (Picked unit)) from PiercingShotTable)
          • Set PiercingDummyUnit = (Load 3 of (Key (Picked unit)) in PiercingShotTable)
          • Set PiercingDummyPoint[(Player number of (Owner of (Picked unit)))] = (Position of PiercingDummyUnit)
          • Unit - Move PiercingDummyUnit instantly to (PiercingDummyPoint[(Player number of (Owner of (Picked unit)))] offset by PiercingShotDistance towards PiercingShotAngle degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PiercingShotTime Greater than 0.00
            • Then - Actions
              • Set PiercingShotUnitGroup[(Player number of (Owner of (Picked unit)))] = (Units within 75.00 of PiercingDummyPoint[(Player number of (Owner of (Picked unit)))] matching ((((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True) and (((Matching unit) is in PiercingShotDamagedUnitGroup[(Player number of (Owne
              • Unit Group - Pick every unit in PiercingShotUnitGroup[(Player number of (Owner of (Picked unit)))] and do (Actions)
                • Loop - Actions
                  • Unit - Cause PlayerHeroes[(Player number of (Owner of PiercingDummyUnit))] to damage (Picked unit), dealing ((Real((Strength of PlayerHeroes[(Player number of (Owner of PiercingDummyUnit))] (Include bonuses)))) x 4.50) damage of attack type Hero and damage type Normal
                  • Unit Group - Add (Picked unit) to PiercingShotDamagedUnitGroup[(Player number of (Owner of PiercingDummyUnit))]
              • Custom script: call DestroyGroup(udg_PiercingShotUnitGroup[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
              • Hashtable - Save (PiercingShotTime - 0.10) as 2 of (Key (Picked unit)) in PiercingShotTable
            • Else - Actions
              • Special Effect - Create a special effect at PiercingDummyPoint[(Player number of (Owner of (Picked unit)))] using Objects\Spawnmodels\Human\FragmentationShards\FragBoomSpawn.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Remove PiercingDummyUnit from the game
              • Unit Group - Remove (Picked unit) from PiercingGroup
              • Unit Group - Remove all units from PiercingShotDamagedUnitGroup[(Player number of (Owner of (Picked unit)))]
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in PiercingShotTable
              • Custom script: call RemoveLocation(udg_PiercingDummyPoint[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
              • Custom script: call DestroyGroup(udg_PiercingShotUnitGroup[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
I think its leak free...
Btw, after i got surprised with lag, and i try to create new game in LAN, its not lagging. So now im a bit confuse. My computer sucks or my trigger leaks?

Thanks for help.
 
This leaks;

  • Set PiercingShotAngle = (Angle from (Position of (Triggering unit)) to temp_Point)
Anyways, the lag is probably coming from you constantly enumerating units ever 0.04 seconds.

By that I mean you have a unit group inside a unit group. Though if it's lagging in LAN and not offline then it's probably your connection.
 
Status
Not open for further replies.
Top