# Why does this cause game crash

#### Blazing_Legion

Level 5
when the unit is ordered to move outside the 1000 range the game crash's can someone tell me why and how to fix it please.
• Check Costs Structures and Units
• Events
• Unit - A unit Is issued an order with no target
• Unit - A unit Is issued an order targeting a point
• Conditions
• Actions
• Set Temp_Player = (Triggering player)
• Set Temp_Group = (Units in (Entire map) matching (((Level of Construction Range for (Matching unit)) Greater than or equal to 1) and ((Owner of (Matching unit)) Equal to Temp_Player)))
• Custom script: loop
• Custom script: set udg_Temp_Unit = FirstOfGroup(udg_Temp_Group)
• Set Temp_Loc = (Position of Temp_Unit)
• Set Temp_Loc2 = (Target point of issued order)
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Or - Any (Conditions) are true
• Conditions
• (Distance between Temp_Loc and Temp_Loc2) Less than or equal to (650.00 + (350.00 x (Real((Level of Construction Range for Temp_Unit)))))
• ((Ordered unit) is A structure) Equal to True
• Then - Actions
• Set Temp_Unit = (Ordered unit)
• Set Player_Number = (Player number of Temp_Player)
• Set Unit_Type = (Unit-type((String((Issued order)))))
• Custom script: set udg_Temp_Int = udg_Unit_Type
• Set Temp_Int2 = 0
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Player_Gold[Player_Number] Greater than or equal to (Load 0 of Temp_Int from Cost_Table)
• Then - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Player_Lumber[Player_Number] Greater than or equal to (Load 1 of Temp_Int from Cost_Table)
• Then - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Player_Stone[Player_Number] Greater than or equal to (Load 2 of Temp_Int from Cost_Table)
• Then - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Player_Iron[Player_Number] Greater than or equal to (Load 4 of Temp_Int from Cost_Table)
• Then - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Player_Coal[Player_Number] Greater than or equal to (Load 5 of Temp_Int from Cost_Table)
• Then - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Player_Uranium[Player_Number] Greater than or equal to (Load 6 of Temp_Int from Cost_Table)
• Then - Actions
• Set Temp_Int2 = 1
• Else - Actions
• Set Temp_Players = (Player group(Temp_Player))
• Game - Display to Temp_Players for 5.00 seconds the text: Not enough Uranium.
• Custom script: call DestroyForce(udg_Temp_Players)
• Else - Actions
• Set Temp_Players = (Player group(Temp_Player))
• Game - Display to Temp_Players for 5.00 seconds the text: Not enough Coal.
• Custom script: call DestroyForce(udg_Temp_Players)
• Else - Actions
• Set Temp_Players = (Player group(Temp_Player))
• Game - Display to Temp_Players for 5.00 seconds the text: Not enough Iron.
• Custom script: call DestroyForce(udg_Temp_Players)
• Else - Actions
• Set Temp_Players = (Player group(Temp_Player))
• Game - Display to Temp_Players for 5.00 seconds the text: Not enough Stone.
• Custom script: call DestroyForce(udg_Temp_Players)
• Else - Actions
• Set Temp_Players = (Player group(Temp_Player))
• Game - Display to Temp_Players for 5.00 seconds the text: Not enough Lumber.
• Custom script: call DestroyForce(udg_Temp_Players)
• Else - Actions
• Set Temp_Players = (Player group(Temp_Player))
• Game - Display to Temp_Players for 5.00 seconds the text: Not enough Gold.
• Custom script: call DestroyForce(udg_Temp_Players)
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Temp_Int2 Equal to 1
• Then - Actions
• Set Player_Gold[Player_Number] = (Player_Gold[Player_Number] - (Load 0 of Temp_Int from Cost_Table))
• Set Player_Lumber[Player_Number] = (Player_Lumber[Player_Number] - (Load 1 of Temp_Int from Cost_Table))
• Set Player_Stone[Player_Number] = (Player_Stone[Player_Number] - (Load 2 of Temp_Int from Cost_Table))
• Set Player_Iron[Player_Number] = (Player_Iron[Player_Number] - (Load 4 of Temp_Int from Cost_Table))
• Set Player_Coal[Player_Number] = (Player_Coal[Player_Number] - (Load 5 of Temp_Int from Cost_Table))
• Set Player_Uranium[Player_Number] = (Player_Uranium[Player_Number] - (Load 6 of Temp_Int from Cost_Table))
• Custom script: call RemoveLocation(udg_Temp_Loc)
• Custom script: call RemoveLocation(udg_Temp_Loc2)
• Custom script: call DestroyGroup(udg_Temp_Group)
• Skip remaining actions
• Else - Actions
• Trigger - Turn off Cancels Costs Units <gen>
• Custom script: call IssueImmediateOrderById( udg_Temp_Unit, 851976 )
• Trigger - Turn on Cancels Costs Units <gen>
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Temp_Unit is A structure) Equal to False
• Then - Actions
• Unit - Pause Temp_Unit
• Unit - Unpause Temp_Unit
• Unit - Order Temp_Unit to Stop
• Else - Actions
• Custom script: call RemoveLocation(udg_Temp_Loc)
• Custom script: call RemoveLocation(udg_Temp_Loc2)
• Custom script: call DestroyGroup(udg_Temp_Group)
• Skip remaining actions
• Else - Actions
• Set Temp_Unit = (Ordered unit)
• Unit - Pause Temp_Unit
• Unit - Unpause Temp_Unit
• Unit - Order Temp_Unit to Stop
• Set Temp_Players = (Player group(Temp_Player))
• Game - Display to Temp_Players for 5.00 seconds the text: Cannot Build outsid...
• Custom script: call DestroyForce(udg_Temp_Players)
• Custom script: call RemoveLocation(udg_Temp_Loc)
• Custom script: call RemoveLocation(udg_Temp_Loc2)
• Custom script: call DestroyGroup(udg_Temp_Group)
• Skip remaining actions
• Custom script: call RemoveLocation(udg_Temp_Loc)
• Custom script: call RemoveLocation(udg_Temp_Loc2)
• Unit Group - Remove Temp_Unit from Temp_Group
• Custom script: exitwhen(IsUnitGroupEmptyBJ(udg_Temp_Group) == true)
• Custom script: endloop
• Custom script: call DestroyGroup(udg_Temp_Group)

Level 16
Why is the trigger looped?

• Custom script: loop
• Custom script: endloop

Level 16
IT is looping

lol, ok...I didn't see anything wrong with his trigger, but I don't know what the custom scripts are for. Since I know what a loop is (lol), I thought it was strange he would loop with custom script and not GUI. Hence why I thought I'd investigate what I already know little of. Sorry for the stupid question.

#### edo494

Level 23
this most likely crashes because of infinite trigger loop
when you want to order the unit to lets say stop as you do, turn off the trigger before you order the unit and turn on the teigger after you have ordered it

#### Blazing_Legion

Level 5
thanks edo494 I didn't realise that was causing my trigger to run again your method worked but I also added the condition
• Or - Any (Conditions) are true
• Conditions
• (Distance between Temp_Loc and Temp_Loc2) Less than or equal to (650.00 + (350.00 x (Real((Level of Construction Range for Temp_Unit)))))
• ((Ordered unit) is A structure) Equal to True
• (Substring((String((Issued order))), 1, 6)) Not equal to custom
I think that should work as all custom units have that at the start don't they?

Replies
7
Views
6K
Replies
9
Views
504
[Trigger] Portal
Replies
1
Views
513
[Trigger] Spell not working
Replies
2
Views
533
Replies
4
Views
581