HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How do i make this Memory leak free

02-09-2006, 11:53 PM#1
Immoralis
Trigger:
Actions
Unit - Move (Attacked unit) instantly to ((Position of (Attacked unit)) offset by 8.00 towards (Angle from (Position of (Attacking unit)) to (Position of (Attacked unit))) degrees)
Wait 0.15 seconds
Unit - Move (Attacked unit) instantly to ((Position of (Attacked unit)) offset by 8.00 towards (Angle from (Position of (Attacking unit)) to (Position of (Attacked unit))) degrees)
Wait 0.15 seconds
Unit - Move (Attacked unit) instantly to ((Position of (Attacked unit)) offset by 8.00 towards (Angle from (Position of (Attacking unit)) to (Position of (Attacked unit))) degrees)
please post a comlplete actions trigger, i am very jass-challenged
02-10-2006, 03:44 AM#2
Hemlock
I don't see why this coud lead to a memory leak?

What is the event?
02-10-2006, 04:24 AM#3
Naakaloh
This should be a suitable solution.

Trigger:
Actions
Set AttackedPosition = Position of (Attacked unit)
Set AttackerPosition = Position of (Attacking unit)
Unit - Move (Attacked unit) instantly to AttackedPosition offset by 8.00 towards (Angle from AttackerPosition to AttackedPosition) degrees
Wait 0.15 seconds
Unit - Move (Attacked unit) instantly to AttackedPosition offset by 8.00 towards (Angle from AttackerPosition to AttackedPosition) degrees
Wait 0.15 seconds
Unit - Move (Attacked unit) instantly to AttackedPosition offset by 8.00 towards (Angle from AttackerPosition to AttackedPosition) degrees
Custom Script - call RemoveLocation(udg_AttackedPosition)
Custom Script - call RemoveLocation(udg_AttackerPosition)
02-10-2006, 10:49 AM#4
Anitarf
The polar offset will still leak, and since you now set the position of attacked unit to a variable, it doesn't change as the unit moves, so you should use increasing offset values: 8, 16, 24.
02-10-2006, 01:11 PM#5
Zoxc
It might also couse problems if the trigger runs twice at the same time. Use locals.
02-10-2006, 01:15 PM#6
Immoralis
Quote:
Originally Posted by Naakaloh
This should be a suitable solution.

Trigger:
Actions
Set AttackedPosition = Position of (Attacked unit)
Set AttackerPosition = Position of (Attacking unit)
Unit - Move (Attacked unit) instantly to AttackedPosition offset by 8.00 towards (Angle from AttackerPosition to AttackedPosition) degrees
Wait 0.15 seconds
Unit - Move (Attacked unit) instantly to AttackedPosition offset by 8.00 towards (Angle from AttackerPosition to AttackedPosition) degrees
Wait 0.15 seconds
Unit - Move (Attacked unit) instantly to AttackedPosition offset by 8.00 towards (Angle from AttackerPosition to AttackedPosition) degrees
Custom Script - call RemoveLocation(udg_AttackedPosition)
Custom Script - call RemoveLocation(udg_AttackerPosition)

I thought of this but , its not mutilinstanceable,and in this one the 2nd move downsn't do anything because attacked position doesn't get declared again. how do you use locals btw
02-10-2006, 02:43 PM#7
Chuckle_Brother
Collapse JASS:
function DoSomething takes nothing returns nothing
    local integer i
    local integer c=UnitUserData(GetTriggerUnit())
endfunction

Note that like in any real language you can also merge the delare with an initialization to save lines.

If you were in gui it would be
Trigger:
Custom Script: local integer i

Of course this means using custom scripts for any actions you do in the trigger
02-10-2006, 06:30 PM#8
Immoralis
i see so what would i need exactly for the actions part?
02-10-2006, 06:40 PM#9
Taur
chuckle brother gave it to you, go to the custom script function and copy the lines (1 per function)