library ItemProtect requires Reset
function DroupItemConditions takes nothing returns boolean
return ((GetSpellAbilityId() == 'A0EN'))
endfunction
function ItemProtectConditions takes nothing returns boolean
return (((GetUnitTypeId(GetManipulatingUnit()) == 'h003') or (IsUnitType(GetManipulatingUnit(), UNIT_TYPE_HERO) == true)))
endfunction
function ItemProtectActions takes nothing returns nothing
if ((GetItemUserData(GetManipulatedItem()) == 0)) then
call SetItemUserData( GetManipulatedItem(), ( GetPlayerId(GetOwningPlayer(GetManipulatingUnit())) + 1 ) )
return
else
if ((GetItemUserData(GetManipulatedItem()) != ( GetPlayerId(GetOwningPlayer(GetManipulatingUnit())) + 1 ))) then
call DroupItem( GetManipulatedItem(), GetManipulatingUnit() )
call DisplayTextToPlayer( GetOwningPlayer(GetManipulatingUnit()), 0, 0, "|cffff0000这个物品不是你的,不能拾取!|r" )
return
endif
endif
endfunction
function DroupItemActions takes nothing returns nothing
local item it =GetSpellTargetItem()
if (((GetItemUserData(it) == 1) or (GetItemUserData(it) == 2) or (GetItemUserData(it) == 3) or (GetItemUserData(it) == 4) or (GetItemUserData(it) == 5))) then
if ((GetItemUserData(it) == ( GetPlayerId(GetTriggerPlayer()) + 1 ))) then
call SetItemUserData( it, 0 )
call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, "|cff00ff00物品已经解封。|r" )
return
else
call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, ( "|cffff0000不能解封" + ( GetPlayerName(Player(GetItemUserData(it)-1)) + "的物品。|r" ) ) )
return
endif
else
call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, "|cffff0000不能解封不在保护状态中的物品。|r" )
endif
set it =null
endfunction
//===========================================================================
function InitTrig_ItemProtect takes nothing returns nothing
set UnitPickItem = CreateTrigger()
set UnitSetItem = CreateTrigger()
call TriggerRegisterAnyUnitEvent(UnitSetItem, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(UnitSetItem, Condition(function DroupItemConditions))
call TriggerAddAction(UnitSetItem, function DroupItemActions)
call TriggerRegisterAnyUnitEvent( UnitPickItem, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition(UnitPickItem, Condition(function ItemProtectConditions))
call TriggerAddAction(UnitPickItem, function ItemProtectActions)
endfunction
endlibrary
LZ自己看着改吧 我写的 一个保护物品的