• 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.

Keeping a unit on its first route before heading to its next?

Level 5
Joined
Nov 17, 2022
Messages
84
Sorry if the title is weird, wasn't sure how to phrase it so I'll go into detail. I set up a trigger for these Raven units that wander the map to fly towards units that have been killed to give the illusion they're off to get some carcass meat like how Ravens scavenge in real life. They also play as a little hint to give players an idea where a Worg or Poacher might be, since they'll be killing Wildlife a lot in this map and need to find/evade eachother. Issue is while the trigger DOES work, I'd like to have it that the Ravens dont immediately abandon their route the moment another critter is killed and instead finish their first route, wait a second or two and then fly off towards the next killed unit on the map. Any ideas how I can accomplish this?
1721932179831.png
 
I've had to do some similar stuff in my maps in the past, and it usually involves a fair amount of manual work. :( Ideally, it'd be awesome if Blizz allowed us to queue orders similar to when you hold down shift and right-click in-game. They seemed to add some natives that are supposed to do that in the latest patches (e.g. BlzQueuePointOrderById), but they don't seem to behave the way I expect.

At its essence, you'll want to do what Duckfarter described (check if the Raven is idle and make a decision based off that)--but you'll still need some way to "queue" the next order to go to the next dying unit. Unfortunately, it gets pretty complicated on that step because you'll need to "observe" the order of each Raven and keep track of all the queued orders yourself.

I'll attach a sample map with a basic system you can use written in vanilla JASS. You'll just need to copy the triggers/variables under the folder "QueueOrder" and then paste them into your map. Then you can use it like so:
  • FollowCorpse
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Pig
    • Actions
      • Unit Group - Pick every unit in RavenGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet QueueOrder_Unit = (Picked unit)
          • Set VariableSet QueueOrder_TargetPoint = (Position of (Triggering unit))
          • Set VariableSet QueueOrder_Order = (Order(move))
          • Set VariableSet QueueOrder_Delay = 3.00
          • Trigger - Run QueueOrder <gen> (ignoring conditions)
The variables starting with QueueOrder_ can be used to tell the system what order you want to "queue up". In the example above, I'm telling the system that I want the picked unit (the raven) to move to the position of the dying unit, and then to wait at least 3 seconds before doing any follow-up orders.

If you want to target a unit instead, you can just set QueueOrder_TargetUnit instead of QueueOrder_TargetPoint. If you want to do an instant order (no target), you can just omit setting a target point/unit.

You can run the sample map and press ESC to kill the pigs around the area. Hopefully that helps!
 

Attachments

  • RavenSample.w3m
    22.5 KB · Views: 2

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
Purge's solution works great and you should use it, but I wanted to add one little trick I like to use for situations like these.

The Channel ability can be your best friend when it comes to creating your own "custom orders":
1721976859064.png

  • Raven AI
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Pig
    • Actions
      • Set VariableSet Raven_Dead_Point = (Position of (Triggering unit))
      • Unit Group - Pick every unit in RavenGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet Raven_Move_Point = (Raven_Dead_Point offset by (Random real number between 0.00 and 128.00) towards (Random angle) degrees.)
          • Unit - Order (Picked unit) to Orc Tauren Chieftain - Shockwave Raven_Move_Point
          • Custom script: call RemoveLocation( udg_Raven_Move_Point )
      • Custom script: call RemoveLocation( udg_Raven_Move_Point )
(The custom script stuff is optional, it helps deal with memory leaks which can help with game performance over time)

So note the 3.00 second Follow Through Time on the ability, this is the duration it spends Channeling the ability, which means the Unit will stand there for 3 seconds when it reaches it's destination. I believe this will queue any orders given to it during the channeling time, plus if you give the ability a cooldown it will disregard new "scavenge" orders during that cooling period.

But more importantly, it will run an Event the exact moment it reaches it's destination:
  • Events
    • Unit - A unit Begins casting an ability
  • Conditions
    • (Ability being cast) Equal to Raven Scavenge
You can also detect when the Ability Stops channeling for any reason or Finishes a complete channel using the other ability Events. So this method gives you a very good level of control with a very easy to understand design pattern. Art - Animation Names, Mana Cost, Cast Range, Cooldown, Requirements, Levels, all of these fields can be used to create your ideal setup.

Just remember that it's an Ability so if the Raven gets Silenced or something odd like that then it will force it to Stop.
 
Last edited:
Top