• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Save units orders

Status
Not open for further replies.
Level 9
Joined
Dec 31, 2016
Messages
316
So I have a unit that has orders to move to a point, but under certain conditions I interupt that order by another order. I can save the original order in an order variable, but I don't know how to order it to perform that order in the variable.

Is it possible?

There are only "issue an order" actions, but they don't have an "order" type component.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,576
LastOrder - Wc3C.net

I imagine the system I linked above uses these functions:
Code:
GetIssuedOrderId() <-- Use this in response to "A unit is issued an order targeting point/object/no target" and save it as a variable

Use these when issuing the unit to resume it's last order:
IssuePointOrderByIdLoc(whichUnit, order, whichLocation)
IssueTargetOrderById(whichUnit, order, targetWidget)
IssueImmediateOrderById(whichUnit, order)
Basically, whenever a unit issues an order you save the Issued Order Id and save the Type of that order (Point, Target, Immediate).

With this information saved you can use one of those 3 listed functions and plug in the saved Order Id to order the unit to perform the order.

Trigger Example:
  • Events:
  • A unit is issued an order targeting a point
  • Conditions:
  • Actions:
  • Set OrderUnit = GetTriggerUnit()
  • Set OrderId = GetIssuedOrderId()
  • Set OrderPoint = Target point of issued order
  • Set OrderType = Point
Then when you want to return to this point:
  • Custom script: call IssuePointOrderByIdLoc(udg_OrderUnit, udg_OrderId, udg_OrderPoint)
I didn't show OrderType being referenced here but it would be used to determine which of the 3 functions you should use. Like, "If OrderType equal to Point then: call IssuePointOrderByIdLoc()"
 
Last edited:
Level 9
Joined
Dec 31, 2016
Messages
316
I've played around a bit with hashtables, but I just can't get it to work. What am I doing wrong here?
For test purposes I assinged number 5 to each unit, but the debug text in the second trigger shows 0.
So the custom script also doesn't work.
  • Save Orders
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet SaveOrders = (Last created hashtable)
      • Hashtable - Save Handle Of(Target point of issued order) as 0 of (Key (Ordered unit).) in SaveOrders.
      • Hashtable - Save 5 as 1 of (Key (Ordered unit).) in SaveOrders.
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Ordered unit)) Equal to Grunt (Unit) [Upgrade 2]
        • Then - Actions
          • Unit Group - Add (Ordered unit) to GruntsLvL2
        • Else - Actions
  • Grunt Rage
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in GruntsLvL2 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Less than or equal to ((Real((Max HP of (Picked unit)))) / 2.00)
            • Then - Actions
              • Unit - Add Critical Strike (Grunt) [LvL 2] to (Picked unit)
              • Unit - Add Berserk (Grunt) [LvL 2] to (Picked unit)
              • Unit - Order (Picked unit) to Orc Troll Berserker - Berserk.
              • Unit - Remove Berserk (Grunt) [LvL 2] from (Picked unit)
              • Game - Display to (All players) the text: (String((Load 1 of (Key (Picked unit).) from SaveOrders.)))
              • Custom script: call IssuePointOrderByIdLoc(GetEnumUnit(), 2, LoadLocationHandleBJ(0, GetHandleIdBJ(GetEnumUnit()), udg_SaveOrders))
              • Unit Group - Remove (Picked unit) from GruntsLvL2.
            • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,576
Create the Hashtable during Map Initialization. You only need 1 Table for everything.

And your custom script for
IssuePointOrderByIdLoc(whichUnit, order, whichLocation) makes no sense. You're ordering the unit to 2, which is not a valid order.

An example of ordering it to Move to the point: call IssuePointOrderByIdLoc( GetEnumUnit(), "move", LoadLocationHandleBJ(0, GetHandleIdBJ(GetEnumUnit()), udg_SaveOrders) )

"move" is the order string.

For testing purposes use normal GUI and just issue a Move order:
  • Unit - Order (Picked unit) to Move To (Load 0 of (Key (Picked unit)) in SaveOrders)
 
Last edited:
Level 9
Joined
Dec 31, 2016
Messages
316
Oh, yes. I'm stupid I didn't realize I create a new hash map every time the trigger runs.

As for the custom script it wants integer as a second argument, not string.
So I assumed it has something to do with order ID, so I gave it the ID of the order. But I don't really know. Doesn't matter will use the gui order.

It works fine now. The orders are restored perfectly, thanks for helping me.
 
Status
Not open for further replies.
Top