HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item Selection Event

02-20-2010, 02:00 PM#1
Panto
Greetings.

Is there an event for an item being selected by a player? I have looked and didn't find one, but it seems like it should exist.
02-20-2010, 02:27 PM#2
Troll-Brain
There is none.
02-20-2010, 02:29 PM#3
Panto
Is there perhaps a way to fool the unit-selection event into working for items?
02-20-2010, 02:51 PM#4
Troll-Brain
Quote:
Originally Posted by Panto
Is there perhaps a way to fool the unit-selection event into working for items?
Searching in common.j there is only two things about selecting events :

EVENT_UNIT_(DE)SELECTED and EVENT_PLAYER_UNIT_(DE)SELECTED.

The first must be used with TriggerRegisterUnitEvent which use an unit argument.
Just for the lulz i've tried that :

Collapse JASS:
scope test initializer onInit

globals
    private hashtable HashT
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg("select")
endfunction

private function onInit takes nothing returns nothing
    local trigger trig = CreateTrigger()
    set HashT = InitHashtable()
    
    call SaveWidgetHandle(HashT,0,0,CreateItem('h000',0.,0.))
    call TriggerRegisterUnitEvent(trig,LoadUnitHandle(HashT,0,0),EVENT_UNIT_SELECTED)
    call TriggerAddAction(trig,function Actions)
    
endfunction

endscope

'h000' is the rawcode for a custom unit AND ALSO for a custom item.
Obviously it doesn't work.

The only way is to create a custom native event, which will work only if the players use the hack to launch the map.
02-20-2010, 02:52 PM#5
Panto
Drat.

Thank you for your thoroughness!

Edit: I realized a workaround might involve using Neutral Passive units as items and triggering the pertinent behavior changes, although I'm not sure that's worth it in this case. Nevertheless, thanks again!
02-20-2010, 03:03 PM#6
Troll-Brain
But you can't still use trackables (it won't detect box selections though) and the result might be inaccurate (could depends the model used, i simply don't know since i have never use trackables).
Also the big problem with trackables is that you can't move neither destroy them once it's created, which is by itself really lame.
02-20-2010, 03:05 PM#7
Panto
I don't have any practical experience with trackables either. From what you say, it sounds like it's not worth picking it up for this solution.
02-20-2010, 03:11 PM#8
Troll-Brain
Yep, especially because if i'm right items can have the same place, like units.
I would go for a dummy unit instead, when an unit receive a "smart" order on it, check the distance between the triggering unit and the fake item, if it is less or equal to the distance needed to get the item (there is a constant for that, no ?), then remove the fake item, create the item and give it to the triggering unit.
And if the distance is to big, check it periodically, and stop it if the fake item is destroyed or the needed distance reached.

Meh, the player could make item groups so