- Joined
- Nov 13, 2006
- Messages
- 1,814
JASS:
function Trig_Stacking_item_Actions takes nothing returns nothing
local item itm = GetManipulatedItem()
local item itm2
local integer itype1 = GetItemTypeId(itm)
local integer itype2
local unit u = GetTriggerUnit()
local integer cv = GetUnitUserData(u)
local player p = GetTriggerPlayer()
local integer amount
local integer maxC = CHARGE_MAX()
local integer Id = GetHandleId(itm)
local integer pl = GetPlayerId(p) + 1
local integer ilv = GetItemLevel(itm)
local integer i = 100
local integer a = 0
local integer charge
local integer freeSlot = - 1
local integer gold
local integer utype = GetUnitTypeId(u)
local integer icv = GetItemUserData(itm)
if IsUnitType(u, UNIT_TYPE_HERO) then
if itype1 == 'tkno' then
call SuspendHeroXP(u, false)
call SetHeroLevel(u, GetHeroLevel(u) + 1, true)
call SuspendHeroXP(u, true)
set icv = 22
elseif itype1 == 'gold' then
set gold = GetItemUserData(itm)
if gold > 0 then
set icv = 22
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + gold)
if udg_Camera_Lock[pl] > 0 then
if udg_Camera_Lock[pl] != 1 then
call UpdateGoldinShop (pl)
endif
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffffaaObtained|r |cffffff00" + I2S(gold) + " gold|r")
else
call FT_Ex (p, p, "+" + I2S(gold) + " gold", 1.5, u, 13, 255, 255, 0, 255, 90)
endif
endif
endif
if true == true then//icv == 0 or icv == pl then
//------------------------------------
if not udg_Stop_Stack[cv] then
endif
if not udg_Stop_Stack[cv] and pl != 0 then
if GetItemType(itm) != ITEM_TYPE_POWERUP and ilv > 10 then
if StackingItemType(ilv) then
set charge = GetItemCharges(itm)
if charge == 100 then
set charge = 1
call SetItemCharges(itm, 1)
endif
if charge > 0 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Obtained |cffffff00" + GetItemName(itm) + "|r x |cffaaaaff" + I2S(charge) + "|r")
set amount = charge
if LoadInteger(udg_FSS, 630, utype) != 0 or utype == 'h004' then
set i = 100
loop
exitwhen i == 120 or amount == 0
set itm2 = LoadItemHandle(udg_Stat_Table, cv, i)
if itm2 != null then
if itype1 == GetItemTypeId(itm2) and LoadInteger(udg_Stat_Table, cv, - i) == ilv then
set a = GetItemCharges(itm2)
if a != maxC then
if amount + a > maxC then
call SetItemCharges(itm2, maxC)
set amount = amount + a - maxC
else
call SetItemCharges(itm2, amount + a)
call SetItemCharges(itm, 0)
set amount = 0
endif
endif
endif
elseif LoadInteger(udg_Stat_Table, cv, - i) == 0 and freeSlot == - 1 then
set freeSlot = i
endif
set i = i + 1
endloop
if GetItemCharges(itm) == 0 then
call RemoveItem(itm)
endif
if itm != null and freeSlot != - 1 then
if GetItemCharges(itm) > 0 then
call SaveItemHandle(udg_Stat_Table, cv, freeSlot, itm)
call SaveInteger(udg_Stat_Table, cv, - freeSlot, ilv)
call SetItemCharges(itm, amount)
call UnitRemoveItem (u, itm)
call SetItemVisible(itm, false)
set amount = 0
endif
endif
endif
if amount > 0 then
loop
set i = 0
exitwhen i > 5 or amount == 0
set itm2 = UnitItemInSlot(u, i)
if itm2 != null then
if itype1 == GetItemTypeId(itm2) and itm2 != itm then
set a = GetItemCharges(itm2)
if charge + a > maxC then
call SetItemCharges(itm2, maxC)
call SetItemCharges(itm, charge + a - maxC)
else
call SetItemCharges(itm2, charge + a)
call SetItemCharges(itm, 0)
if GetItemCharges(itm) == 0 then
call RemoveItem(itm)
endif
endif
set amount = 0
endif
endif
set i = i + 1
endloop
endif
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Acquired " + GetFullItemName(itm, true) + "|r")
if LoadInteger(udg_FSS, 630, utype) != 0 or utype == 'h004' then
set amount = 1
set i = 100
loop
exitwhen i == 120 or amount == 0
if LoadInteger(udg_Stat_Table, cv, - i) == 0 then
call SaveInteger(udg_Stat_Table, cv, - i, ilv)
call SaveItemHandle(udg_Stat_Table, cv, i, itm)
set amount = 0
call UnitRemoveItem(u, itm)
call SetItemVisible(itm, false)
if ilv == 111 then
call EquipAItem (cv, itm, true)
endif
endif
set i = i + 1
endloop
endif
endif
endif
endif
elseif icv > 0 and icv < 13 and itype1 != 'gold' then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "This item owned by |cffffff00" + GetPlayerName(Player(icv - 1)) + "|r")
endif
endif
call RemoveItemRot (itm, false)
set itm = null
set itm2 = null
call TriggerSleepAction(0)
set u = null
set p = null
endfunction
//===========================================================================
function InitTrig_Stacking_item_in_old_inv takes nothing returns nothing
set gg_trg_Stacking_item_in_old_inv = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Stacking_item_in_old_inv, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Stacking_item_in_old_inv, function Trig_Stacking_item_Actions )
endfunction
Last edited: