HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Prevent item from being used

09-01-2008, 03:56 AM#1
Ammorth
Any way to prevent an item from being used other than replacing that item with a dummy item that isn't consumable?
09-01-2008, 08:01 AM#2
Pyrogasm
No, because you can't detect when an item is used.
09-02-2008, 01:06 AM#3
Ammorth
actually you can, with EVENT_PLAYER_UNIT_USE_ITEM. I could restore the initial settings and refund the item, but I can't reset the cooldown for a single group.
09-02-2008, 01:11 AM#4
Pyrogasm
Wow. Dunno where my comment came from... I think I was thinking about detecting when an item casts a spell (orbs).
09-02-2008, 01:22 AM#5
Ammorth
No problem. I think I might have a work-around only relevant to my use (pausing the hero). I really don't have to disable item usage, it just makes my code 100 times easier.
09-02-2008, 02:35 AM#6
Pyrogasm
A random idea here:

Can't you catch the order for a hero to use an item, and then just order the unit to stop? Or is there a reason you didn't think of a simple solution like that?
09-02-2008, 05:05 AM#7
Vexorian
It is quite possible to block it.

Use this: http://www.wc3campaigns.net/showthread.php?t=101437 If the item is the one you wish to block, then just go through the usual procedure for blocking orders, I personally prefer to send a stop order after 0.0 seconds
09-02-2008, 06:00 AM#8
Ammorth
I couldn't stop it with both an instant order and a 0.0 second order (both stop and move to current point). If I'm missing something, can someone please point it out.

Also, I'm using GetManipulatedItem() on the order event and it seems to return the item just fine (at least the handle value is correct).
09-02-2008, 08:30 AM#9
blu_da_noob
Try pausing, issueing stop order and then unpausing. I think that's what I've done before.

In search of a cleaner solution, have you tried removing the item from the unit and instantly readding it and things along that line?
09-02-2008, 07:39 PM#10
Ammorth
It seems that EVENT_PLAYER_UNIT_USE_ITEM happens right after the item was used (like spell effects finished for spells) while EVENT_PLAYER_UNIT_ISSUED_ORDER happens directly before the order. The second event allows me to stop the unit before it starts the effects of the item, thus disabling the item (no cool-down or charge used).