function GetHandleTriggerAction takes handle subject, string name returns triggeraction
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function MakeItemUnmovable_Timer takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit(t,"u")
local item i = GetHandleItem(t,"i")
local integer s = GetHandleInt(t,"s")
call SetHandleInt(i,"g",1) //use this handlevar to find w/e or not the item was moved by the function
call UnitDropItemSlotBJ(u,i,s)
call SetHandleInt(i,"g",0)
set u = null
set i = null
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
endfunction
function MakeItemUnmovable_Actions takes nothing returns nothing
local trigger x = GetTriggeringTrigger()
local timer t = CreateTimer()
local integer g = GetHandleInt(GetOrderTargetItem(),"g")
if not (GetIssuedOrderId() >= 852002) and (GetIssuedOrderId() <= 852007) then
call DestroyTimer(t)
set t = null
return
endif
//above if statment finds if the order was a drag and drop order (between 852002-852007 depending on slot)
if GetOrderTargetItem() == GetHandleItem(x,"i") and g == 0 then
//if the drag n dropped item matches the one that the trigger should lock then
// it will get moved back to its previous slot
call SetHandleHandle( t, "u", GetTriggerUnit())
call SetHandleInt(t, "s", GetItemSlot(GetTriggerUnit(),GetOrderTargetItem()) )
call SetHandleHandle(t, "i", GetOrderTargetItem())
call TimerStart(t,0,false,function MakeItemUnmovable_Timer)
else
call DestroyTimer(t)
endif
set t = null
endfunction
function MakeItemUnmovable takes unit whichUnit, item whichItem returns nothing
local trigger x = CreateTrigger()
call SetHandleHandle(x,"i",whichItem)
call TriggerRegisterUnitEvent( x, whichUnit,EVENT_UNIT_ISSUED_TARGET_ORDER)
call SetHandleHandle(x,"a", TriggerAddAction( x, function MakeItemUnmovable_Actions ))
call SetHandleHandle(whichItem,"droptrg",x)
set x = null
endfunction
function MakeItemMovable takes unit whichUnit, item whichItem returns nothing
local trigger x = GetHandleTrigger(whichItem,"droptrg")
//this function simply destroyes the trigger thats responisble for the locking of the item
call SetHandleHandle(whichItem,"droptrg",null)
call TriggerRemoveAction(x,GetHandleTriggerAction(x,"a"))
call FlushHandleLocals(x)
call DestroyTrigger(x)
set x = null
endfunction