• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

Issue after issue

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
You want to order a new destination when it reaches a destination or when it stops?

You can either check if the unit is standing still (search for Is Unit Moving) and give it the next order when that happens or you can give it a new order when it reaches it's destination. The latter being triggered when it enters the destination region perhaps?
 
Level 10
Joined
Mar 17, 2012
Messages
582
Perhaps he mean when a unit enter a region then order it to move or Attack-move.
No, that would be too easy.

Okay, I'll explain. I have a bridge on my map :)
http://prntscr.com/bfkee5
On the screenshot above you can see the Butcher wanting to get through under the bridge :)
I need a trigger that will make a unit, that is issued to move to the point "2", to move to the point "1", because otherwise he will try to go around.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,220
  • ((Playable map area) contains (Target point of issued order)) Equal to True
b7806b2795287d8a8520f5197e8af69c.png
 
Level 10
Joined
Mar 17, 2012
Messages
582
Remember to clear any location leaks.

  • Issues under the bridge
    • Events
    • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
    • Set Player_Number_Int = (Player number of (Owner of (Triggering unit)))
    • Set Try_To_Cross_Unit[Player_Number_Int] = (Triggering unit)
    • Set Try_To_Cross_Point[Player_Number_Int] = (Position of Try_To_Cross_Unit[Player_Number_Int])
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • And - All (Conditions) are true
    • Conditions
    • (SE TryToCross <gen> contains (Target point of issued order)) Equal to True
    • (Distance between Try_To_Cross_Point[Player_Number_Int] and (Center of Bridge SW enter <gen>)) Less than or equal to 450.00
    • Then - Actions
    • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To (Center of Bridge SW enter <gen>)
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • And - All (Conditions) are true
    • Conditions
    • (SW TryToCross <gen> contains (Target point of issued order)) Equal to True
    • (Distance between Try_To_Cross_Point[Player_Number_Int] and (Center of Bridge SE enter <gen>)) Less than or equal to 450.00
    • Then - Actions
    • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To (Center of Bridge SE enter <gen>)
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • And - All (Conditions) are true
    • Conditions
    • (NE TryToCross <gen> contains (Target point of issued order)) Equal to True
    • (Distance between Try_To_Cross_Point[Player_Number_Int] and (Center of Bridge NW enter <gen>)) Less than or equal to 450.00
    • Then - Actions
    • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To (Center of Bridge NW enter <gen>)
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • And - All (Conditions) are true
    • Conditions
    • (NW TryToCross <gen> contains (Target point of issued order)) Equal to True
    • (Distance between Try_To_Cross_Point[Player_Number_Int] and (Center of Bridge NE enter <gen>)) Less than or equal to 450.00
    • Then - Actions
    • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To (Center of Bridge NE enter <gen>)
    • Else - Actions
    • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
How's that? Will it be cleared enough if I have only 4 regions?
 
Level 10
Joined
Mar 17, 2012
Messages
582
It leaks locations, you will need to remove them if you want your map to perform well.
Okay, my WC started to turn off, I guess it's because of this trigger because that never happened before.
How do I have to clean it up? Do I need to
- create 4 Variables to SE TryToCross <gen>, etc;
- create variables to regions Centre of Bridge SW, etc;
- clear them up?

Could you please point what exactly leaks here?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,264
You are creating locations which you never remove. For example...
(Center of Bridge SE enter <gen>)
This returns a new location object which you use in...
join.gif
if.gif
(Distance between Try_To_Cross_Point[Player_Number_Int] and (Center of Bridge SE enter <gen>)) Less than or equal to 450.00
You never remove this object. Hence it leaks.

You either need to assign it to a constant like variable at map initaliation and reference that variable each time (fastest) or you need to assign it to a temporary global/local variable which you then remove after using it for your distance check. Local declared local variables have another leak but that only applies if you use them (not available in GUI).
 
Level 10
Joined
Mar 17, 2012
Messages
582
You are creating locations which you never remove. For example...

This returns a new location object which you use in...

You never remove this object. Hence it leaks.

You either need to assign it to a constant like variable at map initaliation and reference that variable each time (fastest) or you need to assign it to a temporary global/local variable which you then remove after using it for your distance check. Local declared local variables have another leak but that only applies if you use them (not available in GUI).

Take a look at that:

  • Issues under the bridge
    • Events
    • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
    • Set Player_Number_Int = (Player number of (Owner of (Triggering unit)))
    • Set Try_To_Cross_Unit[Player_Number_Int] = (Triggering unit)
    • Set Try_To_Cross_Point[Player_Number_Int] = (Position of Try_To_Cross_Unit[Player_Number_Int])
    • Set Issue_Point[Player_Number_Int] = (Target point of issued order)
    • Set Bridge_SW_Point[Player_Number_Int] = (Center of Bridge SW enter <gen>)
    • Set Bridge_SE_Point[Player_Number_Int] = (Center of Bridge SE enter <gen>)
    • Set Bridge_NW_Point[Player_Number_Int] = (Center of Bridge NW enter <gen>)
    • Set Bridge_NE_Point[Player_Number_Int] = (Center of Bridge NE enter <gen>)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • And - All (Conditions) are true
    • Conditions
    • (SE TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
    • (Distance between Try_To_Cross_Point[Player_Number_Int] and Bridge_SW_Point[Player_Number_Int]) Less than or equal to 450.00
    • Then - Actions
    • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_SW_Point[Player_Number_Int]
    • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • And - All (Conditions) are true
    • Conditions
    • (SW TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
    • (Distance between Try_To_Cross_Point[Player_Number_Int] and Bridge_SE_Point[Player_Number_Int]) Less than or equal to 450.00
    • Then - Actions
    • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_SE_Point[Player_Number_Int]
    • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • And - All (Conditions) are true
    • Conditions
    • (NE TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
    • (Distance between Try_To_Cross_Point[Player_Number_Int] and Bridge_NW_Point[Player_Number_Int]) Less than or equal to 450.00
    • Then - Actions
    • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_NW_Point[Player_Number_Int]
    • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • And - All (Conditions) are true
    • Conditions
    • (NW TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
    • (Distance between Try_To_Cross_Point[Player_Number_Int] and Bridge_NE_Point[Player_Number_Int]) Less than or equal to 450.00
    • Then - Actions
    • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_NE_Point[Player_Number_Int]
    • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
    • Else - Actions
    • Custom script: call RemoveLocation(udg_Issue_Point[udg_Player_Number_Int])
    • Custom script: call RemoveLocation(udg_Bridge_SW_Point[udg_Player_Number_Int])
    • Custom script: call RemoveLocation(udg_Bridge_SE_Point[udg_Player_Number_Int])
    • Custom script: call RemoveLocation(udg_Bridge_NW_Point[udg_Player_Number_Int])
    • Custom script: call RemoveLocation(udg_Bridge_NE_Point[udg_Player_Number_Int])
It seems to have less leaks, what do you say?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,264
Because 2 or more units owned by different players can do it at the same time.
Except the value is constant (player invariant)?

Also it might still leak due to recursive nature of the trigger? The trigger fires itself before you clean up the location objects resulting in the variables being over written with new values and the old ones leaking.
 
Level 10
Joined
Mar 17, 2012
Messages
582
Except the value is constant (player invariant)?

Also it might still leak due to recursive nature of the trigger? The trigger fires itself before you clean up the location objects resulting in the variables being over written with new values and the old ones leaking.

I don't fully understand you. How can trigger fire itself? Variables and conditions are used before I clean them up.

And about invariance - there can be any of 12 players.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,264
How can trigger fire itself?
One of the trigger's actions is to issue a point order to a unit. The trigger's event fires when a unit is issued a point order. Hence the trigger can fire itself. When this occurs multiple location leaks occur as new locations overwrite the old locations in the variables losing all reference to the old locations before the old locations are destroyed.
And about invariance - there can be any of 12 players.
Which according to the logic for selecting directional locations makes no difference as the locations themselves are all constant.

More specifically...
(Center of Bridge SW enter <gen>)
Is player invariant? It is the same for all players. Hence it makes no sense why you are assigning it to a player variant variable just for leak removal.
 
Level 10
Joined
Mar 17, 2012
Messages
582
One of the trigger's actions is to issue a point order to a unit. The trigger's event fires when a unit is issued a point order. Hence the trigger can fire itself. When this occurs multiple location leaks occur as new locations overwrite the old locations in the variables losing all reference to the old locations before the old locations are destroyed.

But all of those points are put into variables that makes them not to leak as they're under control :)
I mean look:
Set Try_To_Cross_Point[Player_Number_Int] = (Position of Try_To_Cross_Unit[Player_Number_Int])
Set Issue_Point[Player_Number_Int] = (Target point of issued order)
Set Bridge_SW_Point[Player_Number_Int] = (Center of Bridge SW enter <gen>)

and then ITE:
If
(SE TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
and
(Distance between Try_To_Cross_Point[Player_Number_Int] and Bridge_SW_Point[Player_Number_Int]) Less than or equal to 450.00
Then
Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_SW_Point[Player_Number_Int]
Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])

seems logical to me o_O
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,264
But all of those points are put into variables that makes them not to leak as they're under control :)
Except they are global variables, not local variables.

seems logical to me o_O
Except when...
Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_SW_Point[Player_Number_Int]
Is run the trigger should fire again, resulting in...
Set Try_To_Cross_Point[Player_Number_Int] = (Position of Try_To_Cross_Unit[Player_Number_Int])
Set Issue_Point[Player_Number_Int] = (Target point of issued order)
Set Bridge_SW_Point[Player_Number_Int] = (Center of Bridge SW enter <gen>)
All being set again, so the previous locations are lost before they were removed and hence leak.
 
Level 10
Joined
Mar 17, 2012
Messages
582
Except they are global variables, not local variables.


Except when...

Is run the trigger should fire again, resulting in...

All being set again, so the previous locations are lost before they were removed and hence leak.


OOOOOOOOH! Now I get it! And what if I'll turn off this trigger while ordering a unit to move to that point? Will it keep working after that?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,264
OOOOOOOOH! Now I get it! And what if I'll turn off this trigger while ordering a unit to move to that point? Will it keep working after that?
If you turn it off, run the actions then turn it back on then it should not leak. If it works depends on if it was intentionally recursive or not.

I still do not see a reason for the location array however as the location still is player invariant.
 
Level 10
Joined
Mar 17, 2012
Messages
582
If you turn it off, run the actions then turn it back on then it should not leak. If it works depends on if it was intentionally recursive or not.

Can you help me to do it properly? Because I'm not sure if I know how to manage it :ogre_icwydt:
Will this option work in your opinion? http://prntscr.com/bgysp9

I still do not see a reason for the location array however as the location still is player invariant.

You mean these? http://prntscr.com/bgyrzd
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,264
Level 10
Joined
Mar 17, 2012
Messages
582
Yes that would work. You could also make the turn off the first action and turn on the last action of the trigger. As long as there is not a thread crash between turn off and turn on it is fine.

Yes those set actions.

  • Issues under the bridge
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Set Player_Number_Int = (Player number of (Owner of (Triggering unit)))
      • Set Try_To_Cross_Unit[Player_Number_Int] = (Triggering unit)
      • Set Try_To_Cross_Point[Player_Number_Int] = (Position of Try_To_Cross_Unit[Player_Number_Int])
      • Set Issue_Point[Player_Number_Int] = (Target point of issued order)
      • Set Bridge_SW_Point = (Center of Bridge SW enter <gen>)
      • Set Bridge_SE_Point = (Center of Bridge SE enter <gen>)
      • Set Bridge_NW_Point = (Center of Bridge NW enter <gen>)
      • Set Bridge_NE_Point = (Center of Bridge NE enter <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (SE TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
              • (Distance between Bridge_SW_Point and Try_To_Cross_Point[Player_Number_Int]) Less than or equal to 450.00
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_SW_Point
          • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
          • Trigger - Turn on (This trigger)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (SW TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
                  • (Distance between Bridge_SE_Point and Try_To_Cross_Point[Player_Number_Int]) Less than or equal to 450.00
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_SE_Point
              • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
              • Trigger - Turn on (This trigger)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (NW TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
                      • (Distance between Bridge_NE_Point and Try_To_Cross_Point[Player_Number_Int]) Less than or equal to 450.00
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                  • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_NE_Point
                  • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
                  • Trigger - Turn on (This trigger)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • (NE TryToCross <gen> contains Issue_Point[Player_Number_Int]) Equal to True
                          • (Distance between Bridge_NW_Point and Try_To_Cross_Point[Player_Number_Int]) Less than or equal to 450.00
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                      • Unit - Order Try_To_Cross_Unit[Player_Number_Int] to Move To Bridge_NW_Point
                      • Custom script: call RemoveLocation(udg_Try_To_Cross_Point[udg_Player_Number_Int])
                      • Trigger - Turn on (This trigger)
                    • Else - Actions
      • Custom script: call RemoveLocation(udg_Issue_Point[udg_Player_Number_Int])
      • Custom script: call RemoveLocation(udg_Bridge_SW_Point)
      • Custom script: call RemoveLocation(udg_Bridge_SE_Point)
      • Custom script: call RemoveLocation(udg_Bridge_NW_Point)
      • Custom script: call RemoveLocation(udg_Bridge_NE_Point)


Seems like it works good! Thank you for help! What would I do without you :)
 
Status
Not open for further replies.
Top