| 07-19-2007, 04:37 AM | #1 |
This trigger [ideally] forces a unit to use an item when an ability is casted. It fires fine and all the debug message appear, but whatever I do the hero will NOT use the item I tried using the native call UnitUseItem(u, i) but it doesnt do ANYTHING. Here's the code: JASS:function HotKeyExecChild takes nothing returns nothing local timer t = GetExpiredTimer() local string d = GetAttachmentTable(t) local hotkeydata hkd = GetTableInt(d, "hkd") debug call BJDebugMsg("ImRunning") call UnitUseItem(hkd.u, hkd.i) call hkd.destroy() call ClearTable(d) call DestroyTimer(t) set t = null endfunction function HotKeyExec takes nothing returns nothing local unit u = GetTriggerUnit() local integer slot local hotkeydata hkd = hotkeydata.create() local timer t = CreateTimer() local string d = GetAttachmentTable(t) debug call BJDebugMsg("HotKeyHIT") //=========================================== // SLOT 1 //=========================================== if GetSpellAbilityId() == 'A05R' then set hkd.i = UnitItemInSlot(u, 0) set hkd.u = u call SetTableInt(d, "hkd", hkd) call TimerStart(t, 3, false, function HotKeyExecChild) //I added a timer for testing purposes to make sure using the ability wasnt preventing using the item endif set t = null set d = null set u = null endfunction //function BlahBlahBlah_InitTrig takes nothing returns nothing //... And just to clarify, I dont want the hero to actually CAST the item ability, I just want to emulate left-clicking the ability. P.S. I should mention the item im using is not a consumable or a potion or anything like that. It's a non-droppable, pawnable item that has a unit ability on it |
| 07-19-2007, 06:47 AM | #2 |
You can't emulate 'left clicking' an item. If you have an ability which requires a target you have to issue an order with a target and it will use the item. Unless the force key function works on the numpad but I doubt it. |
| 07-19-2007, 10:34 AM | #3 | |
Doesnt work New Code:
No idea why.. |
| 07-19-2007, 01:47 PM | #4 |
Are you sure:
|
| 07-19-2007, 05:16 PM | #5 |
Yeah that was a typo, ive been testing 852008 I'm starting to feel like those otrders are nonexistant It doesn't matter what item I put in slot one, it simply won't use it I was reading a thread posted by a dude who was trying to do the exact same thi ng and had the exact same results (actually, you were the only one helping him out too). Has anyone actually gotten a unit to use items via order IDs? EDIT: Okay, I got it to work, but NOT via that native For anyone who's interested (or anyone who spends 6 hours like I did pullinig their hair out trying to figure this shit out) I used 'UnitUseItemTarget()'. I've never even HEARD of that function before now But it seems like IssueTargetOrderById seems to be compltely useless for USING items. I found, however, that it works great for prohibiting/controlling item movement (IE for extended invetory systems with dragging) thanks for your help though blu |
