- Joined
- Jul 10, 2011
- Messages
- 562
okay Spartipilo...first thanks for your work
it really helped me ^.^
now what i did with your help....it now works perfectly for my purpose even if the item picked up occupies the slot it should be in. You can take a look and tell me whether i should change something because it could cause bugs or whatever.
and im really proud of this trigger ^-^ especially because my jass knowledge is really small ^^
thread can me set to solved
now what i did with your help....it now works perfectly for my purpose even if the item picked up occupies the slot it should be in. You can take a look and tell me whether i should change something because it could cause bugs or whatever.
JASS:
function Trig_Hero_and_Item_List_Actions takes nothing returns nothing
set udg_ItemRestrictionTable = InitHashtable()
// | Table | ItemID | 000 | ItemClass |
call SaveInteger(udg_ItemRestrictionTable, 'ofro', 0, 1) // Item 1
call TriggerSleepAction(0.25) // Add one of these every 10 actions.
// and so on...
// | Table | Hero ID | item Class | If forbidden = true |
// Hero 1
call SaveBoolean(udg_ItemRestrictionTable, 'H02Q', 1, true)
call SaveBoolean(udg_ItemRestrictionTable, 'H00F', 1, false)
// and so on...
endfunction
//===========================================================================
function InitTrig_Hero_and_Item_List takes nothing returns nothing
set gg_trg_Hero_and_Item_List = CreateTrigger( )
call TriggerRegisterTimerEvent( gg_trg_Hero_and_Item_List, 1.00, false )
call TriggerAddAction( gg_trg_Hero_and_Item_List, function Trig_Hero_and_Item_List_Actions )
endfunction
and im really proud of this trigger ^-^ especially because my jass knowledge is really small ^^
JASS:
function Item_Acquire_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local item i = (GetManipulatedItem())
local integer lvl = GetItemLevel(i)
local integer ItemClass = LoadInteger(udg_ItemRestrictionTable, GetItemTypeId(i), 0)
local item i2 = UnitItemInSlot(u, lvl-1)
local item i3 = UnitItemInSlot(u, lvl)
local boolean b = false
if GetUnitTypeId(u) == 'H02B' or GetUnitTypeId (u) == 'H015' or GetUnitTypeId (u) == 'H029' or GetUnitTypeId (u) == 'H00R' then
set b = true
endif
if LoadBoolean(udg_ItemRestrictionTable, GetUnitTypeId(u),ItemClass ) == true then // Checks if the Acquired Item is Useable by the Unit
// Drops the item and Displays Message
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 10, "You can't carry this item.")
call UnitRemoveItem(u, i)
call SetItemUserData(i, 0 )
if GetItemLevel(UnitItemInSlot(u, 0)) == null then
call UnitRemoveItem(u , GetItemOfTypeFromUnitBJ (u , 'I001'))
endif
elseif b == true and lvl == 1 then
if i2 == null or i2 == i then // Checks if the Item Slot is Empty or the Item in the slot is the desired item.
call IssueTargetOrderById(u, 852001+lvl, i) // Moves the Item to the correct Slot
elseif i3 == null or i3 == i then
call IssueTargetOrderById(u, 852001+lvl+1, i)
else
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 10, "Needed slot is already occupied.")
call UnitRemoveItem(u, i)
call SetItemUserData(i, 0 )
if GetItemLevel(UnitItemInSlot(u, 0)) == null then
call UnitRemoveItem(u , GetItemOfTypeFromUnitBJ (u , 'I001'))
endif
endif
elseif b == false then
// Drops the item and Displays Message
if i2 == null or i2 == i then
call IssueTargetOrderById(u, 852001+lvl, i)
if ItemClass <= 8 and GetItemTypeId(i) != 'I001' then
call UnitAddItemToSlotById(u,'I001',1)
endif
else
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 10, "Needed slot is already occupied.")
call UnitRemoveItem(u, i)
call SetItemUserData(i, 0 )
if GetItemLevel(UnitItemInSlot(u, 0)) == null then
call UnitRemoveItem(u , GetItemOfTypeFromUnitBJ (u , 'I001'))
endif
endif
endif
set u = null
set i = null
set i2 = null
set i3 = null
set b = false
endfunction
//===========================================================================
function InitTrig_Item_Acquire takes nothing returns nothing
set gg_trg_Item_Acquire = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Item_Acquire, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Item_Acquire, function Item_Acquire_Actions )
endfunction
thread can me set to solved