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

Moving lightning causes lags- Help pls.

Status
Not open for further replies.
Hi fellow hivers, I made a lightning move system that makes my map to lag, so naturally I know it must be leaking, but i have no idea what is leaking so much so if you please could help me i would be very glad.

  • Move Lightning
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set UnitG = (Units in (Playable map area) matching (((Matching unit) has buff Time Ray ) Equal to True))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in UnitG) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in UnitG and do (Actions)
            • Loop - Actions
              • Custom script: local real lx1
              • Custom script: local real ly1
              • Custom script: local real lz1
              • Custom script: local real lx2
              • Custom script: local real ly2
              • Custom script: local real lz2
              • Set PU = (Picked unit)
              • Set LPU = (Position of PU)
              • Custom script: set udg_Handle = udg_PU
              • Set TU = (Load 22 of (Key Handle) in Arcanum_Race)
              • Set LTU = (Position of TU)
              • Custom script: set lx1 = GetUnitX(udg_TU)
              • Custom script: set ly1 = GetUnitY(udg_TU)
              • Custom script: set lz1 = 75
              • Custom script: set lx2 = GetUnitX(udg_PU)
              • Custom script: set ly2 = GetUnitY(udg_PU)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (PU is A flying unit) Equal to True
                • Then - Actions
                  • Custom script: set lz2 = GetLocationZ(GetUnitLoc(udg_PU)) + GetUnitFlyHeight(udg_PU) + 50
                • Else - Actions
                  • Custom script: set lz2 = 50
              • Set Lightning = (Load 20 of (Key Handle) in Arcanum_Race)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (PU is A flying unit) Equal to True
                • Then - Actions
                  • Custom script: call MoveLightningEx(udg_Lightning,true,lx1,ly1,lz1,lx2,ly2,lz2)
                • Else - Actions
                  • Custom script: call MoveLightningLoc(udg_Lightning,GetUnitLoc(udg_PU),udg_LTU)
              • Set Lightning = (Load 21 of (Key Handle) in Arcanum_Race)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (PU is A flying unit) Equal to True
                • Then - Actions
                  • Custom script: call MoveLightningEx(udg_Lightning,true,lx1,ly1,lz1,lx2,ly2,lz2)
                • Else - Actions
                  • Custom script: call MoveLightningLoc(udg_Lightning,GetUnitLoc(udg_PU),udg_LTU)
              • Custom script: call DestroyGroup(udg_UnitG)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_UnitG)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Nulling is what you do to local object variables, which of you have none.

Analogue to destroying the group, you save the returned handle of the location create function in some variable, then call

  • Custom script: call RemoveLocation(<locVar>)
when the location is no longer needed/before you overwrite the variable.

Better make a header function for getting the z terrain height and avoid the use of functions that take locations (there are coordinates variants most times).
 
thats y i said if. also nulling globals isnt a bad idea if they arent going to be used for a while or if they are arrays. as they might not be used again for a while. it just nulls the pointer so it clears up handle ids faster.

it can also help with some mistakes if u use tempPlayer and something bugs it wont select the last player stored in that variable.
 
Status
Not open for further replies.
Top