| 01-18-2009, 06:24 PM | #1 |
JASS:function Trig_GE_Item_Dropping_Actions takes nothing returns nothing local unit u = GetTriggerUnit() local item it = GetManipulatedItem() local real x1 = GetUnitX(u) local real y1 = GetUnitY(u) if GetItemTypeId(it)=='I000' then call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'n000', x1, y1, 0) call RemoveItem(it) endif endfunction //=========================================================================== function InitTrig_GE_Item_Dropping takes nothing returns nothing set gg_trg_GE_Item_Dropping = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_GE_Item_Dropping, EVENT_PLAYER_UNIT_DROP_ITEM ) call TriggerAddAction( gg_trg_GE_Item_Dropping, function Trig_GE_Item_Dropping_Actions ) endfunction WHAT'S SUPPOSED TO HAPPEN: When a bottled is dropped, it will spawn a Faerie unit. WHAT IS HAPPENING: It spawns two faerie units. Is there something I don't know about RemoveItem() that I really should? |
| 01-18-2009, 06:27 PM | #2 |
Weird, i have never seen someone use exitwhen without loops, that may be the problem or it may be something i have never heard of before. So yea, i have a feeling it's something with the exitwhen. |
| 01-18-2009, 06:30 PM | #3 |
Oh that's an accident from something I tried before; using some weird-ass inny-outy loop that had an intricate way of using booleans didn't work. However, it happens without it. |
| 01-18-2009, 06:34 PM | #4 |
lol, Was going to say. JASS:function Trig_GE_Item_Dropping_Actions takes nothing returns nothing local unit u = GetTriggerUnit() local item it = GetManipulatedItem() local real x1 = GetUnitX(u) local real y1 = GetUnitY(u) call BJDebugMsg("It ran") if GetItemTypeId(it)=='I000' then call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'n000', x1, y1, 0) call RemoveItem(it) endif endfunction //=========================================================================== function InitTrig_GE_Item_Dropping takes nothing returns nothing set gg_trg_GE_Item_Dropping = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_GE_Item_Dropping, EVENT_PLAYER_UNIT_DROP_ITEM ) call TriggerAddAction( gg_trg_GE_Item_Dropping, function Trig_GE_Item_Dropping_Actions ) endfunction Try that, maybe the function is being triggered twice. |
| 01-18-2009, 06:38 PM | #5 |
It's triggering twice, I know that part, but I don't know why. How do I know it's triggering twice? It's doing the same action twice. |
| 01-18-2009, 07:03 PM | #6 |
JASS:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing local unit u = GetTriggerUnit() local item it = GetManipulatedItem() local real x1 = GetUnitX(u) local real y1 = GetUnitY(u) call TriggerSleepAction(0.01) if GetItemTypeId(it)=='ratf' and it != null then call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'hfoo', x1, y1, 0) call RemoveItem(it) endif endfunction //=========================================================================== function InitTrig_Untitled_Trigger_001 takes nothing returns nothing set gg_trg_Untitled_Trigger_001 = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_DROP_ITEM ) call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions ) endfunction Worked for me, i have a feeling it's because RemoveItem counts as a unit dropping an item so it runs it twice. The only bad thing about this is it has a TSA. |
| 01-18-2009, 07:14 PM | #7 |
You could avoid TSA by turning off the trigger before removing the item and then turning it on immediately afterwards. |
| 01-18-2009, 07:15 PM | #8 |
You are so smart |
| 01-18-2009, 07:18 PM | #9 |
Due to the weird nature that I need of my map and can't have the item showing, I did some weird voodoo to reduce the interval from 0.2ish (waits have a minimum time as far as I know) based on what you gave me. Final result:function FaeriePlace takes nothing returns nothing local timer t = GetExpiredTimer() call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'n000', udg_x, udg_y, 0) call RemoveItem(udg_item) call DestroyTimer(t) set t = null endfunction function Trig_GE_Item_Dropping_Actions takes nothing returns nothing local unit u = GetTriggerUnit() local item it = GetManipulatedItem() local real x1 = GetUnitX(u) local real y1 = GetUnitY(u) local timer t = CreateTimer() if GetItemTypeId(it)=='I000' and it != null then set udg_x = x1 set udg_y = y1 set udg_item = it call TimerStart(t, 0.01, false, function FaeriePlace) endif set t = null endfunction + rep EDIT! I was doing stuff and engineering my solution and I don't understand what Anitarf said so I'm sticking to my solution! EDIT! I'll try Anitarf's method... EDIT! I really can't be bothered to rewrite this thing and I just got it working. |
| 01-18-2009, 07:28 PM | #10 |
you can use a 0 second timer there. I think the problem is that "most" item event trigger before the item is actually "evented" on. Therefore, the item is removed before it is dropped, which probably counts as a drop in the game engine. I say most cause there are a couple of them (don't remember which) that ran after the event, and screwed up a lot of my system. |
| 01-18-2009, 07:29 PM | #11 |
tl;dr- Blizzard messed something else up?... or something of a deeper reason? |
| 01-18-2009, 07:42 PM | #12 |
Why are you making it when the bottle is dropped it makes a fairy? Why not when you click on the item in the inventory it makes a fairy?... I'm kind of confused as to why you need this approach. Especially since now you're using a timer. Seems unnecessary without all the details. |
| 01-18-2009, 07:53 PM | #13 |
Might I add that the way you're using that timer isn't very agreeable. I think the solution with turning off the trigger is a lot more elegant. |
| 01-19-2009, 08:08 AM | #14 | |
Quote:
You are correct. Removing an item has a different order ID, check the units current order ID and see if it's dropping or removing, I had the same issue. |
