• 🏆 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] Check my work (leaks)

Status
Not open for further replies.
Level 8
Joined
Apr 30, 2009
Messages
338
Just started making spells with hashtables again after almost a year away from it. I was amazed that this spell worked the very first time I tested it, but need to make sure it is efficient as far as GUI goes.

Here is what it is supposed to do:
Unit casts it in a target direction, a projectile goes in target direction for 2500 distance. When projectile comes in contact with enemy unit, it explodes and damages an AOE based on how far it went (25 damage at point blank, 75 damage at 1500+ range, linear increase). Projectile is unit "P.ELE-1" and every frame of the spell (0.03 sec), a unit "E.ELE-1" is spawned at the projectiles location, using the model "trap-fire" for visual effect only.

Here is the code, trigger 1 generates the projectile with all the values (angle, speed, etc) that are checked each frame in trigger 2.

  • Lava Surge 01
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ELE-1 Lava Surge
    • Actions
      • Set current_hashtable = H_LavaSurge
      • Set current_group = G_LavaSurge
      • Set temp_point = (Position of (Triggering unit))
      • Set temp_point2 = (Target point of ability being cast)
      • Set temp_real = (Angle from temp_point to temp_point2)
      • Custom script: call RemoveLocation(udg_temp_point2)
      • Set temp_point2 = (temp_point offset by 50.00 towards temp_real degrees)
      • Custom script: call RemoveLocation(udg_temp_point)
      • Unit - Create 1 P.ELE-1 Lava Surge for (Owner of (Triggering unit)) at temp_point2 facing temp_real degrees
      • Custom script: call RemoveLocation(udg_temp_point2)
      • Hashtable - Save Handle Of(Triggering unit) as (Key caster) of (Key (Last created unit)) in current_hashtable
      • Hashtable - Save temp_real as (Key angle) of (Key (Last created unit)) in current_hashtable
      • Hashtable - Save 720.00 as (Key speed) of (Key (Last created unit)) in current_hashtable
      • Hashtable - Save 50.00 as (Key distance) of (Key (Last created unit)) in current_hashtable
      • Hashtable - Save 25.00 as (Key damage) of (Key (Last created unit)) in current_hashtable
      • Unit Group - Add (Last created unit) to current_group
      • Trigger - Turn on Lava Surge 02 <gen>
      • Custom script: set udg_current_hashtable = null
      • Custom script: call DestroyGroup(udg_current_group)
  • Lava Surge 02
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set current_hashtable = H_LavaSurge
      • Set current_group = G_LavaSurge
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in current_group) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in current_group and do (Actions)
            • Loop - Actions
              • Set temp_point = (Position of (Picked unit))
              • Set temp_group = (Units within 50.00 of temp_point matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is Mechanical) Equal to False) and (((Matching unit) belongs to an ally of (Owner of (Picked unit))) Equal to False))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in temp_group) Greater than 0
                • Then - Actions
                  • Custom script: call DestroyGroup(udg_temp_group)
                  • Unit - Kill (Picked unit)
                  • Special Effect - Create a special effect at temp_point using Abilities\Spells\Other\Doom\DoomDeath.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set temp_group = (Units within 300.00 of temp_point matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is Mechanical) Equal to False) and (((Matching unit) belongs to an ally of (Owner of (Picked unit))) Equal to False))))
                  • Custom script: call RemoveLocation(udg_temp_point)
                  • Set temp_unit = (Load (Key caster) of (Key (Picked unit)) in current_hashtable)
                  • Set temp_real = (Load (Key damage) of (Key (Picked unit)) from current_hashtable)
                  • Unit Group - Remove (Picked unit) from current_group
                  • Unit Group - Pick every unit in temp_group and do (Actions)
                    • Loop - Actions
                      • Unit - Cause temp_unit to damage (Picked unit), dealing temp_real damage of attack type Hero and damage type Normal
                      • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Unit Group - Remove (Picked unit) from temp_group
                  • Custom script: call DestroyGroup(udg_temp_group)
                • Else - Actions
                  • Unit - Create 1 E.ELE-1 Lava Surge for (Owner of (Picked unit)) at temp_point facing Default building facing degrees
                  • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                  • Set temp_point2 = (temp_point offset by ((Load (Key speed) of (Key (Picked unit)) from current_hashtable) x R_FRAME_PROJECTILES) towards (Load (Key angle) of (Key (Picked unit)) from current_hashtable) degrees)
                  • Unit - Move (Picked unit) instantly to temp_point2
                  • Hashtable - Save ((Load (Key distance) of (Key (Picked unit)) from current_hashtable) + (Distance between temp_point and temp_point2)) as (Key distance) of (Key (Picked unit)) in current_hashtable
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load (Key damage) of (Key (Picked unit)) from current_hashtable) Greater than or equal to 75.00
                    • Then - Actions
                      • Hashtable - Save 75.00 as (Key damage) of (Key (Picked unit)) in current_hashtable
                    • Else - Actions
                      • Hashtable - Save ((Load (Key damage) of (Key (Picked unit)) from current_hashtable) + ((Distance between temp_point and temp_point2) / 30.00)) as (Key damage) of (Key (Picked unit)) in current_hashtable
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load (Key distance) of (Key (Picked unit)) from current_hashtable) Greater than or equal to 2500.00
                    • Then - Actions
                      • Unit - Kill (Picked unit)
                      • Unit Group - Remove (Picked unit) from current_group
                    • Else - Actions
        • Else - Actions
          • Trigger - Turn off (This trigger)
      • Custom script: set udg_current_hashtable = null
      • Custom script: call DestroyGroup(udg_current_group)
 
  • Set current_hashtable = H_LavaSurge
  • Custom script: set udg_current_hashtable = null
You don't need that. You just need to initialize your hashtable in the Map Initialization and that's all.

  • Custom script: call RemoveLocation(udg_temp_point2)
You use this line two times and the first time is before the temp_point2 is actually used.

  • Set current_group = G_LavaSurge
  • Unit Group - Pick every unit in current_group and do (Actions)
Again, you don't need that. Just do:
  • Unit Group - Pick every unit in G_LavaSurge and do (Actions)
  • Custom script: call DestroyGroup(udg_temp_group)
Use another group, when you make the new temp_group, don't use the same.

  • Custom script: call RemoveLocation(udg_temp_point)
Don't use this line under the "Then - Actions". Get it out of the If/Then/Else loop.

  • Custom script: set udg_current_hashtable = null
Again, stop using that :S
 
Level 8
Joined
Apr 30, 2009
Messages
338
You don't need that. You just need to initialize your hashtable in the Map Initialization and that's all.

I do have a trigger to make all hashtables, but I use the "current" variables in some triggers so if i have some similar spells, I just change the "current hashtable" and don't have to go in every line of the spell to change the hashtable being used.


You use this line two times and the first time is before the temp_point2 is actually used.

I destroyed one temp_point2, made a new one, and destroyed it. They are different points...
  • Set temp_point2 = (Target point of ability being cast)
  • Set temp_real = (Angle from temp_point to temp_point2)
  • Custom script: call RemoveLocation(udg_temp_point2)
  • Set temp_point2 = (temp_point offset by 50.00 towards temp_real degrees)
  • Custom script: call RemoveLocation(udg_temp_point)
  • Unit - Create 1 P.ELE-1 Lava Surge for (Owner of (Triggering unit)) at temp_point2 facing temp_real degrees
  • Custom script: call RemoveLocation(udg_temp_point2)

Use another group, when you make the new temp_group, don't use the same.

I don't understand this


Don't use this line under the "Then - Actions". Get it out of the If/Then/Else loop.

ok
 
I do have a trigger to make all hashtables, but I use the "current" variables in some triggers so if i have some similar spells, I just change the "current hashtable" and don't have to go in every line of the spell to change the hashtable being used.
This is not Jass. You didn't make a table to adjust a spell to a specific hashtable. It would be idiot, either way.

You use this line two times and the first time is before the temp_point2 is actually used.
Ok, didn't notice that.
 
Status
Not open for further replies.
Top