• 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.

[Trigger] Leak? Text ManaBar

Status
Not open for further replies.
  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in ManaBar_group and do (Actions)
      • Loop - Actions
        • Set ManaBar = (Load (Key ManaBar) of (Key (Picked unit)) in ManaHashIf the label is not found, this function returns NULL.)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked unit) is dead) Equal to True
          • Then - Actions
            • Unit Group - Remove (Picked unit) from ManaBar_group
            • Floating Text - Destroy ManaBar
            • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in ManaHash
          • Else - Actions
            • Set ManaStatus = (((Mana of (Picked unit)) / (Max mana of (Picked unit))) x (Real((Length of StateString))))
            • Floating Text - Change text of ManaBar to (((|c001414FF + (Substring(StateString, 1, (Integer(ManaStatus))))) + |r) + ((|c00000000 + (Substring(StateString, (Integer((ManaStatus + 1.00))), (Length of StateString)))) + |r)) using font size 4.00
            • Set tempp1 = (Position of (Picked unit))
            • Set tempp2 = (tempp1 offset by (-40.00, 0.00))
            • Floating Text - Change the position of ManaBar to tempp2 with Z offset 167.00
            • Custom script: call RemoveLocation(udg_tempp2)
            • Custom script: call RemoveLocation(udg_tempp1)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (ManaBar_group is empty) Equal to True
      • Then - Actions
        • Trigger - Turn off (This trigger)
      • Else - Actions
I'm getting lag that starts slow and builds until the game is unplayable. I'm almost 100% sure it is this trigger because when I set it to run every 0.01, the lag got really bad. But it looks leakess, what could be causing this?
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
  • Set ManaBar = (Load (Key ManaBar) of (Key (Picked unit)) in ManaHashIf the label is not found, this function returns NULL.
this line looks oddly wrong. Just use:

  • Set ManaBar = (Load (Key ManaBar) of (Key (Picked unit)) in ManaHash

edit: I also think that you load incorrect values. I've never used something other than key(someUnit) and then a number as the second key. But you use Key(Manabar) which I've never seen anything like before.
 
  • AdditionalAdd
    • Events
      • Unit - A unit enters (Playable map area)
      • Unit - A unit Begins reviving
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to DummyCaster
    • Actions
      • Unit Group - Add (Triggering unit) to HealthBar_group
      • Set tempp1 = (Position of (Triggering unit))
      • Set tempp2 = (tempp1 offset by (-100.00, 0.00))
      • Set HealthStatus = (((Life of (Triggering unit)) / (Max life of (Triggering unit))) x (Real((Length of StateString))))
      • Floating Text - Create floating text that reads StateString at tempp2 with Z offset 190.00, using font size 3.00, color (100.00%, 100.00%, 100.00%), and 100.00% transparency
      • Floating Text - Change text of (Last created floating text) to (((|c0000A400 + (Substring(StateString, 1, (Integer(HealthStatus))))) + |r) + ((|c00444444 + (Substring(StateString, (Integer((HealthStatus + 1.00))), (Length of StateString)))) + |r)) using font size 0.00
      • Hashtable - Save Handle Of(Last created floating text) as (Key HealthBar) of (Key (Triggering unit)) in HealthHash
      • Trigger - Turn on HealthBar loop <gen>
      • Custom script: call RemoveLocation(udg_tempp2)
      • Custom script: call RemoveLocation(udg_tempp1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Max mana of (Triggering unit)) Greater than 0.00
        • Then - Actions
          • Unit Group - Add (Triggering unit) to ManaBar_group
          • Set tempp1 = (Position of (Triggering unit))
          • Set tempp2 = (tempp1 offset by (-100.00, 0.00))
          • Set ManaStatus = (((Mana of (Triggering unit)) / (Max mana of (Triggering unit))) x (Real((Length of StateString))))
          • Floating Text - Create floating text that reads StateString at tempp2 with Z offset 180.00, using font size 3.00, color (0.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Change text of (Last created floating text) to (((|c004646FF + (Substring(StateString, 1, (Integer(ManaStatus))))) + |r) + ((|c00444444 + (Substring(StateString, (Integer((ManaStatus + 1.00))), (Length of StateString)))) + |r)) using font size 3.00
          • Hashtable - Save Handle Of(Last created floating text) as (Key ManaBar) of (Key (Triggering unit)) in ManaHash
          • Trigger - Turn on ManaBar loop <gen>
          • Custom script: call RemoveLocation(udg_tempp2)
          • Custom script: call RemoveLocation(udg_tempp1)
        • Else - Actions
This is the trigger that adds units to the ManaBar_group.

I know the lag must be coming from the first trigger though because it gets worse when I set it to repeat every .001.

I need to find the leak and stop the lag, not just make the trigger better. Please explain how that would help and what is leaking. Comments that just say "do this" are not really that helpful.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
I dont know much about hashtanles but I know strings leak. Strings leak only a tiny bit of data and you cant prevent a string leak. Strings with the same text only leak once. This means whenever you create a new string it will leak, but if you display a string the game has already disllayed before, it will not leak.

I noticed you have floating texts which display a text. Given this floating text is displaying a unique text every time it is run, it will create a leak. So im not eniterly sure how many leaks your strings are generating without looking at your map and im not sure if these leaks are even significant enough to cause any trouble.

Dont know enough about hastables to see any other leaks. Someone else will need to elaborate on tge string leaks for me.
 
Status
Not open for further replies.
Top