// create icon above the empty slot in full screen system
function AddIcon takes integer pl, integer slot returns nothing
local destructable d
local integer cv = udg_Inv_Unit[pl]
local real x = LoadReal(udg_FSS, slot, 1)
local real y = LoadReal(udg_FSS, slot, 2)
if slot < 200 then
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, GetItemTypeId(LoadItemHandle(udg_Stat_Table, cv,slot))), x, y, 5, 0, 0.6, 0)
elseif slot < 300 then
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, GetItemTypeId(UnitItemInSlot(udg_UDexUnits[cv], slot - 200))), x, y, 5, 0, 0.6, 0)
elseif slot > 2200 and slot < 2225 and udg_Inv_Bag[pl] > 0 then
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, GetItemTypeId(LoadItemHandle(udg_CItem_Table, udg_Inv_Bag[pl],slot-2200))), x, y, 5, 0, 0.6, 0)
endif
call SaveDestructableHandle(udg_FSS, 2409 + pl, slot, d)
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
set d = null
endfunction
//Get item position in inventory, return the slot number where is the item
function GetItemPos takes integer cv, item itm returns integer
local integer i = 0
local integer slot = - 1
loop
exitwhen i > 5 or slot != - 1
if UnitItemInSlot(udg_UDexUnits[cv], i) == itm then
set slot = i + 200
endif
set i = i + 1
endloop
if slot == - 1 then
set i = 100
loop
exitwhen i > 119 or slot != - 1
if LoadItemHandle(udg_Stat_Table, cv, i) == itm then
set slot = i
endif
set i = i + 1
endloop
endif
return slot
endfunction
//swap 2 item (bag<=>inventory,old inventory<=>new inventory,equipment slot/new inv.<=>new inventory)
function SwapItem2Slot takes integer cv, integer slot1, integer slot2 returns nothing
local item itm1
local item itm2
local integer ilv2
local integer a1
local integer a2
local integer itmId
local integer ilv1
local integer dur
local unit u = udg_UDexUnits[cv]
local integer pl = GetPlayerId(GetOwningPlayer(u))+1
set udg_Stop_Stack[cv] = true
if slot1 < 200 and slot2 >= 200 and slot2 < 210 then
//------------------------------------------------------------------------
set itm1 = LoadItemHandle(udg_Stat_Table, cv, slot1)
set ilv1 = GetItemLevel(itm1)
if ilv1 == 111 then
call EquipAItem (cv, itm1, false)
endif
set itm2 = UnitItemInSlot(u, slot2 - 200)
if itm2 != null then
call UnitRemoveItem(u, itm2)
call SetItemVisible(itm2, false)
call SaveItemHandle(udg_Stat_Table, cv, slot1, itm2)
call SaveInteger(udg_Stat_Table, cv, - slot1, GetItemLevel(itm2))
else
call ClearSlot(cv, slot1)
endif
call AddItem2Slot (cv, itm1, slot2 - 200)
elseif slot1 >= 200 and slot2 < 200 and slot1 < 210 then
set itm1 = UnitItemInSlot(u, slot1 - 200)
set ilv1 = GetItemLevel(itm1)
if ilv1 == 111 then
call EquipAItem (cv, itm1, true)
endif
call UnitRemoveItem(u, itm1)
call SetItemVisible(itm1, false)
set itm2 = LoadItemHandle(udg_Stat_Table, cv, slot2)
if itm2 != null then
call AddItem2Slot (cv, itm2, slot1 - 200)
endif
call SaveItemHandle(udg_Stat_Table, cv, slot2, itm1)
call SaveInteger(udg_Stat_Table, cv, - slot2, ilv1)
elseif slot1 < 200 and slot2 < 200 then
set a1 = LoadInteger(udg_Stat_Table, cv, -slot1)
set a2 = LoadInteger(udg_Stat_Table, cv, -slot2)
set itm1 = LoadItemHandle(udg_Stat_Table, cv, slot1)
set itm2 = LoadItemHandle(udg_Stat_Table, cv, slot2)
if itm2 != null then
call SaveItemHandle(udg_Stat_Table, cv, slot1, itm2)
call SaveInteger(udg_Stat_Table, cv, - slot1, a2)
else
call ClearSlot(cv, slot1)
endif
call SaveItemHandle(udg_Stat_Table, cv,slot2, itm1)
call SaveInteger(udg_Stat_Table, cv, -slot2, a1)
elseif slot1 >= 200 and slot2 >= 200 and slot2 < 210 and slot1 < 210 then
set itm1 = UnitItemInSlot(u, slot1 - 200)
call UnitRemoveItem(u, itm1)
set itm2 = UnitItemInSlot(u, slot2 - 200)
if itm2 != null then
call UnitRemoveItem(u, itm2)
call AddItem2Slot (cv, itm2, slot1 - 200)
endif
call AddItem2Slot (cv, itm1, slot2 - 200)
elseif slot1 >= 2200 and slot1 < 2225 and slot2 >= 2200 and slot2 < 2225 then
set a1 = udg_Inv_Bag[pl]
if a1 > 0 then
set itm1 = LoadItemHandle(udg_CItem_Table, a1, slot1-2200)
set itm2 = LoadItemHandle(udg_CItem_Table, a1, slot2-2200)
if itm2 == null then
call RemoveSavedHandle(udg_CItem_Table, a1, slot1-2200)
else
call SaveItemHandle(udg_CItem_Table, a1, slot1-2200, itm2)
endif
call SaveItemHandle(udg_CItem_Table, a1, slot2-2200, itm1)
endif
elseif slot1 >= 2200 and slot1 < 2225 and slot2 < 200 then
set a1 = udg_Inv_Bag[pl]
if a1 > 0 then
set itm1 = LoadItemHandle(udg_CItem_Table, a1, slot1-2200)
set itm2 = LoadItemHandle(udg_Stat_Table, cv, slot2)
if itm2 == null then
call RemoveSavedHandle(udg_CItem_Table, a1, slot1-2200)
set a2 = LoadInteger(udg_CItem_Table, a1, 0)
call SaveInteger(udg_CItem_Table, a1, 0, a2-1)
else
call SaveItemHandle(udg_CItem_Table, a1, slot1-2200, itm2)
endif
call SaveItemHandle(udg_Stat_Table, cv, slot2, itm1)
call SaveInteger(udg_Stat_Table, cv, -slot2, GetItemLevel(itm1))
endif
elseif slot1 < 200 and slot2 >= 2200 and slot2 < 2225 then
set a1 = udg_Inv_Bag[pl]
if a1 > 0 then
set itm1 = LoadItemHandle(udg_Stat_Table, cv, slot1)
set itm2 = LoadItemHandle(udg_CItem_Table, a1, slot2-2200)
if itm2 == null then
call ClearSlot(cv, slot1)
else
call SaveItemHandle(udg_Stat_Table, cv, slot1, itm2)
call SaveInteger(udg_Stat_Table, cv, -slot1, GetItemLevel(itm2))
endif
call SaveItemHandle(udg_CItem_Table, a1, slot2-2200, itm1)
endif
endif
set udg_Stop_Stack[cv] = false
set itm1 = null
set itm2 = null
set u = null
endfunction
//add item to unit with icon
function AddItem2HeroExt takes integer cv, item itm, boolean drop returns nothing
local integer id = GetHandleId(itm)
local integer itype = GetItemTypeId(itm)
local integer ilv = GetItemLevel(itm)
local integer i = 100
local integer n = 0
local integer a = 0
local integer amount = GetItemCharges(itm)
local integer freeSlot = - 1
local unit u = udg_UDexUnits[cv]
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local item itm2
local integer pl = GetPlayerId(GetOwningPlayer(u))+1
set udg_Stop_Stack[cv] = true
if StackingItemType(ilv) then
if not drop then
set i = 100
loop
exitwhen i == 120 or amount == 0
set itm2 = LoadItemHandle(udg_Stat_Table, cv, i)
if ilv == LoadInteger(udg_Stat_Table, cv, - i) then
if GetItemTypeId(itm2) == itype then
set a = GetItemCharges(itm2)
if amount + a > 99 then
call SetItemCharges(itm2, 99)
set amount = amount + a - 99
else
call SetItemCharges(itm2, amount + a)
call RemoveItem(itm)
set amount = 0
endif
endif
elseif LoadInteger(udg_Stat_Table, cv, - i) == 0 and freeSlot == - 1 then
set freeSlot = i
endif
set i = i + 1
endloop
if amount > 0 and freeSlot != - 1 then
call SaveItemHandle (udg_Stat_Table, cv, freeSlot, itm)
call SaveInteger (udg_Stat_Table, cv, - freeSlot, ilv)
set amount = 0
endif
if amount > 0 then
set freeSlot = - 1
set i = 200
loop
exitwhen i == 206 or amount == 0
set itm2 = UnitItemInSlot(u, i - 200)
if itm2 == null then
if freeSlot == - 1 then
set freeSlot = i - 200
endif
elseif GetItemTypeId(itm2) == itype then
set a = GetItemCharges(itm2)
if amount + a > 99 then
call SetItemCharges(itm2, 99)
set amount = amount + a - 99
else
set amount = 0
call SetItemCharges(itm2, amount + a)
call RemoveItem(itm)
endif
endif
set i = i + 1
endloop
if amount > 0 and freeSlot != - 1 then
call AddItem2Slot (cv, itm, freeSlot)
set amount = 0
endif
else
call SetItemVisible(itm, false)
endif
call SetChargesText(pl)
else
call UnitRemoveItem(u, itm)
call SetItemVisible(itm, true)
call SetItemPosition(itm, x, y)
endif
else
set amount = 1
if not drop then
set i = 100
loop
exitwhen i == 206 or amount == 0
if i < 200 then
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)
call SetItemVisible(itm, false)
set amount = 0
if ilv == 111 then
call EquipAItem (cv, itm, true)
endif
endif
else
set itm2 = UnitItemInSlot(u, i - 200)
if itm2 == null then
call AddItem2Slot (cv, itm, i - 200)
call SetItemVisible(itm, false)
set amount = 0
endif
endif
if i==119 then
set i = 199
endif
set i = i + 1
endloop
else
call UnitRemoveItem(u, itm)
call SetItemVisible(itm, true)
call SetItemPosition(itm, x, y)
endif
endif
call RemoveItemRot (itm, false)
if itm != null then
set i = GetItemPos(cv, itm)
if i > -1 then
call AddIcon(pl, i)
endif
endif
set udg_Stop_Stack[cv] = false
set u = null
set itm = null
endfunction
//insert socket into the equipment
function AddSocket takes integer cv, integer slot, integer amount, integer stone returns integer
local item itm
local integer itmId
local integer ilv
local integer socket
local integer maxsocket = 0
local integer ok = 0
local integer place
local unit u = udg_UDexUnits[cv]
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
local integer i = 0
if slot < 200 then
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
elseif slot < 300 then
set itm = UnitItemInSlot(u, slot - 200)
endif
set ilv = GetItemLevel(itm)
set itmId = GetHandleId(itm)
set socket = LoadInteger(udg_CItem_Table, itmId, 18)
set place = ilv - 100
set maxsocket = LoadInteger(udg_CItem_Table, itmId, 20)
if amount > 0 then
if socket + amount <= maxsocket then
set socket = socket + amount
if (place > 0 and place < 5) or place == 9 then
if slot < 100 then
if place == 1 or place == 2 or place == 4 then
if stone == 'I001' then
call AddHPMP(true, 25 * amount, u)
elseif stone == 'I002' then
call AddHPMP(true, 50 * amount, u)
elseif stone == 'I003' then
call AddHPMP(true, 75 * amount, u)
elseif stone == 'I004' then
call AddHPMP(true, 100 * amount, u)
elseif stone == 'I005' then
call AddHPMP(true, 125 * amount, u)
elseif stone == 'I006' then
call AddHPMP(true, 175 * amount, u)
endif
elseif place == 3 then
if stone == 'I001' then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + 1 * amount
elseif stone == 'I002' then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + 2 * amount
elseif stone == 'I003' then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + 3 * amount
elseif stone == 'I004' then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + 4 * amount
elseif stone == 'I005' then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + 5 * amount
elseif stone == 'I006' then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + 7 * amount
endif
elseif place == 9 then
if stone == 'I001' then
set udg_Stat_HpRegen[cv] = udg_Stat_HpRegen[cv] + 2 * amount
elseif stone == 'I002' then
set udg_Stat_HpRegen[cv] = udg_Stat_HpRegen[cv] + 4 * amount
elseif stone == 'I003' then
set udg_Stat_HpRegen[cv] = udg_Stat_HpRegen[cv] + 6 * amount
elseif stone == 'I004' then
set udg_Stat_HpRegen[cv] = udg_Stat_HpRegen[cv] + 8 * amount
elseif stone == 'I005' then
set udg_Stat_HpRegen[cv] = udg_Stat_HpRegen[cv] + 10 * amount
elseif stone == 'I006' then
set udg_Stat_HpRegen[cv] = udg_Stat_HpRegen[cv] + 15 * amount
endif
endif
endif
call SaveInteger(udg_CItem_Table, itmId, 18, socket)
loop
exitwhen i > socket - 1
if LoadInteger(udg_CItem_Table, itmId, 1500 + i) == stone then
call SaveInteger(udg_CItem_Table, itmId, 1000 + i, LoadInteger(udg_CItem_Table, itmId, 1000 + i) + amount)
set i = socket + 2
elseif i == socket - 1 then
call SaveInteger(udg_CItem_Table, itmId, 1500 + socket, stone)
call SaveInteger(udg_CItem_Table, itmId, 1000 + socket, amount)
endif
set i = i + 1
endloop
//call SaveInteger(udg_CItem_Table, itmId, 19, socketv)
set ok = 1
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm) + "|r not socketable.")
endif
else
if (place > 0 and place < 5) or (place == 9) then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm) + "|r if filled with gems, you can't add more gem.")
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm) + "|r don't have socket.")
endif
endif
endif
set u = null
set itm = null
set u = null
call ShowStat(pl)
return ok
endfunction
//refine the selected equipment what is in selected slot
function AddRefine takes integer cv, integer slot, integer amount, boolean SafeRefine returns integer
local item itm
local integer itmId
local integer ilv
local integer refv
local integer reflv
local integer grade
local integer dmg
local integer mdmg
local real r
local integer subtype
local integer o
local integer ok = 0
local integer place
local integer AddStat = 0
local integer chance = 0
local integer random = GetRandomInt(0, 99)
local unit u = udg_UDexUnits[cv]
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
if slot < 200 then
if slot < 100 then
set AddStat = 1
endif
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
elseif slot < 300 then
set itm = UnitItemInSlot(u, slot - 200)
endif
set ilv = GetItemLevel(itm)
set itmId = GetHandleId(itm)
set reflv = LoadInteger(udg_CItem_Table, itmId, 16)
set refv = LoadInteger(udg_CItem_Table, itmId, 17)
set grade = LoadInteger(udg_CItem_Table, itmId, 7)
set dmg = LoadInteger(udg_CItem_Table, itmId, 52)
set mdmg = LoadInteger(udg_CItem_Table, itmId, 53)
set subtype = LoadInteger(udg_CItem_Table, itmId, 3)
set place = ilv - 100
if reflv + amount < 11 and place > 0 and place < 10 then
if amount > 0 then
if place == 1 or place == 2 or place == 4 then
set o = (grade * 2) * amount
if place == 1 then
set r = I2R(o) * 0.75
elseif place == 2 then
set r = I2R(o) * 1.00
elseif place == 4 then
set r = I2R(o) * 0.60
endif
set o = R2I(r)
elseif place == 3 then
if subtype > 7 then
set o = R2I(( I2R(mdmg) / 10.00 )) * amount
else
set o = R2I(( I2R(dmg) / 10.00 )) * amount
endif
elseif place == 5 or place == 8 then
if place == 5 then
set o = grade * 10 * amount
else
set o = grade * 10 * amount
endif
elseif place == 6 or place == 7 then
if place == 6 then
set o = grade * 10 * amount
else
set o = grade * 10 * amount
endif
elseif place == 9 then
set o = 2 * amount
endif
set ok = 1
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "This item is reached the |cffff0000maximum|r refine level.")
endif
if not SafeRefine and ok == 1 then
set chance = 100 - reflv * 10
if random < chance then
set ok = 1
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm) + " refined succefully.|r")
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff0000Refineing failed.|r")
set ok = 2
endif
endif
if ok == 1 then
if AddStat == 1 then
if place == 1 or place == 2 or place == 4 then
call AddHPMP(true, R2I(r), u)
elseif place == 3 then
if ilv > 1000 then
set udg_Stat_SpellPower[cv] = udg_Stat_SpellPower[cv] + o
else
set udg_Stat_Dmg[cv] = udg_Stat_Dmg[cv] + o
if GetHeroStr(u, true) > GetHeroAgi(u, true) then
set udg_Total_Dmg[cv] = udg_Stat_Dmg[cv] + udg_Stat_Dmg[cv] * (GetHeroStr(u, true) / 400)
else
set udg_Total_Dmg[cv] = udg_Stat_Dmg[cv] + udg_Stat_Dmg[cv] * (GetHeroAgi(u, true) / 400)
endif
call AddDMG(true, cv, udg_Total_Dmg[cv])
endif
elseif place == 5 or place == 8 then
set udg_Stat_Pdef[cv] = udg_Stat_Pdef[cv] + o
elseif place == 6 or place == 7 then
set udg_Stat_Mdef1[cv] = udg_Stat_Mdef1[cv] + o
set udg_Stat_Mdef2[cv] = udg_Stat_Mdef2[cv] + o
set udg_Stat_Mdef3[cv] = udg_Stat_Mdef3[cv] + o
set udg_Stat_Mdef4[cv] = udg_Stat_Mdef4[cv] + o
set udg_Stat_Mdef5[cv] = udg_Stat_Mdef5[cv] + o
elseif place == 9 then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + o
set udg_Stat_DefLv[cv] = udg_Stat_DefLv[cv] + o
endif
endif
call SaveInteger(udg_CItem_Table, itmId, 16, reflv + amount)
call SaveInteger(udg_CItem_Table, itmId, 17, refv + o)
endif
call ShowStat(pl)
set itm = null
set u = null
return ok
endfunction
//check the equipment requiment before equip it and write out the error if not equipable
function CheckRequiment takes integer cv, integer slot, integer slot2 returns boolean
local unit u = udg_UDexUnits[cv]
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
local item itm
local item itm2
local integer ilv
local integer id
local integer lv = GetHeroLevel(u)
local integer subtype
local integer lvR
local integer strR
local integer agiR
local integer intR
local real dur
local integer str = GetHeroStr(u, true)
local integer agi = GetHeroAgi(u, true)
local integer int = GetHeroInt(u, true)
local integer ok = 0
local string s = ""
local string r = "|cffff0000"
local integer iclass
local integer hclass = LoadInteger(udg_FSS, 633, GetUnitTypeId(u))
if slot < 200 then
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
else
set itm = UnitItemInSlot(u, slot - 200 )
endif
set ilv = GetItemLevel(itm)
set id = GetHandleId(itm)
set lv = GetHeroLevel(u)
set subtype = LoadInteger(udg_CItem_Table, id, 3)
set lvR = LoadInteger(udg_CItem_Table, id, 8)
set strR = LoadInteger(udg_CItem_Table, id, 9)
set agiR = LoadInteger(udg_CItem_Table, id, 10)
set intR = LoadInteger(udg_CItem_Table, id, 11)
set dur = LoadReal(udg_CItem_Table, id, 14)
set iclass = LoadInteger(udg_CItem_Table, id, 6)
if ilv >= 100 and ilv < 112 then
if ilv != 111 then
if lvR > lv then
set s = s + " |cffffff88Level|r " + r + I2S(lvR) + "|r"
endif
if strR > str then
set s = s + " |cffffff88STR:|r " + r + I2S(strR) + "|r"
endif
if agiR > agi then
set s = s + " |cffffff88AGI:|r " + r + I2S(agiR) + "|r"
endif
if intR > int then
set s = s + " |cffffff88INT:|r " + r + I2S(intR) + "|r"
endif
if s != "" then
set s = "|cffffff00Need:|r" + s + " |cffffffaa for |r |cffffff33" + GetItemName(itm) + "|r"
endif
if iclass > 0 and hclass > 0 and hclass != iclass then
if ilv < 105 and ilv != 103 then
// we make exception about armor because both archer+assassin use same light armor like warrior and tank too heavy armor
if not ((iclass == 1 and hclass == 2) or (iclass==3 and hclass == 4)) then
set s = "|cffffff00This item class restricted!|r"
endif
else
set s = "|cffffff00This item class restricted!|r"
endif
endif
if dur >= 1 or (ilv == 110) then
if not ((ilv - 100 == slot2) or (ilv - 100 == 6 and slot2 == 7)) then
set s = " |cffffff33Wrong slot!|r"
endif
else
set s = " |cffffff33Item too damaged!|r"
endif
if ilv - 100 == 3 then
if LoadInteger(udg_Stat_Table, cv, - 5) > 0 and subtype > 2 then
set s = r + " - Can't wear shield with two handed weapons" + "|r"
endif
elseif ilv - 100 == 5 then
set itm2 = LoadItemHandle(udg_Stat_Table, cv, 3)
set subtype = LoadInteger(udg_CItem_Table, GetHandleId(itm2), 3)
if subtype > 2 then
set s = r + " - Can't wear shield with two handed weapons" + "|r"
endif
set itm2 = null
endif
else
set s = "|cffff0000Non equipable item!|r"
endif
if s == "" then
set ok = - 1
else
set ok = 1
call DisplayTextToPlayer(Player(pl - 1), 0, 0, s)
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Not equipable item!")
endif
set s = null
set r = null
set itm = null
return ok == - 1
endfunction
//make special effect at slot position
function BumpSlot takes integer pl, integer slot, integer style returns nothing
local real x1 = LoadReal(udg_FSS, slot, 1)
local real y1 = LoadReal(udg_FSS, slot, 2)
local real z = 1
local string s
local destructable d
if style == 1 then
set s = "Abilities\\Spells\\Orc\\FeralSpirit\\feralspiritdone.mdl"
elseif style == 2 then
set s = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl"
elseif style == 3 then
set s = "Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl"
elseif style == 4 then
set s = "Abilities\\Spells\\Human\\Polymorph\\PolyMorphTarget.mdl"
elseif style == 5 then
set z = 10
set s = "Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl"
endif
if GetLocalPlayer() != Player (pl - 1) then
set s = ""
endif
set d = CreateDestructableZ( 'OTip', x1, y1, z, 0.00, 1, 0 )
call DestroyEffect(AddSpecialEffect(s, x1, y1))
call RemoveDestructable( d )
set d = null
set s = null
endfunction
//swap icon between 2 slot
function SwapIcon takes integer pl, integer slot1, integer slot2 returns nothing
local destructable d1 = LoadDestructableHandle(udg_FSS, 2409 + pl, slot1)
local destructable d2 = LoadDestructableHandle(udg_FSS, 2409 + pl, slot2)
local integer dt1 = GetDestructableTypeId(d1)
local integer dt2 = GetDestructableTypeId(d2)
local real x1 = LoadReal(udg_FSS, slot1, 1)
local real y1 = LoadReal(udg_FSS, slot1, 2)
local real x2 = LoadReal(udg_FSS, slot2, 1)
local real y2 = LoadReal(udg_FSS, slot2, 2)
call RemoveDestructable(d1)
call RemoveDestructable(d2)
if dt1 != 0 then
set d1 = CreateDestructableZ(dt1, x2, y2, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + pl, slot2, d1)
call ShowDestructable(d1, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d1, true)
endif
endif
if dt2 != 0 then
set d2 = CreateDestructableZ(dt2, x1, y1, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + pl, slot1, d2)
call ShowDestructable(d2, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d2, true)
endif
endif
set d1 = null
set d2 = null
endfunction
//remove icon
function RemoveIcon takes integer pl, integer slot returns nothing
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2409 + pl, slot))
endfunction
//remove the equiped item from equipment slot
function UnEquip takes integer cv, integer slot returns nothing
local integer pl = GetPlayerId(GetOwningPlayer(udg_UDexUnits[cv])) + 1
local item itm = LoadItemHandle(udg_Stat_Table, cv, slot)
call RemoveIcon(pl, slot)
call EquipItem (cv, slot, false)
call SetItemVisible(itm, true)
call AddItem2HeroExt (cv, itm, false)
call ClearSlot(cv, slot)
set itm = null
endfunction
//unit use charged item in full screen inventory
function UseItem takes integer cv, integer slot returns nothing
local integer c1
local integer c2
local unit u = udg_UDexUnits[cv]
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
local item itm1
local item itm2
local integer ilv = 0
set udg_Stop_Stack[cv] = true
if slot < 200 then
set itm1 = LoadItemHandle(udg_Stat_Table, cv, slot)
set itm2 = UnitItemInSlot(u, 0)
if itm2 != null then
call UnitDropItemSlot(u, itm2, 0)
endif
call SetItemVisible(itm1, true)
call UnitAddItem(u, itm1)
else
set itm1 = UnitItemInSlot(u, slot - 200)
set itm2 = null
endif
set ilv = GetItemLevel(itm1)
set c1 = GetItemCharges(itm1)
call UnitUseItem( u, itm1 )
if itm1 != null then
set c2 = GetItemCharges(itm1)
if slot < 200 then
call UnitRemoveItem (u, itm1)
call SetItemVisible(itm1, false)
if itm2 != null then
call AddItem2Slot(cv, itm2, 0)
endif
endif
else
set c2 = 0
endif
if c1 != c2 or ilv == BOX_LEVEL() then
if c2 == 0 or ilv == BOX_LEVEL() then
call RemoveIcon(pl, slot)
call RemoveItem(itm1)
call ClearSlot(cv, slot)
endif
call BumpSlot (pl, slot, 1)
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00Can't use it!|r")
endif
call SetChargesText(cv)
set udg_Stop_Stack[cv] = false
set itm1 = null
set itm2 = null
set u = null
endfunction
//return with item raw code in selected slot (slot is ls, main category is mc, sub category sc)
function GetItemIdFromShop takes integer pl, integer mc, integer sc, integer ls returns integer
local integer id = LoadInteger(udg_Shop_Table, mc, - sc)
if mc > 0 and sc > 0 and ls > 0 then
return LoadInteger(udg_Shop_Table, id, ls)
else
return 0
endif
endfunction
//same than previous just shorter
function CheckItemIdFromShop takes integer pl returns integer
local integer mc = LoadInteger(udg_FSS, 2402, pl) - 2000 //selected main category
local integer sc = LoadInteger(udg_FSS, 2402, 20 + pl) - 2100 //selected sub category
local integer ls = LoadInteger(udg_FSS, 2402, 40 + pl) - 2200 //selected item
return GetItemIdFromShop (pl, mc, sc, ls)
endfunction
//fade a slot, create a semi transparent image above the slot, with similiar size than slot also refresh the floating text there
function FadeSlot takes integer pl, integer slot, integer opacity, boolean apply returns nothing
local real x = LoadReal(udg_FSS, slot, 1)
local real y = LoadReal(udg_FSS, slot, 2)
local texttag tt = LoadTextTagHandle(udg_FSS, 1000 + pl, slot)
local integer c = 0
local integer alphaImg = 255
local image Img
local item itm
local integer cv = udg_Inv_Unit[pl]
set opacity = 255 - opacity
if GetLocalPlayer() == Player(pl - 1) then
set alphaImg = opacity
else
set alphaImg = 0
endif
if slot > 2302 and slot < 2306 then
if udg_Camera_Lock[GetPlayerId(GetLocalPlayer()) + 1] == 2 then
set c = LoadInteger(udg_FSS, 2405, - (100 + pl + ((slot - 2302) * 20 - 20)))
endif
else
set c = 1
endif
set Img = LoadImageHandle(udg_FSS, 2406, 10000 * pl + slot)
if apply then
call DestroyTextTag(tt)
set tt = null
if c > 0 then
if GetLocalPlayer() == Player(pl - 1) then
set tt = CreateTextTag()
if c > 10 then
set x = x - 8
endif
call SetTextTagText( tt, I2S(c), 0.7 * 0.023 )
call SetTextTagPos( tt, x + 16, y - 27, 30.00 )
call SetTextTagColor( tt, 255 - (opacity / 2), 255 - (opacity / 2), 255 - (opacity / 2), opacity )
call SetTextTagPermanent( tt, true )
endif
endif
call SaveTextTagHandle(udg_FSS, 1000 + pl, slot, tt)
if Img != null then
call SetImageColor(Img, 255, 255, 255, opacity)
else
set Img = CreateImage("64x64.blp", 62.00, 62.00, 1, x - 32, y - 32, 1, 0, 0, 0, 1)
call SetImageRenderAlways (Img, true)
call SetImageColor(Img, 255, 255, 255, alphaImg)
call SetImageConstantHeight (Img, true, 35)
call SaveImageHandle(udg_FSS, 2406, 10000 * pl + slot, Img)
endif
else
set Img = LoadImageHandle(udg_FSS, 2406, 10000 * pl + slot)
if Img != null then
call DestroyImage(Img)
call SaveImageHandle(udg_FSS, 2406, 10000 * pl + slot, null)
endif
call DestroyTextTag(tt)
//call SaveTextTagHandle(udg_FSS, 1000 + pl, slot, null)
call RemoveSavedHandle(udg_FSS, 1000 + pl, slot)
if slot < 200 and slot >= 100 then
set c = LoadInteger(udg_Stat_Table, cv, - slot)
if c > 0 and (c < 100 or c > 200) then
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
set c = GetItemLevel(itm)
if c < 100 or c > 200 then
set c = GetItemCharges(itm)
else
set c = 0
endif
else
set c = 0
endif
if c > 0 then
set tt = null
if GetLocalPlayer() == Player(pl - 1) then
set tt = CreateTextTag()
if c > 10 then
set x = x - 8
endif
call SetTextTagText( tt, I2S(c), 0.7 * 0.023 )
call SetTextTagPos( tt, x + 16, y - 27, 30.00 )
call SetTextTagColor( tt, 255, 255, 255, 255 )
call SetTextTagPermanent( tt, true )
endif
call SaveTextTagHandle(udg_FSS, 1000 + pl, slot, tt)
endif
endif
endif
set itm = null
set tt = null
set Img = null
endfunction
//refresh the item list if user selected different main or sub item category - icons
function UpdateShopList takes integer pl returns nothing
local integer mc = LoadInteger(udg_FSS, 2402, pl) - 2000 //selected main category
local integer sc = LoadInteger(udg_FSS, 2402, 20 + pl) - 2100 //selected sub category
local integer id = LoadInteger(udg_Shop_Table, mc, - sc)
local integer i = 1
local destructable d
local integer itid
local real x
local real y
call SaveInteger(udg_FSS, 2405, pl, 0)
loop
set d = LoadDestructableHandle(udg_FSS, 2404, 100 * pl + i) //sub cat icon
exitwhen d == null
call RemoveDestructable(d)
set i = i + 1
endloop
if mc > 0 and sc > 0 then
set i = 1
loop
set itid = LoadInteger(udg_Shop_Table, id, i)
exitwhen itid == 0
set x = LoadReal(udg_FSS, 2200 + i, 1)
set y = LoadReal(udg_FSS, 2200 + i, 2)
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, itid), x, y, 5, 0, 0.55, 0)
call SaveDestructableHandle(udg_FSS, 2404, 100 * pl + i, d) //sub cat icon
if GetLocalPlayer() != Player(pl-1) then
call ShowDestructable(d, false)
endif
set i = i + 1
endloop
endif
call SaveInteger(udg_FSS, 612, pl, 0)
set d = null
endfunction
//refresh the subcategory list - icons
function UpdateShopBar takes integer pl returns nothing
local integer mc = LoadInteger(udg_FSS, 2402, pl) - 2000 //selected main category
local integer i = 1
local destructable d
local integer itid
local real x
local real y
call SaveInteger(udg_FSS, 2405, pl, 0)
loop
set d = LoadDestructableHandle(udg_FSS, 2403, 100 * pl + i) //sub cat icon
exitwhen d == null
call RemoveDestructable(d)
set i = i + 1
endloop
if mc > 0 then
set i = 1
loop
set itid = LoadInteger(udg_Shop_Table, mc, i)
exitwhen itid == 0
set x = LoadReal(udg_FSS, 2100 + i, 1)
set y = LoadReal(udg_FSS, 2100 + i, 2)
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, itid), x, y, 5, 0, 0.55, 0)
call SaveDestructableHandle(udg_FSS, 2403, 100 * pl + i, d) //sub cat icon
if GetLocalPlayer() != Player(pl-1) then
call ShowDestructable(d, false)
endif
set i = i + 1
endloop
endif
call SaveInteger(udg_FSS, 612, pl, 0)
set d = null
endfunction
//sell item from inventory to shop
function SellItemToShop takes integer pl, integer slot returns nothing
local integer id
local item itm
local integer charge
local integer dur
local integer cost
local integer pgold
local integer cv = udg_Inv_Unit[pl]
local integer ilv = LoadInteger(udg_Stat_Table, cv, -slot)
if ilv > 0 and slot < 200 then
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
set id = GetHandleId(itm)
if itm != null then
set ilv = GetItemLevel(itm)
set pgold = GetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD)
if ilv >= 100 and ilv < 200 then
if ilv < 110 then
set cost = R2I(LoadInteger(udg_CItem_Table, id, 12) * (R2I(LoadReal(udg_CItem_Table, id, 14)) / R2I(LoadReal(udg_CItem_Table, id, 15)))*0.5)
else
set cost = R2I(LoadInteger(udg_CItem_Table, id, 12)*0.5)
endif
else
set charge = GetItemCharges(itm)
set cost = R2I(LoadInteger(udg_FSS, 602, GetItemTypeId(itm)) * charge * 0.5)
endif
if ilv == 111 then
call EquipAItem (cv, itm, false)
endif
call SetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD, pgold + cost)
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Obtained |cffffff33" + I2S(cost) + "|r gold")
call UpdateGoldinShop (pl)
call RemoveIcon(pl, slot)
call RemoveItemRot (itm, true)
call RemoveItemData(id)
call ClearSlot(cv, slot)
call SetChargesText(pl)
endif
endif
set itm = null
endfunction
//get craft materia amount, because if we use only 1 item type for lv1 and lv100 item then we must make difference at craft materia requiments
function GetCraftMatAmount takes integer pl, integer mc, integer sc, integer ls, integer mat returns integer
local integer id
local integer ilv
local integer c = 0
if mc > 0 and sc > 0 and ls > 0 then
set id = GetItemIdFromShop(pl, mc, sc, ls)
if id != 0 then
set ilv = LoadInteger(udg_FSS, 603, id)
if (ilv >= 100 and ilv < 109) or (ilv == 1902 or ilv == 1903)then
set c = LoadInteger(udg_FSS, 605 + (mat * 2), id) * ls
else
set c = LoadInteger(udg_FSS, 605 + (mat * 2), id)
endif
endif
endif
return c
endfunction
//execute the buy/crafting so create item and give to buyer, set item price, if it is bought then decrease the buyer gold
function BuyItemFromShop takes integer pl, integer mc, integer sc, integer ls, boolean craft returns nothing
local integer ilv
local integer price
local integer id = CheckItemIdFromShop(pl)
local integer pgold
local integer Sp = 0 //space
local integer i = 100
local item itm
local string s
local integer lv = 0
local integer subtype = 0
local integer quality = 2
local integer rnd
local integer greq
local integer ui
local integer ctype = 0//craft type
local integer clv = 0
local integer cv = udg_Inv_Unit[pl]
local unit u = udg_UDexUnits[cv]
local real x = GetUnitX(u)
local real y = GetUnitY(u)
set ls = ls - 2200
if id > 0 then
set ilv = LoadInteger(udg_FSS, 603, id)
set pgold = GetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD)
set price = LoadInteger(udg_FSS, 602, id)
set ui = GetShopUniqueId (mc - 2000, sc - 2100, ls)
if ilv >= 100 and ilv < 200 then
if ui == 0 then
set price = price * ls * 5
endif
elseif ilv != 0 and ui > 0 then
set price = price * ui
elseif ilv == 1902 or ilv == 1903 then
set price = price * ls
endif
if craft then
set price = 0
endif
set greq = R2I(price * (100.00 - udg_Global_Discount[cv]) / 100.00)
if greq <= pgold then
loop
exitwhen i > 119 or Sp != 0
if LoadInteger(udg_Stat_Table, cv, - i) == 0 then
set Sp = i
endif
set i = i + 1
endloop
if Sp > 0 and Sp < 120 then
set ui = GetShopUniqueId (mc - 2000, sc - 2100, ls)
if ilv >= 100 and ilv < 112 then
if ui == 0 then
set subtype = 1
set sc = sc - 2100
if ilv == 105 then
set subtype = 1
set ctype = 2
elseif ilv == 101 or ilv == 102 or ilv == 104 then
set subtype = sc - ((sc / 3) * 3)
set ctype = 2
if subtype == 0 then
set subtype = 3
endif
elseif ilv == 103 then
set subtype = sc
set ctype = 1
elseif ilv > 105 and ilv < 112 then
set ctype = 3
endif
set lv = ls * 5
if craft and ilv < 109 then
if ctype > 0 then
set clv = LoadInteger(udg_Stat_Table, 27000 + cv, ctype)
endif
set rnd = GetRandomInt(0, 99)
if rnd < clv * 2 then
set quality = 3
if rnd < clv / 5 then
set quality = 4
endif
endif
endif
if ilv == 111 then
set i = GenerateEQ (11, 1, -1, lv, lv, x, y, false, -1)
else
set i = GenerateEQ (ilv - 100, subtype, quality, lv, lv, x, y, false, 2)
endif
else
set i = GenerateUnique (pl, ui, x, y)
endif
if craft then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00Craft is done|r")
call SaveStr(udg_CItem_Table, i, 21, GetPlayerName(Player(pl - 1)))
endif
set itm = LoadItemHandle(udg_CItem_Table, i, 100)
set price = LoadInteger(udg_FSS, 602, id)
if ilv >= 100 and ilv < 200 then
if ui == 0 then
set price = price * ls * 5
endif
endif
if price > 0 then
set price = R2I(price * (100.00 - udg_Global_Discount[cv]) / 100.00)
endif
call SaveInteger(udg_CItem_Table, i, 12, R2I(price))
else
if ilv > 1901 and ilv < 1906 then
if ilv == 1902 or ilv == 1904 then
set i = 26
elseif ilv == 1903 or ilv == 1905 then
set i = 30
endif
if ilv < 1904 then
set rnd = ls*25+250
if craft then
set rnd = GetRandomInt(rnd, rnd+50*LoadInteger(udg_Stat_Table, 27000 + cv, 4))
endif
set price = LoadInteger(udg_FSS, 602, id) * ls
set i = CreatePotion(ilv-1901, x, y, ls * 5, i, rnd, 0, i)
else
set price = LoadInteger(udg_FSS, 602, id)
set rnd = 2000 //here a value for pot effect
if craft then
set rnd = GetRandomInt(rnd, rnd+200*LoadInteger(udg_Stat_Table, 27000 + cv, 4))
endif
set i = CreatePotion(ilv-1901, x, y, 0, i, rnd, 0, i)
endif
if price > 0 then
set price = R2I(price * (100.00 - udg_Global_Discount[cv]) / 100.00)
endif
call SaveInteger(udg_CItem_Table, i, 12, R2I(price))
set itm = LoadItemHandle(udg_CItem_Table,i,100)
else
set itm = CreateItem(id, x, y)
if ui == 0 then
set ui = 1
endif
if craft then
set clv = LoadInteger(udg_Stat_Table, 27000 + cv, 4)
set rnd = GetRandomInt(0, 99)
if rnd < clv then
set ui = ui + 1
endif
endif
if ilv != BAG_LEVEL() and ilv != BOX_LEVEL() then
call SetItemCharges(itm, ui)
elseif ilv == BOX_LEVEL() then
call SaveInteger(udg_CItem_Table,i, 3, ui)
endif
endif
endif
if itm != null then
call SaveInteger(udg_FSS, 2402, 40 + pl, 0)
call AddItem2HeroExt (cv, itm, false)
call SetItemInvulnerable(itm, true)
call SetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD, pgold - greq)
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff3333Not space in inventory!|r")
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff3333Not enough gold!|r")
endif
endif
set u = null
endfunction
//refresh craftbox
function UpdateCraftBox takes integer pl returns nothing
local integer mc = LoadInteger(udg_FSS, 2402, pl) //selected main category
local integer sc = LoadInteger(udg_FSS, 2402, 20 + pl) //selected subcategory
local integer ls = LoadInteger(udg_FSS, 2402, 40 + pl) //selected item from list
local integer on = LoadInteger(udg_FSS, 2405, pl)
local integer stat = LoadInteger(udg_FSS, 2405, 20 + pl)
local integer sid = GetItemIdFromShop(pl, mc - 2000, sc - 2100, ls - 2200)
local integer ilv
local integer id
local integer c
local destructable d
local real x
local real y
local integer i = 0
local integer count = 0
local integer ds
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2405, 40 + pl))
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2405, 60 + pl))
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2405, 80 + pl))
if sid > 0 and ls > 0 and mc > 0 and sc > 0 then
set ilv = LoadInteger(udg_FSS, 603, sid)
if on == 1 then
loop
exitwhen i > 2
set id = LoadInteger(udg_FSS, 606 + (i * 2), sid)
set c = GetCraftMatAmount (pl, mc - 2000, sc - 2100, ls - 2200, i + 1)
if id != 0 and c > 0 then
set count = count + 1
set x = LoadReal(udg_FSS, 2303 + i, 1)
set y = LoadReal(udg_FSS, 2303 + i, 2)
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, id), x , y, 5, 0, 0.55, 0)
call SaveDestructableHandle(udg_FSS, 2405, (40 + i * 20) + pl, d)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
else
call ShowDestructable(d, false)
endif
set ds = LoadInteger(udg_FSS, 2405, 180 + (i * 20) + pl)
if LoadInteger(udg_FSS, 2405, 100 + (i * 20) + pl) == c and LoadInteger(udg_FSS, 2405, 180 + (i * 20) + pl) != 0 then
call FadeSlot (pl, 2303 + i, 255, true)
if ds > 0 then
call FadeSlot (pl, ds, 155, true)
endif
else
call FadeSlot (pl, 2303 + i, 100, true)
if ds > 0 then
call FadeSlot (pl, ds, 100, false)
endif
endif
endif
set i = i + 1
endloop
if count > 0 then
call SaveInteger(udg_FSS, 2405, 160 + pl, sid)
endif
else
set i = -1
endif
else
set i = -1
endif
if i == - 1 then
set i = 0
loop
exitwhen i > 2
call SaveInteger(udg_FSS, 2405, 100 + (i * 20) + pl, 0)
set ds = LoadInteger(udg_FSS, 2405, 180 + (i * 20) + pl)
if ds > 0 then
call FadeSlot (pl, ds, 100, false)
endif
call SaveInteger(udg_FSS, 2405, 180 + (i * 20) + pl, 0)
call FadeSlot (pl, 2303 + i, 100, false)
set i = i + 1
endloop
endif
if LoadInteger(udg_FSS, 2405, pl) == 1 then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 2302, 0), true)
else
call ShowDestructable(LoadDestructableHandle(udg_FSS, 2302, 0), false)
endif
if LoadInteger(udg_FSS, 2405, 40 + pl) == 0 then
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 675, i)
exitwhen d == null
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, false)
endif
set i = i + 1
endloop
endif
call ShowCraftBox()
set d = null
endfunction
//show with images a progressbar
function CraftProgressbar takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer pl = LoadInteger(udg_FSS, 2408, GetHandleId(t))
local integer i
local image Img
local integer alpha = 0
if pl == 0 then
call PauseTimer(t)
call DestroyTimer(t)
else
set i = LoadInteger(udg_FSS, 2407, pl * 100) + 1
call SaveInteger(udg_FSS, 2407, pl * 100, i)
set Img = LoadImageHandle(udg_FSS, 2407, 100 * pl + 2 + i)
if GetLocalPlayer() == Player(pl - 1) then
set alpha = 220
endif
call SetImageColor(Img, 255, 255, 255, alpha)
if i < LoadInteger(udg_FSS, 2407, pl * 100 + 1) then
call TimerStart(t, 0.50, false, function CraftProgressbar)
else
set i = 2
loop
exitwhen i > LoadInteger(udg_FSS, 2407, pl * 100 + 1) + 2
set Img = LoadImageHandle(udg_FSS, 2407, 100 * pl + i)
call DestroyImage(Img)
call SaveImageHandle(udg_FSS, 2407, 100 * pl + i, null)
set i = i + 1
endloop
call PauseTimer(t)
call DestroyTimer(t)
call BuyItemFromShop (pl, LoadInteger(udg_FSS, 2402, pl), LoadInteger(udg_FSS, 2402, 20 + pl), LoadInteger(udg_FSS, 2402, 40 + pl), true)
call SaveInteger(udg_FSS, 2405, 0 + pl, 0)
call SaveInteger(udg_FSS, 2405, 160 + pl, 0)
call SaveInteger(udg_FSS, 2405, 20 + pl, 0)
call UpdateCraftBox(pl)
endif
endif
set t = null
endfunction
//check if you inserted enough mat for craft the selected item
function CraftShopItem takes integer pl returns nothing
local integer mc = LoadInteger(udg_FSS, 2402, pl) - 2000 //selected main category
local integer sc = LoadInteger(udg_FSS, 2402, 20 + pl) - 2100 //selected subcategory
local integer ls = LoadInteger(udg_FSS, 2402, 40 + pl) - 2200 //selected item from list
local integer CraftItem = LoadInteger(udg_FSS, 2405, 160 + pl)
local integer count = 3
local integer d
local integer c
local integer i = 100
local integer ilv
local integer ch
local integer cv = udg_Inv_Unit[pl]
local integer id
local integer slot
local integer Sp = 0
local integer v1
local integer v2
local integer v3
local integer v4
local real x
local real y
local item itm
local image Img
local integer alpha = 0
local destructable de
local timer t
loop
exitwhen i > 119 or Sp != 0
if LoadInteger(udg_Stat_Table, cv, - i) == 0 then
set Sp = i
endif
set i = i + 1
endloop
if Sp > 0 then
set i = 0
loop
exitwhen i > 2
set d = LoadInteger(udg_FSS, 606 + (i * 2), CraftItem)
set c = GetCraftMatAmount (pl, mc, sc, ls, i + 1)
if c > 0 and d !=0 then
set slot = LoadInteger(udg_FSS, 2405, 180 + (i * 20) + pl)
if slot >= 100 and slot < 120 then
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
if itm != null then
set id = GetItemTypeId(itm)
set ch = GetItemCharges(itm)
if id == d and ch >= c then
set count = count - 1
endif
endif
endif
else
set count = count - 1
endif
set i = i + 1
endloop
if count == 0 then
set ilv = LoadInteger(udg_FSS, 603, LoadInteger(udg_FSS, 2405, 160 + pl))
if (ilv > 100 and ilv < 200) or (ilv > 1899 and ilv<1906) then
set count = 3
set v1 = GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 1), true)
set v2 = GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 2), true)
set v3 = GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 3), true)
set v4 = GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 4), true)
set i = R2I(ls / 2.00 + 0.5) + 1
if ilv > 100 and ilv < 106 and ilv != 103 and i >= v2 and i - v2 < 2 then
set count = 0
if i - v2 > 0 then
call SaveInteger(udg_Stat_Table, 27000 + cv, 2, LoadInteger(udg_Stat_Table, 27000 + cv, 2) + 1)
endif
elseif ilv == 103 and i >= v1 and i - v1 < 2 then
set count = 0
if i - v1 > 0 then
call SaveInteger(udg_Stat_Table, 27000 + cv, 1, LoadInteger(udg_Stat_Table, 27000 + cv, 1) + 1)
endif
elseif ((ilv == 106 or ilv == 108) and i >= v3 and i - v3 < 2) or ((ilv == 109 or ilv == 110) and v3 > 2) then
set count = 0
if (ilv == 106 or ilv == 108) and i - v3 > 0 then
call SaveInteger(udg_Stat_Table, 27000 + cv, 3, LoadInteger(udg_Stat_Table, 27000 + cv, 3) + 1)
endif
elseif ilv == 1900 or ilv == 1901 then
set count = 0
//call SaveInteger(udg_Stat_Table, 27000 + cv, 4, LoadInteger(udg_Stat_Table, 27000 + cv, 4) + 1)
elseif (ilv == 1902 or ilv == 1903) and i >= v2 and i - v2 < 2 then
set count = 0
if i - v4 > 0 then
call SaveInteger(udg_Stat_Table, 27000 + cv, 4, LoadInteger(udg_Stat_Table, 27000 + cv, 4) + 1)
endif
elseif (ilv == 1904 or ilv == 1905) and v4 > 3 then
set count = 0
if v4 == 4 or v4 == 5 then
call SaveInteger(udg_Stat_Table, 27000 + cv, 4, LoadInteger(udg_Stat_Table, 27000 + cv, 4) + 1)
endif
endif
else
set count = 0
endif
if count == 0 then
set i = 0
loop
exitwhen i > 2
set d = LoadInteger(udg_FSS, 606 + (i * 2), CraftItem)
set c = GetCraftMatAmount (pl, mc, sc, ls, i + 1)
if c > 0 and d != 0 then
set slot = LoadInteger(udg_FSS, 2405, 180 + (i * 20) + pl)
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
set ch = GetItemCharges(itm)
if (ch - c) == 0 then
call RemoveItem(itm)
call RemoveIcon(pl, slot)
call ClearSlot(cv, slot)
else
call SetItemCharges(itm, ch - c)
endif
endif
set i = i + 1
endloop
call FadeSlot (pl, 2303, 100, true)
call FadeSlot (pl, 2304, 100, true)
call FadeSlot (pl, 2305, 100, true)
call SetChargesText(pl)
call SaveInteger(udg_FSS, 2405, 20 + pl, 1)
set x = LoadReal(udg_FSS, 0, 1)
set y = LoadReal(udg_FSS, 0, 2)
set i = 0
loop
set de = LoadDestructableHandle(udg_FSS, 675, i)
exitwhen de == null
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(de, true)
endif
set i = i + 1
endloop
if GetLocalPlayer() == Player(pl - 1) then
set alpha = 100
endif
set i = 873
set c = pl * 100 + 2
loop
exitwhen i > 1173
set c = c + 1
set Img = CreateImage("16x16r.blp", 16.00, 16.00, 1, x + i - 12, y + 280, 1, 0, 0, 0, 1)
call SetImageRenderAlways (Img, true)
call SetImageColor(Img, 255, 255, 255, alpha)
call SetImageConstantHeight (Img, true, 35)
call SaveImageHandle(udg_FSS, 2407, c, Img)
set i = i + 16
endloop
call SaveInteger(udg_FSS, 2407, pl * 100, 0)
call SaveInteger(udg_FSS, 2407, pl * 100 + 1, 19)
set t = CreateTimer()
call SaveInteger(udg_FSS, 2408, GetHandleId(t), pl)
call TimerStart(t, 0.50, false, function CraftProgressbar)
set t = null
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff3333Too low your craft skill for this item!|r")
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff3333Drag items to craft slots!|r")
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff3333Not space in inventory!|r")
endif
set itm = null
set Img = null
endfunction
//the shop handeling function, this handle what must to do the shop when u click to things, like select item, sell, buy, craft, drag to craftbox the items etc
function SelectShopSlot takes integer pl, integer slot returns nothing
local integer mc = LoadInteger(udg_FSS, 2402, pl) //selected main category
local integer sc = LoadInteger(udg_FSS, 2402, 20 + pl) //selected subcategory
local integer ls = LoadInteger(udg_FSS, 2402, 40 + pl) //selected item from list
local real x1 = LoadReal(udg_FSS, 0, 1)
local destructable d
local real x
local real y
local integer id
local integer n1
local integer n2
local integer n3
local integer cv = udg_Inv_Unit[pl]
local item itm
set d = LoadDestructableHandle(udg_FSS, 2402, 100 + pl) //selected main category destructable
if ((slot >= 2000 and slot < 2100 and slot != mc)) and d != null then
call RemoveDestructable(d)
endif
set d = LoadDestructableHandle(udg_FSS, 2402, 120 + pl) //selected sub category destructable
if (((slot >= 2100 and slot < 2200 and slot != sc)) or (slot >= 2000 and slot < 2100)) and d != null then
call RemoveDestructable(d)
endif
set d = LoadDestructableHandle(udg_FSS, 2402, 140 + pl) //selected item from list destructable
if (((slot >= 2200 and slot < 2300 and slot != ls)) or (slot >= 2000 and slot < 2100) or (slot >= 2100 and slot < 2200)) and d != null then
call RemoveDestructable(d)
endif
set d = LoadDestructableHandle(udg_FSS, 2402, 300 + pl) //selected item from inevntory destructable
if d != null then
call RemoveDestructable(d)
endif
if udg_Camera_Lock[pl] == 2 then
if slot > 0 then
set x = LoadReal(udg_FSS, slot, 1)
set y = LoadReal(udg_FSS, slot, 2)
if slot < 2000 then
call SaveInteger(udg_FSS, 2402, 320 + pl, slot)
if (udg_Selected_Slot[pl] == slot and slot < 200) or (udg_Selected_Slot[pl] < 200 and LoadInteger(udg_Stat_Table, cv, - slot) == 0) then
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 300 + pl))
set udg_Selected_Slot[pl] = 0
elseif (udg_Selected_Slot[pl] == 0 or udg_Selected_Slot[pl] < 200) and LoadInteger(udg_Stat_Table, cv, - slot) > 0 then
set d = CreateDestructableZ(udg_Icons[24], x , y, 5, 0, 0.55, 0)
call SaveDestructableHandle(udg_FSS, 2402, 300 + pl, d)
call ShowDestructable(d, false)
set udg_Selected_Slot[pl] = slot
elseif GetItemIdFromShop(pl, mc - 2000, sc - 2100, udg_Selected_Slot[pl] - 2200) > 0 and udg_Selected_Slot[pl] >= 2200 or udg_Selected_Slot[pl] < 2300 then
set n1 = GetItemIdFromShop(pl, mc - 2000, sc - 2100, udg_Selected_Slot[pl] - 2200)
set n2 = LoadInteger(udg_Stat_Table, cv, -slot)
set n3 = 0
if n2 > 0 then
set n3 = GetItemTypeId(LoadItemHandle(udg_Stat_Table, cv, slot))
endif
if n2 != 0 and (LoadInteger(udg_FSS, 606, n1) == n3 or LoadInteger(udg_FSS, 608, n1) == n3 or LoadInteger(udg_FSS, 610, n1) == n3) then
set d = CreateDestructableZ(udg_Icons[24], x , y, 5, 0, 0.55, 0)
call SaveDestructableHandle(udg_FSS, 2402, 300 + pl, d)
call ShowDestructable(d, false)
set udg_Selected_Slot[pl] = slot
else
call BuyItemFromShop (pl, mc, sc, ls, false)
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 140 + pl))
// call SaveInteger(udg_FSS, 2402, 40 + pl, 0)
set udg_Selected_Slot[pl] = 0
call SaveInteger(udg_FSS, 2405, pl, 0)
call ShowCraftBox()
call UpdateCraftBox(pl)
endif
endif
elseif slot < 2100 then
if mc != slot then
set d = CreateDestructableZ(udg_Icons[24], x , y , 5, 0, 0.55, 0)
call SaveDestructableHandle(udg_FSS, 2402, 100 + pl, d)
call ShowDestructable(d, false)
call SaveInteger(udg_FSS, 2405, pl, 0)
call SaveInteger(udg_FSS, 2402, pl, slot)
call SaveInteger(udg_FSS, 2402, 20 + pl, slot)
call SaveInteger(udg_FSS, 2402, 40 + pl, slot)
call UpdateShopBar(pl)
call UpdateShopList(pl)
set udg_Selected_Slot[pl] = 0
endif
elseif slot < 2200 then
//call DisplayTextToPlayer(Player(pl - 1), 0, 0, I2S(mc)+I2S(sc)+I2S(LoadInteger(udg_Shop_Table, mc-2000, slot - 2100)))
if mc != 0 and sc != slot and LoadInteger(udg_Shop_Table, mc - 2000, slot - 2100) != 0 then
set d = CreateDestructableZ(udg_Icons[24], x , y , 5, 0, 0.55, 0)
call SaveDestructableHandle(udg_FSS, 2402, 120 + pl, d)
call ShowDestructable(d, false)
call SaveInteger(udg_FSS, 2405, pl, 0)
call SaveInteger(udg_FSS, 2402, 20 + pl, slot)
call SaveInteger(udg_FSS, 2402, 40 + pl, slot)
call UpdateShopList(pl)
set udg_Selected_Slot[pl] = 0
endif
elseif slot < 2300 then
if udg_Selected_Slot[pl] == 0 or udg_Selected_Slot[pl] > 200 then
if udg_Selected_Slot[pl] == slot then
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 140 + pl))
call SaveInteger(udg_FSS, 2402, 40 + pl, 0)
set udg_Selected_Slot[pl] = 0
call SaveInteger(udg_FSS, 2405, pl, 0)
call ShowCraftBox()
else
set id = GetItemIdFromShop(pl, mc - 2000, sc - 2100, slot - 2200)
if sc != 0 and ls != slot and id != 0 then
call SaveInteger(udg_FSS, 2402, 40 + pl, slot)
set d = CreateDestructableZ(udg_Icons[24], x , y , 5, 0, 0.55, 0)
call SaveDestructableHandle(udg_FSS, 2402, 140 + pl, d)
call ShowDestructable(d, false)
call SaveInteger(udg_FSS, 2402, 40 + pl, slot)
set udg_Selected_Slot[pl] = slot
call SaveInteger(udg_FSS, 2405, pl, 0)
call UpdateCraftBox(pl)
if LoadInteger(udg_FSS, 606, id) != 0 and LoadInteger(udg_FSS, 607, id) != 0 then
call SaveInteger(udg_FSS, 2405, pl, 1)
call SaveInteger(udg_FSS, 2405, 180 + pl, 0)
call SaveInteger(udg_FSS, 2405, 200 + pl, 0)
call SaveInteger(udg_FSS, 2405, 220 + pl, 0)
call SaveInteger(udg_FSS, 2405, -100 -pl, GetCraftMatAmount (pl, mc - 2000, sc - 2100, slot - 2200, 1))
call SaveInteger(udg_FSS, 2405, -120 -pl, GetCraftMatAmount (pl, mc - 2000, sc - 2100, slot - 2200, 2))
call SaveInteger(udg_FSS, 2405, -140 -pl, GetCraftMatAmount (pl, mc - 2000, sc - 2100, slot - 2200, 3))
endif
elseif id == 0 then
call SaveInteger(udg_FSS, 2405, pl, 0)
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 140 + pl))
call SaveInteger(udg_FSS, 2402, 40 + pl, 0)
set udg_Selected_Slot[pl] = 0
call ShowCraftBox()
endif
endif
elseif LoadInteger(udg_Stat_Table, cv, -udg_Selected_Slot[pl]) > 0 and udg_Selected_Slot[pl] < 200 then
call SellItemToShop (pl, udg_Selected_Slot[pl])
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 300 + pl))
set udg_Selected_Slot[pl] = 0
call SaveInteger(udg_FSS, 2402, 320 + pl, 0)
call SaveInteger(udg_FSS, 2402, 40 + pl, 0)
call SaveInteger(udg_FSS, 2405, pl, 0)
endif
elseif slot < 2306 then
if LoadInteger(udg_FSS, 2405, pl) == 1 then
set n1 = LoadInteger(udg_FSS, 2402, 320 + pl)
set n2 = LoadInteger(udg_FSS, 2405, 180 + ((slot - 2303) * 20) + pl)
if n1 > 0 and n1 < 200 then
set itm = LoadItemHandle(udg_Stat_Table, cv, n1)
if itm != null then
set id = GetItemTypeId(itm)
set n2 = GetItemCharges(itm)
set n1 = LoadInteger(udg_FSS, 2405, 160 + pl)
set n3 = GetCraftMatAmount (pl, mc - 2000, sc - 2100, ls - 2200, slot - 2302)
if id == LoadInteger(udg_FSS, 606 + ((slot - 2303) * 2), n1) and n2 >= n3 then
call SaveInteger(udg_FSS, 2405, 180 + (20 * (slot - 2303)) + pl, udg_Selected_Slot[pl])
call SaveInteger(udg_FSS, 2405, 100 + (20 * (slot - 2303)) + pl, n3)
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Required |cffffff00" + GetObjectName(LoadInteger(udg_FSS, 606 + ((slot - 2303) * 2), n1)) + "|r |cff9999ff x " + I2S(n3) + "|r")
endif
endif
elseif n1 == 0 and n2 > 0 then
call SaveInteger(udg_FSS, 2405, 180 + ((slot - 2303) * 20) + pl, 0)
call FadeSlot (pl, slot, 100, true)
call FadeSlot (pl, n2, 100, false)
endif
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 300 + pl))
call SaveInteger(udg_FSS, 2402, 320 + pl, 0)
set udg_Selected_Slot[pl] = 0
endif
endif
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
endif
else
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 100 + pl))
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 120 + pl))
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 140 + pl))
endif
if slot > 200 then
call ShowCraftBox()
call UpdateCraftBox(pl)
endif
call UpdateGoldinShop (pl)
call SetChargesText(pl)
set d = null
endfunction
//this handle the switch/turn off between full screen window types
function WindowTransition takes integer pl, integer w1, integer w2 returns nothing
local integer i = 1
local integer cv = udg_Inv_Unit[pl]
local integer id
local destructable d
local integer c
call DestroyMultiboard(udg_Mb_Table[pl])
set udg_Mb_Type[pl] = 0
if w1 != 3 then
set udg_Inv_Prev[pl] = w1
endif
if w1 == 1 then
set udg_Selected_Slot[pl] = 0
call FlushFT_Stat(pl)
set udg_TradeReq[pl] = 0
set udg_TradeReq[udg_Trader[pl]] = 0
loop
exitwhen i == 206
call DestroyTextTag (LoadTextTagHandle(udg_FSS, pl + 1000, i))
call SaveTextTagHandle(udg_FSS, pl + 1000, i, null)
call RemoveIcon(pl, i)
if i==119 then
set i = 199
endif
set i = i + 1
endloop
if udg_Trader[pl] > 0 then
set i = udg_Trader[pl]
set udg_Trader[pl] = 0
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 1250 + pl, 6))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 1250 + i, 6))
call WindowTransition (i, 1, 0)
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00Trade was canceled .")
call SaveInteger(udg_FSS, 1275 + pl, 1, 0)
call SaveInteger(udg_FSS, 1250 + pl, 7, 0)
set i = 1200
loop
exitwhen i == 1212
call RemoveIcon(pl, i)
if i < 1206 then
if LoadInteger(udg_FSS, 1249 + pl, i) > 0 then
call FadeSlot (pl, LoadInteger(udg_FSS, 1249 + pl, i), 255, false)
call SaveInteger(udg_FSS, 1249 + pl, i, 0)
endif
endif
set i = i + 1
endloop
endif
set i = 1
loop
exitwhen i == 10
if i == 1 or i == 2 or i == 5 or i == 9 then
call DestroyEffect(LoadEffectHandle(udg_FSS, 650 + pl, i))
elseif i == 3 or i == 4 then
call DestroyEffect(LoadEffectHandle(udg_FSS, 650 + pl, i))
call DestroyEffect(LoadEffectHandle(udg_FSS, 650 + pl, i + 100))
endif
set i = i + 1
endloop
if LoadUnitHandle(udg_FSS, 551, pl) != null then
call RemoveUnit(LoadUnitHandle(udg_FSS, 551, pl))
call SaveUnitHandle(udg_FSS, 551, pl, null)
endif
call RemoveAttachment (cv, 3)
call AddAttachment (cv, 3)
call RemoveDestructable (udg_Selector[pl])
set udg_Selected_Slot[pl] = 0
set udg_Stop_Stack[cv] = false
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 60 + pl))
set c = LoadInteger(udg_FSS, 0, - pl * 20)
if c > 0 then
set i = 1
loop
exitwhen i > c
call ShowUnit(LoadUnitHandle( udg_FSS, 0, - pl * 20 - i * 2 - 1), false)
call RemoveUnit(LoadUnitHandle( udg_FSS, 0, - pl * 20 - i * 2 - 1))
call DestroyEffect(LoadEffectHandle(udg_FSS, 0, - pl * 20 - i * 2))
call RemoveSavedHandle(udg_FSS, 0, - pl * 20 - i * 2 - 1)
call RemoveSavedHandle(udg_FSS, 0, - pl * 20 - i * 2)
set i = i + 1
endloop
call SaveInteger(udg_FSS, 0, - pl * 20, 0)
endif
call ShowTradeWindow()
elseif w1 == 2 then
set i = 100
loop
exitwhen i == 120
call RemoveIcon(pl, i)
set i = i + 1
endloop
//remove the welcome floating text and the gold floating text
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 60 + pl))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 80 + pl))
//remove the 3 selector
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 100 + pl))
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 120 + pl))
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 140 + pl))
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2402, 300 + pl))
//clear select amounts
call SaveInteger(udg_FSS, 2402, 0 + pl, 0)
call SaveInteger(udg_FSS, 2402, 20 + pl, 0)
call SaveInteger(udg_FSS, 2402, 40 + pl, 0)
call SaveInteger(udg_FSS, 2402, 320 + pl, 0)
//remove the sub category
set i = 1
loop
set d = LoadDestructableHandle(udg_FSS, 2403, 100 * pl + i)
exitwhen d == null
call RemoveDestructable(d)
set i = i + 1
endloop
set udg_Selected_Slot[pl] = 0
call UpdateShopList(pl)
call UpdateCraftBox(pl)
set udg_Selected_Slot[pl] = 0
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 180 + pl))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 200 + pl))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 220 + pl))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 240 + pl))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 260 + pl))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 280 + pl))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 300 + pl))
call SaveTextTagHandle(udg_FSS, 2402, 180 + pl, null)
call SaveTextTagHandle(udg_FSS, 2402, 200 + pl, null)
call SaveTextTagHandle(udg_FSS, 2402, 220 + pl, null)
call SaveTextTagHandle(udg_FSS, 2402, 240 + pl, null)
call SaveTextTagHandle(udg_FSS, 2402, 260 + pl, null)
call SaveTextTagHandle(udg_FSS, 2402, 280 + pl, null)
call SaveTextTagHandle(udg_FSS, 2402, 300 + pl, null)
set i = 2200
loop
exitwhen i > 2230
call DestroyTextTag (LoadTextTagHandle(udg_FSS, 1000 + pl, i))
call SaveTextTagHandle(udg_FSS, 1000 + pl, i, null)
set i = i + 1
endloop
set i = 100
loop
exitwhen i > 119
call DestroyTextTag (LoadTextTagHandle(udg_FSS, 1000 + pl, i))
call SaveTextTagHandle(udg_FSS, 1000 + pl, i, null)
set i = i + 1
endloop
elseif w1 == 3 then
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 60 + pl))
set i = 2201
loop
exitwhen i > 2224
call DestroyTextTag (LoadTextTagHandle(udg_FSS, 1000 + pl, i))
call SaveTextTagHandle(udg_FSS, 1000 + pl, i, null)
set i = i + 1
endloop
set i = 100
loop
exitwhen i == 2225
call RemoveIcon(pl, i)
set i = i + 1
if i == 120 then
set i = 2201
endif
endloop
call DestroyMultiboard(udg_Mb_Table[pl])
set udg_Mb_Type[pl] = 0
call RemoveDestructable (udg_Selector[pl])
set udg_Selected_Slot[pl] = 0
endif
set d = LoadDestructableHandle(udg_FSS, 2100, 6)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, false)
endif
set udg_Camera_Lock[pl] = w2
call CWInterface()
if w2 == 1 then
call StartInventory(pl)
elseif w2 == 2 then
call StartShop(pl)
elseif w2 == 3 then
call StartBagpack(pl)
call SetChargesText(pl)
elseif w1 != 0 and w2 == 0 then
call DisableCamLock(pl)
set udg_Inv_Bag[pl] = 0
set udg_Inv_Unit[pl] = 0
set udg_Inv_Prev[pl] = 0
endif
set d = null
endfunction
//item handle the clicking in inventory
function SwitchItem takes integer pl, integer slot1, integer slot2 returns nothing
local integer ilv1 = 0
local integer ilv2 = 0
local integer n1
local integer n2
local integer n3
local integer n4
local integer n5
local integer n6
local integer lvreq
local integer id
local real dur
local item itm1
local item itm2
local string s
local integer lock = LoadInteger(udg_FSS, 1275 + pl, 1)
local boolean abort = false
local integer cv = udg_Inv_Unit[pl]
local unit u = udg_UDexUnits[cv]
set udg_Stop_Stack[cv] = true
// ---------------slot value and click type checking-------------------
if slot2 < 200 then
set itm2 = LoadItemHandle(udg_Stat_Table, cv, slot2)
elseif slot2 < 300 then
set itm2 = UnitItemInSlot(u, slot2 - 200)
endif
if itm2 == null then
set ilv2 = 0
else
call Mb_ToolTip(pl, pl, slot)
endif
endif
endif
set u = null
endfunction
//===========================================================================
function InitTrig_ClickToTrackable takes nothing returns nothing
set gg_trg_ClickToTrackable = CreateTrigger()
call TriggerAddAction( gg_trg_ClickToTrackable, function Click_To_Trackable )
endfunction