• 🏆 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!

Does this spell leak?

Status
Not open for further replies.
Level 2
Joined
Aug 31, 2009
Messages
8
Hey folks

I am currently working with gui spells - i downloaded some spell packs and read some tutorials (some about memory leaks, too :smile:)
and created this Pyroblast spell:
(Thanks to Rmx for his spell pack here)

  • Pyroblast
    • Events
      • Unit - A unit Starts the effect of an ability (Bad)
    • Conditions
      • (Ability being cast) Equal to Pyro (dummy)
    • Actions
      • Set S_KAEL_PYRO_Caster[1] = (Casting unit)
      • Set S_KAEL_PYRO_points[1] = (Position of S_KAEL_PYRO_Caster[1])
      • Set S_KAEL_PYRO_points[2] = (Target point of ability being cast)
      • Unit - Create 1 Dummy Unit {Blast for (Owner of S_KAEL_PYRO_Caster[1]) at (S_KAEL_PYRO_points[1] offset by 50.00 towards (Angle from S_KAEL_PYRO_points[1] to S_KAEL_PYRO_points[2]) degrees) facing (Facing of S_KAEL_PYRO_Caster[1]) degrees
      • Set S_KAEL_PYRO_geschoss = (Last created unit)
      • Unit - Turn collision for S_KAEL_PYRO_geschoss Off
      • Set Real[29] = 10.00
      • Trigger - Turn on Pyroblast Loop <gen>
  • Pyroblast Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Point1[1] = (Position of S_KAEL_PYRO_geschoss)
      • Set S_KAEL_PYRO_points[3] = (Position of S_KAEL_PYRO_geschoss)
      • Set S_KAEL_PYRO_points[4] = (S_KAEL_PYRO_points[3] offset by 30.00 towards (Angle from S_KAEL_PYRO_points[1] to S_KAEL_PYRO_points[2]) degrees)
      • Set S_KAEL_PYRO_Group = (Units within 130.00 of S_KAEL_PYRO_points[3] matching (((Owner of (Matching unit)) Not equal to (Owner of S_KAEL_PYRO_Caster[1])) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is in S_KAEL_PYRO_Blast) Equal to False))))
      • Unit - Move S_KAEL_PYRO_geschoss instantly to S_KAEL_PYRO_points[4]
      • Custom script: call DestroyGroup(udg_S_KAEL_PYRO_Group)
      • Custom script: call RemoveLocation(udg_S_KAEL_PYRO_points[3])
      • Custom script: call RemoveLocation(udg_S_KAEL_PYRO_points[4])
      • Set Real[29] = (Real[29] + 30.00)
      • -------- DAMAGE --------
      • Set S_KAEL_PYRO_Targets = (Units within 200.00 of Temp_Point1[1] matching (((Matching unit) belongs to an enemy of (Owner of S_KAEL_PYRO_Caster[1])) Equal to True))
      • Unit Group - Pick every unit in S_KAEL_PYRO_Targets and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1]) Equal to 1
            • Then - Actions
              • Unit - Cause S_KAEL_PYRO_Caster[1] to damage (Picked unit), dealing 3.30 damage of attack type Spells and damage type Fire
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1]) Equal to 2
                • Then - Actions
                  • Unit - Cause S_KAEL_PYRO_Caster[1] to damage (Picked unit), dealing 5.00 damage of attack type Spells and damage type Fire
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1]) Equal to 3
                    • Then - Actions
                      • Unit - Cause S_KAEL_PYRO_Caster[1] to damage (Picked unit), dealing 7.50 damage of attack type Spells and damage type Fire
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1]) Equal to 4
                        • Then - Actions
                          • Unit - Cause S_KAEL_PYRO_Caster[1] to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Fire
                        • Else - Actions
                          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Real[29] Greater than or equal to 1200.00
        • Then - Actions
          • Unit - Add a 0.10 second Generic expiration timer to S_KAEL_PYRO_geschoss
          • Custom script: call RemoveLocation(udg_S_KAEL_PYRO_points[1])
          • Custom script: call RemoveLocation(udg_Temp_Point1[1])
          • Custom script: call RemoveLocation(udg_S_KAEL_PYRO_points[2])
          • Set Real[29] = 0.00
          • Set S_KAEL_PYRO_Caster[1] = No unit
          • Set S_KAEL_PYRO_geschoss = No unit
          • Unit Group - Remove all units from S_KAEL_PYRO_Blast
          • Unit Group - Remove all units from S_KAEL_PYRO_Group
          • Unit Group - Remove all units from S_KAEL_PYRO_Targets
          • Custom script: call DestroyGroup(udg_S_KAEL_PYRO_Targets)
          • Trigger - Turn off Pyroblast Loop <gen>
        • Else - Actions

I checked it several times with LeakCheck v3.1 and everything seemed to be okay..

But when i trigger the spell..after say 10 times the game begins to lag... after another 10 times it is nearly unplayable :confused:


I tried what happens if i test my map and do nothing special or use other spells.. Everything stays normal

Looks like something is wrong with that trigger and I don't know what :bored:

Any ideas or tips are welcome


greetings Holzkopf
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
First trigger:

Point 1 = Position of caster.
Point 2 = Point of ability beign cast.
Point 3 = Point 1 offset by...
Create unit at point 3...


Second trigger:

You create temp_point and S_KAEL_PYRO_targets every 0.05 seconds, but only remove the leaks once at the end. Move the leak removal thingies to right before the IF/THEN/ELSE.
 
Level 4
Joined
Jul 28, 2009
Messages
64
I could see a problem if you cast the spell multiple times BEFORE the real[29] reaches 1200 on one of them.

So if your cooldown is less than the time it takes for that to happen (2 seconds) then all of the variables are going to get screwy because it isn't MUI, and you wont destroy the correct unit.

A few simple suggestions:

Just remove the dummy unit from the game at the end instead of adding an expiration timer.

Change the dummy unit to have no collision in the object editor instead of in the trigger

Also, I would add an If then else function to see if there are ANY units in your Damage group, if true, then run the damage triggers, if not, just do nothing.

Im not sure if these will completely fix your lag issue, but those are just some problems i saw at first glance.

try them out :)

If you want some more direct help, like making this MUI or something (which would probably reduce the lag to almost nothing) let me know.
 
Level 2
Joined
Aug 31, 2009
Messages
8
Okay first thanks for the answers

I tried to fix all the mentioned problems and this is what the trigger looks like atm:

  • Pyroblast
    • Events
      • Unit - A unit Starts the effect of an ability (Bad)
    • Conditions
      • (Ability being cast) Equal to Pyro (dummy)
    • Actions
      • Set S_KAEL_PYRO_Caster[1] = (Casting unit)
      • Set S_KAEL_PYRO_points[1] = (Position of S_KAEL_PYRO_Caster[1])
      • Set S_KAEL_PYRO_points[2] = (Target point of ability being cast)
      • Unit - Create 1 Dummy Unit {Blast for (Owner of S_KAEL_PYRO_Caster[1]) at (S_KAEL_PYRO_points[1] offset by 50.00 towards (Angle from S_KAEL_PYRO_points[1] to S_KAEL_PYRO_points[2]) degrees) facing (Facing of S_KAEL_PYRO_Caster[1]) degrees
      • Set S_KAEL_PYRO_geschoss = (Last created unit)
      • Set Real[29] = 10.00
      • Trigger - Turn on Pyroblast Loop <gen>
  • Pyroblast Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Point1[1] = (Position of S_KAEL_PYRO_geschoss)
      • Set S_KAEL_PYRO_points[3] = (Position of S_KAEL_PYRO_geschoss)
      • Set S_KAEL_PYRO_points[4] = (S_KAEL_PYRO_points[3] offset by 30.00 towards (Angle from S_KAEL_PYRO_points[1] to S_KAEL_PYRO_points[2]) degrees)
      • Set S_KAEL_PYRO_Group = (Units within 130.00 of S_KAEL_PYRO_points[3] matching (((Owner of (Matching unit)) Not equal to (Owner of S_KAEL_PYRO_Caster[1])) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is in S_KAEL_PYRO_Blast) Equal to False))))
      • Unit - Move S_KAEL_PYRO_geschoss instantly to S_KAEL_PYRO_points[4]
      • Custom script: call RemoveLocation(udg_S_KAEL_PYRO_points[3])
      • Custom script: call RemoveLocation(udg_S_KAEL_PYRO_points[4])
      • Set Real[29] = (Real[29] + 30.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in S_KAEL_PYRO_Group) Not equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in S_KAEL_PYRO_Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1]) Equal to 1
                • Then - Actions
                  • Unit - Cause S_KAEL_PYRO_Caster[1] to damage (Picked unit), dealing 3.30 damage of attack type Spells and damage type Fire
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1]) Equal to 2
                    • Then - Actions
                      • Unit - Cause S_KAEL_PYRO_Caster[1] to damage (Picked unit), dealing 5.00 damage of attack type Spells and damage type Fire
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1]) Equal to 3
                        • Then - Actions
                          • Unit - Cause S_KAEL_PYRO_Caster[1] to damage (Picked unit), dealing 7.50 damage of attack type Spells and damage type Fire
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1]) Equal to 4
                            • Then - Actions
                              • Unit - Cause S_KAEL_PYRO_Caster[1] to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Fire
                            • Else - Actions
          • Unit Group - Remove all units from S_KAEL_PYRO_Targets
        • Else - Actions
      • Custom script: call DestroyGroup(udg_S_KAEL_PYRO_Targets)
      • Custom script: call RemoveLocation(udg_Temp_Point1[1])
      • Custom script: call DestroyGroup(udg_S_KAEL_PYRO_Group)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Real[29] Greater than or equal to 1200.00
        • Then - Actions
          • Unit - Remove S_KAEL_PYRO_geschoss from the game
          • Custom script: call RemoveLocation(udg_S_KAEL_PYRO_points[1])
          • Custom script: call RemoveLocation(udg_S_KAEL_PYRO_points[2])
          • Set Real[29] = 0.00
          • Set S_KAEL_PYRO_Caster[1] = No unit
          • Set S_KAEL_PYRO_geschoss = No unit
          • Unit Group - Remove all units from S_KAEL_PYRO_Blast
          • Unit Group - Remove all units from S_KAEL_PYRO_Group
          • Custom script: call DestroyGroup(udg_S_KAEL_PYRO_Blast)
          • Custom script: call DestroyGroup(udg_S_KAEL_PYRO_Group)
          • Trigger - Turn off Pyroblast Loop <gen>
        • Else - Actions
unfortunately the lags still occur :(
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You still leak the creation location of the dummy in the first trigger.

  • Set location = S_KAEL_PYRO_points[1] offset by 50.00 towards (Angle from...
  • Unit - Create 1 Dummy Unit {Blast for (Owner of S_KAEL_PYRO_Caster[1]) at (location) facing...
Also I don't think you need to remove all units from the group before destroying it. You also don't need to set the units to no unit.

I believe it will be faster if you do

  • set integer = (Level of Pyro (dummy) for S_KAEL_PYRO_Caster[1])
and then

  • If - Conditions
  • integer Equal to 1
etc.
 
Level 4
Joined
Jul 28, 2009
Messages
64
Hmmm.. Well you can certinly remove the "remove all units from group" triggers because you are creating and destroying the group anyway to remove the leak every time...

Perhaps it is your timing mechanism (the real[29] variable). I've never seen a timer used like that before.

Do you have any experience using hashtables? those could help a lot. There is a tutorial on hive that could help you learn them, i believe the example spell has a nice timer used, that might help lower lag... im struggling to find a "leak" however... ill keep looking though

EDIT:

oh and maker is correct, to be more specific, you have to set every point (even points withina point's trigger, if you know what i mean) to a variable
 
Status
Not open for further replies.
Top