Something wrong - Tossing units and Hashtables

denmax

You can change this now in User CP.
Reaction score
155
I basically made an ability which hurls units from a target point towards your location. Before, I used real variables to store the distance and angle.

Now, after learning about Hashtables, I'm slowly trying to shift the needed reals to hashtable to make them somewhat closer to being MUI. The problem I am facing right now is that though it lifts everyone, it will only move one (random?) unit towards your. The result is everyone being lifted, with one guy slowly going towards your location.

I'm also unsure about the memory leaks concerning hashtables, so I guess that'll be part of my question too.

Here are the triggers

Trigger:
  • Lavapult cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mandrakhor 2nd (Lavapult)
    • Actions
      • Set LavapultCaster = (Triggering unit)
      • Set Point[1] = (Target point of ability being cast)
      • Set UnitGroup[1] = (Units within 210.00 of Point[1])
      • Unit Group - Pick every unit in UnitGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is A structure) Not equal to True
              • ((Picked unit) is Mechanical) Not equal to True
              • ((Picked unit) is Magic Immune) Not equal to True
            • Then - Actions
              • Unit - Add Storm Crow Form to (Picked unit)
              • Unit - Remove Storm Crow Form from (Picked unit)
              • Unit - Turn collision for (Picked unit) Off
              • Unit - Pause (Picked unit)
              • Unit Group - Add (Picked unit) to LavapultTossed
              • Hashtable - Create a hashtable
              • Set LavapultHashtable = (Last created hashtable)
              • Hashtable - Save 0.00 as 0 of (Key (Picked unit)) in LavapultHashtable
              • Hashtable - Save (Angle from (Target point of ability being cast) to (Position of (Triggering unit))) as 1 of (Key (Picked unit)) in LavapultHashtable
              • Hashtable - Save (Distance between (Target point of ability being cast) and (Position of (Triggering unit))) as 2 of (Key (Picked unit)) in LavapultHashtable
            • Else - Actions
      • Special Effect - Create a special effect at Point[1] using Abilities\Spells\Other\Volcano\VolcanoDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_Point[1])
      • Custom script: call DestroyGroup(udg_UnitGroup[1])


Trigger:
  • Lavapult toss
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in LavapultTossed and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 0 of (Key (Picked unit)) from LavapultHashtable) Less than 50.00
            • Then - Actions
              • Hashtable - Save ((Load 0 of (Key (Picked unit)) from LavapultHashtable) + 1.00) as 0 of (Key (Picked unit)) in LavapultHashtable
              • Set Point[1] = (Position of (Picked unit))
              • Set Point[2] = (Point[1] offset by ((Load 2 of (Key (Picked unit)) from LavapultHashtable) / 50.00) towards (Load 1 of (Key (Picked unit)) from LavapultHashtable) degrees)
              • Unit - Move (Picked unit) instantly to Point[2]
              • Set LavapultHeight = ((Power(25.00, 2.00)) - ((25.00 - (Load 0 of (Key (Picked unit)) from LavapultHashtable)) x (25.00 - (Load 0 of (Key (Picked unit)) from LavapultHashtable))))
              • Animation - Change (Picked unit) flying height to LavapultHeight at 0.00
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load 0 of (Key (Picked unit)) from LavapultHashtable) Greater than or equal to 50.00
                • Then - Actions
                  • Unit - Turn collision for (Picked unit) On
                  • Unit - Unpause (Picked unit)
                  • Unit Group - Remove (Picked unit) from LavapultTossed
                  • Animation - Change (Picked unit) flying height to 0.00 at 0.00
                  • Special Effect - Create a special effect at Point[2] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Create 1 Peasant for (Owner of LavapultCaster) at Point[2] facing Default building facing degrees
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                  • Set Real[1] = ((60.00 x (Real((Level of Mandrakhor 2nd (Lavapult) for LavapultCaster)))) + (0.60 x (Real((Strength of LavapultCaster (Include bonuses))))))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in ApocalypseAlsoTossed) Equal to True
                    • Then - Actions
                      • Unit - Cause (Last created unit) to damage (Picked unit), dealing (Real[1] + (Real(ApocalypseDamage))) damage of attack type Spells and damage type Normal
                      • Unit - Add Mandra Dummy (Apocalypse) - Slow to (Last created unit)
                      • Unit - Order (Last created unit) to Undead Necromancer - Cripple (Picked unit)
                      • Unit Group - Remove (Picked unit) from ApocalypseAlsoTossed
                    • Else - Actions
                      • Unit - Cause (Last created unit) to damage (Picked unit), dealing Real[1] damage of attack type Spells and damage type Normal
                  • Destructible - Pick every destructible within 200.00 of Point[2] and do (Actions)
                    • Loop - Actions
                      • Destructible - Kill (Picked destructible)
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in LavapultHashtable
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Point[1])
              • Custom script: call RemoveLocation(udg_Point[2])
            • Else - Actions
 

denmax

You can change this now in User CP.
Reaction score
155
Ugh.. nevermind...

I created a hashtable on the unitgroup, which caused it to create a hashtables per unit

Now my only issue is if it creates memory leaks, esp. on Loads 1 and 2
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top