• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Issue Target Order Problem

Status
Not open for further replies.
Level 11
Joined
Aug 24, 2009
Messages
706
I've devised a small system that stored every unit's order so it can be recalled easily by adding the unit to TempGroupOrder and running the Last Order trigger as you see below in the first two screenshots. This worked perfectly fine with the downside of it being in GUI and not being able to use order IDs meaning that I would have to copy and paste the same triggers for each different order (ie move, attack, smart, etc)
88d23f2945bdbd999df380b813bfbdac.png
c6ee0c675f60f622da024a34c4a8e975.png
I then decided to revamp the system using some jass to make it work with all orders in the future without having to use repetitive GUI for new orders but for some reason ordering the unit to a unit or destructible doesn't work while a point target still works. Any one have any ideas on how to fix this?
0524baef765920f64b7404b41c4e3f94.png

9785f981c0764fb204c20dd93ec15630.png

Edit: Only the New System needs fixing to make it work for units and destructibles, it only works for points atm.
 
Last edited:
Level 11
Joined
Oct 9, 2015
Messages
721
What about storing the order into the custom value of the unit? something like this:
  • Order Trigger
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • Set OrderVar[(Custom value of (Triggering unit))] = (Issued order)
 
Level 11
Joined
Aug 24, 2009
Messages
706
@streetpunk

That screen was the old system that worked, the new one stores the order in the custom script line here: set udg_lastorder[udg_lasttemp] = GetIssuedOrderId()
Also it works for point targets not widgets for some odd reason
0524baef765920f64b7404b41c4e3f94.png



@Pyrogasm
I'd rather have my own as I can modify it more easily to suit my needs rather than that one as mine just needs 1 small fix to make it work properly
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
Maybe take a look at this for some guidance. In one of my maps I needed a dummy to mimic my actual unit so I ordered them by issuing the same orders to the dummy. This should only be a tweak or two away from saving the last order.

I cut some of the excess code out.

Part of your difficulty is coming from the fact that GUI does not let you have widgets, which means you're having to filter to figure out what the object is. When it so happens you don't actually care what the object is, you just want to save the order to whatever the object is.

  • Mimic
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • Custom script: local widget w
      • Set TempUnit = (Triggering unit)
      • Custom script: if GetHandleId(GetTriggerEventId()) == 40 then // This is the number that represents the event -- "targeting an object"
      • Custom script: set w = GetOrderTarget()
      • Custom script: call IssueTargetOrderById(udg_someUnit, GetIssuedOrderId(), w) // Rather than order the unit, just save all this information.
      • Custom script: elseif GetHandleId(GetTriggerEventId()) == 39 then // "targeting a point"
      • Set TempPoint = (Target point of issued order)
      • Custom script: call IssuePointOrderByIdLoc(udg_someUnit, GetIssuedOrderId(), udg_TempPoint) // same
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: else // "no target"
      • Custom script: call IssueImmediateOrderById(udg_someUnit, GetIssuedOrderId()) // same
      • Custom script: endif
      • Custom script: set w = null
 
Last edited:
Level 11
Joined
Aug 24, 2009
Messages
706
@pOke
My filtering worked fine in the first system that that used all GUI and I bug tested to see if it got the right variable and it does depending on the target, so I'm still puzzled on why it's not working, the code is supposed to take any unit/dest/item var isn't it?
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
Edit: All right, I think I've got it working now. My problem was that I was saving the units last order, but then when I would try to change the order, the cancelled order was overwriting what ought to be the actual last order. Take a look at the trigger, and my test map.

  • Last Order
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • Set lastOrderIndex = (Custom value of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • lastOrderCheck[lastOrderIndex] Equal to True
        • Then - Actions
          • Custom script: set udg_lastOrderId2[udg_lastOrderIndex] = udg_lastOrderId[udg_lastOrderIndex]
          • Set lastOrderType2[lastOrderIndex] = lastOrderType[lastOrderIndex]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • lastOrderType2[lastOrderIndex] Equal to 1
            • Then - Actions
              • Custom script: set lastOrderTarget2[udg_lastOrderIndex] = lastOrderTarget[udg_lastOrderIndex]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • lastOrderType2[lastOrderIndex] Equal to 2
                • Then - Actions
                  • Custom script: if udg_lastOrderPoint2[udg_lastOrderIndex] != null then
                  • Custom script: call RemoveLocation(udg_lastOrderPoint2[udg_lastOrderIndex])
                  • Custom script: endif
                  • Set lastOrderPoint2[lastOrderIndex] = (Point((X of lastOrderPoint[lastOrderIndex]), (Y of lastOrderPoint[lastOrderIndex])))
                • Else - Actions
        • Else - Actions
      • Set lastOrderCheck[lastOrderIndex] = True
      • Custom script: set udg_lastOrderId[udg_lastOrderIndex] = GetIssuedOrderId()
      • Custom script: if GetHandleId(GetTriggerEventId()) == 40 then
      • Custom script: set lastOrderTarget[udg_lastOrderIndex] = GetOrderTarget()
      • Set lastOrderType[lastOrderIndex] = 1
      • Custom script: elseif GetHandleId(GetTriggerEventId()) == 39 then
      • Custom script: if udg_lastOrderPoint[udg_lastOrderIndex] != null then
      • Custom script: call RemoveLocation(udg_lastOrderPoint[udg_lastOrderIndex])
      • Custom script: endif
      • Set lastOrderPoint[lastOrderIndex] = (Target point of issued order)
      • Set lastOrderType[lastOrderIndex] = 2
      • Custom script: else
      • Set lastOrderType[lastOrderIndex] = 3
      • Custom script: endif
  • Last Order 2
    • Events
    • Conditions
    • Actions
      • Set TempInteger = (Custom value of TempUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • lastOrderType2[lastOrderIndex] Equal to 1
        • Then - Actions
          • Custom script: call IssueTargetOrderById(udg_TempUnit, udg_lastOrderId2[udg_TempInteger], lastOrderTarget2[udg_TempInteger])
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • lastOrderType2[lastOrderIndex] Equal to 2
            • Then - Actions
              • Custom script: call IssuePointOrderByIdLoc(udg_TempUnit, udg_lastOrderId2[udg_TempInteger], udg_lastOrderPoint2[udg_TempInteger])
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • lastOrderType2[lastOrderIndex] Equal to 3
                • Then - Actions
                  • Custom script: call IssueImmediateOrderById(udg_TempUnit, udg_lastOrderId2[udg_TempInteger])
                • Else - Actions
So a few things. Currently this only begins to work upon the unit being given its second order. Meaning if you call this on a newly created unit, it will do nothing. If you order that unit to then do "something" once then try to call this, it will also do nothing.

However upon the unit having a first and second order it will work properly.

Another issue that you'll have to decide if it is important is how stuns are handled. A stun issues an order, meaning that the unit's "last order" will become "stun" however it is really just a pseudo stop when not caused from an ability. You can easily filter out the stun by using an If when the order id is <851973>.

It might be obvious, it might not, but if the last order's target does not exist, it will also do nothing. (i.e. ordered to pick up an item that is already in a units inventory or destroyed)

Also, the two widget arrays I use are declared in a globals block. So in order to utilize the convenience of widgets you must have JNGP.
 

Attachments

  • LastOrder.w3x
    18.7 KB · Views: 82
Last edited:
Status
Not open for further replies.
Top