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

[General] Redirecting orders

Status
Not open for further replies.
Hey everyone

I hide the attack button to make more space for spells (spell books won't work because you cannot add abilities via triggers into a spell book) but now I can't attack passive units anymore. So I made an item that when you cast the item upon a target, the caster will be redirected to attack the unit instead. However the unit still stops for a short moment and cast the spell before attacking. How can I prevent that?

  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to AttackItem
    • Actions
      • Unit - Order (Triggering unit) to Attack (Target unit of ability being cast)
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Base your event on the order being given, not ability being cast.

Also, it is possible to add spells to spellbooks due to a mechanic called spellbook collision. There's a tutorial in my signature that tells how it works(among other things).
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
I don't think there are any tutorials specifically for that, because it's all about understanding how some specific functions work.

There are some orders that don't have orderstrings.
Nestharus has a resource called "OrderIDs" that lists all known orders. Taken from that are those:
JASS:
constant integer ORDER_moveslot1=852002
constant integer ORDER_moveslot2=852003
constant integer ORDER_moveslot3=852004
constant integer ORDER_moveslot4=852005
constant integer ORDER_moveslot5=852006
constant integer ORDER_moveslot6=852007
constant integer ORDER_useslot1=852008
constant integer ORDER_useslot2=852009
constant integer ORDER_useslot3=852010
constant integer ORDER_useslot4=852011
constant integer ORDER_useslot5=852012
constant integer ORDER_useslot6=852013

In JASS you can use GetEventOrderId to get the issued order. This returns a number, which you would normally convert into an orderstring with the function OrderId2String.
However, since those orders don't really have order strings you have to handle them with JASS code.

Just make a trigger that detects orders and inside it filter the orders to find out if they were any of the above.
Example:
JASS:
local integer orderID = -1
if GetEventOrderId() == 852002 then
    set orderID = 1
elseif GetEventOrderId() == 852003 then
    set orderID = 2
elseif GetEventOrderId() == 852004 then
    set orderID = 3
endif

This code checks if the issued order was any of the item move orders to slots 1-3. You can check for all slots by just adding elseif lines.
What you do with that information depends on the trigger, but this is the basic functionality.

Back to the original topic, you will probably want to use the "useitem" orders. Each of them corresponds to an item in a specific slot being used, no matter what order string it has. This is partly the reason why the abilities on items almost never collide with those on units.
 
Thanks I checked the order ID's but I'm not skilled enough with jass to use those yet.
you will probably want to use the "useitem" orders
Then how can check what type of item is used?

I saw your tutorial but I couldn't find out how to add spells to spell books [EDIT] Nvm I've found the test map in the link
 
Last edited:
Level 21
Joined
Mar 27, 2012
Messages
3,232
I am also trying to understand this specific thing. Ideally I would want to know the slot of the used item and what it's used on.
However, the slot is told by the order event and the target by an ability event(likely).
I believe currently you will accomplish whatever you wanted to do with spellbook collisions, aka adding?
 
Level 25
Joined
May 11, 2007
Messages
4,650
"events: A unit is ordered to do something with a target"
"conditions: order == right click and owner of target == neutral passive"
"actions: unit - order ordered unit to attack the target"

Could work?
 
Status
Not open for further replies.
Top