HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Massive leaking on this trigger (GUI). But I can't figure where.

01-21-2010, 11:15 AM#1
Matarael
It's not mine (I believe I picked it up from Hive years ago when it was still called... what was it? Nvm). The idea was simple and I thought I could adapt it but it kept leaking. And so bad that by the 3rd use, the fps drops to under 10.

The trigger basically makes the unit rams towards a target location, and stops at the first enemy unit encountered, dealing damage to it based on how far it "traveled". It also kills trees.

Here is the trigger:

Trigger:
Ram Cast
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Ram
Collapse Actions
Set ramangle = (Angle from (Position of (Triggering unit)) to (Position of (Target unit of ability being cast)))
Set ramangle = (Angle from (Position of (Triggering unit)) to (Target point of ability being cast))
Set ramtarget = (Position of (Target unit of ability being cast))
Set ramtarget = (Target point of ability being cast)
Set ramdamage = 0.00
Set rammaxdistance = (Distance between (Position of (Triggering unit)) and (Target point of ability being cast))
Set ramdistance = 0.00
Set rammer = (Triggering unit)
Special Effect - Create a special effect attached to the origin of rammer using dust.mdx
Set ramdust = (Last created special effect)
Unit - Make rammer Invulnerable
Unit - Pause rammer
Unit - Turn collision for rammer Off
Trigger - Turn on Ram Movement Copy <gen>

And then

Trigger:
Ram Movement Copy
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
ramdistance Less than rammaxdistance
Collapse Then - Actions
Set ramdistance = (ramdistance + 100.00)
Set Ram_loc = ((Position of rammer) offset by 100.00 towards (Facing of rammer) degrees)
Unit - Move rammer instantly to Ram_loc, facing ramangle degrees
Collapse Destructible - Pick every destructible within 200.00 of Ram_loc and do (Actions)
Collapse Loop - Actions
Destructible - Kill (Picked destructible)
Custom script: call RemoveLocation(udg_Ram_loc)
Set ramdamage = (ramdistance / 4.00)
Animation - Play rammer's walk fast animation
Special Effect - Create a special effect attached to the chest of rammer using Abilities\Spells\Human\Defend\DefendCaster.mdl
Special Effect - Destroy (Last created special effect)
Collapse Else - Actions
Trigger - Turn off (This trigger)
Trigger - Run Ram Stop <gen> (checking conditions)

And then

Trigger:
Ram Stop
Events
Conditions
Collapse Actions
Set Ram_loc = (Position of rammer)
Collapse Unit Group - Pick every unit in (Units within 200.00 of Ram_loc matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of rammer)) Equal to True)))) and do (Actions)
Collapse Loop - Actions
Unit Group - Add (Picked unit) to ramtargets
Unit - Cause rammer to damage (Picked unit), dealing ramdamage damage of attack type Normal and damage type Normal
Custom script: call RemoveLocation(udg_Ram_loc)
Unit - Make rammer Vulnerable
Unit - Unpause rammer
Unit - Turn collision for rammer On
Unit Group - Remove all units from ramtargets
Custom script: call DestroyGroup(udg_ramtargets)
Special Effect - Destroy ramdust
Set ramdamage = 0.00
Set ramdistance = 0.00
Set rammer = No unit

Anyone know why this is happening?
01-21-2010, 11:31 AM#2
Anachron
Quote:
Unit Group - Add (Picked unit) to ramtargets
Unit Group - Remove all units from ramtargets

I don't see the sense here.

Quote:
Set ramangle = (Angle from (Position of (Triggering unit)) to (Position of (Target unit of ability being cast)))
Set ramangle = (Angle from (Position of (Triggering unit)) to (Target point of ability being cast))
Set ramtarget = (Position of (Target unit of ability being cast))
Set ramtarget = (Target point of ability being cast)
Set rammaxdistance = (Distance between (Position of (Triggering unit)) and (Target point of ability being cast))
Set Ram_loc = ((Position of rammer) offset by 100.00 towards (Facing of rammer) degrees)
Leaks all.
01-21-2010, 11:54 AM#3
Matarael
But they're all just variables. They get destroyed afterwards.

Right?


I mean, there's that "function" in there.
01-21-2010, 11:58 AM#4
Anachron
Wehrm, but you never actually destroy them.

Quote:
Set rammaxdistance = (Distance between (Position of (Triggering unit)) and (Target point of ability being cast))
Can only be destroyed if you create 2 variables of type location and then clean them up after setting the distance.

Quote:
((Position of rammer) offset by 100.00 towards (Facing of rammer) degrees)
Put the position of hammer into a new variable and then clean it after settings the new position.
01-21-2010, 12:07 PM#5
Matarael
Oh damn, so basically I have to create variables FOR variables so they wont leak? LOL I never realised that.

Let me try this. Thanks, and let me know if you can think of something else :)
01-21-2010, 12:19 PM#6
Anachron
Quote:
((Position of rammer)
Isn't a variable. Its getting a handle that is never been destroyed, because you haven't saved that handle anywhere.
01-23-2010, 05:10 PM#7
Matarael
Damnit, it's still causing lags after 5-6 uses... Does anyone know of a similar trigger which does basically the same thing but doesn't lag?

I'm getting a bit sick of this one (literally, the lags is causing me to feel nauseous) but I don't wish to change it.
01-24-2010, 02:32 AM#8
thehellman
Post the new code.
01-24-2010, 12:55 PM#9
Matarael
Interestingly, I managed to reduce the lag to just above 10 fps (around 14, before the changes it could go down to about 8 fps when used more than once), so whatever was changed was doing something. I suspect it has something to do with the special effect but I cannot be certain.
Anyway, here it is the "improved" yet still lagging code:

Hidden information:


Trigger:
Ram Cast
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Ram
Collapse Actions
Set rammer = (Triggering unit)
Set rammerposition = (Position of rammer)
Set ramtarget = (Position of (Target unit of ability being cast))
Set ramtarget = (Target point of ability being cast)
Set ramangle = (Angle from rammerposition to ramtarget)
Set ramdamage = 0.00
Set rammaxdistance = (Distance between rammerposition and ramtarget)
Set ramdistance = 0.00
Special Effect - Create a special effect attached to the origin of rammer using dust.mdx
Set ramdust = (Last created special effect)
Special Effect - Destroy ramdust
Animation - Play rammer's walk fast animation
Animation - Change rammer's animation speed to 0.00% of its original speed
Unit - Make rammer Invulnerable
Unit - Pause rammer
Unit - Turn collision for rammer Off
Trigger - Turn on Ram Movement ori <gen>

Trigger:
Ram Movement ori
Collapse Events
Time - Every 0.05 seconds of game time
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
ramdistance Less than rammaxdistance
Collapse Then - Actions
Set Ram_loc = (rammerposition offset by 50.00 towards (Facing of rammer) degrees)
Unit - Move rammer instantly to Ram_loc, facing ramangle degrees
Set rammerposition = (Position of rammer)
Set ramdistance = (ramdistance + 50.00)
Set ramdamage = (ramdistance / 4.00)
Collapse Unit Group - Pick every unit in (Units within 200.00 of (Position of rammer) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an ally of (Owner of rammer)) Equal to False)))) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Picked unit) Not equal to rammer
Collapse Then - Actions
Unit Group - Add (Picked unit) to ramtargets
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in ramtargets) Greater than 0
Collapse Then - Actions
Trigger - Turn off (This trigger)
Trigger - Run Ram Stop <gen> (checking conditions)
Collapse Else - Actions
Do nothing
Else - Actions
Collapse Else - Actions
Trigger - Turn off (This trigger)
Trigger - Run Ram Stop <gen> (checking conditions)

Trigger:
Ram Stop
Events
Conditions
Collapse Actions
Collapse Destructible - Pick every destructible within 200.00 of Ram_loc and do (Actions)
Collapse Loop - Actions
Destructible - Kill (Picked destructible)
Collapse Unit Group - Pick every unit in (Units within 200.00 of Ram_loc matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of rammer)) Equal to True)))) and do (Actions)
Collapse Loop - Actions
Unit Group - Add (Picked unit) to ramtargets
Unit - Cause rammer to damage (Picked unit), dealing ramdamage damage of attack type Normal and damage type Normal
Custom script: call RemoveLocation(udg_Ram_loc)
Custom script: call RemoveLocation(udg_rammerposition)
Custom script: call RemoveLocation(udg_ramtarget)
Unit - Make rammer Vulnerable
Unit - Unpause rammer
Unit - Turn collision for rammer On
Unit Group - Remove all units from ramtargets
Custom script: call DestroyGroup(udg_ramtargets)
Special Effect - Create a special effect attached to the origin of rammer using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
Set ramdust = (Last created special effect)
Special Effect - Destroy ramdust
Animation - Change rammer's animation speed to 100.00% of its original speed
Set ramdamage = 0.00
Set ramdistance = 0.00
Set rammer = No unit

01-24-2010, 07:54 PM#10
Anitarf
You are leaking the locations rammerposition and Ram_loc in the movement trigger, that is 40 locations per second.

Also, it seems like it is possible for the spell to do double or even triple damage if the rammer comes in range of multiple units with one periodic move (since Ram Stop would be run multiple times).
01-24-2010, 10:21 PM#11
Matarael
Holy crap 40 locs/second... No wonder it drops 10 fps per use. Can you be specific as to where it's leaking? I'm not going to lie, I'm still hazy about what causes leaks and what doesn't.

Thanks, mate.
01-24-2010, 10:33 PM#12
Anitarf
"Set rammerposition = (Position of rammer)"
You are creating a new location and storing it in the rammerposition variable here without first destroying the location that was stored in that variable previously.

"Set Ram_loc = (rammerposition offset by 50.00 towards (Facing of rammer) degrees)"
Same here, only for Ram_loc.
01-24-2010, 10:36 PM#13
blanc_dummy
group also leak, do this

Trigger:
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within 200.00 of (Position of rammer) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an ally of (Owner of rammer)) Equal to False)))) and do (Actions)

or store the group instantly to a variable, and then destroy it manually
Trigger:
Set GroupVar = Pick every unit in (Units within 200.00 of (Position of rammer) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an ally of (Owner of rammer)) Equal to False)))) and do (Actions)
Unit Group - Pick every unit in GroupVar and do (Unit - Hide (Picked unit))
Custom script: call DestroyGroup(udg_GroupVar)
01-24-2010, 11:07 PM#14
Matarael
Wait let me get this straight... Storing something in a variable doesn't delete/clear the previous one? Why did I get an impression that it overwrites the previous "set"/store function?

Is what you're saying before I store another position I have to first clear/destroy the previous position first?
01-25-2010, 03:43 AM#15
SmileyJeff
Nope it doesn't delete. Instead it points the variable towards the new position. Leaving that old position hanging therefore leak because you can't point it back anymore.