• 🏆 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!

is it possible to redirect targeted (point or unit) comands?

Status
Not open for further replies.
Level 8
Joined
Jul 6, 2012
Messages
65
I work on a spell which confuses enemies when hitting them. Confused enemies can't perform targeted orders properly.

Currently, the system just makes them run around randomly when given a targeted order.

  • Confuse
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • ((Triggering unit) has buff -Confuse ) Equal to True
    • Actions
      • Set TempLoc[1] = (Position of (Triggering unit))
      • Set TempLoc[2] = (TempLoc[1] offset by (Random real number between 300.00 and 500.00) towards (Random angle) degrees)
      • Trigger - Turn off (This trigger)
      • Unit - Order (Triggering unit) to Move To TempLoc[2]
      • Trigger - Turn on (This trigger)
      • Custom script: call RemoveLocation(udg_TempLoc[1])
      • Custom script: call RemoveLocation(udg_TempLoc[2])
What I want it to do is to make the units target random points or units with the order they were given. So when they for example cast Shockwave, I want it to choose a random direction for it.

I can catch the given order by saving it in variables. But I can't put it into the Order triggers, because it simply doesn't accept variables, and only accepts whatever it has listed.

So this here does not work
  • Set OrderVariable = (Issued order)
  • Unit - Order (Triggering unit) to OrderVariable To TempLoc[2]
Is there a way to do this without going through every single order with if calls?
 
With a little bit of JASS, you can use the following natives:

JASS:
native GetIssuedOrderId() -> integer orderId
    // Gets the Id of the issued order on an order event.
native IssueImmediateOrderById(unit u, integer orderId)
    // The no-target issued order.
native IssuePointOrderById(unit u, real targetX, real targetY, integer orderId)
    // The go-to point issued order.
native IssueTargetOrderById(unit u, widget w, integer orderId).
    // The go-to target issued order.
native GetTriggerEventId() -> eventid eventId
    // Returns the event id of the current trigger.

playerunitevent EVENT_PLAYER_UNIT_ISSUED_ORDER
playerunitevent EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER
playerunitevent EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER

With that in place, compare the triggering event id with any of the three playerunitevents provided above (Hint: use Custom Script with if <condition> then)

When it is just a plain order, use the Immediate native. Else if point, the point native (use GetLocationX and GetLocationY if needed, they only require a point handle). Else if target, the target native.

Remember to turn off the trigger first before doing so and turn it back on thereafter. Otherwise, an infinite loop will crash the game.
 
Level 8
Joined
Jul 6, 2012
Messages
65
That works, thanks (btw you got the order wrong, it's unit -> order id -> target/locations).

  • Confuse
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Triggering unit) has buff -Confuse ) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Custom script: set udg_TempInt = GetIssuedOrderId()
      • Set TempLoc[1] = (Position of (Triggering unit))
      • Set TempLoc[2] = (TempLoc[1] offset by (Random real number between 300.00 and 500.00) towards (Random angle) degrees)
      • Custom script: if GetTriggerEventId() == EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER then
      • Custom script: call IssuePointOrderById(GetTriggerUnit(), udg_TempInt, GetLocationX(udg_TempLoc[2]), GetLocationY(udg_TempLoc[2]))
      • Custom script: elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER then
      • Unit Group - Pick every unit in (Random 1 units from (Units within 500.00 of TempLoc[1])) and do (Actions)
        • Loop - Actions
          • Custom script: call IssueTargetOrderById(GetTriggerUnit(), udg_TempInt, GetEnumUnit())
      • Custom script: endif
      • Custom script: call RemoveLocation(udg_TempLoc[1])
      • Custom script: call RemoveLocation(udg_TempLoc[2])
      • Trigger - Turn on (This trigger)
 
Last edited:
Status
Not open for further replies.
Top