Hello,
I'm trying to fix healing abuse in a map by preventing players from dropping their life boosting items before restoring their hero's life.
The items should remain movable in inventory and droppable in base.
(Game version is 1.27 with ydwe support.)
I setup a trigger that looks for 'EVENT_PLAYER_UNIT_DROP_ITEM'; removes the item and then returns the item back to the unit which triggered it.
This is what I have in my trigger actions (no idea what I'm doing, never used this).
It worked, but for some reason, it triggered 6 times. Putting PolledWait(.1) before the calls fixed that issue. Putting it after RemoveItem caused the item being added infinitely, big question mark.
Question: The event is firing on items sold to vendor and items passed to another unit and possibly something else I'm not thinking of. How do I filter these? Items sold should be ignored and items passed between units need to have their own countermeasure.
Whole trigger simplified
I'm trying to fix healing abuse in a map by preventing players from dropping their life boosting items before restoring their hero's life.
The items should remain movable in inventory and droppable in base.
(Game version is 1.27 with ydwe support.)
I setup a trigger that looks for 'EVENT_PLAYER_UNIT_DROP_ITEM'; removes the item and then returns the item back to the unit which triggered it.
This is what I have in my trigger actions (no idea what I'm doing, never used this).
JASS:
local integer it=GetItemTypeId(GetManipulatedItem())
call RemoveItem(GetManipulatedItem())
call UnitAddItemById(GetTriggerUnit(),it)
Question: The event is firing on items sold to vendor and items passed to another unit and possibly something else I'm not thinking of. How do I filter these? Items sold should be ignored and items passed between units need to have their own countermeasure.
Whole trigger simplified
JASS:
function InitTrig_abuse takes nothing returns nothing
set gg_trg_abuse=CreateTrigger()
call TriggerRegisterPlayerUnitEvent(gg_trg_abuse,Player(0),EVENT_PLAYER_UNIT_DROP_ITEM,null)
call TriggerAddCondition(gg_trg_abuse,Condition(function Trig_abuseConditions))
call TriggerAddAction(gg_trg_abuse,function Trig_abuseActions)
endfunction
function Trig_abuseActions takes nothing returns nothing
local integer it=GetItemTypeId(GetManipulatedItem())
call PolledWait(.01)
call RemoveItem(GetManipulatedItem())
call UnitAddItemById(GetTriggerUnit(),it)
endfunction
function Trig_abuseConditions takes nothing returns boolean
return true
endfunction