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

Re-ordering variable order

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
Hmm... If it's just a point or unit target, then yes, but what if my unit is about to build a building? Or cast a spell?
Those are also instant, point or widget target orders.

You will need multiple variables to store the order correctly.
  • Integer Order ID: The order ID integer of the triggering order. Must be order ID and not string because some orders have no order string.
  • Unit Target: Target unit of triggering unit target order.
  • Item Target: Target item of triggering item target order.
  • Destructable Target: Target destructable of triggering unit target order.
  • Point Target: Target point of triggering point target order.
  • Integer Order Type: Unique integer value for each type of order. Is used by flow control code to select which order action to run.
Use separate triggers for each basic type of order. Order targeting object trigger has extra logic to resolve what type of target was used. This is likely done by checking the values returned by the appropriate event response functions for a non-null (not no value) value. Each type of order is given a unique integer used by the order type variable. This integer can be used inside an if/then/else structure to call the appropiate issue order action.

If using JASS the following variables can be merged together...
  • Unit Target: Target unit of triggering unit target order.
  • Item Target: Target item of triggering item target order.
  • Destructable Target: Target destructable of triggering unit target order.
Into...
  • Widget Target: Target widget of triggering object target order.
And 2 of the unique integer constants used for order type could be removed. This is because the order can be processed as a widget rather than its 3 child types.

Integer Order Type could be replaced with Trigger Order Type. One sets this to a trigger which sole action is the appropriate issue order action. This avoids the ugly constants and flow control but will be slower due to the huge overhead of running a trigger as opposed to calling a function or performing some tests.

The lookup of Integer Order Type could be optimized using a binary search tree arrangement. This would reduce the worst case lookup time from O(n) to O(log2(n)) where n is 5 (3 for JASS) for slightly fewer comparison operations.
 
Level 2
Joined
Mar 17, 2016
Messages
18
Those are also instant, point or widget target orders.

You will need multiple variables to store the order correctly.
  • Integer Order ID: The order ID integer of the triggering order. Must be order ID and not string because some orders have no order string.
  • Unit Target: Target unit of triggering unit target order.
  • Item Target: Target item of triggering...

Thank you very much Dr Super Good! :D
 
Status
Not open for further replies.
Top