| 07-12-2008, 09:32 AM | #1 |
I suppose it was already asked, but If I call UnitRemoveItem or functions like that (e.g. UnitDropItem) in response to EVENT_PLAYER_UNIT_SELL_ITEM (remove the sold item) the unit will still get item bonuses. I could work around that by inserting TriggerSleepAction but this way the item icon briefly appears in the inventory. Is there any other way to do it? |
| 07-12-2008, 09:41 AM | #2 |
You could make the shop sell dummy items, then when the items in the Hero's possession, run a check to see if they can use it, if they can, replace it with the real item, if not remove it and give an error message. :) |
| 07-12-2008, 09:47 AM | #3 |
My guess: JASS:library UnitRemoveItemSoon requires AnyTimerRecycler private struct WABLAA unit who item it endstruct private function callback takes nothing returns nothing local timer t = GetExpiredTimer() local WABLAA w = R2I(TimerGetTimeout(t)*2147483648.) call UnitRemoveItem(w.who, w.it) call w.destroy() call ReleaseTimer(t) endfunction function UnitRemoveItemSoon takes unit who, item it returns nothing local timer t = NewTimer() local WABLAA w = WABLAA.create() set w.who = who set w.it = it call TimerStart(t, integer(w)/2147483648., false, function callback) endfunction endlibrary |
| 07-12-2008, 03:58 PM | #4 |
Yes theres the way with fake items but i was wondering if anything can be done without it >< And DiscipleOfLife, why do it that way when this is much better: JASS:globals private unit array rem_u private item array rem_i private integer num_rem = 0 private timer rem_t = CreateTimer () endglobals function ItemRemoveTimer takes nothing returns nothing local integer i = 0 loop exitwhen i >= num_rem call UnitRemoveItem (rem_u[i], rem_i[i]) set rem_u[i] = null set rem_i[i] = null set i = i + 1 endloop set num_rem = 0 endfunction function UnitRemoveItemEx takes unit u, item it returns nothing set rem_u[num_rem] = u set rem_i[num_rem] = it set num_rem = num_rem + 1 if num_rem == 1 then call TimerStart (rem_t, .0, false, function ItemRemoveTimer) endif endfunction |
| 07-12-2008, 05:21 PM | #5 |
Instead of using the EVENT_PLAYER_UNIT_SELL_ITEM check the orders maybe ? |
| 07-12-2008, 07:56 PM | #6 | |
Quote:
Because it doesn't look like crap, it is only mildly worse and it was only ment to show you how damn easy it is to solve your TriggerSleepAction(0) problem. btw did you actually try and see if the item flashes or did you just guess? I have used this exact method to handle items, but haven't seen any flashing myself, but then again I haven't used them at the sell event. |
| 07-12-2008, 08:12 PM | #7 |
I didn't mean TriggerSleepAction, I meant any way of pausing execution until next frame. I put triggersleepaction in to see if it works and it did, but the items did flash. I did need to handle sell and pickup events separately because on pickup event, you make the unit drop that item. On sell you remove the item and give the gold back. I don't trust in cancelling orders because thats theoretically possible to bypass (pretty sure thats possible, by spamming orders or if you have lag, or shift key or whatever). |
| 07-12-2008, 08:34 PM | #8 | |
Quote:
|
