• 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] Memory leaks and not working spell

Status
Not open for further replies.
Level 2
Joined
Aug 2, 2010
Messages
14
So I have created this spell that is supposed to hit an enemy and when it does, split into three projectiles (that's why it is called splitfire). Right now when I try to fix some memory leaks, the triggers stops working and I don't know why.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set SplitLightning = (Last created hashtable)
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
  • Init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Carrion Swarm
    • Actions
      • Set Caster = (Casting unit)
      • Set HeroPos = (Position of Caster)
      • Set TargetPos = (Target point of ability being cast)
      • Set MoveDist = 9.00
      • Set Angle = (Angle from HeroPos to TargetPos)
      • Set TimeLeft = 8.00
      • Unit - Create 1 Ghoul for (Owner of Caster) at HeroPos facing Angle degrees
      • Set Projectile = (Last created unit)
      • Set SplitLightningHandle = (Last created unit)
      • Hashtable - Save MoveDist as 3 of (Key SplitLightningHandle) in SplitLightning
      • Hashtable - Save Angle as 4 of (Key SplitLightningHandle) in SplitLightning
      • Hashtable - Save TimeLeft as 5 of (Key SplitLightningHandle) in SplitLightning
      • Unit Group - Add Projectile to Projectiles
      • Custom script: call RemoveLocation(udg_HeroPos)
      • Custom script: call RemoveLocation(udg_TargetPos)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Loop <gen>
        • Else - Actions
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Projectiles and do (Actions)
        • Loop - Actions
          • Set MoveDist = (Load 3 of (Key (Picked unit)) from SplitLightning)
          • Set Angle = (Load 4 of (Key (Picked unit)) from SplitLightning)
          • Set TimeLeft = (Load 5 of (Key (Picked unit)) from SplitLightning)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TimeLeft Greater than or equal to 0.03
            • Then - Actions
              • Set ProjectilePos = (Position of (Picked unit))
              • Set ProjectileMovePos = (ProjectilePos offset by MoveDist towards Angle degrees)
              • Unit - Move (Picked unit) instantly to ProjectileMovePos
              • Hashtable - Save (TimeLeft - 0.03) as 5 of (Key (Picked unit)) in SplitLightning
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TimeLeft Less than or equal to 7.40
                • Then - Actions
                  • Set Targets = (Units within 60.00 of ProjectilePos matching ((((Matching unit) belongs to an enemy of (Owner of Projectile)) Equal to True) and (((Matching unit) is alive) Equal to True)))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in Targets) Greater than or equal to 1
                    • Then - Actions
                      • Set Angle = (Angle - 80.00)
                      • Unit - Cause Projectile to damage (Random unit from Targets), dealing 100.00 damage of attack type Spells and damage type Normal
                      • Custom script: call DestroyGroup(udg_Targets)
                      • For each (Integer A) from 1 to 6, do (Actions)
                        • Loop - Actions
                          • Unit - Create 1 Ghoul for (Owner of (Picked unit)) at ProjectilePos facing Default building facing degrees
                          • Set Projectile = (Last created unit)
                          • Set SplitLightningHandle = (Last created unit)
                          • Set Angle = (Angle + 20.00)
                          • Set TimeLeft = 8.00
                          • Set MoveDist = 8.00
                          • Hashtable - Save MoveDist as 3 of (Key SplitLightningHandle) in SplitLightning
                          • Hashtable - Save Angle as 4 of (Key SplitLightningHandle) in SplitLightning
                          • Hashtable - Save TimeLeft as 5 of (Key SplitLightningHandle) in SplitLightning
                          • Unit Group - Add Projectile to Projectiles
                      • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SplitLightning
                      • Unit Group - Remove (Picked unit) from Projectiles
                      • Unit - Remove (Picked unit) from the game
                    • Else - Actions
                      • Custom script: call DestroyGroup(udg_Targets)
                • Else - Actions
              • Custom script: call RemoveLocation(udg_ProjectileMovePos)
              • Custom script: call RemoveLocation(udg_ProjectilePos)
            • Else - Actions
              • Custom script: call RemoveLocation(udg_ProjectilePos)
              • Custom script: call RemoveLocation(udg_ProjectileMovePos)
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SplitLightning
              • Unit Group - Remove (Picked unit) from Projectiles
              • Unit - Remove (Picked unit) from the game
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in Projectiles) Equal to 0
                • Then - Actions
                  • Trigger - Turn off Loop <gen>
                • Else - Actions
Thanks Space Ship, it works now but it still starts to lag when there are loads of projectiles on the map. I can't find any more leaks.
 

Attachments

  • SplitFireTestMapa.w3x
    35.4 KB · Views: 82
Last edited:
Level 6
Joined
Oct 4, 2011
Messages
226
You don't need to save the location of your projectile unit into the hashtable. However you should simply set the location each time in your loop. set TempUnit = (Picked Unit) set TempLocation position of (TempUnit.) You only set a location variable for the temp unit, I think this also applies for your 3 summoned projectiles in the loop.
 
Status
Not open for further replies.
Top