Are these leaks fixed correctly?

Edward

New Member
Reaction score
2
Since there is so much looping here I can't tell. I also don't know if unit variables (not unit groups) can leak.

Trigger:
  • Verticle Line
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set Z01A = (Position of (Random unit from FormVertRedGroup))
      • Set Z01B = Z01A
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] Off
          • Unit - Move RedVertArray[(Integer A)] instantly to (Z01B offset by (80.00 x (Real((Integer A)))) towards 270.00 degrees), facing 0.00 degrees
          • Unit - Order RedVertArray[(Integer A)] to Hold Position
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Custom script: call DestroyGroup(udg_VertRedGroup)
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] Off
          • Unit - Move RedVertArray[(Integer A)] instantly to (Z01B offset by (80.00 x ((Real((Integer A))) - 1.00)) towards 90.00 degrees), facing 0.00 degrees
          • Unit - Order RedVertArray[(Integer A)] to Hold Position
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Custom script: call DestroyGroup(udg_VertRedGroup)
      • Custom script: call RemoveLocation(udg_Z01A)
      • Custom script: call RemoveLocation(udg_Z01B)
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] On
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Custom script: call DestroyGroup(udg_VertRedGroup)
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set RedVertArray[1] = (Random unit from FormVertRedGroup)
      • Sound - Attach Bugleface2 <gen> to RedVertArray[1]
      • Sound - Play Bugleface2 <gen>
      • Custom script: call DestroyGroup(udg_VertRedGroup)
 

Exide

I am amazingly focused right now!
Reaction score
448
Unit - Move RedVertArray[(Integer A)] instantly to (Z01B offset by (80.00 x (Real((Integer A)))) towards 270.00 degrees), facing 0.00 degrees

Red-colored text leaks.
Why are you setting Z01A and Z01B?
 

Edward

New Member
Reaction score
2
Double variable set

Z01A = Random unit
In order to make Z01A a constant point I need to equate its first value to Z01B. The trigger bugged hard before I did that and it took me ages to discover the problem.

How would i fix that red text though?

EDIT:

Simple question, do you know if there's is an option to change the event to "Any player" types -v, and the first action to Units currently selected by "triggering player."
 

Exide

I am amazingly focused right now!
Reaction score
448
You can use Z01A as start point.
You can use Z01B as the second point.

Start by setting Z01A (you have already done that.)

Move Z01B into the beginning of your loops:
set Z01B = Z01A offset by (80.00 x (Real((Integer A)))

Finally clean up the Z01B -leak inside each loop:
Custom Script call RemoveLocation(udg_Z01B)

EDIT: There is no such event.
However, you can add all the other players:

Player - Player 1 (Red) types a chat message containing -v as An exact match
Player - Player 2 (Blue) types a chat message containing -v as An exact match
Player - Player 3 (Teal) types a chat message containing -v as An exact match
.and so on..

and use (Triggering Player) to find out who wrote it.

EDIT #2: You should only set and destroy FormVertRedGroup once in your trigger.
It is the same group throughout the trigger, setting it and destroying it several times is just a waste.
 

Edward

New Member
Reaction score
2
Nice you rock. :)

Here's a very similar trigger, it lines up units facing an angle that the user wants. So if I type -cm135, the units will make a line facing 135 degrees (the line itself would be along the 225 degree polar offset).

I didn't fix any leaks here yet, but I know know how to fix them now. Is there any additional leaks in this?

Trigger:
  • Custom Line
    • Events
      • Player - Player 1 (Red) types a chat message containing (Substring(-me, 1, 3)) as A substring
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set Z01A = (Position of (Random unit from FormVertRedGroup))
      • Set Z01B = Z01A
      • Set Angle = (Real((Substring((Entered chat string), 4, 6))))
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] Off
          • Unit - Move RedVertArray[(Integer A)] instantly to (Z01B offset by (80.00 x (Real((Integer A)))) towards (Angle + 90.00) degrees), facing Angle degrees
          • Unit - Order RedVertArray[(Integer A)] to Hold Position
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] Off
          • Unit - Move RedVertArray[(Integer A)] instantly to (Z01B offset by (80.00 x ((Real((Integer A))) - 1.00)) towards (Angle - 90.00) degrees), facing Angle degrees
          • Unit - Order RedVertArray[(Integer A)] to Hold Position
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] On
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set RedVertArray[1] = (Random unit from FormVertRedGroup)
      • Sound - Attach Bugleface2 <gen> to RedVertArray[1]
      • Sound - Play Bugleface2 <gen>
 

Edward

New Member
Reaction score
2
EDIT #2: You should only set and destroy FormVertRedGroup once in your trigger.
It is the same group throughout the trigger, setting it and destroying it several times is just a waste.

I actually do need to reset it, because the group itself is changed with each loop. A unit is removed from it each time. This prevents a random unit pick from choosing the same unit again.
 

Exide

I am amazingly focused right now!
Reaction score
448
I actually do need to reset it, because the group itself is changed with each loop. A unit is removed from it each time. This prevents a random unit pick from choosing the same unit again.

True.
Why are you removing units from the group, then picking them again, though?
 

Edward

New Member
Reaction score
2
Picking Again

Well there can be up to 12 units in the selected group.

Each picked unit is lined up with ONE point, offset by 80(A) at some constant angle X.

If I allowed all 12 to line up in one loop, half of them will go off the screen and out of view.

I fixed this by making 6 of them go 80(A) at angle A and making the other 6 go 80(A-1) at angle (A + 180 degrees). This greatly reduces the chances of them appearing out of view.
 

Edward

New Member
Reaction score
2
Finished Trigger

Thanks to you! Thank for warning me that I was destroying the Group early for the second integer loop.

Trigger:
  • Verticle Line
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set Z01A = (Position of (Random unit from FormVertRedGroup))
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Z01B = Z01A
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] Off
          • Unit - Move RedVertArray[(Integer A)] instantly to (Z01B offset by (80.00 x (Real((Integer A)))) towards 270.00 degrees), facing 0.00 degrees
          • Custom script: call RemoveLocation(udg_Z01B)
          • Unit - Order RedVertArray[(Integer A)] to Hold Position
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Z01B = Z01A
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] Off
          • Unit - Move RedVertArray[(Integer A)] instantly to (Z01B offset by (80.00 x ((Real((Integer A))) - 1.00)) towards 90.00 degrees), facing 0.00 degrees
          • Custom script: call RemoveLocation(udg_Z01B)
          • Unit - Order RedVertArray[(Integer A)] to Hold Position
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Custom script: call DestroyGroup(udg_FormVertRedGroup)
      • Custom script: call RemoveLocation(udg_Z01A)
      • Custom script: call RemoveLocation(udg_Z01B)
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] On
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Custom script: call DestroyGroup(udg_FormVertRedGroup)
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set RedVertArray[1] = (Random unit from FormVertRedGroup)
      • Sound - Attach Bugleface2 <gen> to RedVertArray[1]
      • Sound - Play Bugleface2 <gen>
      • Custom script: call DestroyGroup(udg_FormVertRedGroup)
 

Exide

I am amazingly focused right now!
Reaction score
448
You're still leaking points:

Unit - Move RedVertArray[(Integer A)] instantly to (Z01B offset by (80.00 x (Real((Integer A)))) towards 270.00 degrees), facing 0.00 degrees


This should be Z01B.
Z01B should not be Z01A.
 

Edward

New Member
Reaction score
2
Final Finished Version?

K, here it is now. It works perfectly, just tested it.

Thank you. :)

Trigger:
  • Verticle Line
    • Events
      • Player - Player 1 (Red) types a chat message containing -v as An exact match
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set Z01A = (Position of (Random unit from FormVertRedGroup))
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Z01B = (Z01A offset by (80.00 x (Real((Integer A)))) towards 270.00 degrees)
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] Off
          • Unit - Move RedVertArray[(Integer A)] instantly to Z01B, facing 0.00 degrees
          • Custom script: call RemoveLocation(udg_Z01B)
          • Unit - Order RedVertArray[(Integer A)] to Hold Position
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Z01B = (Z01A offset by (80.00 x ((Real((Integer A))) - 1.00)) towards 90.00 degrees)
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] Off
          • Unit - Move RedVertArray[(Integer A)] instantly to Z01B, facing 0.00 degrees
          • Custom script: call RemoveLocation(udg_Z01B)
          • Unit - Order RedVertArray[(Integer A)] to Hold Position
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Custom script: call DestroyGroup(udg_FormVertRedGroup)
      • Custom script: call RemoveLocation(udg_Z01A)
      • Custom script: call RemoveLocation(udg_Z01B)
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Unit - Turn collision for RedVertArray[(Integer A)] On
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
      • Custom script: call DestroyGroup(udg_FormVertRedGroup)
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set RedVertArray[1] = (Random unit from FormVertRedGroup)
      • Sound - Attach Bugleface2 <gen> to RedVertArray[1]
      • Sound - Play Bugleface2 <gen>
      • Custom script: call DestroyGroup(udg_FormVertRedGroup)
 

Edward

New Member
Reaction score
2
Another possible leak?

This is a trigger that is used to move lines after they are formed.

Does the "face [direction of UnitArray(IntegerA)] degrees leak here?

Trigger:
  • Move a line march
    • Events
      • Player - Player 1 (Red) types a chat message containing -m as An exact match
      • Player - Player 2 (Blue) types a chat message containing -m as An exact match
      • Player - Player 3 (Teal) types a chat message containing -m as An exact match
      • Player - Player 4 (Purple) types a chat message containing -m as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -m as An exact match
      • Player - Player 6 (Orange) types a chat message containing -m as An exact match
      • Player - Player 7 (Green) types a chat message containing -m as An exact match
      • Player - Player 8 (Pink) types a chat message containing -m as An exact match
      • Player - Player 9 (Gray) types a chat message containing -m as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -m as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -m as An exact match
      • Player - Player 12 (Brown) types a chat message containing -m as An exact match
    • Conditions
    • Actions
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set RedVertArray[(Integer A)] = (Random unit from FormVertRedGroup)
          • Set Z01A = (Position of RedVertArray[(Integer A)])
          • Unit - Order RedVertArray[(Integer A)] to Move To (Z01A offset by 1000.00 towards (Facing of RedVertArray[(Integer A)]) degrees)
          • Unit Group - Remove RedVertArray[(Integer A)] from FormVertRedGroup
          • Custom script: call RemoveLocation(udg_Z01A)
      • Custom script: call DestroyGroup(udg_FormVertRedGroup)
      • Set FormVertRedGroup = (Units currently selected by Player 1 (Red))
      • Set RedVertArray[1] = (Random unit from FormVertRedGroup)
      • Custom script: call DestroyGroup(udg_FormVertRedGroup)
      • Sound - Attach BugleCharge <gen> to RedVertArray[1]
      • Sound - Play BugleCharge <gen>
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Trigger:
  • Unit - Order RedVertArray[(Integer A)] to Move To (Z01A offset by 1000.00 towards (Facing of RedVertArray[(Integer A)]) degrees)


That still leaks :p

And no, "face [direction of UnitArray(IntegerA)] degrees" doesn't leak :D
 

Komaqtion

You can change this now in User CP.
Reaction score
469
@ Ancanus: That app doesn't work too good...

It might give you some leaks and such, but it also displays stuff which doesn't leak, and it's better to learn for yourself than to use something to do all the work for you...

@ Edward:
Code:
Unit - Order RedVertArray[(Integer A)] to Move To [COLOR="Red"](Z01A offset by 1000.00 towards (Facing of RedVertArray[(Integer A)]) degrees)[/COLOR]

The red part there leaks, because it uses a point (Which you've already set, and also cleans up afterwards... Good :D) to create another point offset that point (This is where it leaks ;))
You'll need to put that "Offset point" in a variable too, and clean that up after use :D
 
Reaction score
54
Komaqtion, are we implying that it's better for Edward to learn by himself, rather than asking us if his triggers are leaking? The application does the same thing that we're doing: pointing out where the leaks are and suggesting how to fix them.

Nevertheless, it's much easier for Edward to use the application instead of posting and waiting for a reply.


P.D: If you can supply an example of a false leak trigger detection, I'm sure I could fix it up in the definition files.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
I'm just implying that it's better to learn and try for yourself first than to simply use an application for all triggers...

And, also, if you post triggers here, you usually (If possible of course) get suggestions for improvements, which that (Or any other for that matter) application gives you :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top