Oddly I'm getting a bug. It may not be possible for you guys to help without a ton of other triggers that I don't want to subject you to. I'm still new to leaks, so perhaps you could just answer this question:
If I do a custom script: call RemoveLocation and remove a variable just BEFORE I assign it, is there any problem with that? I would assume that would remove the old point, and store the new one. That doesn't seem to happen in my trigger below. Roughly what happens is this, there's an array of integers from 1 to 75 that stores integers that correspond to the custom values of different units. I use the following variable arrays to correpond to those custom values.
The boolean variable AiBoolean[1-75] stores a boolean that determines if I use AI to move the unit.
The point variable MovePoint[1-75] determines where on the map the unit is going.
The unit variable AiTarget[1-75] stores the enemy of the current unit.
The point variable defaultMove[1-75] stores where the target should move to if he isn't fighting anyone.
So for the unit with custom value 1, AiBoolean[1] tells me if the computer controls him or not, MovePoint[1] tells me where to move him, AiTarget[1] tells me who he's trying to kill, and if that guy dies defaultMove[1] tells me where to send him next.
The following trigger goes through all the computer units every .5 seconds and assigns their appropriate move points.
For each (Integer a2) from 1 to 75, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
AiBoolean[a2] Equal to True
//Only computer controlled units (AiBoolean = yes) get updated
Then - Actions
//Here I want to remove their previous order to avoid a leak. ***this is what breaks it***
Custom script: call RemoveLocation (udg_MovePoint[udg_a2])
//Below I assign their new move point to be their target, so they move toward their enemy
Set MovePoint[a2] = (Position of AiTargets[a2])
Set turn[a2] = True
Else - Actions
Do nothing
-------- if you have no target, and are AI; go to default position and overwrite the center of map, which it was assigned above --------
//If AiTargets is dead or non-existent, its position is the middle of the map; so I just assigned a lot of units to go to the middle if they have no target. This trigger corrects that.
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
AiBoolean[a2] Equal to True
Or - Any (Conditions) are true
Conditions
(AiTargets[a2] is alive) Equal to False
AiTargets[a2] Equal to No unit
Then - Actions
//If their target is dead or non-existent, I assign their new MovePoint to be their default
Custom script: call RemoveLocation (udg_MovePoint[udg_a2])
Set MovePoint[a2] = defaultMove[a2]
Set turn[a2] = True
Else - Actions
Do nothing
Here's what happens. When I delete the first Custom Script removeLocation action, the trigger works fine. Units chase their enemies; when their enemies die they move to their default move location. So the second Custom Script doesn't seem to break anything.
But when I leave in the first Custom Script which I marked above with ***this is what breaks it****, units move to the center of the map and try to kill it. In other words, their MovePoint variable is still set to the center of the map, not to their defaultMove.
I understand I'm not posting the other massive triggers I have, but all I'm doing is deleting a point that I'm about to overwrite anyway! If I understand leaks, deleting a point with a Custom Script one line before I assign that point a new variable shouldn't make any changes at all; and yet it is.
Thanks, sorry for being so long.
Darwin
If I do a custom script: call RemoveLocation and remove a variable just BEFORE I assign it, is there any problem with that? I would assume that would remove the old point, and store the new one. That doesn't seem to happen in my trigger below. Roughly what happens is this, there's an array of integers from 1 to 75 that stores integers that correspond to the custom values of different units. I use the following variable arrays to correpond to those custom values.
The boolean variable AiBoolean[1-75] stores a boolean that determines if I use AI to move the unit.
The point variable MovePoint[1-75] determines where on the map the unit is going.
The unit variable AiTarget[1-75] stores the enemy of the current unit.
The point variable defaultMove[1-75] stores where the target should move to if he isn't fighting anyone.
So for the unit with custom value 1, AiBoolean[1] tells me if the computer controls him or not, MovePoint[1] tells me where to move him, AiTarget[1] tells me who he's trying to kill, and if that guy dies defaultMove[1] tells me where to send him next.
The following trigger goes through all the computer units every .5 seconds and assigns their appropriate move points.
For each (Integer a2) from 1 to 75, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
AiBoolean[a2] Equal to True
//Only computer controlled units (AiBoolean = yes) get updated
Then - Actions
//Here I want to remove their previous order to avoid a leak. ***this is what breaks it***
Custom script: call RemoveLocation (udg_MovePoint[udg_a2])
//Below I assign their new move point to be their target, so they move toward their enemy
Set MovePoint[a2] = (Position of AiTargets[a2])
Set turn[a2] = True
Else - Actions
Do nothing
-------- if you have no target, and are AI; go to default position and overwrite the center of map, which it was assigned above --------
//If AiTargets is dead or non-existent, its position is the middle of the map; so I just assigned a lot of units to go to the middle if they have no target. This trigger corrects that.
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
AiBoolean[a2] Equal to True
Or - Any (Conditions) are true
Conditions
(AiTargets[a2] is alive) Equal to False
AiTargets[a2] Equal to No unit
Then - Actions
//If their target is dead or non-existent, I assign their new MovePoint to be their default
Custom script: call RemoveLocation (udg_MovePoint[udg_a2])
Set MovePoint[a2] = defaultMove[a2]
Set turn[a2] = True
Else - Actions
Do nothing
Here's what happens. When I delete the first Custom Script removeLocation action, the trigger works fine. Units chase their enemies; when their enemies die they move to their default move location. So the second Custom Script doesn't seem to break anything.
But when I leave in the first Custom Script which I marked above with ***this is what breaks it****, units move to the center of the map and try to kill it. In other words, their MovePoint variable is still set to the center of the map, not to their defaultMove.
I understand I'm not posting the other massive triggers I have, but all I'm doing is deleting a point that I'm about to overwrite anyway! If I understand leaks, deleting a point with a Custom Script one line before I assign that point a new variable shouldn't make any changes at all; and yet it is.
Thanks, sorry for being so long.
Darwin
Last edited: