HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Stop a hero from using an item

11-01-2009, 01:31 PM#1
Tom_Kazansky
What I mean is: when a hero begins cast a spell, certain conditions are check and if they are not matched, pause/stop/unpause the hero to "stop" him

so I want to check some conditions before an item is used, but with the same event (A unit begins casting a spell), I can't "stop" the use of the item

is there any way to solve this ?
11-01-2009, 01:45 PM#2
Vexorian
http://www.wc3c.net/showthread.php?t=108044
11-01-2009, 01:48 PM#3
Hans_Maulwurf
what conditions? you could replace the item with a disabled version of itself, while they are not meet.
11-01-2009, 02:11 PM#4
Rising_Dusk
Use the ISSUED_ORDER events and detect when they are ordered to use an item, intercept it, done.
11-01-2009, 02:20 PM#5
Troll-Brain
Quote:
Originally Posted by Rising_Dusk
Use the ISSUED_ORDER events and detect when they are ordered to use an item, intercept it, done.

When the USE_ITEM event fire, the item is already used, and there is no way to stop it.
I haven't read, neither test grim001's code, but maybe it fires just before the item is used.

Also simply check issue_order doesn't let you know if the unit use an item or one of his ability.
11-01-2009, 02:25 PM#6
Tom_Kazansky
>what conditions? you could replace the item with a disabled version of itself, while they are not meet.

err.. so I have to un-do the replacement after that ? ( I mean replace the disable version with the enable version)
11-01-2009, 02:29 PM#7
Rising_Dusk
Quote:
Originally Posted by Troll-Brain
When the USE_ITEM event fire, the item is already used, and there is no way to stop it.
I haven't read, neither test grim001's code, but maybe it fires just before the item is used.
The ISSUED_ORDER events fire before the ITEM_USE. Unless you have an instant-activation item, there is a distinct delay between the two. (I still think the order events run first, even if it does instantly activate)
11-01-2009, 02:44 PM#8
Troll-Brain
The order event run first, but you can't directly stop the order.
Indirectly we can catch witch item will be used with the order (as you know 852008 == first slot, and so one).
But the only way i've found to avoid the use is to put the item on a map, wait a short time (for the test i used a TSA, but a Timer(0) should also work ) and give it back to the unit.

I've tested it with a potion of invulnerability, a pretty common item.
11-01-2009, 02:56 PM#9
Rising_Dusk
Quote:
Originally Posted by Troll-Brain
The order event run first, but you can't directly stop the order.
Yes you can. Protip: Search the library for AbortOrder. (We've used this method forever)
11-01-2009, 03:01 PM#10
Troll-Brain
Ok, i have not mentioned i had already tried it, for me it's pretty obvious ^^

Test it, you will see what happens. (You would need the library OrderDebug )
It works but the trigger is evaluated many times, because the unit get the order many times, which is very lame.
It seems to be the rule for all no target orders events.

ProTip : Instead of "stop" i prefer 851973 , because it keeps the previous immediate order if the unit had one, like "holdposition"

EDIT : Turn off/on the trigger doesn't help here.
11-01-2009, 03:16 PM#11
Rising_Dusk
I just tested it. You do properly stop the order, but the behavior of items is that they activate right away it seems. (So the events "run" sequentially, even if the Order event callback runs first)
Quote:
Originally Posted by Troll-Brain
ProTip : Instead of "stop" i prefer 851973 , because it keeps the previous immediate order if the unit had one, like "holdposition"
Protip: that's what the IssueLastOrder part of the code is for. Anyways, have you tested this 851973 thoroughly? You sure it properly holds all last orders no matter what, but still stops the current order? How could you "restore" the last order even if it could?
11-01-2009, 03:17 PM#12
Tom_Kazansky
Quote:
Originally Posted by Vexorian

can anyone tell me how to use "function interface" ? let say I have a function named "SpellStealPrecast" which have the same parameters as "function interface UseItemFunc", how do I make the system to call "SpellStealPrecast" ?

sorry but I have read the JassHelperManual but I still don't get it please help
11-01-2009, 03:17 PM#13
Troll-Brain
i've edited my post.
Also 851973 is the stunned order, that's why it preserve the previous (or let's say current) no target order.
11-01-2009, 03:17 PM#14
Rising_Dusk
Vex's Tutorial.
Quote:
Originally Posted by Troll-Brain
Also 851973 is the stunned order, that's why it preserve the previous no target order.
I know that, but I was pretty sure it didn't actually work like being stunned. How do you "remove" that order and restore the previous orders, for instance?
11-01-2009, 03:20 PM#15
Troll-Brain
Just like you but instead of "stop", i use 851973.