HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

what is the code for Give Item order?

04-13-2006, 03:32 PM#1
Exilus
i want to make it so items are impossible to give directly.

trying to make a trigger like

Trigger:
General nogiving
Collapse Events
Unit - A unit Is issued an order targeting an object
Collapse Conditions
(Issued order) Equal to (Order(giveitem))<---not sure if this is correct
Collapse Actions
Unit - Order (Triggering unit) to Stop

what is the order code for giving an item?
04-13-2006, 05:43 PM#2
Vuen
Disable the condition, and add Game - Text Message (OrderToString(Order Given))

Then just start the game, give an item to someone, and see what pops up.
04-13-2006, 05:55 PM#3
Captain Griffen
Advanced -> Gameplay constants -> Item give range

Put that to 0, and you won't be able to give items.
04-13-2006, 06:03 PM#4
Vuen
Quote:
Originally Posted by Captain Griffen
Advanced -> Gameplay constants -> Item give range

Put that to 0, and you won't be able to give items.

Ooh. That works too.

I'm curious to see if his way works too though, because if so, then I could make it so only certain players can give items.


[edit] I just tested it myself. No order event is generated whatsoever when you order anything to do with items. :(

Also, setting the Give Item Range to 0 does not work at all. You can still give items to allied heroes.
04-14-2006, 03:51 PM#5
Exilus
thanks alot
04-14-2006, 07:27 PM#6
Vuen
Quote:
Originally Posted by Exilus
thanks alot

But... It doesn't work. I'd really like to know how to do this too, because I want to prevent heroes from giving items in my tutorial and in my map.
04-14-2006, 08:31 PM#7
blu_da_noob
I seem to recall having problems with this too. One solution is certainly to detect when an item is given, and just give it back straight away.
04-14-2006, 08:35 PM#8
PipeDream
What about
Collapse JASS:
native          SetItemDroppable takes item i, boolean flag returns nothing
?
04-14-2006, 08:39 PM#9
Exilus
Quote:
Originally Posted by PipeDream
What about
Collapse JASS:
native          SetItemDroppable takes item i, boolean flag returns nothing
?


thats jass...my map is in GUI
04-14-2006, 08:50 PM#10
Vuen
Quote:
Originally Posted by PipeDream
What about
Collapse JASS:
native          SetItemDroppable takes item i, boolean flag returns nothing
?

That just makes the item undroppable entirely, so you couldn't even throw it on the ground, let alone sell it back to a store.


Okay, I used blu's idea to get it working, but it was much more complicated than I expected. There is no way to directly detect when an item is given. Thus to detect it indirectly, we need to figure out when item acquired and item dropped events fire simultaneously.

Luckily, the game fires item lost events before item acquired events, so to detect this, when an item is dropped we momentarily set its custom value to 1. If an item is simultaneously acquired, its custom value will be 1, so we simply drop it again. Here are the triggers:

Trigger:
Unit Loses Item
Collapse Events
Unit - A unit Loses an item
Conditions
Collapse Actions
Custom script: local item udg_TEMP_Item
Set TEMP_Item = (Item being manipulated)
Item - Set the custom value of TEMP_Item to 1
Wait 0.00 seconds
Item - Set the custom value of TEMP_Item to 0
Trigger:
Unit Gains Item
Collapse Events
Unit - A unit Acquires an item
Collapse Conditions
(Custom value of (Item being manipulated)) Equal to 1
Collapse Actions
Hero - Drop (Item being manipulated) from (Hero manipulating item)

If you use a custom item system, you'll need to combine the Unit Gains Item trigger with the item acquired trigger of your item system, otherwise they will conflict. This method will also allow you to customize who can give items and to whom.

If you already use the item's custom value field, you could modify this code to use a game cache instead.

Attached is a sample map. Should I write a tutorial about it, or is there a tidbits thread where I can post this?
Attached Files
File type: w3xprevent giving items.w3x (17.1 KB)
04-14-2006, 09:09 PM#11
mmx2000
Quote:
Originally Posted by Exilus
thats jass...my map is in GUI

Equals:
Trigger:
Item - Make (Some Item) Undroppable

Although Vuen's concern still applies, if that matters to you.
04-14-2006, 10:14 PM#12
Captain Griffen
A wait of 0.00 is >0.1 in reality.
04-15-2006, 10:04 AM#13
Vuen
Quote:
Originally Posted by Captain Griffen
A wait of 0.00 is >0.1 in reality.

...So?

I want the wait to be as short as possible, but for it to not be zero. The "unit loses item" fires, setting the custom value to 1. Then it hits the wait, so it defers. Then "unit acquires item" fires; it sees the custom value is 1, so it drops the item. Then WC3 finishes the triggers, calculates its stuff, and draws a frame. Then it checks if it's waited long enough. Did that take longer than 0 seconds? Yup, so set the custom value back to 0.

This is why I call TriggerSleepAction(0) a "frameskip", because it makes the trigger skip a frame (in multiplayer, by frame I simply mean whatever the shortest unit is of whatever synchronization means it uses). I use TriggerSleepAction(0) all over the place in my maps.
04-15-2006, 10:19 AM#14
Captain Griffen
Well, it's quite possible to drop an item and pick it up in 0.1 seconds, and actually recommended so it doesn't get nicked.

I'd personally use a timer to get the shortest time possible.
04-15-2006, 01:33 PM#15
Exilus
Quote:
Originally Posted by mmx2000
Equals:
Trigger:
Item - Make (Some Item) Undroppable

Although Vuen's concern still applies, if that matters to you.


well. i WANT to make the item droppable...just not being able to give directly.