function Trig_Untitled_Trigger_002_Conditions takes nothing returns boolean
if ( not ( GetItemType(GetManipulatedItem()) == ITEM_TYPE_PERMANENT)) then
return false
endif
return true
endfunction
function Trig_Untitled_Trigger_002_Func001C takes nothing returns boolean
if ( not ( GetUnitUserData(GetManipulatingUnit()) == 1)) then
return false
endif
return true
endfunction
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
if ( Trig_Untitled_Trigger_002_Func001C() ) then
call UnitRemoveItem(GetManipulatingUnit(),GetManipulatedItem())
else
endif
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_002, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( gg_trg_Untitled_Trigger_002, Condition( function Trig_Untitled_Trigger_002_Conditions ) )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
function Trig_Untitled_Trigger_003_Conditions takes nothing returns boolean
if ( not ( GetItemType(GetManipulatedItem()) == ITEM_TYPE_PERMANENT)) then
return false
endif
return true
endfunction
function Trig_Untitled_Trigger_003_Func001C takes nothing returns boolean
if ( not ( GetUnitUserData(GetManipulatingUnit()) == 0)) then
return false
endif
return true
endfunction
function Trig_Untitled_Trigger_003_Actions takes nothing returns nothing
if ( Trig_Untitled_Trigger_003_Func001C()) then
call SetUnitUserData( GetManipulatingUnit(), 1)
else
endif
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_003 takes nothing returns nothing
set gg_trg_Untitled_Trigger_003 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_003, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( gg_trg_Untitled_Trigger_003, Condition( function Trig_Untitled_Trigger_003_Conditions ) )
call TriggerAddAction( gg_trg_Untitled_Trigger_003, function Trig_Untitled_Trigger_003_Actions )
endfunction
function Trig_Untitled_Trigger_004_Conditions takes nothing returns boolean
if ( not ( GetItemType(GetManipulatedItem()) == ITEM_TYPE_PERMANENT)) then
return false
endif
return true
endfunction
function Trig_Untitled_Trigger_004_Actions takes nothing returns nothing
call SetUnitUserData( GetManipulatingUnit(),0)
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_004 takes nothing returns nothing
set gg_trg_Untitled_Trigger_004 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_004, EVENT_PLAYER_UNIT_DROP_ITEM )
call TriggerAddCondition( gg_trg_Untitled_Trigger_004, Condition( function Trig_Untitled_Trigger_004_Conditions ) )
call TriggerAddAction( gg_trg_Untitled_Trigger_004, function Trig_Untitled_Trigger_004_Actions )
endfunction
Can you make for other 5 item classes too please ? +rep for this
function Trig_ItemClassLimit_Actions takes nothing returns boolean
local unit u = GetTriggerUnit() //GetTriggerUnit() is same as GetManipulatingUnit()
local item i = GetManipulatedItem()
local item check
local itemtype itype = GetItemType(i)
local integer index = 0
local boolean b = false
if itype == ITEM_TYPE_PERMANENT or itype == ITEM_TYPE_CHARGED or itype == ITEM_TYPE_ARTIFACT or itype == ITEM_TYPE_POWERUP or itype == ITEM_TYPE_CAMPAIGN or itype == ITEM_TYPE_PURCHASABLE then //We'll check if the item meets a certain type. Done this way since it seemed to bug if you checked if the item wasn't ITEM_TYPE_MISCELLANEOUS.
loop
set check = UnitItemInSlot(u,index)
if GetItemType(check) == itype and i != check then
call UnitDropItemPoint(u,i,GetUnitX(u),GetUnitY(u))
call DisplayTextToPlayer(GetOwningPlayer(u),0,0,"Can't have more than one item of the same class!")
set b = true
endif
set index = index + 1
exitwhen index == 6 or b
endloop
endif
set u = null
set i = null
set check = null
return false
endfunction
//===========================================================================
function InitTrig_ItemClassLimit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function Trig_ItemClassLimit_Actions))
endfunction
//
// Check Class of Item
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
function ItemClassCheck takes nothing returns boolean
local integer id = GetItemType(GetManipulatedItem())
local integer data = LoadInteger(udg_hash,GetPlayerId(GetTriggerPlayer()),1)
if id == ITEM_TYPE_PERMANENT and data != 1 then
call UnitRemoveItem(GetTriggerUnit(),GetManipulatedItem())
elseif id = ITEM_TYPE_ARTIFACT and data != 2 then
call UnitRemoveItem(GetTriggerUnit(),GetManipulatedItem())
elseif id = ITEM_TYPE_PURCHASABLE and data != 3 then
call UnitRemoveItem(GetTriggerUnit(),GetManipulatedItem())
elseif id = ITEM_TYPE_CAMPAIGN and data != 4 then
call UnitRemoveItem(GetTriggerUnit(),GetManipulatedItem())
elseif id = ITEM_TYPE_CHARGED and data != 5 then
call UnitRemoveItem(GetTriggerUnit(),GetManipulatedItem())
//elseif id = ITEM_TYPE_POWERUP then <<- How do you plan to stop him collecting powerups?
endif
return false
endfunction
//
// Player Types: "item class (Something)"
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
function ChooseItemClass takes nothing returns boolean
local integer id = GetPlayerId(GetTriggerPlayer())
local string s
if not LoadBoolean(udg_hash,id,0) then
set s = GetEventPlayerChatString()
if s == "item class permanent" then
call SaveInteger(udg_hash,id,1,1)
call SaveBoolean(udg_hash,id,0,true)
elseif s == "item class artifact" then
call SaveInteger(udg_hash,id,1,2)
call SaveBoolean(udg_hash,id,0,true)
elseif s == "item class purchasable" then
call SaveInteger(udg_hash,id,1,3)
call SaveBoolean(udg_hash,id,0,true)
elseif s == "item class campaign" then
call SaveInteger(udg_hash,id,1,4)
call SaveBoolean(udg_hash,id,0,true)
elseif s == "item class charged" then
call SaveInteger(udg_hash,id,1,5)
call SaveBoolean(udg_hash,id,0,true)
endif
endif
return false
endfunction
//
// Initializer
// ¯¯¯¯¯¯¯¯¯¯¯
function InitTrig_ItemChecker takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
local player p
call TriggerAddCondition(t,Condition(function ChooseItemClass))
loop
set p = Player(i)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then
call SaveBoolean(udg_hash,i,0,false)
call TriggerRegisterPlayerChatEvent(t,p,"item class permanent",true)
call TriggerRegisterPlayerChatEvent(t,p,"item class artifact",true)
call TriggerRegisterPlayerChatEvent(t,p,"item class purchasable",true)
call TriggerRegisterPlayerChatEvent(t,p,"item class campaign",true)
call TriggerRegisterPlayerChatEvent(t,p,"item class charged",true)
endif
exitwhen i == 11
set i = i +1
endloop
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function ItemClassCheck))
endfunction