//-------------------------------------------------------------------------
//special effect paths, example for potion
constant function EFFECT takes integer i returns string
if i == 1 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodPeasant.mdl"
elseif i == 26 then
return "Abilities\\Spells\\Human\\Heal\\HealTarget.mdl"
elseif i == 30 then
return "Abilities\\Spells\\Undead\\ReplenishMana\\SpiritTouchTarget.mdl"
else
return ""
endif
endfunction
//where we want attach the effect on unit
constant function EFFECT_POINT takes integer i returns string
if i == 1 then
return "chest"
elseif i == 26 then
return "origin"
elseif i == 30 then
return "origin"
else
return ""
endif
endfunction
//max gold amount what can gain a player, can't be higher than in Gameplay Constants
constant function MAX_GOLD takes nothing returns integer
return 1000000
endfunction
//here i declare the max refine what possible
constant function MAX_REFINE takes nothing returns integer
return 10
endfunction
//max hero level on map (can't be higher than the max hero level in Gameplay Constants)
constant function MAX_HERO_LEVEL takes nothing returns integer
return 100
endfunction
//stat point per level what u can share between str/agi and int
constant function STAT_PER_LV takes nothing returns integer
return 5
endfunction
//weapon dmg modifier function (for shop tooltip and item create)
constant function WEP_MOD takes nothing returns real
return 12.2
endfunction
//start stat points what get hero after it was created
constant function START_POINT takes nothing returns integer
return 5
endfunction
//max stack/charge for stackable items
constant function CHARGE_MAX takes nothing returns integer
return 99
endfunction
//max bag zise
constant function BAG_SIZE_MAX takes nothing returns integer
return 24
endfunction
//max droped item amount on map
constant function MAX_ITEM takes nothing returns integer
return 4
endfunction
//default (without any addon) critical strike damage
constant function DEFAULT_CRITICAL_DAMAGE takes nothing returns integer
return 150
endfunction
//melee villager gero unit type id or raw code
constant function HERO_MELEE takes nothing returns integer
return 'H000'
endfunction
//ranged villager hero unit type id or raw code
constant function HERO_RANGED takes nothing returns integer
return 'H001'
endfunction
//socket gem item level
constant function GEM_LEVEL takes nothing returns integer
return 200
endfunction
//bag item level
constant function BAG_LEVEL takes nothing returns integer
return 199
endfunction
//Surprise box item level
constant function BOX_LEVEL takes nothing returns integer
return 198
endfunction
//dummy unit rawcode what we use for decoration in inventory
constant function DUMMY_ID takes nothing returns integer
return 'h002'
endfunction
//Harvest ability, it is used for harvesting, channel based ability,what let u go to item even ur inventory is full
constant function HARVEST_ID takes nothing returns integer
return 'A00H'
endfunction
//Melee2Ranged ability raw code
constant function MELEE2RANGED_ID takes nothing returns integer
return 'A00D'
endfunction
//Bear form ability for instant special effect destroy
constant function BEARFORM_ID takes nothing returns integer
return 'A00C'
endfunction
//Bear form ability for Dummy Villager for instant special effect destroy
constant function DBEARFORM_ID takes nothing returns integer
return 'A00A'
endfunction
// Add hp ability raw code
constant function ADDHP_ID takes nothing returns integer
return 'A003'
endfunction
// Add mp ability raw code
constant function ADDMP_ID takes nothing returns integer
return 'A004'
endfunction
// Minimum range
constant function MIN_RANGE takes nothing returns integer
return 90000 //300 range
endfunction
//dummy caster unit unit type id
constant function DUMMY_CASTER_ID takes nothing returns integer
return 'e000'
endfunction
//---------------------------------------
//--------save load constant functions-----------
constant function SL_CODE takes nothing returns string
return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$&/+-=[]^_`{}~()*"
endfunction
constant function SL_SAVE_COORD takes nothing returns boolean
return true
endfunction
constant function SL_SAVE_STAT takes nothing returns boolean
return true
endfunction
constant function SL_SAVE_LUMBER takes nothing returns boolean
return true
endfunction
constant function SL_SAVE_GOLD takes nothing returns boolean
return true
endfunction
constant function SL_CRC_LEN takes nothing returns integer
return 2
endfunction
constant function SL_BIND_TO_PLAYER takes nothing returns boolean
return true
endfunction
constant function SL_FOLDER takes nothing returns string
return "SaveLoadCode"
endfunction
//item type to gem type
function ItemType2GemType takes integer i returns integer
if i == 1 or i == 2 or i == 4 then
return 1
elseif i == 3 then
return 2
elseif i == 9 then
return 3
else
endif
endfunction
function SL_IntegerToCode takes integer i, integer len returns string
local string s = ""
local integer m = 0
local integer c
local string ss = SL_CODE()
local integer l = StringLength(ss)
local boolean e = false
if l < 36 then
set c = 7
elseif l < 74 then
set c = 6
else
set c = 5
endif
if i <= Pow(l, c - 1) then
loop
set c = c - 1
if c > 0 then
if not e and i >= Pow(l, c) then
set e = true
endif
set m = i / R2I(Pow(l, c))
set i = i - m * R2I(Pow(l, c))
if not e and m == 0 then
else
set s = s + SubString(ss, m, m + 1)
endif
else
set m = ModuloInteger(i, l)
set s = s + SubString(ss, m, m + 1)
set i = 0
endif
exitwhen c == 0
endloop
endif
if len != - 1 then
loop
exitwhen StringLength(s) >= len
set s = SubString(ss, 0, 1) + s
endloop
endif
return s
endfunction
function SL_CodeToInteger takes string c returns integer
local integer l = StringLength(c)
local integer m = StringLength(SL_CODE())
local integer i = 0
local integer char
local string s
local integer int = 0
if l > 0 then
loop
exitwhen i == l
set s = SubString(c, i, i + 1)
if s != StringCase(s, true) then
set char = LoadInteger(udg_SL_HASHTABLE, StringHash(s), 2)
else
set char = LoadInteger(udg_SL_HASHTABLE, StringHash(s), 1)
endif
if char !=0 or i > 0 then
set int = int + R2I(Pow(m, l - i - 1)) * char
endif
set i = i + 1
endloop
endif
set s = null
return int
endfunction
function SL_GetIntegerSize takes integer a returns integer
local integer base = StringLength(SL_CODE())
local integer max = 4
local integer i = 0
if base < 64 then
set max = 6
elseif base < 74 then
set max = 5
endif
loop
set i = i + 1
exitwhen i > max
if a < R2I(Pow(base,i)) then
return i
endif
endloop
endfunction
function SL_CodeCheckSum takes string c, player p returns string
local string EC = SL_CODE()
local integer cl = SL_CRC_LEN()
local integer MaxV = R2I(Pow(StringLength(EC), cl))
local integer i
if SL_BIND_TO_PLAYER() then
set i = StringHash(c + StringCase(GetPlayerName(p), false))
else
set i = StringHash(c)
endif
if i < 0 then
set i = i * - 1
endif
if i > MaxV then
set i = ModuloInteger(i, MaxV)
endif
return SL_IntegerToCode(i, cl)
endfunction
function SL_CodeValidation takes player p, string c returns boolean
local integer l = StringLength(c)
local integer cl = SL_CRC_LEN()
if StringLength(c) < (2+cl) then
return false
else
return SL_CodeCheckSum(SubString(c, 0, l-cl), p) == SubString(c, l-cl, l)
endif
endfunction
constant function WeaponDamageModifier takes integer subtype returns integer
if subtype == 1 then
return 12
elseif subtype == 2 then
return 11
elseif subtype == 3 then
return 20
elseif subtype == 4 then
return 16
elseif subtype == 5 then
return 15
elseif subtype == 6 then
return 14
elseif subtype == 7 then
return 7
elseif subtype == 8 then
return 14
elseif subtype == 9 then
return 16
else
return 0
endif
endfunction
constant function WeaponMinDamageModifier takes integer subtype returns real
if subtype == 1 then
return .8
elseif subtype == 2 then
return .85
elseif subtype == 3 then
return .5
elseif subtype == 4 then
return .70
elseif subtype == 5 then
return .77
elseif subtype == 6 then
return .98
elseif subtype == 7 then
return .78
elseif subtype == 8 then
return .87
elseif subtype == 9 then
return .79
else
return 1
endif
endfunction
function StringColoring takes string s, integer red1, integer green1, integer blue1, integer red2, integer green2, integer blue2 returns string
local integer len = StringLength(s)
local real redX = (red1 - red2) / len
local real greenX = (green1 - green2) / len
local real blueX = (blue1 - blue2) / len
local integer redY
local integer greenY
local integer blueY
local integer redZ
local integer greenZ
local integer blueZ
local string hexS = "0123456789abcdef"
local string CS = ""
local integer i = 1
loop
exitwhen i > len
set redY = R2I(red1 - redX * i)
set redZ = redY / 16
set greenY = R2I(green1 - greenX * i)
set greenZ = greenY / 16
set blueY = R2I(blue1 - blueX * i)
set blueZ = blueY / 16
set CS = CS + "|cff" + SubString(hexS, redZ, redZ + 1) + SubString(hexS, redY - redZ * 16, redY - redZ * 16 + 1) + SubString(hexS, greenZ, greenZ + 1) + SubString(hexS, greenY - greenZ * 16, greenY - greenZ * 16 + 1) + SubString(hexS, blueZ, blueZ + 1) + SubString(hexS, blueY - blueZ * 16, blueY - blueZ * 16 + 1) + SubString(s, i - 1, i) + "|r"
set i = i + 1
endloop
set hexS = null
set s = CS
set CS = null
return s
//StringColoring(, 100, 100, 255, 255, 255, 255)
endfunction
//-------------------------------------------------------------------------
// BAG and FLOATING TEXT FUNCTION
//-------------------------------------------------------------------------
function AddItemToBag takes unit u, item bag, item itm returns boolean
local integer bagid = GetHandleId(bag)
local integer count = LoadInteger(udg_CItem_Table, bagid, 0)
local integer id = GetHandleId(itm)
local integer pl
local integer i
local destructable d
local real x
local real y
if count < BAG_SIZE_MAX() then
// if IsItemVisible(whichItem)
if UnitHasItem(u, itm) or not IsItemVisible(itm) then
if UnitHasItem(u, itm) then
call UnitRemoveItem(u, itm)
call SetItemVisible(itm, false)
endif
set i = 1
loop
exitwhen LoadItemHandle(udg_CItem_Table, bagid, i) == null
set i = i + 1
endloop
call SaveInteger(udg_CItem_Table, bagid, 0, count + 1)
call SaveItemHandle(udg_CItem_Table, bagid, i, itm)
set pl = GetPlayerId(GetOwningPlayer(u)) + 1
if udg_Camera_Lock[pl] == 3 and udg_Inv_Bag[pl] == bagid then
set x = LoadReal(udg_FSS, i + 2200, 1)
set y = LoadReal(udg_FSS, i + 2200, 2)
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, GetItemTypeId(itm)), x, y, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + pl, i + 2200, d)
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
set d = null
endif
return true
else
return false
endif
else
call DisplayTextToPlayer (GetOwningPlayer(u), 0, 0, "|cffffff00Bag already full, can add more item|r")
return false
endif
endfunction
function RemoveBagContent takes integer bagid returns nothing
local integer max = LoadInteger(udg_CItem_Table, bagid, 0)
local integer i = 1
local integer a
local item itm
loop
exitwhen i > max
set itm = LoadItemHandle(udg_CItem_Table, bagid, i)
if itm != null then
set a = GetHandleId(itm)
call FlushChildHashtable(udg_CItem_Table, a)
endif
set i = i + 1
endloop
set itm = null
endfunction
function FT takes player p1, player p2, string txt, real fsize, unit u, integer speed, integer red, integer green, integer blue, integer alpha returns nothing
local real x
local real y
local real diff
local texttag tt
if IsUnitVisible(u, GetLocalPlayer()) and (GetLocalPlayer() == p1 or GetLocalPlayer() == p2) and udg_Camera_Lock[GetPlayerId(GetLocalPlayer()) + 1] == 0 then
set x = GetUnitX( u )
set y = GetUnitY( u )
set diff = StringLength( txt ) * fsize / 2.00 + 1
set tt = CreateTextTag( )
call SetTextTagText( tt, txt, fsize * 0.023 )
call SetTextTagPos( tt, x - diff, y, 100.00 )
call SetTextTagColor( tt, red, green, blue, alpha )
call SetTextTagPermanent( tt, false )
call SetTextTagLifespan( tt, 4.50 )
call SetTextTagFadepoint( tt, 2.50 )
call SetTextTagVelocity( tt, speed * 0.71 / 128 * Cos( 3.14159 / 2 ), speed * 0.71 / 128 * Sin( 3.14159 / 2 ) )
set tt = null
endif
endfunction
function FT_Ex takes player p1, player p2, string txt, real fsize, unit u, integer speed, integer red, integer green, integer blue, integer alpha, integer dir returns nothing
local real x
local real y
local real diff
local texttag tt
if IsUnitVisible(u, GetLocalPlayer()) and (GetLocalPlayer() == p1 or GetLocalPlayer() == p2) and udg_Camera_Lock[GetPlayerId(GetLocalPlayer()) + 1] == 0 then
set x = GetUnitX( u )
set y = GetUnitY( u )
set diff = StringLength( txt ) * fsize / 2.00 + 1
set tt = CreateTextTag( )
call SetTextTagText( tt, txt, fsize * 0.023 )
call SetTextTagPos( tt, x - diff, y, 100.00 )
call SetTextTagColor( tt, red, green, blue, alpha )
call SetTextTagPermanent( tt, false )
call SetTextTagLifespan( tt, 4.50 )
call SetTextTagFadepoint( tt, 2.50 )
set x = speed * 0.71 / 128
call SetTextTagVelocity( tt, x * Cos( dir * bj_DEGTORAD ), x * Sin( dir * bj_DEGTORAD ) )
set tt = null
endif
endfunction
//-------------------------------------------------------------------------
// OTHER ITEM RELATED FUNCTIONS
//-------------------------------------------------------------------------
function itype2TOitemId takes integer itype, integer subtype, integer quality returns integer
if itype == 1 then
if quality > 5 then
return 'ram3'
elseif quality > 2 then
return 'rde4'
else
return 'ckng'
endif
elseif itype == 2 then
if quality > 5 then
return 'rnsp'
elseif quality > 2 then
return 'amrc'
else
return 'rin1'
endif
elseif itype == 3 then
if subtype == 1 then //short sword
return 'rat9'
elseif subtype == 2 then // mace
return 'rde3'
elseif subtype == 3 then // axe / hammer
if quality > 5 then
return 'ofro'
else
return 'rde1'
endif
elseif subtype == 4 then // polearm
return 'evtl'
elseif subtype == 5 then // long sword
return 'ajen'
elseif subtype == 6 then // bow
return 'lgdh'
elseif subtype == 7 then // dagger
return 'desc'
elseif subtype == 8 then // wand
return 'ward'
elseif subtype == 9 then // staff
return 'brac'
endif
elseif itype == 4 then //shoes or boot
if quality > 5 then
return 'ram1'
elseif quality > 2 then
return 'ram2'
else
return 'rag1'
endif
elseif itype == 5 then //shield
return 'sbch'
elseif itype == 6 then //ring
if quality > 5 then
return 'rde0'
elseif quality > 2 then
return 'jdrn'
else
return 'rlif'
endif
elseif itype == 8 then //amulet
if quality > 5 then
return 'ram4'
elseif quality > 2 then
return 'axas'
else
return 'spsh'
endif
elseif itype == 9 then // wing
return 'ccmd'
elseif itype == 10 then //tome
return 'hval'
elseif itype == 11 then //charm
return 'cnob'
else
return 0
endif
endfunction
function RemoveItemData takes integer id returns nothing
if LoadInteger(udg_CItem_Table, id, 0) > 0 then
call RemoveBagContent(id)
endif
call FlushChildHashtable(udg_CItem_Table, id)
endfunction
function ItIsStackingType takes item itm returns boolean
local integer ilv = GetItemLevel(itm)
//list here what isn't stackable
if (ilv > 100 and ilv < 112) or ilv == 0 or ilv == BAG_LEVEL() or GetItemType(itm) == ITEM_TYPE_POWERUP then
return false
else
return true
endif
endfunction
function ItIsStackingItems takes item itm1, item itm2 returns boolean
local integer ilv1 = GetItemLevel(itm1)
local integer ilv2 = GetItemLevel(itm1)
local integer i1
local integer i2
local integer array a
local integer array b
if itm1 != null and itm2 != null and itm1 != itm2 then
if GetItemTypeId(itm1) == GetItemTypeId(itm2) and ItIsStackingType(itm1) then
if ilv1 == GEM_LEVEL() then
set i1 = LoadInteger(udg_CItem_Table, GetHandleId(itm1), 0)
set i2 = LoadInteger(udg_CItem_Table, GetHandleId(itm2), 0)
if i1 == i2 then
return true
else
return false
endif
elseif ilv1 > 1901 and ilv1 < 1906 then //these are custom potion
set i1 = GetHandleId(itm1)
set i2 = GetHandleId(itm2)
set a[1] = LoadInteger(udg_CItem_Table, i1, 8)
set b[1] = LoadInteger(udg_CItem_Table, i2, 8)
set a[2] = LoadInteger(udg_CItem_Table, i1, 5)
set b[2] = LoadInteger(udg_CItem_Table, i2, 5)
set a[3] = LoadInteger(udg_CItem_Table, i1, 2)
set b[3] = LoadInteger(udg_CItem_Table, i2, 2)
set a[4] = LoadInteger(udg_CItem_Table, i1, 3)
set b[4] = LoadInteger(udg_CItem_Table, i2, 3)
set a[5] = LoadInteger(udg_CItem_Table, i1, 19)
set b[5] = LoadInteger(udg_CItem_Table, i2, 19)
if a[1] == b[1] and a[2] == b[2] and a[3] == b[3] and a[4] == b[4] and a[5] == b[5] then
return true
else
return false
endif
else
return true
endif
else
return false
endif
else
return false
endif
endfunction
function ClearSlot takes integer cv, integer slot returns nothing
call SaveInteger(udg_Stat_Table, cv, - slot, 0)
call SaveBoolean(udg_Stat_Table, - cv, - slot, false)
call SaveInteger(udg_Stat_Table, 9000 + cv, slot, 0)
call SaveInteger(udg_Stat_Table, 9000 + cv, - slot, 0)
call SaveInteger(udg_Stat_Table, - 9000 - cv, - slot, 0)
call SaveInteger(udg_Stat_Table, 18000 + cv, slot, 0)
call SaveInteger(udg_Stat_Table, 18000 + cv, - slot, 0)
call RemoveSavedHandle(udg_Stat_Table, cv, slot)
endfunction
function RemoveItemRot takes item itm, boolean remove returns nothing
local integer i = LoadInteger(udg_CItem_Table, GetHandleId(itm), 101)
if i > 0 then
if (remove and IsItemVisible(udg_Item_Item[i]) and not IsItemOwned(udg_Item_Item[i])) or udg_Item_Item[i] == null then
if udg_Item_Item[i] != null then
call RemoveItemData(GetHandleId(itm))
call RemoveItem(udg_Item_Item[i])
else
call FlushChildHashtable(udg_CItem_Table, udg_Item_Id[i])
endif
else
call SaveInteger(udg_CItem_Table, udg_Item_Id[i], 102, 0)
call SaveInteger(udg_CItem_Table, udg_Item_Id[i], 101, 0)
endif
if i != udg_Item_Max then
loop
exitwhen i > udg_Item_Max
set udg_Item_Item[i] = udg_Item_Item[i + 1]
set udg_Item_Id[i] = udg_Item_Id[i + 1]
call SaveInteger(udg_CItem_Table, udg_Item_Id[i], 101, i)
set i = i + 1
endloop
endif
set udg_Item_Item[udg_Item_Max] = null
set udg_Item_Max = udg_Item_Max - 1
endif
endfunction
function AddItemRot takes item itm, integer owner returns nothing
if IsItemVisible(itm) and not IsItemOwned(itm) then //LoadInteger (udg_CItem_Table, GetHandleId(itm), 101) == 0
if udg_Item_Max > MAX_ITEM() then
//call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "|cffffff00Warning: Too much item on map|r")
call RemoveItemRot (udg_Item_Item[1], true)
endif
set udg_Item_Max = udg_Item_Max + 1
set udg_Item_Item[udg_Item_Max] = itm
set udg_Item_Id[udg_Item_Max] = GetHandleId(itm)
call SaveInteger(udg_CItem_Table, udg_Item_Id[udg_Item_Max], 101, udg_Item_Max)
call SaveInteger(udg_CItem_Table, udg_Item_Id[udg_Item_Max], 102, owner)
if GetItemTypeId(itm) != 'gold' then
call SetItemUserData(itm, owner)
endif
endif
endfunction
function SetItemBaseData takes item itm, integer itype, integer subtype, integer quality, integer grade, integer lvreq, integer ethernal, real dur, real maxdur, integer maxsocket, integer setid returns nothing
local integer id = GetHandleId(itm)
local integer str = 0
local integer agi = 0
local integer int = 0
local integer price = grade * 10
local integer class = 0
local real r = 0
if itype == 5 and subtype == 0 then
set subtype = 1
endif
if lvreq > 0 then
if itype < 5 and itype != 3 then
if subtype == 1 then
set class = 1
set str = lvreq * 3 + 5
set agi = lvreq * 1 + 5
elseif subtype == 2 then
set class = 3
set str = lvreq * 1 + 5
set agi = lvreq * 3 + 5
elseif subtype == 3 then
set class = 5
set str = lvreq * 1 + 5
set int = lvreq * 3 + 5
endif
elseif itype == 3 or itype == 5 then
if subtype < 3 or itype == 5 then
set class = 2
set str = lvreq * 2 + 5
set agi = lvreq * 2 + 5
elseif subtype == 3 then
set class = 1
set str = lvreq * 4 + 5
set agi = lvreq + 5
elseif subtype < 6 then
set class = 2
set str = lvreq * 4 + 5
set agi = lvreq + 5
elseif subtype < 8 then
set str = lvreq + 5
set agi = lvreq * 4 + 5
if subtype == 6 then
set class = 3
else
set class = 4
endif
elseif subtype == 8 then
set class = 5
set str = lvreq * 2 + 5
set int = lvreq * 3 + 5
elseif subtype == 9 then
set class = 5
set str = lvreq + 5
set int = lvreq * 4 + 5
endif
endif
endif
if maxdur == 0 then
if itype == 1 then
set r = 1.6
elseif itype == 2 then
set r = 1.7
elseif itype == 3 then
set r = 2
elseif itype == 4 then
set r = 1.55
elseif itype == 5 then
set r = 1.8
elseif itype == 6 then
set r = 1.3
elseif itype == 8 then
set r = 1.45
elseif itype == 9 then
set r = 1.3
endif
set maxdur = (grade * 1.75 + 50) * r
set dur = maxdur
if quality == 0 then
set dur = dur / 4.00 + 10
set maxdur = dur * 2.00
set price = price / 2
elseif quality == 1 then
set dur = dur / 3.00 + 10
set maxdur = dur * 2.00
set price = price / 2
elseif quality == 3 then
set dur = dur * 1.1
set maxdur = dur
set price = R2I(price * 1.1)
elseif quality == 4 then
set dur = dur * 1.2
set maxdur = dur
set price = R2I(price * 1.2)
elseif quality == 5 then
set dur = dur * 1.3
set maxdur = dur
set price = R2I(price * 1.3)
elseif quality == 6 then
set dur = dur * 1.4
set maxdur = dur
set price = R2I(price * 1.4)
elseif quality == 7 then
set dur = dur * 1.5
set maxdur = dur
set price = R2I(price * 1.5)
endif
endif
if maxsocket == - 1 then
set maxsocket = GetRandomInt(quality / 2 + grade / 50, quality / 2 + grade / 50 + 1)
endif
if itype == 10 or itype == 11 then
set price = price * 2
set maxsocket = 0
set lvreq = 0
elseif itype == 6 or itype == 8 or itype == 5 then
set maxsocket = 0
endif
call SaveInteger(udg_CItem_Table, id, 1, GetItemTypeId(itm))
call SaveInteger(udg_CItem_Table, id, 2, itype)
call SaveInteger(udg_CItem_Table, id, 3, subtype)
call SaveInteger(udg_CItem_Table, id, 4, quality)
call SaveInteger(udg_CItem_Table, id, 6, class)
call SaveInteger(udg_CItem_Table, id, 7, grade)
call SaveInteger(udg_CItem_Table, id, 8, lvreq)
call SaveInteger(udg_CItem_Table, id, 12, price)
if itype != 11 then
call SaveInteger(udg_CItem_Table, id, 9, str)
call SaveInteger(udg_CItem_Table, id, 10, agi)
call SaveInteger(udg_CItem_Table, id, 11, int)
call SaveInteger(udg_CItem_Table, id, 13, ethernal)
call SaveReal(udg_CItem_Table, id, 14, dur)
call SaveReal(udg_CItem_Table, id, 15, maxdur)
call SaveInteger(udg_CItem_Table, id, 20, maxsocket)
if setid > 0 then
call SaveInteger(udg_CItem_Table, id, 5, setid)
endif
endif
endfunction
function AddCustomItem takes real x, real y, integer itype, integer subtype, integer quality returns item
local integer i = itype2TOitemId(itype, subtype, quality)
if itype > 0 and itype < 12 and i != 0 then
return CreateItem(i, x, y)
else
return null
endif
endfunction
function AddItem2Slot takes integer cv, item itm, integer slot returns nothing
local unit u = udg_UDexUnits[cv]
local integer i = 0
local item it = null
local integer dummy = 'tfar'
set udg_Stop_Stack[cv] = true
loop
exitwhen i > 5 or i > slot
set it = UnitItemInSlot(u, i)
if it == itm then
call UnitRemoveItem(u, itm)
set it = null
endif
if it == null and i != slot then
call UnitAddItemToSlotById (u, dummy, i)
endif
set i = i + 1
endloop
if not IsItemVisible(itm) then
call SetItemVisible(itm, true)
endif
call UnitAddItem(u, itm)
call RemoveItemRot (itm, false)
set i = 0
loop
exitwhen i > 5 or i > slot
set it = UnitItemInSlot(u, i)
if it != null then
if GetItemTypeId(it) == dummy then
call RemoveItem(it)
endif
endif
set i = i + 1
endloop
set udg_Stop_Stack[cv] = false
set it = null
set u = null
endfunction
// item name functions
function GetClassName takes integer class, integer ilv returns string
if class == 1 then
if ilv < 105 and ilv > 100 and ilv !=103 then
return "Paladin, Warrior"
else
return "Paladin"
endif
elseif class == 2 then
return "Warrior"
elseif class == 3 then
if ilv < 105 and ilv > 100 and ilv !=103 then
return "Archer, Assassin"
else
return "Archer"
endif
elseif class == 4 then
return "Assassin"
elseif class == 5 then
return "Mage, Summoner"
else
return ""
endif
endfunction
function GetArmorType takes integer itype, integer subtype returns string
if itype == 1 or itype == 2 or itype == 4 then
if subtype == 1 then
return "Heavy "
elseif subtype == 2 then
return "Light "
elseif subtype == 3 then
return "Mage "
else
return ""
endif
else
return ""
endif
endfunction
function GetGemGradeName takes integer GemType returns string
if GemType == 1 then
return "Chipped"
elseif GemType == 2 then
return "Broken"
elseif GemType == 3 then
return "Flawed"
elseif GemType == 4 then
return ""
elseif GemType == 5 then
return "Flawless"
elseif GemType == 6 then
return "Perfect"
elseif GemType == 7 then
return "Super"
else
return ""
endif
endfunction
function GetItemQuality takes integer quality, integer itype returns string
if quality == 0 then
return " Cracked "
elseif quality == 1 then
if itype == 11 then
return " Common "
else
return " Low quality "
endif
elseif quality == 2 then
if itype == 11 then
return " Uncommon "
else
return " Normal "
endif
elseif quality == 3 then
if itype == 11 then
return " Superior "
else
return " Enhanced "
endif
elseif quality == 4 then
return " Rare "
elseif quality == 5 then
return " Very Rare "
elseif quality == 6 then
return " Excelent "
elseif quality == 7 then
return " Unique "
else
return " "
endif
endfunction
function GetFullItemName takes item itm, boolean showRefine returns string
local integer ilv = GetItemLevel(itm)
local integer subtype
local integer id = GetHandleId(itm)
local integer ref
local integer ui //unique id
local integer sid //set id
local integer i
local integer q //quality
local integer Gr //item grade
local string RefStr //refine string
local integer array red1
local integer array red2
local integer array green1
local integer array green2
local integer array blue1
local integer array blue2
if ilv>= 100 and ilv < 200 then
if ilv == BAG_LEVEL() then
set id = LoadInteger(udg_CItem_Table, id, 0)
if id > 0 then
return "|cff3377ff" + GetItemName(itm) + "|r |cffffffaa(" + I2S(id) + "/" + I2S(BAG_SIZE_MAX()) + ")|r"
else
return "|cff3377ff" + GetItemName(itm) + "|r |cffaaaaaa(empty)|r"
endif
elseif ilv == BOX_LEVEL() then
return "|cff3377ff" + GetItemName(itm) + "|r"
else
set ui = LoadInteger(udg_CItem_Table, id, 0)
set sid = LoadInteger(udg_CItem_Table, id, 5)
set ref = LoadInteger(udg_CItem_Table, id, 16)
set Gr = LoadInteger (udg_CItem_Table, id, 7)
set RefStr = ""
if ref > 0 and showRefine then
set RefStr = "|cffffff77+" + I2S(ref) + "|r"
endif
if HaveSavedString(udg_CItem_Table, - ui, 21) then
return (StringColoring(LoadStr(udg_CItem_Table, - ui, 21), 255, 0, 0, 255, 150, 150) + " (Gr. |cffffff00" + I2S(Gr) + "|r) " + RefStr )
else
set q = LoadInteger(udg_CItem_Table, id, 4)
set subtype = LoadInteger (udg_CItem_Table, id, 3)
set red1[0] = 205
set green1[0] = 205
set blue1[0] = 205
set red2[0] = 255
set green2[0] = 255
set blue2[0] = 255
set red1[1] = 205
set green1[1] = 205
set blue1[1] = 0
set red2[1] = 255
set green2[1] = 255
set blue2[1] = 255
set red1[2] = 205
set green1[2] = 55
set blue1[2] = 255
set red2[2] = 255
set green2[2] = 150
set blue2[2] = 0
set red1[3] = 205
set green1[3] = 0
set blue1[3] = 0
set red2[3] = 255
set green2[3] = 150
set blue2[3] = 150
set Gr = LoadInteger (udg_CItem_Table, id, 7)
set i = R2I((Gr / 25)) - 1
if i > 3 then
set i = 3
elseif i < 0 then
set i = 0
endif
return (StringColoring(GetItemQuality(q, ilv - 100) + GetArmorType(ilv - 100, subtype) + GetItemName(itm), red1[i], green1[i], blue1[i], red2[i], green2[i], blue2[i]) + " (Gr. |cffffff00" + I2S(Gr) + "|r) " + RefStr )
endif
endif
else
if GetItemCharges(itm) > 0 then
return " |cffffff00" + GetItemName(itm) + "|r x |cffaaaaff" + I2S(GetItemCharges(itm)) + "|r"
else
return " |cffffff00" + GetItemName(itm) + "|r"
endif
endif
return ""
endfunction
//-------------------------------------------------------------------------
// OVER TIME THINGS: Damage, Heal, Mana over time
//-------------------------------------------------------------------------
function AddOT takes unit u1, unit u2, integer t, real value, integer dur returns nothing
set udg_OT_Max = udg_OT_Max + 1
set udg_OT_Source[udg_OT_Max] = u1
set udg_OT_Target[udg_OT_Max] = u2
set udg_OT_Type[udg_OT_Max] = t
set udg_OT_Timer[udg_OT_Max] = dur
set udg_OT_Value[udg_OT_Max] = value
endfunction
//-------------------------------------------------------------------------
// STAT MODIFYING FUNCTIONS
//-------------------------------------------------------------------------
function AddHPMP takes boolean HP, integer v, unit u returns nothing
local integer a
local integer s
local integer i
local integer l
local integer cv
local integer mv
if HP then
set a = ADDHP_ID()
else
set a = ADDMP_ID()
endif
if ( v >= 0 ) then
set s = 1
set cv = v
else
set s = 5
set cv = v * - 1
endif
set mv = cv - ( cv / 1000 ) * 1000
set l = cv / 1000
set i = 1
loop
exitwhen i > l
call UnitAddAbility( u, a )
call SetUnitAbilityLevel( u, a, ( 4 + s ) )
call UnitRemoveAbility( u, a )
set i = i + 1
endloop
set cv = mv
set mv = cv - ( cv / 100 ) * 100
set l = cv / 100
set cv = mv
set i = 1
loop
exitwhen i > l
call UnitAddAbility( u, a )
call SetUnitAbilityLevel( u, a, ( 3 + s ) )
call UnitRemoveAbility( u, a )
set i = i + 1
endloop
set mv = cv - ( cv / 10 ) * 10
set l = cv / 10
set cv = mv
set i = 1
loop
exitwhen i > l
call UnitAddAbility( u, a )
call SetUnitAbilityLevel( u, a, ( 2 + s ) )
call UnitRemoveAbility( u, a )
set i = i + 1
endloop
set i = 1
loop
exitwhen i > cv
call UnitAddAbility( u , a )
call SetUnitAbilityLevel( u, a, ( 1 + s ) )
call UnitRemoveAbility( u, a )
set i = i + 1
endloop
set u = null
endfunction
function AddDMG takes boolean DMG, integer cv, integer v returns nothing
local integer i = 0
local integer n = 0
local integer a1 = 0
local integer a2 = 0
local integer a3 = 0
local integer a4 = 0
local unit u = udg_UDexUnits[cv]
if not DMG then
set a1 = 'A001'//udg_Abilities2[14]
set a2 = 'A005'//udg_Abilities2[15]
set a3 = 'A006'//udg_Abilities2[16]
set i = v
set n = i / 100 + 1
call SetUnitAbilityLevel( u, a3, n )
set i = i - ( i / 100 ) * 100
set n = i / 10 + 1
call SetUnitAbilityLevel( u, a2, n )
set i = i - ( i / 10 ) * 10
set n = i + 1
call SetUnitAbilityLevel( u, a1, n )
else
set a1 = 'A002'//udg_Abilities2[17]
set a2 = 'A007'//udg_Abilities2[18]
set a3 = 'A008'//udg_Abilities2[19]
set a4 = 'A009'//udg_Abilities2[20]
set i = v
set n = i / 1000 + 1
call SetUnitAbilityLevel( u, a4, n )
set i = i - ( i / 1000 ) * 1000
set n = i / 100 + 1
call SetUnitAbilityLevel( u, a3, n )
set i = i - ( i / 100 ) * 100
set n = i / 10 + 1
call SetUnitAbilityLevel( u, a2, n )
set i = i - ( i / 10 ) * 10
set n = i + 1
call SetUnitAbilityLevel( u, a1, n )
endif
set u = null
endfunction
function AddBonusMod takes unit u, integer n, integer v returns nothing
local integer a
local integer i
local integer lv
local integer max
local integer cv = GetUnitUserData(u)
local integer x
if n != 0 then
if v == 1 then
set a = 15
set i = 11
set lv = R2I(udg_Total_HP_Regen[cv])
set udg_Total_HP_Regen[cv] = lv + n
set x = lv
elseif v == 2 then
set a = 26
set i = 11
set lv = R2I(udg_Total_MP_Regen[cv])
set udg_Total_MP_Regen[cv] = lv + n
set x = lv
endif
set max = udg_Pow2[i + 1] - 1
if x + n > max then
set x = max
elseif (x + n) <= 0 then
set x = 0
else
set x = x + n
endif
loop
set lv = GetUnitAbilityLevel (u, udg_Abilities[a + i])
if x >= udg_Pow2[i] and x > 0 then
if lv == 0 then
call UnitAddAbility(u, udg_Abilities[a + i])
call UnitMakeAbilityPermanent(u, true, udg_Abilities[a + i])
endif
set x = x - udg_Pow2[i]
else
if lv > 0 then
call UnitRemoveAbility(u, udg_Abilities[a + i])
endif
endif
set i = i - 1
exitwhen i < 0
endloop
endif
endfunction
//-------------------------------------------------------------------------
// FULL SCREEN INFERFACE AND BASE CALCULATION FUNCTIONS
//-------------------------------------------------------------------------
function GetStringPos takes string s1, string s2 returns integer
local integer i = 0
local integer len = StringLength(s1)
local integer slen = StringLength(s2)
local integer a = 0
loop
exitwhen i >= len or a > 0
if SubString(s1, i, i + slen) == s2 then
set a = i
endif
set i = i + 1
endloop
return a
endfunction
function AddSpace takes string s, integer nr returns string
local integer i = 1
local string t = ""
set nr = R2I(nr * 1.5)
loop
exitwhen i > nr
set t = t + s
set i = i + 1
endloop
set s = t
set t = null
return s
endfunction
function FlushFT_Stat takes integer pl returns nothing
local integer a = 1
local integer i = LoadInteger(udg_FSS, pl + 500, 0)
local destructable d
loop
exitwhen a > i
call DestroyTextTag(LoadTextTagHandle(udg_FSS, pl + 500, a))
set a = a + 1
endloop
call FlushChildHashtable(udg_FSS, pl + 500)
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 0, 500 + i)
exitwhen d == null
call ShowDestructable(d, false)
set i = i + 1
endloop
set d = null
endfunction
function FT_Stat takes player p, string txt, real fsize, real x, real y, integer alpha returns nothing
local integer pl = GetPlayerId(p) + 1
local integer i = LoadInteger(udg_FSS, pl + 500, 0) + 1
local texttag tt = null
call SaveInteger(udg_FSS, pl + 500, 0, i)
if GetLocalPlayer() == p then
set tt = CreateTextTag( )
call SetTextTagText( tt, txt, fsize * 0.023 )
call SetTextTagPos( tt, x, y, 100.00 )
call SetTextTagColor( tt, 255, 255, 255, alpha )
call SetTextTagPermanent( tt, true )
endif
call SaveTextTagHandle(udg_FSS, pl + 500, i, tt)
set tt = null
endfunction
function StatRefresh takes integer cv returns nothing
local unit u = udg_UDexUnits[cv]
local integer str = 0
local integer agi = 0
local integer int = 0
local real r1 = udg_Total_HP_Regen[cv]
local real r2 = udg_Total_MP_Regen[cv]
local real r3
local real r4
if LoadBoolean(udg_Stat_Table, 8890, GetHandleId(u)) then
if IsUnitType(u, UNIT_TYPE_HERO) then
set str = GetHeroStr(u, true)
set agi = GetHeroAgi(u, true)
set int = GetHeroInt(u, true)
endif
set udg_Global_Acc[cv] = udg_Stat_Acc[cv] + agi * 7
set udg_Global_Eva[cv] = udg_Stat_Eva[cv] + agi * 4
set udg_Global_Crit[cv] = udg_Stat_Crit[cv] + agi / 20 + 1
set udg_Global_CritDmg[cv] = udg_Stat_CritDmg[cv]
set udg_Global_AttLv[cv] = udg_Stat_AttackLv[cv]
set udg_Global_DefLv[cv] = udg_Stat_DefLv[cv]
set udg_Global_Pdef[cv] = udg_Stat_Pdef[cv] + R2I(udg_Stat_Pdef[cv] * str / 300.00 )
set udg_Global_Mdef1[cv] = udg_Stat_Mdef1[cv] + R2I(udg_Stat_Mdef1[cv] * int / 300.00 )
set udg_Global_Mdef2[cv] = udg_Stat_Mdef2[cv] + R2I(udg_Stat_Mdef2[cv] * int / 300.00 )
set udg_Global_Mdef3[cv] = udg_Stat_Mdef3[cv] + R2I(udg_Stat_Mdef3[cv] * int / 300.00 )
set udg_Global_Mdef4[cv] = udg_Stat_Mdef4[cv] + R2I(udg_Stat_Mdef4[cv] * int / 300.00 )
set udg_Global_Mdef5[cv] = udg_Stat_Mdef5[cv] + R2I(udg_Stat_Mdef5[cv] * int / 300.00 )
set udg_Global_Reflect[cv] = udg_Stat_Reflect[cv] // + udg_B_Ref[cv]
set udg_Global_LifeSteal[cv] = udg_Stat_LifeSteal[cv] // + udg_B_LS[cv]
set udg_Global_ManaSteal[cv] = udg_Stat_ManaSteal[cv]
set udg_TotalSpellPower[cv] = udg_Stat_SpellPower[cv] + udg_Stat_SpellPower[cv] * (int + udg_B_SP[cv]) / 100
if udg_CombatTimer[cv] < 1 then
set r3 = udg_Stat_HpRegen[cv] * 2
set r4 = udg_Stat_MpRegen[cv] * 2
else
set r3 = udg_Stat_HpRegen[cv]
set r4 = udg_Stat_MpRegen[cv]
endif
if r1 != r3 then
call AddBonusMod(u, R2I(r3 - r1), 1)
endif
if r2 != r4 then
call AddBonusMod(u, R2I(r4 - r2), 2)
endif
endif
set u = null
endfunction
function GetTotalDmg takes integer Tdmg, integer StartDmg, integer HeroStat returns integer
//if each str=1dmg else remove it
return Tdmg+StartDmg+HeroStat//
endfunction
//this function show the charater stat properties if u are in inventory
function ShowStat takes integer pl returns nothing
local real x = LoadReal(udg_FSS, 0, 1)
local real y = LoadReal(udg_FSS, 0, 2)
local integer cv = udg_Inv_Unit[pl]
local unit u = udg_UDexUnits[cv]
local string c = "|cff9999ff"
local string MinDmg1 = ""
local string MinDmg2 = ""
local destructable d
local integer id
local integer subtype
local boolean b = false
local integer pdmg
call StatRefresh(cv)
call FlushFT_Stat(pl)
if udg_Trader[pl] == 0 then
set pdmg = GetTotalDmg(udg_Total_Dmg[cv],LoadInteger(udg_FSS, 634, GetUnitTypeId(u)), GetHeroStr(u, true))
if HaveSavedHandle(udg_Stat_Table, cv, 3) then
set id = GetHandleId(LoadItemHandle(udg_Stat_Table, cv, 3))
set subtype = LoadInteger(udg_CItem_Table, id, 3)
if subtype > 7 then
set MinDmg2 = I2S(R2I(WeaponMinDamageModifier(subtype)*udg_TotalSpellPower[cv]))+"-"
else
set MinDmg1 = I2S(R2I(WeaponMinDamageModifier(subtype)*pdmg))+"-"
endif
endif
call FT_Stat(Player(pl - 1), StringColoring("Character Stat", 100, 100, 255, 255, 255, 255), 1.5, x + 864, y + 540, 200)
call FT_Stat(Player(pl - 1), StringColoring("Phy. Dmg: ", 255, 255, 0, 255, 255, 255) + c +MinDmg1+ I2S(pdmg) + "|r", 0.9, x + 814, y + 512 - 40, 200) // + udg_B_Crit[cv]
call FT_Stat(Player(pl - 1), StringColoring("Critical chance: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Crit[cv]) + "%%|r", 0.8, x + 814, y + 512 - 70, 200) // + udg_B_Crit[cv]
call FT_Stat(Player(pl - 1), StringColoring("Critical damage: ", 255, 255, 0, 255, 255, 255) + c + I2S(DEFAULT_CRITICAL_DAMAGE() + udg_Global_CritDmg[cv]) + "%%|r", 0.8, x + 814, y + 512 - 90, 200)//udg_B_CritDmg[cv]
call FT_Stat(Player(pl - 1), StringColoring("Attack speed: ", 255, 255, 0, 255, 255, 255) + c + I2S(100 + GetHeroAgi(u, true)) + "%%|r", 0.8, x + 814, y + 512 - 110, 200)
call FT_Stat(Player(pl - 1), StringColoring("Movement speed: ", 255, 255, 0, 255, 255, 255) + c + I2S(R2I(GetUnitMoveSpeed (u))) + "|r" , 0.8, x + 814, y + 512 - 130, 200)
call FT_Stat(Player(pl - 1), StringColoring("Accurancy: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Acc[cv]) + "|r", 0.8, x + 814, y + 512 - 150, 200)//udg_B_Acc[cv]
call FT_Stat(Player(pl - 1), StringColoring("Evasion: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Eva[cv]) + "|r", 0.8, x + 814, y + 512 - 170, 200)//udg_B_Eva[cv]
call FT_Stat(Player(pl - 1), StringColoring("Armor pen.: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_ArmorBreak[cv]) + "%%|r", 0.8, x + 814, y + 512 - 190, 200)
call FT_Stat(Player(pl - 1), StringColoring("Reflect damage: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Reflect[cv]) + "%%|r", 0.8, x + 814, y + 512 - 210, 200)
call FT_Stat(Player(pl - 1), StringColoring("Attack level: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_AttLv[cv]) + "|r", 0.8, x + 814, y + 512 - 230, 200)//udg_B_AttLv[cv])
call FT_Stat(Player(pl - 1), StringColoring("Life Steal: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_LifeSteal[cv]) + "%%|r", 0.8, x + 814, y + 512 - 250, 200)
call FT_Stat(Player(pl - 1), StringColoring("Experience: ", 255, 255, 0, 255, 255, 255) + c + I2S(100 + udg_Stat_Exp[cv] ) + "%%|r", 0.8, x + 814, y + 512 - 270, 200)// + udg_B_Exp[cv] + udg_Global_Exp_Buff[a]
call FT_Stat(Player(pl - 1), StringColoring("Mag. Dmg: ", 255, 255, 0, 255, 255, 255) + c +MinDmg2+ I2S(udg_TotalSpellPower[cv]) + "|r", 0.9, x + 1032, y + 512 - 40, 200) // + udg_B_Crit[cv]
call FT_Stat(Player(pl - 1), StringColoring("Physical def.: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Pdef[cv]) + "|r", 0.8, x + 1032, y + 512 - 70, 200)//udg_B_Pdef[cv]
call FT_Stat(Player(pl - 1), StringColoring("Fire ressist: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Mdef1[cv]) + "|r", 0.8, x + 1032, y + 512 - 90, 200)//udg_B_Mdef[cv]
call FT_Stat(Player(pl - 1), StringColoring("Water ressist: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Mdef2[cv]) + "|r", 0.8, x + 1032, y + 512 - 110, 200)//udg_B_Mdef[cv]
call FT_Stat(Player(pl - 1), StringColoring("Lightning ressist: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Mdef3[cv]) + "|r", 0.8, x + 1032, y + 512 - 130, 200)//udg_B_Mdef[cv]
call FT_Stat(Player(pl - 1), StringColoring("Poison ressist: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Mdef4[cv]) + "|r", 0.8, x + 1032, y + 512 - 150, 200)//udg_B_Mdef[cv]
call FT_Stat(Player(pl - 1), StringColoring("Earth ressist: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_Mdef5[cv]) + "|r", 0.8, x + 1032, y + 512 - 170, 200)//udg_B_Mdef[cv]
call FT_Stat(Player(pl - 1), StringColoring("HP regen: ", 255, 255, 0, 255, 255, 255) + c + R2SW(udg_Total_HP_Regen[cv], 4, 2) + " /s|r", 0.8, x + 1032, y + 512 - 190, 200)
call FT_Stat(Player(pl - 1), StringColoring("MP regen: ", 255, 255, 0, 255, 255, 255) + c + R2SW(udg_Total_MP_Regen[cv], 4, 2) + " /s|r", 0.8, x + 1032, y + 512 - 210, 200)
call FT_Stat(Player(pl - 1), StringColoring("Defence level: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_DefLv[cv]) + "|r", 0.8, x + 1032, y + 512 - 230, 200)//udg_B_DefLv[cv])
call FT_Stat(Player(pl - 1), StringColoring("Mana Steal: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Global_ManaSteal[cv]) + "%%|r", 0.8, x + 1032, y + 512 - 250, 200)
call FT_Stat(Player(pl - 1), StringColoring("Block chance: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Stat_BlockDmg[cv]) + "%%|r", 0.8, x + 1032, y + 512 - 270, 200)
if udg_Stat_Point[cv] > 0 then
set c = "|cff0000ff"
endif
call FT_Stat(Player(pl - 1), StringColoring("Unspent stat point: ", 255, 255, 0, 255, 255, 255) + c + I2S(udg_Stat_Point[cv]) + "|r", 0.9, x + 890, y + 512 - 500, 200)
set cv = 0
if GetLocalPlayer() == Player(pl - 1) then
set b = true
endif
loop
set d = LoadDestructableHandle(udg_FSS, 0, 500 + cv)
exitwhen d == null
call ShowDestructable(d, b)
set cv = cv + 1
endloop
endif
set d = null
set u = null
set c = null
endfunction
function AddAbiltityStatPoint2Hero takes unit u returns nothing
local integer cv
local integer i = GetPlayerId(GetOwningPlayer(u)) + 1
local integer utype = GetUnitTypeId(u)
local integer StartPoint = START_POINT() + (GetHeroLevel(u)-1)*5
call SuspendHeroXP( u, true )
// make them permanent
call SetPlayerAbilityAvailable( Player(i - 1), MELEE2RANGED_ID(), false)
call UnitAddAbility( u, 'A00D' )
call UnitAddAbility( u, 'A001' )
call UnitAddAbility( u, 'A005' )
call UnitAddAbility( u, 'A006' )
call UnitAddAbility( u, 'A002' )
call UnitAddAbility( u, 'A007' )
call UnitAddAbility( u, 'A008' )
call UnitAddAbility( u, 'A009' )
call UnitAddAbility( u, 'A00H' )
call UnitAddAbility( u, 'A00G' )
call UnitMakeAbilityPermanent(u, true, 'A00D')
call UnitMakeAbilityPermanent(u, true, 'A001')
call UnitMakeAbilityPermanent(u, true, 'A002')
call UnitMakeAbilityPermanent(u, true, 'A005')
call UnitMakeAbilityPermanent(u, true, 'A006')
call UnitMakeAbilityPermanent(u, true, 'A007')
call UnitMakeAbilityPermanent(u, true, 'A008')
call UnitMakeAbilityPermanent(u, true, 'A009')
call UnitMakeAbilityPermanent(u, true, 'A00B')
call UnitMakeAbilityPermanent(u, true, 'A00E')
call UnitMakeAbilityPermanent(u, true, 'A00G')
call UnitMakeAbilityPermanent(u, true, 'A00H')
call UnitMakeAbilityPermanent(u, true, 'A018')
set cv = GetUnitUserData(u)
set udg_Stat_Point[cv] = StartPoint
call StatRefresh (cv)
call SaveBoolean(udg_Stat_Table, 8890, GetHandleId(u), true)
call TriggerRegisterUnitEvent( gg_trg_Start_Inventory, u, EVENT_UNIT_SPELL_EFFECT )
endfunction
function GetCraftLv takes integer value, boolean flat returns integer
local integer i = 1
local integer lv = 1
local integer array xp
set xp[0] = 0
set xp[11] = 2147483647
//for lv 2 need: 6 exp totally: 6
//for lv 3 need: 8 exp totally: 14
//for lv 4 need: 10 exp totally: 24
//for lv 5 need: 13 exp totally: 37
//for lv 6 need: 17 exp totally: 54
//for lv 7 need: 22 exp totally: 76
//for lv 8 need: 28 exp totally: 104
//for lv 9 need: 34 exp totally: 138
//for lv 10 need: 42 exp totally: 180
loop
set xp[i] = xp[i - 1] + (((i + 4) * (i + 3) * (i + 2)) / (R2I((i * 1.5)) + 33)) + 5
set i = i + 1
exitwhen i == 11
endloop
set i = 1
// if flat true then need the lv, if false then the percentage
if flat then
loop
if value < xp[i] then
return i
endif
set i = i + 1
exitwhen i == 11
endloop
else
if value == 0 then
return 0
elseif value < xp[10] then
// we get the current lv
set lv = 0
loop
if value < xp[i] then
set lv = i
endif
set i = i + 1
exitwhen i == 11 or lv != 0
endloop
//we calculate the percentage
return R2I(((value - xp[lv - 1]) * 100.00) / (xp[lv] - xp[lv - 1]))
else
return 100
endif
endif
endfunction
function HitChance takes integer cv1, integer cv2 returns integer
local integer acc = udg_Global_Acc[cv1]
local integer eva = udg_Global_Eva[cv2]
local real i = R2I(100.00 - ( eva - 1.00 ) / ( ( 2.00 * acc ) + ( eva - 1.00 ) ) * 100.00)
if i > 100.00 then
return 100
elseif i < 0.00 then
return 0
else
return R2I(i)
endif
endfunction
function GetShopUniqueId takes integer mc, integer sc, integer ls returns integer
local integer id
if mc > 0 and sc > 0 and ls > 0 then
set id = LoadInteger(udg_Shop_Table, mc, - sc)
if id > 0 then
return LoadInteger(udg_Shop_Table, id, - ls)
else
return 0
endif
else
return 0
endif
endfunction
function SetChargesText takes integer pl returns nothing
local real x
local real y
local integer ilv
local integer charge
local integer i = 100
local texttag tt = null
local integer mc
local integer sc
local integer id1
local integer id2
local integer max = 205
local integer cv = udg_Inv_Unit[pl]
local unit u = udg_UDexUnits[cv]
local item itm
if udg_Camera_Lock[pl] == 1 then
set max = 205
elseif udg_Camera_Lock[pl] == 2 then
set mc = LoadInteger(udg_FSS, 2402, pl) - 2000 //selected main category
set sc = LoadInteger(udg_FSS, 2402, 20 + pl) - 2100 //selected sub category
set id1 = LoadInteger(udg_Shop_Table, mc, - sc)
set max = 2224
elseif udg_Camera_Lock[pl] == 3 then
set max = 2224
endif
loop
exitwhen i > max
if LoadTextTagHandle(udg_FSS, 1000 + pl, i) != null then
call DestroyTextTag (LoadTextTagHandle(udg_FSS, 1000 + pl, i))
call RemoveSavedHandle(udg_FSS, 1000 + pl, i)
endif
set x = LoadReal(udg_FSS, i, 1) + 15 + 8
set y = LoadReal(udg_FSS, i, 2) - 27
set ilv = 0
set charge = 0
if i < 300 then
if i < 200 then
set ilv = LoadInteger(udg_Stat_Table, cv, - i)
if ilv > 0 and (ilv >= 200 or ilv < 100)then
set charge = GetItemCharges(LoadItemHandle(udg_Stat_Table, cv, i))
endif
else
if udg_Camera_Lock[pl] > 1 then
set i = 1000
else
if GetItemLevel(UnitItemInSlot(u, i - 200)) != BOX_LEVEL() then
set charge = GetItemCharges(UnitItemInSlot(u, i - 200))
endif
endif
endif
elseif i > 2200 then
call DestroyTextTag (LoadTextTagHandle(udg_FSS, 1000 + pl, i))
if udg_Camera_Lock[pl] == 2 then
if id1 != 0 and mc > 0 and sc > 0 then
set id2 = LoadInteger(udg_Shop_Table, id1, i - 2200)
set ilv = LoadInteger(udg_FSS, 603, id2)
if (ilv > 200 or ilv < 100) and ilv != 0 then
set charge = GetShopUniqueId (mc, sc, i - 2200)
else
set charge = 0
endif
endif
elseif udg_Camera_Lock[pl] == 3 and udg_Inv_Bag[pl] > 0 then
set itm = LoadItemHandle(udg_CItem_Table, udg_Inv_Bag[pl], i - 2200)
if itm != null then
set ilv = GetItemLevel(itm)
if (ilv >= 200 or ilv < 100) and ilv != 0 then
set charge = GetItemCharges(itm)
else
set charge = 0
endif
endif
endif
endif
if charge > 0 then
if GetLocalPlayer() == Player(pl - 1) then
set tt = CreateTextTag( )
if charge < 10 then
set x = x - 8
endif
call SetTextTagText( tt, I2S(charge), 0.7 * 0.023 )
call SetTextTagPos( tt, x, y, 35.00 )
call SetTextTagColor( tt, 255, 255, 255, 255 )
call SetTextTagPermanent( tt, true )
endif
call SaveTextTagHandle(udg_FSS, 1000 + pl, i, tt)
endif
if i==119 then
if udg_Camera_Lock[pl] == 1 then
set i = 199
elseif udg_Camera_Lock[pl] > 1 then
set i = 2200
endif
endif
set i = i + 1
endloop
if udg_Trader[pl] > 0 then
//-------------------------------------------------------
//charged text it is but still not done
//-------------------------------------------------------
endif
set u = null
set itm = null
set tt = null
endfunction
//-------------------------------------------------------------------------
// BUFF: ADD, REFRESH, REMOVE
//-------------------------------------------------------------------------
function ApplyBuff takes integer cv, integer bt, integer bv, boolean b returns nothing
local unit u = udg_UDexUnits[cv]
if LoadBoolean(udg_Stat_Table, 8890, GetHandleId(u)) then
if bt == 1 then
set udg_Stat_Acc[cv] = udg_Stat_Acc[cv] + bv
elseif bt == 2 then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + bv
elseif bt == 3 then
set udg_Stat_DefLv[cv] = udg_Stat_DefLv[cv] + bv
elseif bt == 4 then
set udg_Stat_Crit[cv] = udg_Stat_Crit[cv] + bv
elseif bt == 5 then
set udg_Stat_CritDmg[cv] = udg_Stat_CritDmg[cv] + bv
elseif bt == 6 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + bv
elseif bt == 7 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + bv
elseif bt == 8 then
set udg_Stat_Eva[cv] = udg_Stat_Eva[cv] + bv
elseif bt == 9 then
set udg_Stat_LifeSteal[cv] = udg_Stat_LifeSteal[cv] + bv
elseif bt == 10 then
set udg_Stat_ManaSteal[cv] = udg_Stat_ManaSteal[cv] + bv
elseif bt == 11 then
set udg_Stat_Reflect[cv] = udg_Stat_Reflect[cv] + bv
elseif bt == 12 then
set udg_Stat_Exp[cv] = udg_Stat_Exp[cv] + bv
elseif bt == 13 then
call AddHPMP (true, bv, u)
elseif bt == 14 then
call AddHPMP (false, bv, u)
elseif bt == 15 then
set udg_Stat_Pdef[cv] = udg_Stat_Pdef[cv] + bv
elseif bt == 16 then
set udg_Stat_Mdef1[cv] = udg_Stat_Mdef1[cv] + bv
elseif bt == 17 then
set udg_Stat_Mdef2[cv] = udg_Stat_Mdef2[cv] + bv
elseif bt == 18 then
set udg_Stat_Mdef3[cv] = udg_Stat_Mdef3[cv] + bv
elseif bt == 19 then
set udg_Stat_Mdef4[cv] = udg_Stat_Mdef4[cv] + bv
elseif bt == 20 then
set udg_Stat_Mdef5[cv] = udg_Stat_Mdef5[cv] + bv
elseif bt == 21 then
//reserved
endif
else
if bt == 1 then
set udg_Global_Acc[cv] = udg_Global_Acc[cv] + bv
elseif bt == 2 then
set udg_Global_AttLv[cv] = udg_Global_AttLv[cv] + bv
elseif bt == 3 then
set udg_Global_DefLv[cv] = udg_Global_DefLv[cv] + bv
elseif bt == 4 then
set udg_Global_Crit[cv] = udg_Global_Crit[cv] + bv
elseif bt == 5 then
set udg_Global_CritDmg[cv] = udg_Global_CritDmg[cv] + bv
elseif bt == 6 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + bv
elseif bt == 7 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + bv
elseif bt == 8 then
set udg_Global_Eva[cv] = udg_Global_Eva[cv] + bv
elseif bt == 9 then
set udg_Global_LifeSteal[cv] = udg_Global_LifeSteal[cv] + bv
elseif bt == 10 then
set udg_Global_ManaSteal[cv] = udg_Global_ManaSteal[cv] + bv
elseif bt == 11 then
set udg_Global_Reflect[cv] = udg_Global_Reflect[cv] + bv
elseif bt == 12 then
set udg_Global_Exp[cv] = udg_Global_Exp[cv] + bv
elseif bt == 13 then
call AddHPMP (true, bv, u)
elseif bt == 14 then
call AddHPMP (false, bv, u)
elseif bt == 15 then
set udg_Global_Pdef[cv] = udg_Global_Pdef[cv] + bv
elseif bt == 16 then
set udg_Global_Mdef1[cv] = udg_Global_Mdef1[cv] + bv
elseif bt == 17 then
set udg_Global_Mdef2[cv] = udg_Global_Mdef2[cv] + bv
elseif bt == 18 then
set udg_Global_Mdef3[cv] = udg_Global_Mdef3[cv] + bv
elseif bt == 19 then
set udg_Global_Mdef4[cv] = udg_Global_Mdef4[cv] + bv
elseif bt == 20 then
set udg_Global_Mdef5[cv] = udg_Global_Mdef5[cv] + bv
elseif bt == 21 then
//reserved
endif
endif
set u = null
endfunction
function AddUnitBuff takes unit u, integer bt, integer bv, integer dur, integer eff, integer perc returns nothing
local integer cv = GetUnitUserData(u)
local integer a = cv + 36000
local integer b = cv + 45000
if LoadInteger( udg_Stat_Table, cv + 36000, - bt ) == 0 then
//call DisplayTextToForce( GetPlayersAll(), "Added a new buff to |cffffff00" + GetUnitName(u) + "|r buff type is " + I2S(bt) + ", buff value is " + I2S(bv))
if udg_Buff_Count[cv] == 0 then
set udg_Buff_Max = ( udg_Buff_Max + 1 )
set udg_Buff_List[udg_Buff_Max] = cv
endif
set udg_Buff_Count[cv] = udg_Buff_Count[cv] + 1
call SaveInteger(udg_Stat_Table, a, udg_Buff_Count[cv], bt)
call SaveInteger(udg_Stat_Table, - a, - bt, bv)
call SaveInteger(udg_Stat_Table, a, - bt, dur)
if perc > 0 then
call SaveInteger(udg_Stat_Table, b, - bt, perc)
endif
if eff > 0 then
call SaveEffectHandle(udg_Stat_Table, b, bt, AddSpecialEffectTarget(EFFECT(eff), udg_UDexUnits[cv], EFFECT_POINT(eff)))
endif
call ApplyBuff (cv, bt, bv, false)
set bt = GetPlayerId(GetOwningPlayer(u)) + 1
call StatRefresh(cv)
if udg_Inv_Unit[bt] == cv and udg_Camera_Lock[bt] == 1 then
call ShowStat(bt)
endif
else
call ApplyBuff (cv, bt, - LoadInteger(udg_Stat_Table, - a, - bt), false)
call ApplyBuff (cv, bt, bv, false)
call SaveInteger(udg_Stat_Table, - a, - bt, bv)
call SaveInteger(udg_Stat_Table, a, - bt, dur) //reset the timer
endif
endfunction
function RemoveUnitBuff takes integer cv, integer bc returns integer
local integer bv
local integer tl
local integer b = 36000 + cv
local integer c = 45000 + cv
local integer bt = LoadInteger(udg_Stat_Table, b, bc)
local integer bt2 = bt
local integer bv2 = LoadInteger(udg_Stat_Table, - b, - bt)
call SaveInteger(udg_Stat_Table, b, - bt, 0) //reset timer
call SaveInteger(udg_Stat_Table, - b, - bt, 0) //reset buff value
call DestroyEffect(LoadEffectHandle(udg_Stat_Table, c, bt))
call RemoveSavedHandle(udg_Stat_Table, c, bt)
call SaveInteger(udg_Stat_Table, c, - bt, 0) //reset timer
set bt = LoadInteger(udg_Stat_Table, b, udg_Buff_Count[cv])
set tl = LoadInteger(udg_Stat_Table, b, - bt)
set bv = LoadInteger(udg_Stat_Table, - b, - bt)
if bc != udg_Buff_Count[cv] then
call SaveInteger(udg_Stat_Table, b, bc, bt) // save buff type from last record
call SaveInteger(udg_Stat_Table, - b, - bt, bv) // save buff value from last record
call SaveInteger(udg_Stat_Table, b, - bt, tl) // save buff timer from last record
set bc = bc - 1
endif
call SaveInteger(udg_Stat_Table, b, udg_Buff_Count[cv], 0) // reset buff type
set udg_Buff_Count[cv] = udg_Buff_Count[cv] - 1
set bv = - bv2
set bt = bt2
call ApplyBuff (cv, bt2, - bv2, false)
set bt2 = GetPlayerId(GetOwningPlayer(udg_UDexUnits[cv])) + 1
call StatRefresh(cv)
if udg_Inv_Unit[bt2] == cv and udg_Camera_Lock[bt2] == 1 then
call ShowStat(bt2)
endif
return bc
endfunction
function RemoveUnitBuffs takes integer i returns nothing
local integer cv = udg_Buff_List[i]
local integer bc = udg_Buff_Count[cv]
loop
exitwhen bc == 0
call RemoveUnitBuff(cv, bc)
set bc = bc - 1
endloop
if i != udg_Buff_Max then
set udg_Buff_List[i] = udg_Buff_List[udg_Buff_Max]
endif
set udg_Buff_List[udg_Buff_Max] = 0
endfunction
//---------------------------------------------------------------------
// ATTACHMENT FUNCTIONS FOR VILLAGERS
//---------------------------------------------------------------------
function SetAttackAnimation takes integer cv returns nothing
local unit u = udg_UDexUnits[cv]
local integer uid = GetUnitTypeId(u)
local integer ilv = LoadInteger(udg_Stat_Table, cv, - 3)
local integer id = GetHandleId(LoadItemHandle(udg_Stat_Table, cv, 3))
local integer subtype
local string s
if uid == HERO_MELEE() or uid == HERO_RANGED() then
call AddUnitAnimationProperties( u, LoadStr(udg_Stat_Table, - cv, 3), false )
if ilv == 103 then
set subtype = LoadInteger(udg_CItem_Table, id, 3)
if subtype < 3 then
set s = ""
elseif subtype < 4 then
set s = "Channel"
elseif subtype < 6 then
set s = "Flesh"
elseif subtype == 6 then
set s = "Lumber"
elseif subtype == 7 then
set s = "Gold"
else
set s = "none"
endif
call SaveStr(udg_Stat_Table, - cv, 3, s )
else
set s = "none"
call SaveStr(udg_Stat_Table, - cv, 3, s )
endif
call AddUnitAnimationProperties( u, s, true )
endif
set s = null
endfunction
function AddAttachment takes integer cv, integer opt returns nothing
local unit u = udg_UDexUnits[cv]
local integer pl
local integer itype
local integer subtype
local integer i
local integer w
local integer id
local string p = "Equipment\\"
//local real x = GetRandomReal( GetRectMinX( GetPlayableMapRect( ) ), GetRectMaxX( GetPlayableMapRect( ) ) )
//local real y = GetRandomReal( GetRectMinY( GetPlayableMapRect( ) ), GetRectMaxY( GetPlayableMapRect( ) ) )
if LoadBoolean(udg_FSS, 631, GetUnitTypeId(u)) then
set pl = GetPlayerId(GetOwningPlayer(u)) + 1
set i = 1
set w = LoadInteger(udg_Stat_Table, cv, - 3 )
set p = "Equipment\\"
loop
exitwhen i > 9
set id = LoadInteger(udg_Stat_Table, cv, - i )
if id > 0 then
set itype = GetItemTypeId(LoadItemHandle(udg_Stat_Table, cv, i))
if (i < 3 or i == 4) and (opt == 3 or opt == 4 or opt == 1) then
if i == 1 then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 1, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "head" ))
elseif i == 2 then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 2, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "chest" ))
elseif i == 4 then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 4, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "foot right" ))
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, - 4, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "foot left" ))
endif
elseif i == 9 and (opt == 4 or opt == 2 or opt == 3) then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 9, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "chest" ))
elseif i == 5 and (opt == 0 or opt == 3) then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 5, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "hand right" ))
elseif i == 3 then
// in template i created here unit what got same name than equiped weapon class, reason for make ability requiment to weapon depend
//if ( udg_WeaponClass[p] == 1 and udg_Weapon_Dummy_unit[p] == null ) then
// set udg_Weapon_Dummy_unit[p] = CreateUnit( Player( pl ), 'h00D', x, y, 0 )
//else
// if ( ( udg_WeaponClass[p] == 2 or udg_WeaponClass[p] == 3 ) and udg_Weapon_Dummy_unit[p] == null ) then
// set udg_Weapon_Dummy_unit[p] = CreateUnit( Player( pl ), 'h00C', x, y, 0 )
// else
// if ( udg_WeaponClass[p] == 4 or udg_Weapon_Dummy_unit[p] == null ) then
// set udg_Weapon_Dummy_unit[p] = CreateUnit( Player( pl ), 'h00F', x, y, 0 )
// else
// if ( udg_WeaponClass[p] == 5 and udg_Weapon_Dummy_unit[p] == null ) then
// set udg_Weapon_Dummy_unit[p] = CreateUnit( Player( pl ), 'h00E', x, y, 0 )
// else
// if ( ( udg_WeaponClass[p] == 6 or udg_WeaponClass[p] == 7 ) and udg_Weapon_Dummy_unit[p] == null ) then
// set udg_Weapon_Dummy_unit[p] = CreateUnit( Player( pl ), 'h00G', x, y, 0 )
// endif
// endif
// endif
// endif
//endif
set subtype = LoadInteger(udg_CItem_Table, GetHandleId(LoadItemHandle(udg_Stat_Table, cv, i)), 3 )
if subtype < 3 then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 3, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "hand left" ))
elseif subtype == 3 then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 3, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "hand left" ))
elseif subtype == 6 then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 3, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "hand left" ))
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, - 3, AddSpecialEffectTarget(p + "Quiver.mdx" , u, "chest" ))
else
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, 3, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "hand right" ))
if subtype == 7 then
call SaveEffectHandle(udg_Stat_Table, 9000 + cv, - 3, AddSpecialEffectTarget(p + LoadStr(udg_FSS, 601, itype) , u, "hand left" ))
endif
endif
endif
endif
set i = i + 1
if i == 6 then
set i = 9
endif
endloop
endif
set u = null
set p = null
endfunction
function RemoveAttachment takes integer cv, integer opt returns nothing
local unit u = udg_UDexUnits[cv]
local integer pl
local integer a
local integer a1
local integer id
local integer subtype
if LoadBoolean(udg_FSS, 631, GetUnitTypeId(u)) then
set pl = GetPlayerId(GetOwningPlayer(u)) + 1
set a = BEARFORM_ID() // ability raw code what trasfom to bear form
set a1 = MELEE2RANGED_ID() // ability raw code what trasfom melee to ranged form
set id = GetHandleId(LoadItemHandle(udg_Stat_Table, cv, 3 ))
set subtype = LoadInteger(udg_CItem_Table, id, 3 )
if opt == 1 or opt == 3 then
call DestroyEffect( LoadEffectHandle(udg_Stat_Table, 9000 + cv, 2) )
call DestroyEffect( LoadEffectHandle(udg_Stat_Table, 9000 + cv, 4) )
call DestroyEffect( LoadEffectHandle(udg_Stat_Table, 9000 + cv, - 4) )
call DestroyEffect( LoadEffectHandle(udg_Stat_Table, 9000 + cv, 1) )
endif
if opt == 2 or opt == 3 then
call DestroyEffect( LoadEffectHandle(udg_Stat_Table, 9000 + cv, 9) )
endif
if opt == 0 or opt == 3 then
call DestroyEffect( LoadEffectHandle(udg_Stat_Table, 9000 + cv, 5) )
//if ( LoadInteger(udg_Stat_Table, 3, 99 ) != 0 ) then
//if ( udg_Weapon_Dummy_unit[pl] != null ) then
// call RemoveUnit( udg_Weapon_Dummy_unit[cv] )
// set udg_Weapon_Dummy_unit[pl] = null
//endif
call DestroyEffect( LoadEffectHandle(udg_Stat_Table, 9000 + cv, 3) )//normal weapon attachment
call DestroyEffect( LoadEffectHandle(udg_Stat_Table, 9000 + cv, - 3) )//dual handed like dagger and quiver
//endif
endif
call UnitAddAbility( u, a )
call IssueImmediateOrder( u, "bearform" )
call UnitRemoveAbility( u, a )
if subtype == 6 then
if ( GetUnitTypeId( u ) == HERO_MELEE() ) then
call SetPlayerAbilityAvailable( Player( pl - 1 ), a1, true )
call IssueImmediateOrder( u, "metamorphosis" )
call SetPlayerAbilityAvailable( Player( pl - 1 ), a1, false )
endif
else
if ( GetUnitTypeId( u ) == HERO_RANGED() ) then
call SetPlayerAbilityAvailable( Player( pl - 1 ), a1, true )
call IssueImmediateOrder( u, "metamorphosis" )
call SetPlayerAbilityAvailable( Player( pl - 1 ), a1, false )
endif
endif
endif
set u = null
endfunction
function DummyVillagerAttachmentRefresh takes nothing returns nothing
local integer pl = 1
local integer LP = GetPlayerId(GetLocalPlayer()) + 1
local integer cv = udg_Inv_Unit[LP]
local integer i
local integer p = 1
local integer ilv
local unit u = LoadUnitHandle(udg_FSS, 550, 0)
local integer alpha = 0
local integer glp
local real y1 = 250
local real y2 = 300
local real y = LoadReal(udg_FSS, 0, 2)
local string path
local string QuiverPath = ""
local real UScale = 1.2
local integer subtype
local integer BearForm = DBEARFORM_ID()//dummy bear form ability id
call UnitAddAbility( u, BearForm )
call IssueImmediateOrder( u, "bearform" )
call UnitRemoveAbility( u, BearForm )
call SetUnitFacing(u, 90)
if not LoadBoolean(udg_FSS, 631, GetUnitTypeId(udg_UDexUnits[cv])) then
set alpha = 0
elseif udg_Camera_Lock[LP] == 1 then
set alpha = 255
set QuiverPath = "Equipment\\Quiver.mdx"
endif
if LoadInteger(udg_Stat_Table, cv, - 9) == 0 then
set UScale = 2
set y = y + y1
else
set UScale = 1.2
set y = y + y2
endif
call SetUnitVertexColor(u, 255, 255, 255, alpha)
call SetUnitY(u, y)
call SetUnitScale(u, UScale, UScale, UScale)
loop
exitwhen pl > 10
if udg_Camera_Lock[pl] == 1 then
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 ilv = LoadInteger(udg_Stat_Table, cv, - i)
if ilv > 0 and alpha > 0 then
set path = ""
if GetLocalPlayer() == Player(pl - 1) then
set path = "Equipment\\" + LoadStr(udg_FSS, 601, GetItemTypeId(LoadItemHandle(udg_Stat_Table, cv, i)))
endif
if i == 1 then
call SaveEffectHandle(udg_FSS, 650 + pl, i, AddSpecialEffectTarget(path, u, "head"))
elseif i == 2 or i == 9 then
call SaveEffectHandle(udg_FSS, 650 + pl, i, AddSpecialEffectTarget(path, u, "chest"))
elseif i == 3 then
set subtype = LoadInteger(udg_CItem_Table, GetHandleId(LoadItemHandle(udg_Stat_Table, cv, i)), 3)
if subtype < 3 then
call SaveEffectHandle(udg_FSS, 650 + pl, i, AddSpecialEffectTarget(path, u, "hand left"))
elseif subtype == 6 then
call SaveEffectHandle(udg_FSS, 650 + pl, i, AddSpecialEffectTarget(path, u, "hand left"))
call SaveEffectHandle(udg_FSS, 650 + pl, i + 100, AddSpecialEffectTarget(QuiverPath, u, "chest"))
elseif subtype == 7 then
call SaveEffectHandle(udg_FSS, 650 + pl, i, AddSpecialEffectTarget(path, u, "hand left"))
call SaveEffectHandle(udg_FSS, 650 + pl, i + 100, AddSpecialEffectTarget(path, u, "hand right"))
else
call SaveEffectHandle(udg_FSS, 650 + pl, i, AddSpecialEffectTarget(path, u, "hand right"))
endif
elseif i == 4 then
call SaveEffectHandle(udg_FSS, 650 + pl, i, AddSpecialEffectTarget(path, u, "foot left"))
call SaveEffectHandle(udg_FSS, 650 + pl, i + 100, AddSpecialEffectTarget(path, u, "foot right"))
elseif i == 5 then
call SaveEffectHandle(udg_FSS, 650 + pl, i, AddSpecialEffectTarget(path, u, "hand right"))
endif
endif
if i == 5 then
set i = 8
endif
set i = i + 1
endloop
endif
set pl = pl + 1
endloop
set path = null
set QuiverPath = null
set u = null
endfunction
//---------------------------------------------------------------------
// FULL SCREEN ICON and INTERFACE HANDLING
//---------------------------------------------------------------------
function EnableBlackWindow takes integer pl returns nothing
local real x1Img = LoadReal(udg_FSS, 0, 1) - 150
local real y1Img = LoadReal(udg_FSS, 0, 2) - 150
local real x2Img = LoadReal(udg_FSS, 0, 4)
local real y2Img = LoadReal(udg_FSS, 0, 5)
local integer alphaImg = 0
local image Img
if GetLocalPlayer() == Player(pl - 1) then
call FogEnable(false)
call FogMaskEnable(false)
set alphaImg = 255
endif
set Img = CreateImage("Background.tga", x2Img, y2Img, 50, x1Img, y1Img, 50, 0, 0, 50, 2)
call SetImageRenderAlways (Img, true)
call SetImageColor(Img, 255, 255, 255, alphaImg)
call SaveImageHandle(udg_FSS, 0, 800 + pl, Img)
set Img = null
endfunction
function DisableBlackWindow takes integer pl returns nothing
call DestroyImage(LoadImageHandle(udg_FSS, 0, 800 + pl))
endfunction
function ShowFakeInterface takes nothing returns nothing
local integer i = 0
local destructable d
local unit u
local integer alpha = 255
local boolean b = true
local integer pl = GetPlayerId(GetLocalPlayer()) + 1
if udg_Camera_Lock[pl] > 0 then
set alpha = 0
set b = false
endif
loop
set d = LoadDestructableHandle(udg_FSS, 1400, i)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 0
loop
set u = LoadUnitHandle(udg_FSS, 1401, i)
exitwhen u == null
call SetUnitVertexColor(u, 255, 255, 255, alpha)
set i = i + 1
endloop
set d = null
set u = null
endfunction
function ShowTradeWindow takes nothing returns nothing
local integer i = 0
local destructable d = null
local boolean b = false
local integer pl = GetPlayerId(GetLocalPlayer()) + 1
local integer plt = udg_Trader[GetPlayerId(GetLocalPlayer()) + 1]
local real x
local real y
local texttag tt = null
local string s
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 1250 + pl, 6))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 1250 + plt, 6))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 1250 + pl, 5))
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 1250 + plt, 5))
if udg_Camera_Lock[pl] == 1 and udg_Trader[pl] > 0 then
set b = true
set s = GetPlayerName(GetLocalPlayer()) + " trade with " + GetPlayerName(Player(udg_Trader[pl] - 1))
set x = LoadReal(udg_FSS, 0, 1) + 946 - (StringLength(s) * 4)
set y = LoadReal(udg_FSS, 0, 2) + 300
set s = StringColoring ( s, 200, 200, 255, 50, 50, 255 )
set tt = CreateTextTag( )
call SetTextTagText( tt, s, 0.8 * 0.023 )
call SetTextTagPos( tt, x , y, 100.00 )
call SetTextTagPermanent( tt, true )
call SaveTextTagHandle(udg_FSS, 1250 + pl, 5, tt)
if GetLocalPlayer() == Player(pl - 1) then
set x = LoadReal(udg_FSS, 0, 1) + 778 + 64
elseif GetLocalPlayer() == Player(udg_Trader[pl] - 1) then
set x = LoadReal(udg_FSS, 0, 1) + 1020 + 64
endif
set y = LoadReal(udg_FSS, 0, 2) + 215
set tt = CreateTextTag( )
call SetTextTagText( tt, I2S(LoadInteger(udg_FSS, 1250 + pl, 7)), 0.8 * 0.023 )
call SetTextTagPos( tt, x , y, 100.00 )
call SetTextTagPermanent( tt, true )
call SetTextTagColor(tt, 200, 200, 200, 100)
call SaveTextTagHandle(udg_FSS, 1250 + pl, 6, tt)
if GetLocalPlayer() == Player(pl - 1) then
set x = LoadReal(udg_FSS, 0, 1) + 1020 + 64
elseif GetLocalPlayer() == Player(udg_Trader[pl] - 1) then
set x = LoadReal(udg_FSS, 0, 1) + 778 + 64
endif
set tt = CreateTextTag( )
call SetTextTagText( tt, I2S(LoadInteger(udg_FSS, 1250 + udg_Trader[pl], 7)), 0.8 * 0.023 )
call SetTextTagPos( tt, x , y, 100.00 )
call SetTextTagPermanent( tt, true )
call SetTextTagColor(tt, 200, 200, 200, 100)
call SaveTextTagHandle(udg_FSS, 1250 + udg_Trader[pl], 6, tt)
set tt = null
set s = null
elseif udg_Camera_Lock[pl] == 1 then
if LoadInteger(udg_FSS, 1250 + pl, 7) > 0 then
call SetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD) + LoadInteger(udg_FSS, 1250 + pl, 7))
call SaveInteger(udg_FSS, 1250 + pl, 7, 0)
endif
//LoadInteger(udg_FSS, 1250+udg_Trader[pl],7)
set i = 1200
loop
exitwhen i > 1205//1205
if LoadInteger(udg_FSS, 1249 + pl, i) > 0 then
call SaveInteger(udg_FSS, 1249 + pl, i, 0)
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2409 + pl, i ))
endif
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2409 + pl, i + 6 ))
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2409 + udg_Trader[pl], i + 6 ))
if LoadInteger(udg_FSS, 1249 + udg_Trader[pl], i) > 0 then
call SaveInteger(udg_FSS, 1249 + udg_Trader[pl], i, 0)
call RemoveDestructable(LoadDestructableHandle(udg_FSS, 2409 + udg_Trader[pl], i + 6 ))
endif
set i = i + 1
endloop
endif
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 1200 + i, 0)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 0
if udg_Camera_Lock[pl] == 1 and udg_Trader[pl] > 0 then
set b = true
endif
loop
set d = LoadDestructableHandle(udg_FSS, 0, 2000 + i)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 1300 + i, 0)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
if i == 4 then
set b = false
set i = 10
endif
endloop
if LoadInteger(udg_FSS, 1275 + pl, 1) > 0 then
call SaveInteger(udg_FSS, 1275 + pl, 1, 0)
endif
set d = null
set s = null
endfunction
function ShowCraftBox takes nothing returns nothing
local destructable d
local boolean b = false
local integer pl = GetPlayerId(GetLocalPlayer()) + 1
local integer i = 0
if LoadInteger(udg_FSS, 2405, pl) == 1 then
set b = true
endif
loop
set d = LoadDestructableHandle(udg_FSS, 2400, i)
exitwhen i == 6 or d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
call ShowDestructable(LoadDestructableHandle(udg_FSS, 2303, 0), b)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 2304, 0), b)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 2305, 0), b)
//if LoadTextTagHandle(udg_FSS,2400, i -10-20) != null then
// call DestroyTextTag(tt)
//endif
set d = null
endfunction
function UpdateGoldinShop takes integer pl returns nothing
local texttag tt = null
local real x = LoadReal(udg_FSS, 0, 1)
local real y = LoadReal(udg_FSS, 0, 2)
if HaveSavedHandle(udg_FSS, 2402, 60 + pl) then
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 60 + pl))
endif
if GetLocalPlayer() == Player(pl - 1) then
set x = LoadReal(udg_FSS, 0, 1)
set y = LoadReal(udg_FSS, 0, 2)
set tt = CreateTextTag( )
call SetTextTagText( tt, StringColoring(I2S(GetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD)), 255, 255, 100, 255, 255, 255), 1 * 0.023 )
call SetTextTagPos( tt, x + 128, y + 260, 100.00 )
call SetTextTagPermanent( tt, true )
endif
call SaveTextTagHandle(udg_FSS, 2402, 60 + pl, tt)
set tt = null
endfunction
function ShowInventoryBox takes nothing returns nothing
local destructable d
local boolean b = false
local integer pl = GetPlayerId(GetLocalPlayer()) + 1
local integer i = 0
if udg_Camera_Lock[pl] > 0 then
set b = true
endif
loop
set d = LoadDestructableHandle(udg_FSS, 0, 200 + i)
exitwhen d == null or i > 299
call ShowDestructable(d, b)
set i = i + 1
endloop
set d = null
endfunction
function CWInterface takes nothing returns nothing
local integer i = 0
local destructable d
local integer alpha = 0
local boolean b = false
local integer pl = GetPlayerId(GetLocalPlayer()) + 1
local unit u = LoadUnitHandle(udg_FSS, 550, 0)
if udg_Camera_Lock[pl] == 1 then
set b = true
endif
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 0, 300 + i)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 1
loop
set d = LoadDestructableHandle(udg_FSS, i, 0)
exitwhen i > 307
if udg_Camera_Lock[pl] == 2 or udg_Camera_Lock[pl] == 3 then
if i >= 100 and i < 120 then
set b = true
else
set b = false
endif
elseif udg_Camera_Lock[pl] == 1 then
set b = true
endif
call ShowDestructable(d, b)
set i = i + 1
if i == 12 then
set i = 100
elseif i == 120 then
set i = 200
elseif i == 206 then
set i = 300
endif
endloop
if udg_Camera_Lock[pl] == 1 then
set alpha = 255
endif
set b = false
if udg_Camera_Lock[pl] == 2 then
set b = true
endif
set i = 1
loop
set d = LoadDestructableHandle(udg_FSS, 2000, i)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 2100, i)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 1
loop
set d = LoadDestructableHandle(udg_FSS, 2000 + i, 0)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 1
loop
set d = LoadDestructableHandle(udg_FSS, 2100 + i, 0)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 2200 + i, 0)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 2300 + i, 0)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
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
set b = false
if LoadInteger(udg_FSS, 2405, 20 + pl) == 1 then
set b = true
endif
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 675, i)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
if not LoadBoolean(udg_FSS, 631, GetUnitTypeId(udg_UDexUnits[udg_Inv_Unit[pl]])) then
set alpha = 0
endif
call SetUnitVertexColor(u, 255, 255, 255, alpha)
set b = false
if udg_Camera_Lock[pl] == 3 or udg_Camera_Lock[pl] == 2 then
set b = true
endif
set i = 0
loop
set d = LoadDestructableHandle(udg_FSS, 2200 + i, 0)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set i = 1
loop
set d = LoadDestructableHandle(udg_FSS, 2423, i)
exitwhen d == null
call ShowDestructable(d, b)
set i = i + 1
endloop
set d = LoadDestructableHandle(udg_FSS, 2100, 6)
if udg_Camera_Lock[pl] > 0 then
call ShowDestructable(d, true)
endif
call ShowCraftBox()
call ShowInventoryBox()
set u = null
set d = null
endfunction
// ------- clear screen :D if somebody remember to old old Qbasic :P
function CLS takes integer pl returns nothing
if GetLocalPlayer() == Player(pl - 1) then
call ClearTextMessages()
endif
endfunction
function ShowItemToInventory takes integer pl, integer cv returns nothing
local item itm
local integer i
local integer dt
local destructable d
local real x
local real y
//check inventory
set i = 100
loop
exitwhen i > 119
set itm = LoadItemHandle(udg_Stat_Table, cv, i)
if itm != null then
set dt = LoadInteger(udg_FSS, 600, GetItemTypeId(itm))
set x = LoadReal(udg_FSS, i, 1)
set y = LoadReal(udg_FSS, i, 2)
if dt > 0 then
set d = LoadDestructableHandle(udg_FSS, 2409 + pl, i)
if d != null then
call RemoveDestructable(d)
endif
set d = CreateDestructableZ(dt, x, y, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + pl, i, d)
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
endif
endif
set i = i + 1
endloop
if udg_Camera_Lock[pl] == 2 or udg_Camera_Lock[pl] == 3 then
call UpdateGoldinShop(pl)
endif
set itm = null
set d = null
endfunction
function ShowBagContent takes integer pl returns nothing
local integer i
local integer dt
local destructable d
local real x
local real y
local integer id = udg_Inv_Bag[pl]
local item itm
local integer O = 2200
call CWInterface()
//check inventory
if id > 0 then
set i = O + 1
loop
set itm = LoadItemHandle(udg_CItem_Table, id, i - O)
exitwhen i > O + BAG_SIZE_MAX()
if itm != null then
set dt = LoadInteger(udg_FSS, 600, GetItemTypeId(itm))
set x = LoadReal(udg_FSS, i, 1)
set y = LoadReal(udg_FSS, i, 2)
if dt > 0 then
set d = CreateDestructableZ(dt, x, y, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + pl, i, d)
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
endif
endif
set i = i + 1
endloop
endif
set d = null
endfunction
function StartShop takes integer pl returns nothing
local integer ilv
local integer i
local real x = 0
local real y = 0
local integer cv = udg_Inv_Unit[pl]
local texttag tt = null
call IssueImmediateOrder( udg_UDexUnits[cv], "stop" )
if GetLocalPlayer() == Player(pl - 1) then
call ClearSelection()
call SelectUnit(udg_UDexUnits[udg_Inv_Unit[pl]], true)
endif
call UpdateGoldinShop(pl)
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 80 + pl))
set x = LoadReal(udg_FSS, 0, 1)
set y = LoadReal(udg_FSS, 0, 2)
if GetLocalPlayer() == Player(pl - 1) then
set tt = CreateTextTag( )
call SetTextTagText( tt, StringColoring("Welcome (Shop)", 100, 100, 255, 255, 255, 255), 1.4 * 0.023 )
call SetTextTagPos( tt, x + 32, y + 480, 100.00 )
call SetTextTagPermanent( tt, true )
endif
call SaveTextTagHandle(udg_FSS, 2402, 80 + pl, tt)
set tt = null
call ShowItemToInventory (pl, cv)
call FlushFT_Stat(pl)
call CLS (pl)
call CWInterface()
call SetChargesText(pl)
call ShowTradeWindow()
endfunction
function StartBagpack takes integer pl returns nothing
call UpdateGoldinShop(pl)
call SetChargesText(pl)
call ShowBagContent(pl)
call CLS (pl)
call ShowItemToInventory(pl, udg_Inv_Unit[pl])
if GetLocalPlayer() == Player(pl - 1) then
call ClearSelection()
call SelectUnit(udg_UDexUnits[udg_Inv_Unit[pl]], true)
endif
endfunction
function CreateDummyUnit takes integer pl, string path, real x, real y, real z, real sc, integer p returns nothing
local integer c = LoadInteger(udg_FSS, 0, - pl * 20) + 1
local integer dr = DUMMY_ID()
local string s = ""
local effect e
local unit u = CreateUnit( Player(pl - 1), dr, LoadReal(udg_FSS, 0, 1) + x, LoadReal(udg_FSS, 0, 2) + y, 270 )
call SaveInteger(udg_FSS, 0, - pl * 20, c)
if GetLocalPlayer() == Player(pl - 1) then
set s = path
endif
call UnitAddAbility(u, 'Amrf')
call UnitRemoveAbility(u, 'Amrf')
call SetUnitAnimationByIndex(u, p )
call SetUnitScale(u, sc, sc, sc)
call SetUnitFlyHeight(u, z, 0)
set e = AddSpecialEffectTarget( s, u, "chest" )
call SaveUnitHandle( udg_FSS, 0, - pl * 20 - c * 2 - 1, u)
call SaveEffectHandle(udg_FSS, 0, - pl * 20 - c * 2, e)
set u = null
set e = null
set s = null
endfunction
function StartInventory takes integer pl returns nothing
local integer ilv
local integer cv = udg_Inv_Unit[pl]
local integer i
local integer dt
local destructable d
local item itm
local real x
local real y
local unit u = udg_UDexUnits[cv]
local unit u2
call DummyVillagerAttachmentRefresh()
call IssueImmediateOrder( u, "stop" )
if GetLocalPlayer() == Player(pl - 1) then
call ClearSelection()
call SelectUnit(u, true)
endif
call CreateDummyUnit (pl, "Doodads\\Felwood\\Plants\\FelwoodBush\\FelwoodBush0.mdx", 500, 220, 100, 0.7, 155)
call CreateDummyUnit (pl, "Doodads\\LordaeronSummer\\Props\\LanternPost\\LanternPost1.mdl", 630, 250, 150, 1.1, 175)
call CreateDummyUnit (pl, "units\\critters\\BlackStagMale\\BlackStagMale.mdl", 500, 250, 50, 1.3, 155)
//check inventory
set i = 1
loop
exitwhen i == 11
set ilv = LoadInteger(udg_Stat_Table, cv, - i)
if ilv != 0 then
set dt = LoadInteger(udg_FSS, 600, GetItemTypeId(LoadItemHandle(udg_Stat_Table, cv, i)))
set x = LoadReal(udg_FSS, i, 1)
set y = LoadReal(udg_FSS, i, 2)
if dt > 0 then
set d = CreateDestructableZ(dt, x, y, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + pl, i, d)
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
endif
endif
set i = i + 1
endloop
call ShowItemToInventory(pl, cv)
set i = 200
loop
exitwhen i > 205
set itm = UnitItemInSlot(u, i - 200)
if itm != null then
set ilv = GetItemLevel(itm)
set dt = LoadInteger(udg_FSS, 600, GetItemTypeId(itm))
set x = LoadReal(udg_FSS, i, 1)
set y = LoadReal(udg_FSS, i, 2)
if dt > 0 then
set d = CreateDestructableZ(dt, x, y, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + pl, i, d)//i - 200
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
endif
endif
set i = i + 1
endloop
//we clear the screen from text
call CLS (pl)
call ShowStat(pl)
call SetChargesText(pl)
call CWInterface()
call ShowTradeWindow()
set i = GetUnitTypeId(u)
if LoadStr(udg_FSS, 635, i) != null then
call CreateDummyUnit (pl, LoadStr(udg_FSS, 635, i), 580, 160, 50, LoadReal(udg_FSS, 632, i), 170)
endif
call UpdateGoldinShop(pl)
set itm = null
set u = null
endfunction
function EnableCamLock takes integer pl, integer CamType returns nothing
local integer i
local integer a = 10 * pl + 100
call SaveReal(udg_FSS, 0, a, GetCameraTargetPositionX())
call SaveReal(udg_FSS, 0, a + 1, GetCameraTargetPositionY())
call SaveReal(udg_FSS, 0, a + 2, GetCameraTargetPositionZ())
call SaveReal(udg_FSS, 0, a + 3, GetCameraField(CAMERA_FIELD_TARGET_DISTANCE))
call SaveReal(udg_FSS, 0, a + 4, GetCameraField(CAMERA_FIELD_FARZ))
call SaveReal(udg_FSS, 0, a + 5, GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK))
call SaveReal(udg_FSS, 0, a + 6, GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW))
call SaveReal(udg_FSS, 0, a + 7, GetCameraField(CAMERA_FIELD_ROLL))
call SaveReal(udg_FSS, 0, a + 8, GetCameraField(CAMERA_FIELD_ROTATION))
call SaveReal(udg_FSS, 0, a + 9, GetCameraField(CAMERA_FIELD_ZOFFSET))
//call DisplayTextToPlayer(Player(pl - 1), 0, 0, R2S(GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK)))
call SetUnitPropWindow (udg_UDexUnits[udg_Inv_Unit[pl]], 0)
call EnableBlackWindow(pl)
set udg_Cam_Index = udg_Cam_Index + 1
set i = udg_Cam_Index
set udg_Cam_Pl[i] = pl
set udg_Camera_Lock[pl] = CamType
if CamType == 1 then
call StartInventory(pl)
elseif CamType == 2 then
call StartShop(pl)
elseif CamType == 3 then
call StartBagpack(pl)
endif
set udg_Inv_Prev[pl] = 0
call ShowFakeInterface()
if i == 1 then
call EnableTrigger( gg_trg_Periodic_camera_lock )
endif
if GetLocalPlayer() == Player(pl - 1) then
call CameraSetupApplyForceDuration(udg_Cam1, true, 0.00)
endif
if udg_Mb_Type[pl] > 0 then
call DestroyMultiboard(udg_Mb_Table[pl])
set udg_Mb_Type[pl] = 0
endif
endfunction
function DisableCamLock takes integer pl returns nothing
local integer index = 0
local integer i = 1
local integer a = 100 + 10 * pl
local unit u = udg_UDexUnits[udg_Inv_Unit[pl]]
loop
exitwhen i > udg_Cam_Index or index != 0
if udg_Cam_Pl[i] == pl then
set index = i
endif
set i = i + 1
endloop
if index == udg_Cam_Index then
set udg_Cam_Pl[index] = 0
else
set udg_Cam_Pl[index] = udg_Cam_Pl[udg_Cam_Index]
endif
if udg_Cam_Index > 0 then
set udg_Cam_Index = udg_Cam_Index - 1
endif
set udg_Camera_Lock[pl] = 0
call DisableBlackWindow(pl)
call SetUnitPropWindow(u, GetUnitDefaultPropWindow(u))
if GetLocalPlayer() == Player(pl - 1) then
call ResetToGameCamera(0.00)
call ClearSelection()
call SelectUnit(u, true)
endif
if GetLocalPlayer() == Player(pl - 1) then
call FogEnable(true)
call FogMaskEnable(true)
endif
call ShowFakeInterface()
if udg_Cam_Index == 0 then
call DisableTrigger( gg_trg_Periodic_camera_lock )
endif
set udg_Inv_Prev[pl] = 0
if Player(pl - 1) == GetLocalPlayer() then
call SetCameraPosition(LoadReal(udg_FSS, 0, a), LoadReal(udg_FSS, 0, a + 1))
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, LoadReal(udg_FSS, 0, a + 3), 0)
call SetCameraField(CAMERA_FIELD_FARZ, LoadReal(udg_FSS, 0, a + 4), 0)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, bj_RADTODEG * LoadReal(udg_FSS, 0, a + 5), 0)
call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, bj_RADTODEG * LoadReal(udg_FSS, 0, a + 6), 0)
call SetCameraField(CAMERA_FIELD_ROLL, bj_RADTODEG * LoadReal(udg_FSS, 0, a + 7), 0)
call SetCameraField(CAMERA_FIELD_ROTATION, bj_RADTODEG * LoadReal(udg_FSS, 0, a + 8), 0)
call SetCameraField(CAMERA_FIELD_ZOFFSET, LoadReal(udg_FSS, 0, a + 9), 0)
endif
set u = null
endfunction
//---------------------------------------------------------------------
// MULTIBOARDS
//---------------------------------------------------------------------
function UpdateMb takes multiboard m, integer x, integer y, string t returns nothing
local multiboarditem mbitem = MultiboardGetItem(m, x, y)
call MultiboardSetItemValue(mbitem, t)
call MultiboardReleaseItem(mbitem)
set mbitem = null
endfunction
function scaning takes unit u, unit ut, player p returns nothing
local integer pl = GetPlayerId(p) + 1
local integer lv
local integer lvt
local integer cv = GetUnitUserData(u)
local integer cvt = GetUnitUserData(ut)
local real eva = udg_Global_Eva[cv]
local real evat = udg_Global_Eva[cvt]
local real acc = udg_Global_Acc[cv]
local real acct = udg_Global_Acc[cvt]
local integer hit
local integer hitt
local integer hpt = R2I(GetWidgetLife(ut))
local integer mpt = R2I(GetUnitState(ut, UNIT_STATE_MANA))
local integer maxhpt = R2I(GetUnitState(ut, UNIT_STATE_MAX_LIFE))
local integer maxmpt = R2I(GetUnitState(ut, UNIT_STATE_MAX_MANA))
local real dmg = udg_Total_Dmg[cv] + 27
local real spelldmg = udg_TotalSpellPower[cv]
local integer AttLv = udg_Global_AttLv[cv]// + udg_B_AttLv[cv]
local integer AttLvt = udg_Global_AttLv[cvt]// + udg_B_AttLv[cvt]
local integer DefLv = udg_Global_DefLv[cvt]// + udg_B_DefLv[cvt]
local integer critdmg = udg_Global_CritDmg[cv] + 200// + udg_B_CritDmg[cv]
local integer pdef = udg_Global_Pdef[cvt]// + udg_B_Pdef[cvt]
local integer mdef1 = udg_Global_Mdef1[cvt]// + udg_B_Mdef[cvt]
local integer mdef2 = udg_Global_Mdef2[cvt]// + udg_B_Mdef[cvt]
local integer mdef3 = udg_Global_Mdef3[cvt]// + udg_B_Mdef[cvt]
local integer mdef4 = udg_Global_Mdef4[cvt]// + udg_B_Mdef[cvt]
local integer mdef5 = udg_Global_Mdef5[cvt]// + udg_B_Mdef[cvt]
local integer ap = GetPlayerId(GetOwningPlayer(ut)) + 1
local real pdefr
local real mdef1r
local real mdef2r
local real mdef3r
local real mdef4r
local real mdef5r
local multiboarditem mbitem
local multiboard m = CreateMultiboard()
local integer i = 0
local string ttype
local integer exp = R2I(udg_Global_Exp[cvt] * (100 + udg_Stat_Exp[cv]) / 100.00) // = R2I((udg_Global_Exp[cvt] * udg_Difficulty * (100 + udg_Stat_Exp[pl] + udg_B_Exp[cv]) / 100.00) / 2) + 50
if udg_Mb_Type[pl] != 0 then
call DestroyMultiboard( udg_Mb_Table[pl] )
endif
set udg_Mb_Table[pl] = m
call MultiboardClear( m )
set udg_Mb_Type[pl] = 2
call MultiboardSetRowCount(m, 22)
call MultiboardSetColumnCount(m, 2)
call MultiboardSetTitleText(m, "Scan board")
call MultiboardSetTitleTextColor(m, 255, 200, 200, 255)
loop
exitwhen i > 22
set mbitem = MultiboardGetItem(m, i, 0)
call MultiboardSetItemWidth(mbitem, 12 / 100.0)
call MultiboardSetItemValueColor(mbitem, 230, 230, 230, 255)
call MultiboardSetItemStyle(mbitem, true, false)
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, i, 1)
call MultiboardSetItemValue(mbitem, " ")
call MultiboardSetItemValueColor(mbitem, 150, 150, 150, 255)
call MultiboardSetItemWidth(mbitem, 12 / 100.0)
call MultiboardSetItemStyle(mbitem, true, false)
call MultiboardReleaseItem(mbitem)
set i = i + 1
endloop
if IsUnitType(u, UNIT_TYPE_HERO) then
set lv = GetHeroLevel(u)
else
set lv = GetUnitLevel(u)
endif
if IsUnitType(ut, UNIT_TYPE_HERO) then
set lvt = GetHeroLevel(ut)
else
set lvt = GetUnitLevel(ut)
endif
if udg_Hero[ap] != ut then
if GetUnitPointValue(ut) == 50 then
set ttype = "Fire"
elseif GetUnitPointValue(ut) == 51 then
set ttype = "Water"
elseif GetUnitPointValue(ut) == 52 then
set ttype = "Lightning"
elseif GetUnitPointValue(ut) == 53 then
set ttype = "Poison"
elseif GetUnitPointValue(ut) == 54 then
set ttype = "Earth"
else
set ttype = "Physical"
endif
else
set ttype = "Hero"
endif
set dmg = dmg + (udg_Global_DmgInc[cv] - udg_Global_DmgRed[cvt]) / 100.00 * dmg
set spelldmg = spelldmg + (udg_Global_DmgInc[cv] - udg_Global_DmgRed[cvt]) / 100.00 * spelldmg
set pdefr = ((1 - pdef / ( 40.00 * lv + pdef + 25.00)) * 100.00 )
set mdef1r = ((1 - mdef1 / ( 40.00 * lv + mdef1 + 25.00)) * 100.00 )
set mdef2r = ((1 - mdef2 / ( 40.00 * lv + mdef2 + 25.00)) * 100.00 )
set mdef3r = ((1 - mdef3 / ( 40.00 * lv + mdef3 + 25.00)) * 100.00 )
set mdef4r = ((1 - mdef4 / ( 40.00 * lv + mdef4 + 25.00)) * 100.00 )
set mdef5r = ((1 - mdef5 / ( 40.00 * lv + mdef5 + 25.00)) * 100.00 )
if mdef1 < 0 then
set mdef1 = 0
endif
if mdef2 < 0 then
set mdef2 = 0
endif
if mdef3 < 0 then
set mdef3 = 0
endif
if mdef4 < 0 then
set mdef4 = 0
endif
if mdef5 < 0 then
set mdef5 = 0
endif
if pdef < 0 then
set pdef = 0
endif
if ( AttLv > DefLv ) then
set dmg = 0 //dmg * ( 1 + ( AttLv - DefLv ) / 100.00 ) * pdefr / 100.00
set spelldmg = 0 //spelldmg * ( 1 + ( AttLv - DefLv ) / 100.00 ) * mdefr / 100.00
else
set dmg = 0 //dmg / ( 1.00 + ( DefLv - AttLv ) / 120.00) * pdefr / 100.00
set spelldmg = 0 //spelldmg / ( 1.00 + ( DefLv - AttLv ) / 120.00) * mdefr / 100.00
endif
set hit = HitChance(cv, cvt)
set hitt = 100 - HitChance(cvt, cv)
set mbitem = MultiboardGetItem(m, 0, 0)
call MultiboardSetItemValue(mbitem, "Level")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 1, 0)
call MultiboardSetItemValue(mbitem, "Type")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 2, 0)
call MultiboardSetItemValue(mbitem, "Attack Type")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 3, 0)
call MultiboardSetItemValue(mbitem, "HP")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 4, 0)
call MultiboardSetItemValue(mbitem, "Critical Chance")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 5, 0)
call MultiboardSetItemValue(mbitem, "Critical Damage")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 6, 0)
call MultiboardSetItemValue(mbitem, "Attack Level")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 7, 0)
call MultiboardSetItemValue(mbitem, "Def. Level")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 8, 0)
call MultiboardSetItemValue(mbitem, "Life Steal")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 9, 0)
call MultiboardSetItemValue(mbitem, "Mana Steal")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 10, 0)
call MultiboardSetItemValue(mbitem, "Reflect")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 11, 0)
call MultiboardSetItemValue(mbitem, "Armor Break")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 12, 0)
call MultiboardSetItemValue(mbitem, "Phy. defence")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 13, 0)
call MultiboardSetItemValue(mbitem, "Fire ress.")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 14, 0)
call MultiboardSetItemValue(mbitem, "Water ress.")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 15, 0)
call MultiboardSetItemValue(mbitem, "Light. ress.")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 16, 0)
call MultiboardSetItemValue(mbitem, "Poison. ress.")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 17, 0)
call MultiboardSetItemValue(mbitem, "Earth. ress.")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 18, 0)
call MultiboardSetItemValue(mbitem, "Accurancy")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 19, 0)
call MultiboardSetItemValue(mbitem, "Evasion")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 20, 0)
call MultiboardSetItemValue(mbitem, "Exp.")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(m, 21, 0)
call MultiboardSetItemValue(mbitem, "Block chance")
call MultiboardReleaseItem(mbitem)
call UpdateMb (m, 0, 1, I2S(lvt))
call UpdateMb (m, 1, 1, GetUnitName(ut))
call UpdateMb (m, 2, 1, ttype)
call UpdateMb (m, 3, 1, "|cffffff00" + I2S(R2I(GetWidgetLife(ut))) + "|r / |cffff3300" + I2S(R2I(GetUnitState(ut, UNIT_STATE_MAX_LIFE))) + "|r")
call UpdateMb (m, 4, 1, (I2S(udg_Global_Crit[cvt]) + " %%"))
call UpdateMb (m, 5, 1, (I2S(udg_Global_CritDmg[cvt]+DEFAULT_CRITICAL_DAMAGE()) + " %%"))
call UpdateMb (m, 6, 1, I2S(AttLvt))
call UpdateMb (m, 7, 1, I2S(DefLv))
call UpdateMb (m, 8, 1, (I2S(udg_Global_LifeSteal[cvt] ) + " %%"))// + udg_B_LS[cvt]
call UpdateMb (m, 9, 1, (I2S(R2I(udg_Global_ManaSteal[cvt])) + " %%"))
call UpdateMb (m, 10, 1, (I2S(udg_Global_Reflect[cvt]) + " %%"))// + udg_B_Ref[cvt]
call UpdateMb (m, 11, 1, (I2S(udg_Global_ArmorBreak[cvt]) + " %%"))
call UpdateMb (m, 12, 1, I2S(pdef) + " |cff999900(" + R2S(100 - pdefr) + "%%)|r")
call UpdateMb (m, 13, 1, I2S(mdef1) + " |cff999900(" + R2S(100 - mdef1r) + "%%)|r")
call UpdateMb (m, 14, 1, I2S(mdef2) + " |cff999900(" + R2S(100 - mdef2r) + "%%)|r")
call UpdateMb (m, 15, 1, I2S(mdef3) + " |cff999900(" + R2S(100 - mdef3r) + "%%)|r")
call UpdateMb (m, 16, 1, I2S(mdef4) + " |cff999900(" + R2S(100 - mdef4r) + "%%)|r")
call UpdateMb (m, 17, 1, I2S(mdef5) + " |cff999900(" + R2S(100 - mdef5r) + "%%)|r")
call UpdateMb (m, 18, 1, I2S(udg_Global_Acc[cvt]) + " |cff999900(" + I2S(hit) + "%%)|r")
call UpdateMb (m, 19, 1, I2S(udg_Global_Eva[cvt]) + " |cff999900(" + I2S(hitt) + "%%)|r")
call UpdateMb (m, 20, 1, I2S(exp))
call UpdateMb (m, 21, 1, I2S(udg_Global_Block[cvt]) + " %%")
call MultiboardMinimize(m, true)
call MultiboardMinimize(m, false)
call MultiboardDisplay( m, false )
if GetLocalPlayer() == p then
call MultiboardDisplay( m, true )
endif
set m = null
set mbitem = null
set ttype = null
endfunction
function GetItemStatName takes integer i, boolean Sign, boolean Perc returns string
if Sign then
// in few case we need ret
if i == 81 or i == 72 then
return "-"
elseif i == 72 then
return ""
else
return "+"
endif
else
if Perc then
if i == 47 or i == 28 or i == 32 or i == 22 or i == 23 or i == 24 or i == 48 or i == 49 or i == 66 or i == 71 or i == 81 or i == 55 then
return "%%"
else
return ""
endif
else
if i == 67 then
return "Duratibility"
elseif i == 40 then
return "Movement Speed"
elseif i == 47 then
return "Attack Speed"
elseif i == 27 then
return "HP Regen"
elseif i == 31 then
return "MP Regen"
elseif i == 28 then
return "Life Steal"
elseif i == 29 then
return "Life per kill"
elseif i == 32 then
return "Mana Steal"
elseif i == 33 then
return "Mana per kill"
elseif i == 22 then
return "Experience"
elseif i == 23 then
return "Rare drop"
elseif i == 24 then
return "Gold Drop"
elseif i == 44 then
return "Strength"
elseif i == 45 then
return "Agility"
elseif i == 46 then
return "Intelligence"
elseif i == 48 then
return "Reflect"
elseif i == 55 then
return "Critical Damage"
elseif i == 49 then
return "Armor penetration"
elseif i == 57 then
return "Fire Damage"
elseif i == 58 then
return "Water Damage"
elseif i == 59 then
return "Lightning Damage"
elseif i == 60 then
return "Poison Damage"
elseif i == 61 then
return "Earth Damage"
elseif i == 62 then
return "Physical Attack"
elseif i == 63 then
return "Magical Attack"
elseif i == 64 then
return "Life"
elseif i == 65 then
return "Mana"
elseif i == 66 then
return "Critical strike"
elseif i == 67 then
return "Duratibility"
elseif i == 68 then
return "Element Ressist"
elseif i == 69 then
return "Attack Level"
elseif i == 70 then
return "Defence Level"
elseif i == 71 then
return "Block chance"
elseif i == 72 then
return "Level requiment"
elseif i == 73 then
return "Accurancy"
elseif i == 74 then
return "Evasion"
elseif i == 75 then
return "Physical Defence"
elseif i == 76 then
return "Fire Ressist"
elseif i == 77 then
return "Water Ressist"
elseif i == 78 then
return "Lightning Ressist"
elseif i == 79 then
return "Poison Ressist"
elseif i == 80 then
return "Earth Ressist"
elseif i == 81 then
return "Shop Price"
elseif i == 82 then
return "Attack"
else
return ""
endif
endif
endif
endfunction
function Mb_Pager takes integer pl, integer page returns nothing
local integer i = 0
local integer a
local integer c //row counter
local integer MaxRowPerPlayer
local integer startAt
local integer RRPPL = 100 //reserved row per player
local integer sh = 2 //shift because 0 is counter, 1 is title so start from 2
local integer RPP = 29 //row limit per page
local string title
local string s
local string ss
local multiboarditem mbitem
set startAt = ((pl - 1) * RRPPL + (page - 1) * (RPP + sh))
set c = S2I(udg_Mb_Row[startAt])
if c > 0 then
if c > RPP then
set c = RPP
endif
set i = 0
set c = c + sh
set title = udg_Mb_Row[startAt + 1]
call MultiboardClear(udg_Mb_Table[pl])
call DestroyMultiboard(udg_Mb_Table[pl])
set udg_Mb_Table[pl] = CreateMultiboard()
set udg_Mb_Type[pl] = 1
call MultiboardSetRowCount(udg_Mb_Table[pl], c - sh)
call MultiboardSetColumnCount(udg_Mb_Table[pl], 1)
call MultiboardSetItemsWidth (udg_Mb_Table[pl], 0.20)
call MultiboardSetTitleText(udg_Mb_Table[pl], title)
//call MultiboardSetTitleText(udg_Mb_Table[pl], title)
call MultiboardSetTitleTextColor(udg_Mb_Table[pl], 255, 200, 200, 255)
loop
exitwhen i == c
set mbitem = MultiboardGetItem(udg_Mb_Table[pl], i, 0)
call MultiboardSetItemWidth(mbitem, 16 / 100.0)
set s = udg_Mb_Row[startAt + i + sh]
set a = GetStringPos (s, ":icon:")
if a > 0 then
set ss = SubString(s, 0, a)
//call BJDebugMsg(SubString(s, a + 6, 0))
call MultiboardSetItemStyle(mbitem, true, true)
call MultiboardSetItemIcon (mbitem, SubString(s, a + 6, 0))
call MultiboardSetItemValue(mbitem, ss)
//call MultiboardSetItemValue(mbitem, ss + AddSpace (" ", 25 - StringLength(ss)) + SubString(s, a + 1, 0))
else
call MultiboardSetItemStyle(mbitem, true, false)
call MultiboardSetItemValue(mbitem, s)
endif
call MultiboardReleaseItem(mbitem)
set i = i + 1
endloop
call MultiboardReleaseItem(mbitem)
call MultiboardDisplay(udg_Mb_Table[pl], false)
if ( GetLocalPlayer() == Player(pl - 1) ) then
call MultiboardDisplay(udg_Mb_Table[pl], true)
call MultiboardMinimize(udg_Mb_Table[pl], false)
endif
endif
set mbitem = null
endfunction
//we inline the bonus stats for make it easier for other functions, like SaveLoad and Multiboard
function Inline_Item_Bonus_Stat takes integer i returns integer
local integer a = 0
local integer max = 42
local integer array IS
set IS[0] = 40
set IS[1] = 47
set IS[2] = 27
set IS[3] = 31
set IS[4] = 28
set IS[5] = 29
set IS[6] = 32
set IS[7] = 33
set IS[8] = 22
set IS[9] = 23
set IS[10] = 24
set IS[11] = 44
set IS[12] = 45
set IS[13] = 46
set IS[14] = 48
set IS[15] = 55
set IS[16] = 49
//57-81
set a = 17
loop
set IS[a] = a + 40
set a = a + 1
exitwhen a > max
endloop
if i >= 0 and i <= max then
return IS[i]
else
return 0
endif
endfunction
//we inline the bonus stats length for make it easier for other functions, like SaveLoad
//this need to type manually, what is the max value for each item stat bonus, if return 1 then
//stat not higher than 82, if return 2 then not higher than 82*82
function Inline_Item_Bonus_Stat_Length takes integer i returns integer
local integer a = 0
local integer max = 99
if i >= 0 and i <= max then
//bonus: hp, mp, mdef, pdef, damages could be higher than 83
if (i >= 57 and i < 66) or i == 67 or i == 68 or (i > 72 and i < 81) or i == 82 or i == 40 or i == 47 then
return 2
else
return 1
endif
else
return 0
endif
endfunction
function Mb_Create_Item_Info takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local item itm = LoadItemHandle(udg_SL_HASHTABLE, 11, id)
local integer cv = LoadInteger(udg_SL_HASHTABLE, 12, id)
local integer slot = LoadInteger(udg_SL_HASHTABLE, 13, id)
local integer ilv = GetItemLevel(itm)
local integer itmId = GetHandleId(itm)
local unit u = udg_UDexUnits[cv]
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
local integer viewer = pl
local integer itype = 0
local integer dur
local integer maxdur = 0
local integer ref
local integer refv
local integer socket = 0
local integer subtype
local integer maxsocket
local integer quality
local integer charge = GetItemCharges(itm)
local integer rcost = 0
local integer page = 1
local integer sh = 2 //shift, we save the stuff with index + 2
local integer RPP = 29 //row limit per page
local integer RRPPL = 100 //reserved row per player
local integer startAt1 = ((pl - 1) * RRPPL + (page - 1) * (RPP + sh))
local integer startAt2 = startAt1 + page * (RPP + sh)
local integer i = startAt1 + 2 //starter row in multiboard page 1
local integer i2 = startAt2 + 2 //starter row in multiboard page 2
local integer str
local integer agi
local integer int
local integer hlv
local integer lvR
local integer strR
local integer agiR
local integer intR
local integer UniqueId = 0
local integer SetId = 0
local integer array EUId //equiped item unique id's
local integer array TUId //target set item unique id's
local integer EUId_i //how much unique item was equiped
local integer TUId_i //how much unique item was in target item set
local integer a
local integer b = 0
local integer c = 0
local integer d
local integer e
local integer f
local integer price = 0
local string reqColor1 = "|cffff3333"
local string reqColor2 = "|cffff3333"
local string noreqColor = "|cffffff33"
local string MinDmg = ""
local integer place = 0
local string s
local string title
local string title2
local string array qc
local integer hclass = LoadInteger(udg_FSS, 633, GetUnitTypeId(u))
local integer iclass
local integer act_id
local integer array IS //item stat properties, so key2 for item data
if charge == 100 then
set charge = 1
endif
//-------- we clean if was previously showed multiboard -------------
if udg_Mb_Table[viewer] != null then
call DestroyMultiboard(udg_Mb_Table[viewer])
endif
loop
exitwhen b > RRPPL + 2
set udg_Mb_Row[(pl - 1) * RRPPL + b] = ""
set b = b + 1
endloop
//------------------------------------------------
set b = 0
set lvR = LoadInteger(udg_CItem_Table, itmId, 8)-LoadInteger(udg_CItem_Table, itmId, 72)
set hlv = GetHeroLevel(u)
set itype = GetItemTypeId(itm)
if ilv >= 100 and ilv <= 200 then
set title = GetFullItemName (itm, true)
if ilv == GEM_LEVEL() then
set UniqueId = LoadInteger(udg_CItem_Table, itmId, 0)
//call SaveStr(udg_FSS, 601, id, iconpath)
//LoadInteger(udg_CItem_Table,-ui,8)
if UniqueId != 0 then
set UniqueId = 2000 + UniqueId
set a = LoadInteger(udg_CItem_Table, - UniqueId, 9)
set b = LoadInteger(udg_CItem_Table, - UniqueId, 10)
set c = LoadInteger(udg_CItem_Table, - UniqueId, 11)
set d = LoadInteger(udg_CItem_Table, - UniqueId, a)
set e = LoadInteger(udg_CItem_Table, - UniqueId, b)
set f = LoadInteger(udg_CItem_Table, - UniqueId, c)
set lvR = LoadInteger(udg_CItem_Table, - UniqueId, 8)
set title = StringColoring(GetGemGradeName(LoadInteger(udg_CItem_Table, - UniqueId, 7)) + " " + GetItemName(itm), 200, 50, 50, 255, 100, 255)
set i = i + 1
set udg_Mb_Row[i] = "|cff7777ffArmor:|r |cffffff00+" + I2S(d)+ GetItemStatName(a, false, true) + " " + GetItemStatName(a, false, false)+"|r"
set i = i + 1
set udg_Mb_Row[i] = "|cff7777ffWeapon:|r |cffffff00+" + I2S(e)+ GetItemStatName(b, false, true) + " " + GetItemStatName(b, false, false)+"|r"
set i = i + 1
set udg_Mb_Row[i] = "|cff7777ffWings:|r |cffffff00+" + I2S(f)+ GetItemStatName(c, false, true) + " " + GetItemStatName(c, false, false)+"|r"
set i = i + 1
set udg_Mb_Row[i] = ""
set i = i + 1
set s = noreqColor
if lvR > hlv then
set s = reqColor1
endif
set udg_Mb_Row[i] = "|cff7777ffItem grade req:|r "+s+"Grade " + I2S(lvR)
set price = LoadInteger(udg_CItem_Table, - UniqueId, 12)
endif
elseif ilv == BAG_LEVEL() then
set b = 1
set c = 0
loop
exitwhen b > 24
if HaveSavedHandle(udg_CItem_Table, itmId, b) then
set udg_Mb_Row[c+2] = GetFullItemName (LoadItemHandle(udg_CItem_Table, itmId, b), true)
set b = b + 1
set c = c + 1
endif
set b = b + 1
endloop
set i = c + 2
if c == 0 then
if LoadStr(udg_FSS, 647, itype) != null then
set udg_Mb_Row[i] = "|caaaaffaa" + LoadStr(udg_FSS, 647, itype) + "|r"
if LoadStr(udg_FSS, 648, itype) != null then
set i = i + 1
set udg_Mb_Row[i] = "|caaaaffaa" + LoadStr(udg_FSS, 648, itype) + "|r"
if LoadStr(udg_FSS, 649, itype) != null then
set i = i + 1
set udg_Mb_Row[i] = "|caaaaffaa" + LoadStr(udg_FSS, 649, itype) + "|r"
endif
endif
set i = i + 1
endif
endif
set b = 0
elseif ilv == BOX_LEVEL() then
if LoadStr(udg_FSS, 647, itype) != null then
set udg_Mb_Row[i] = "|caaaaffaa" + LoadStr(udg_FSS, 647, itype) + "|r"
if LoadStr(udg_FSS, 648, itype) != null then
set i = i + 1
set udg_Mb_Row[i] = "|caaaaffaa" + LoadStr(udg_FSS, 648, itype) + "|r"
if LoadStr(udg_FSS, 649, itype) != null then
set i = i + 1
set udg_Mb_Row[i] = "|caaaaffaa" + LoadStr(udg_FSS, 649, itype) + "|r"
endif
endif
set i = i + 1
endif
else
set UniqueId = LoadInteger(udg_CItem_Table, itmId, 0)
set SetId = LoadInteger(udg_CItem_Table, itmId, 5)
set quality = LoadInteger(udg_CItem_Table, itmId, 4)
set subtype = LoadInteger(udg_CItem_Table, itmId, 3)
set place = ilv - 100
set str = GetHeroStr(u, true)
set agi = GetHeroAgi(u, true)
set int = GetHeroInt(u, true)
set strR = LoadInteger(udg_CItem_Table, itmId, 9)
set agiR = LoadInteger(udg_CItem_Table, itmId, 10)
set intR = LoadInteger(udg_CItem_Table, itmId, 11)
set ref = LoadInteger(udg_CItem_Table, itmId, 16)
set refv = LoadInteger(udg_CItem_Table, itmId, 17)
set socket = LoadInteger(udg_CItem_Table, itmId, 18)
set maxsocket = LoadInteger(udg_CItem_Table, itmId, 20)
set maxdur = R2I(LoadReal(udg_CItem_Table, itmId, 15))
set dur = R2I(LoadReal(udg_CItem_Table, itmId, 14))
set iclass = LoadInteger(udg_CItem_Table, itmId, 6)
if ilv == 103 then
if subtype > 7 then
set MinDmg = I2S(R2I(WeaponMinDamageModifier(subtype)*LoadInteger(udg_CItem_Table, itmId, 53)))+"-"
else
set MinDmg = I2S(R2I(WeaponMinDamageModifier(subtype)*LoadInteger(udg_CItem_Table, itmId, 52)))+"-"
endif
endif
if place == 3 then
set act_id = LoadInteger(udg_CItem_Table, itmId, 25)
else
set act_id = 0
endif
if place != 10 then
if place == 11 then
set price = LoadInteger(udg_CItem_Table, itmId, 12)
set rcost = 0
else
set rcost = R2I(maxdur - dur)
set price = R2I(LoadInteger(udg_CItem_Table, itmId, 12) * (dur / maxdur))
endif
else
set price = 1000
set rcost = 0
endif
set s = ""
if lvR > 0 then
if hlv >= lvR then
set reqColor1 = noreqColor
endif
set udg_Mb_Row[i] = "|cff999999Requiments:|r |cffffffaaLevel |r" + reqColor1 + I2S(lvR) + "|r"
set i = i + 1
set s = " "
set reqColor1 = "|cffff3333"
if strR > 0 and agiR > 0 then
if str >= strR then
set reqColor1 = noreqColor
endif
if agi >= agiR then
set reqColor2 = noreqColor
endif
set s = s + "|cff777777STR:|r " + reqColor1 + I2S(strR) + "|r |cff777777AGI:|r " + reqColor2 + I2S(agiR) + "|r"
elseif strR > 0 and intR > 0 then
if str >= strR then
set reqColor1 = noreqColor
endif
if int >= intR then
set reqColor2 = noreqColor
endif
set s = s + "|cff777777INT:|r " + reqColor2 + I2S(intR) + "|r |cff777777STR:|r " + reqColor1 + I2S(strR) + "|r"
endif
set s = s + "|r"
set udg_Mb_Row[i] = s
set i = i + 1
set s = null
endif
if iclass > 0 then
set reqColor1 = "|cffff3333"
if hclass == 0 or hclass == iclass or (((iclass == 1 and hclass == 2) or (iclass == 3 and hclass == 4)) and ilv < 105 and ilv != 103) then
set reqColor1 = noreqColor
endif
set s = " " + reqColor1 + GetClassName(iclass, ilv) + " only |r"
set udg_Mb_Row[i] = s
set i = i + 1
endif
if place == 11 then
set s = "Charm"
elseif place == 10 then
set s = "Tome"
elseif place == 2 then
set s = "Armor"
elseif place == 1 then
set s = "Helmet"
elseif place == 4 then
set s = "Boot"
elseif place == 9 then
set s = "Wing"
elseif place == 6 then
set s = "Ring"
elseif place == 8 then
set s = "Amulet"
elseif place == 5 then
set s = "Shield"
elseif place == 3 and subtype < 3 then
set s = "One-Handed"
elseif place == 3 and subtype > 2 then
set s = "Two-Handed"
endif
set udg_Mb_Row[i] = "|cff999999Type:|r |cffffff77" + s + "|r"
set i = i + 1
if place < 10 then
if place != 10 then
if LoadInteger(udg_CItem_Table, itmId, 67) == 0 then
set udg_Mb_Row[i] = "|cff999999Duratibility:|r |cffffff77" + I2S(dur) + "/" + I2S(maxdur) + "|r"
else
set udg_Mb_Row[i] = "|cff999999Duratibility:|r |cff7777ff" + I2S(dur) + "/" + I2S(maxdur) + "|r"
endif
set i = i + 1
if LoadInteger(udg_CItem_Table, itmId, 13) == 1 then
set udg_Mb_Row[i] = " |cffff9999[Ethernal]|r"
set i = i + 1
endif
endif
if maxsocket > 0 then
set udg_Mb_Row[i] = "|cff999999Socket:|r |cffffff77" + I2S(socket) + "/" + I2S(maxsocket) + "|r"
set i = i + 1
set f = ItemType2GemType(place)
//we list the gems
if socket > 0 and f != 0 then
set i2 = i2 + 1
set udg_Mb_Row[i2] = StringColoring(" Socket (" + I2S(socket) + "/" + I2S(maxsocket) + ")", 255, 50, 50, 255, 150, 150)
set i2 = i2 + 1
set b = 0
loop
exitwhen b > socket
set c = LoadInteger(udg_CItem_Table, itmId, 1000 + b)
set d = 2000+LoadInteger(udg_CItem_Table, itmId, 1500 + b)
if c > 0 and d > 0 then
set e = LoadInteger(udg_CItem_Table, -d, 8+f)
set udg_Mb_Row[i2] = " +|cffffff00" + I2S(LoadInteger(udg_CItem_Table, -d, e))+GetItemStatName(e, false, true) + " "+GetItemStatName(e, false, false)+ " |r x |cffffff77" + I2S(c) + "|r :icon:"+LoadStr(udg_FSS, 601, LoadInteger(udg_CItem_Table, -d, 1))
set i2 = i2 + 1
endif
set b = b + 1
endloop
set b = 0
endif
endif
endif
if LoadInteger(udg_CItem_Table, itmId, 52) > 0 then
set udg_Mb_Row[i] = "|cff999999Physical damage:|r |cffffff77"+ MinDmg + I2S(LoadInteger(udg_CItem_Table, itmId, 52)) + "|r"
if place == 3 and ref > 0 and subtype < 8 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif place == 3 and subtype < 8 and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Physical Damage:|r 0" + " |cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 53) > 0 then
set udg_Mb_Row[i] = "|cff999999Magic damage:|r |cffffff77"+ MinDmg + I2S(LoadInteger(udg_CItem_Table, itmId, 53)) + "|r"
if place == 3 and ref > 0 and subtype > 7 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif place == 3 and subtype > 7 and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Magic damage:|r 0" + " |cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 26) > 0 then
set udg_Mb_Row[i] = "|cff999999HP:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 26)) + "|r"
if (place == 1 or place == 2 or place == 4) and ref > 0 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif (place == 1 or place == 2 or place == 4) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Life:|r " + " |cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 30) > 0 then
set udg_Mb_Row[i] = "|cff999999Mana:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 30)) + "|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 56) > 0 then
set udg_Mb_Row[i] = "|cff999999Pet Power:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 56)) + " %% |r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 34) > 0 then
if (place == 5 or place == 8) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Phys. Def.:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 34)) + "|r" + " |cff999900(+" + I2S(refv) + ")|r"
else
set udg_Mb_Row[i] = "|cff999999Physical Defence:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 34)) + "|r"
endif
set i = i + 1
elseif (place == 5 or place == 8) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Physical Defence:|r " + "|cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 35) > 0 then
if (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Fire Ressist:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 35)) + "|r"+" |cff999900(+" + I2S(refv) + ")|r"
else
set udg_Mb_Row[i] = "|cff999999Fire Ressist:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 35)) + "|r"
endif
set i = i + 1
elseif (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Fire Ressist:|r " + "|cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 36) > 0 then
set udg_Mb_Row[i] = "|cff999999Water Ressist:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 36)) + "|r"
if (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Water Ressist:|r " + "|cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 37) > 0 then
set udg_Mb_Row[i] = "|cff999999Lightning Ressist:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 37)) + "|r"
if (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Lightning Ressist:|r " + "|cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 38) > 0 then
set udg_Mb_Row[i] = "|cff999999Poison Ressist:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 38)) + "|r"
if (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Poison Ressist:|r " + "|cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 39) > 0 then
set udg_Mb_Row[i] = "|cff999999Earth Ressist:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 39)) + "|r"
if (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif (place == 6 or place == 7) and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Earth Ressist:|r " + "|cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 43) > 0 then
set udg_Mb_Row[i] = "|cff999999Block Dmg. Chance:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 43)) + " %% |r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 54) > 0 then
set udg_Mb_Row[i] = "|cff999999Critical Strike:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 54)) + " %% |r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 41) > 0 then
set udg_Mb_Row[i] = "|cff999999Accurancy:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 41)) + "|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 42) > 0 then
set udg_Mb_Row[i] = "|cff999999Evasion:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 42)) + "|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 50) > 0 then
set udg_Mb_Row[i] = "|cff999999Attack Level:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 50)) + "|r"
if place == 9 and ref > 0 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif place == 9 and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Attack Level:|r " + " |cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
if LoadInteger(udg_CItem_Table, itmId, 51) > 0 then
set udg_Mb_Row[i] = "|cff999999Defence Level:|r |cffffff77+" + I2S(LoadInteger(udg_CItem_Table, itmId, 51)) + "|r"
if place == 9 and ref > 0 then
set udg_Mb_Row[i] = udg_Mb_Row[i] + " |cff999900(+" + I2S(refv) + ")|r"
endif
set i = i + 1
elseif place == 9 and ref > 0 then
set udg_Mb_Row[i] = "|cff999999Defence Level:|r " + " |cff999900(+" + I2S(refv) + ")|r"
set i = i + 1
endif
//-------------- now we write out every data what can be write out with loop --------------------------
set a = 0
loop
set b = Inline_Item_Bonus_Stat(a)
exitwhen b == 0
if LoadInteger(udg_CItem_Table, itmId, b) != 0 then
set udg_Mb_Row[i] = " " + StringColoring(GetItemStatName(b, true, false) + I2S(LoadInteger(udg_CItem_Table, itmId, b)) + GetItemStatName(b, false, true) + " " + GetItemStatName(b, false, false) + " ", 150, 150, 255, 50, 50, 255)
set i = i + 1
endif
set a = a + 1
endloop
set b = 0
//--------------------------------------------------------------------
// --- weapon auto skill - this occured randomly during you attack ---
//--------------------------------------------------------------------
if act_id > 0 then
if act_id == 1 then
set udg_Mb_Row[i] = "|cffff3333Sacrificial Assault:|r |cffeeffddMinor chance|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd for double damage|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd but cost 5%% Max HP.|r"
elseif act_id == 2 then
set udg_Mb_Row[i] = "|cffff3333Bless:|r |cffeeffddMinor chance for|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd recover back 10%% Max HP|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd is last 20 second.|r"
elseif act_id == 3 then
set udg_Mb_Row[i] = "|cffff3333Bleed:|r |cffeeffddMinor chance for|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd make target bleed|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd is last 20 second.|r"
elseif act_id == 4 then
set udg_Mb_Row[i] = "|cffff3333Rage:|r |cffeeffddMinor chance for|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd increase the dealed and|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd taked damage, 5 second.|r"
elseif act_id == 5 then
set udg_Mb_Row[i] = "|cffff3333Streaming:|r |cffeeffddMinor chance for|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd increase life & mana steal|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd by 13%%, is last 6 second.|r"
elseif act_id == 6 then
set udg_Mb_Row[i] = "|cffff3333Amplify:|r |cffeeffddMinor chance for|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd increase every damage on|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd target by 15%%|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd is last 5 second.|r"
elseif act_id == 7 then
set udg_Mb_Row[i] = "|cffff3333Thorn:|r |cffeeffddMinor chance for|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd reflect back every|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd damage, 4 second.|r"
elseif act_id == 8 then
set udg_Mb_Row[i] = "|cffff3333Protection:|r |cffeeffddMinor chance for|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd increase defences by 60%%|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd in last 20 second.|r"
elseif act_id == 9 then
set udg_Mb_Row[i] = "|cffff3333Eagle-Eye:|r |cffeeffddMinor chance for|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd increase critical strike|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd damage by 50%%|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffeeffdd is last 5 second.|r"
endif
set i = i + 1
endif
//--------------------------------------------------------------------
// we store our hero equiped unique item index (if item is unique) to EUId
if UniqueId > 0 and SetId > 0 and HaveSavedString(udg_CItem_Table, itmId, 21) then
set a = 1
set c = 0
loop
exitwhen a == 11
set b = LoadInteger(udg_CItem_Table, GetHandleId(LoadItemHandle(udg_Stat_Table, cv, a)), 0)
if b != 0 then
set d = 1
set e = 0
loop
exitwhen d > c or e == 1
if EUId[d] == b then
set e = 1
endif
set d = d + 1
endloop
if e == 0 then
set c = c + 1
set EUId[c] = b
endif
else
set EUId[a] = 0
endif
set a = a + 1
endloop
set EUId_i = c
set TUId_i = LoadInteger(udg_CItem_Table, - 1000 - SetId, 1)
//-----------------------------------------------------------
//-- here we just count (b) how much part we got (EUId) from whole set (TUId)
set a = 2
set b = 0
loop
exitwhen a > TUId_i + 1
set TUId[a] = LoadInteger(udg_CItem_Table, - 1000 - SetId, a)
set c = 0
loop
exitwhen c > EUId_i
set c = c + 1
if TUId[a] == EUId[c] then
set b = b + 1
endif
endloop
set a = a + 1
endloop
//------------------ we show set bonus if we got more than 1 parts ---------
if b > 1 then
set i = i + 1
set udg_Mb_Row[i] = "<< " + StringColoring(LoadStr(udg_CItem_Table, - 1000 - SetId, 0), 255, 50, 50, 255, 150, 150) + " >>"
set i = i + 1
set a = 2
set c = 0
loop
exitwhen a > b
set c = LoadInteger(udg_CItem_Table, - 1000 - SetId, TUId_i + a)
set udg_Mb_Row[i] = " |cffffff00" + GetItemStatName(c, true, false) + I2S(LoadInteger(udg_CItem_Table, - 1000 - SetId, - TUId_i - a)) + GetItemStatName(c, false, true) + " " + GetItemStatName(c, false, false) + "|r"
set i = i + 1
set a = a + 1
endloop
endif
//-----------------------------------------------------------
//---------------- here we write out the set parts
set title2 = "<< " + StringColoring(LoadStr(udg_CItem_Table, - 1000 - SetId, 0), 255, 50, 50, 255, 150, 150) + "|cffffffaa (" + I2S(b) + "/" + I2S(TUId_i) + ")|r >>"
set i2 = i2 + 1
set udg_Mb_Row[i2] = "<< " + StringColoring(LoadStr(udg_CItem_Table, - 1000 - SetId, 0), 255, 150, 0, 255, 255, 0) + " >>"
set i2 = i2 + 2
set a = 2
loop
exitwhen a > TUId_i + 1
set TUId[a] = LoadInteger(udg_CItem_Table, - 1000 - SetId, a)
set c = 0
set b = 0
loop
exitwhen c > EUId_i or b != 0
set c = c + 1
if TUId[a] == EUId[c] then
set b = 1
endif
endloop
if b == 1 then
set udg_Mb_Row[i2] = " " + StringColoring(LoadStr(udg_CItem_Table, - TUId[a], 21), 255, 255, 75, 255, 250, 150) + " |r"
else
set udg_Mb_Row[i2] = " " + StringColoring(LoadStr(udg_CItem_Table, - TUId[a], 21), 255, 75, 75, 255, 150, 150) + " |r"
endif
set i2 = i2 + 1
set a = a + 1
endloop
//----------- set part writeing end ---------------------------
else
if HaveSavedString(udg_CItem_Table, itmId, 21) then
set i = i + 1
set udg_Mb_Row[i] = "|cff7777ffCrafter:|r |cffffff77" + LoadStr(udg_CItem_Table, itmId, 21) + " |r"
set i = i + 1
endif
endif
if udg_Camera_Lock[pl] == 1 then
if rcost > 0 then
set i = i + 1
set udg_Mb_Row[i] = "|cffffff33Repair Cost:|r |cffffff88" + I2S(rcost) + " Gold|r"
set i = i + 1
else
if udg_Camera_Lock[pl] == 2 or rcost == 0 then
set i = i + 1
set udg_Mb_Row[i] = "|cffffff33Price:|r |cffffff88" + I2S(price / 2) + " Gold|r"
set i = i + 1
endif
endif
elseif udg_Camera_Lock[pl] == 2 or udg_Camera_Lock[pl] == 3 then
set i = i + 1
set udg_Mb_Row[i] = "|cffffff33Price:|r |cffffff88" + I2S(price / 2) + " Gold|r"
set i = i + 1
endif
endif
else
set title = GetItemName(itm)
set s = ""
set price = LoadInteger(udg_FSS, 602, GetItemTypeId(itm))
if charge > 0 and (ilv < 1902 or ilv > 1905) then
if charge == 100 then
set charge = 1
endif
if GetItemTypeId(itm) != 'gold' then
set s = "|cffffff00 x " + I2S(charge) + "|r"
else
set s = " (|cffffff00" + I2S(GetItemUserData(itm)) + " piece|r)"
endif
set price = price * charge
elseif ilv > 1901 and ilv < 1906 then
if lvR > 0 then
if hlv >= lvR then
set reqColor1 = noreqColor
endif
set udg_Mb_Row[i] = "|cff999999Requiments:|r |cffffffaaLevel |r" + reqColor1 + I2S(lvR) + "|r"
set i = i + 1
endif
set i = i + 1
if ilv == 1902 then
set udg_Mb_Row[i] = "|cffaaaaffRestore " + I2S(LoadInteger(udg_CItem_Table, itmId, 26)) + " hit point|r"
elseif ilv == 1903 then
set udg_Mb_Row[i] = "|cffaaaaffRestore " + I2S(LoadInteger(udg_CItem_Table, itmId, 30)) + " mana point|r"
elseif ilv == 1904 then
set udg_Mb_Row[i] = "|cffaaaaffRegenerate " + I2S(LoadInteger(udg_CItem_Table, itmId, 26)) + " hit point|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffaaaaffin last 30 second.|r"
elseif ilv == 1905 then
set udg_Mb_Row[i] = "|cffaaaaffRegenerate " + I2S(LoadInteger(udg_CItem_Table, itmId, 30)) + " mana point|r"
set i = i + 1
set udg_Mb_Row[i] = "|cffaaaaffin last 30 second.|r"
endif
set price = LoadInteger(udg_CItem_Table, itmId, 12)
set rcost = 0
set i = i + 1
endif
set title = StringColoring(GetItemName(itm), 100, 100, 255, 255, 255, 255) + s
if charge > 0 then
if itype != 0 then
if HaveSavedString(udg_FSS, 647, itype) then
set i = i + 1
set udg_Mb_Row[i] = "|cffaaaaaa" + LoadStr(udg_FSS, 647, itype) + "|r"
if HaveSavedString(udg_FSS, 648, itype) != null then
set i = i + 1
set udg_Mb_Row[i] = "|cffaaaaaa" + LoadStr(udg_FSS, 648, itype) + "|r"
if HaveSavedString(udg_FSS, 649, itype) != null then
set i = i + 1
set udg_Mb_Row[i] = "|cffaaaaaa" + LoadStr(udg_FSS, 649, itype) + "|r"
endif
endif
set i = i + 1
endif
endif
if udg_Camera_Lock[pl] == 2 then
set i = i + 1
set udg_Mb_Row[i] = " |cffffff33Price:|r |cffffff88" + I2S(price / 2) + " Gold|r"
set i = i + 1
endif
endif
endif
if i > 0 then
if SetId > 0 or socket > 0 then
set udg_Mb_Row[i] = "Press |cffffff77[DOWN]|r for Socket/Set"
set i = i + 1
set udg_Mb_Row[i2 + 1] = "Press |cffffff77[UP]|r for Normal view"
set i2 = i2 + 1
else
set i = i - 1
endif
set udg_Mb_Row[startAt1] = I2S(i - startAt1)
set udg_Mb_Row[startAt1 + 1] = title
set udg_Mb_Row[startAt2] = I2S(i2 - startAt2)
set udg_Mb_Row[startAt2 + 1] = title
call Mb_Pager (viewer, 1)
endif
call PauseTimer(t)
call DestroyTimer(t)
set u = null
set itm = null
set t = null
endfunction
function Mb_Item_ToolTip takes item itm, integer cv, integer slot returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
call SaveItemHandle(udg_SL_HASHTABLE, 11, id, itm)
call SaveInteger(udg_SL_HASHTABLE, 12, id, cv)
call SaveInteger(udg_SL_HASHTABLE, 13, id, slot)
call TimerStart(t, 0.1, false, function Mb_Create_Item_Info)
set t = null
endfunction
function Mb_ToolTip takes integer viewer, integer pl, integer slot returns nothing
local integer ilv
local item itm
local string s
local string title
local integer cv = udg_Inv_Unit[pl]
if slot < 200 then
set ilv = LoadInteger(udg_Stat_Table, cv, - slot)
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
else
if udg_Camera_Lock[viewer] == 1 then
set itm = UnitItemInSlot(udg_UDexUnits[udg_Inv_Unit[pl]], slot - 200)
set ilv = GetItemLevel(itm)
elseif slot > 2200 and slot < 2225 then
set itm = LoadItemHandle(udg_CItem_Table, udg_Inv_Bag[pl], slot - 2200)
if itm != null then
set ilv = - 1
endif
endif
endif
if ilv == - 1 then
call Mb_Item_ToolTip (itm, cv, 0)
elseif ilv > 0 then
call Mb_Item_ToolTip (itm, cv, slot)
elseif (slot >= 300 and slot < 350) or (slot >= 1300 and slot < 1302) then
set s = ""
if slot == 300 then
set s = " Drop"
elseif slot == 301 then
set s = " Repair"
elseif slot == 302 then
set s = " Repair All"
elseif slot == 303 then
set s = " Close "
elseif slot == 307 then
set s = " Restat "
elseif slot == 306 then
set s = " Add +1 Str "
elseif slot == 305 then
set s = " Add +1 Agi "
elseif slot == 304 then
set s = " Add +1 Int "
elseif slot == 1300 then
if udg_Trader[pl] > 0 then
if LoadInteger(udg_FSS, 1275 + pl, 1) == 0 then
set s = " Locked "
else
set s = " Unlocked "
endif
endif
elseif slot == 1301 then
if udg_Trader[pl] > 0 then
set s = " Trade "
endif
endif
call MultiboardClear(udg_Mb_Table[viewer])
call DestroyMultiboard(udg_Mb_Table[viewer])
if s != "" then
set udg_Mb_Table[viewer] = CreateMultiboard()
set udg_Mb_Type[viewer] = 1
call MultiboardSetRowCount(udg_Mb_Table[viewer], 0)
call MultiboardSetColumnCount(udg_Mb_Table[viewer], 0)
call MultiboardSetTitleText(udg_Mb_Table[viewer], "|cffffff00 " + s + " |r")
call MultiboardSetTitleTextColor(udg_Mb_Table[viewer], 255, 200, 200, 255)
call MultiboardDisplay(udg_Mb_Table[viewer], false)
if ( GetLocalPlayer() == Player(viewer - 1) ) then
call MultiboardDisplay(udg_Mb_Table[viewer], true)
call MultiboardMinimize(udg_Mb_Table[viewer], true)
endif
endif
else
call DestroyMultiboard(udg_Mb_Table[viewer])
set udg_Mb_Type[viewer] = 0
endif
set s = null
set itm = null
set title = null
endfunction
//-------------------------------------------------------------------------
// EQUIPING FUNCTIONS
//-------------------------------------------------------------------------
function EquipAItem takes integer cv, item itm, boolean equip returns nothing
local integer pl = GetPlayerId(GetOwningPlayer(udg_UDexUnits[cv])) + 1
local unit u = udg_UDexUnits[cv]
local integer i = 1
local integer ii = 0
local integer id = GetHandleId(itm)
local integer ilv = GetItemLevel(itm)
local integer sl = ilv - 100
local integer x = 1
local integer hp = 0
local integer mp = 0
local integer amount = 0
local integer reflv = LoadInteger(udg_CItem_Table, id, 16 )
local integer refv = LoadInteger(udg_CItem_Table, id, 17 )
local integer socket = LoadInteger(udg_CItem_Table, id, 18 )
local integer subtype = LoadInteger(udg_CItem_Table, id, 3 )
//set bonus variables
local integer UniqueId = LoadInteger(udg_CItem_Table, id, 0 )
local integer SetId = LoadInteger(udg_CItem_Table, id, 5 )
local integer a
local integer b
local integer c
local integer d
local integer e = 0
local integer f = 0
local integer EUId_i
local integer TUId_i
local integer array EUId
local integer array TUId
local integer array STAT
local integer StatType = 0
local item itm2
//i just want avoid the problem with useing null variable so fill array with 0
set a = 22
loop
exitwhen a == 82
set STAT[a] = 0
set a = a + 1
endloop
//--------------------------------------------------------------------
// we store our hero equiped unique item index (if item is unique) to EUId
if UniqueId > 0 and SetId > 0 then
set a = 1
set c = 1
loop
exitwhen a == 11
set itm2 = LoadItemHandle(udg_Stat_Table, cv, a)
set b = LoadInteger(udg_CItem_Table, GetHandleId(itm2), 0)
if b != 0 then
if b == UniqueId then
set f = f + 1
endif
set d = 1
set e = 0
loop
exitwhen d > c //or e == 1
if EUId[d] == b then
set e = 1
endif
set d = d + 1
endloop
if e == 0 then
set EUId[c] = b
set c = c + 1
endif
else
set EUId[c] = 0
endif
set a = a + 1
endloop
set EUId_i = c - 1
set TUId_i = LoadInteger(udg_CItem_Table, - 1000 - SetId, 1)
//-----------------------------------------------------------
//-- here we just count (b) how much part we got (EUId) from whole set (TUId)
set a = 2
set b = 0
loop
exitwhen a > TUId_i + 1
set TUId[a] = LoadInteger(udg_CItem_Table, - 1000 - SetId, a)
set c = 1
loop
exitwhen c > EUId_i
if TUId[a] == EUId[c] then
set b = b + 1
endif
set c = c + 1
endloop
set a = a + 1
endloop
//------------------ we show set bonus if we got more than 1 parts ---------
if b > 1 then
if not equip then
set b = b - 1
if b > 0 and f == 1 then
set c = LoadInteger(udg_CItem_Table, - 1000 - SetId, TUId_i + 1 + b) //properties number
set d = LoadInteger(udg_CItem_Table, - 1000 - SetId, - TUId_i - 1 - b) //properties value
endif
else
if b > 1 and f < 2 then
set c = LoadInteger(udg_CItem_Table, - 1000 - SetId, TUId_i + b) //properties number
set d = LoadInteger(udg_CItem_Table, - 1000 - SetId, - TUId_i - b) //properties value
endif
endif
if c != 0 and d != 0 then
set STAT[c] = STAT[c] + d
endif
endif
endif
//-----------------------------------------------------------
if ilv == 103 then
if equip then
set udg_Global_Act_Id[cv] = LoadInteger(udg_CItem_Table, id, 25 )
else
set udg_Global_Act_Id[cv] = 0
endif
endif
if not equip then
set x = - 1
endif
// ------------------- Socket Gem Part ---------------------------
if socket > 0 and (sl < 5 or sl == 9 ) then
set i = 1
loop
exitwhen i > socket
set amount = LoadInteger(udg_CItem_Table, id, 1000 + i)
set ii = LoadInteger(udg_CItem_Table, id, 1500 + i)
set StatType = ItemType2GemType (ilv-100)
//8+1 or 2 or 3=>9=armor,10=weapon,11=wings
set f = LoadInteger(udg_CItem_Table, -ii-2000, 8 + StatType)
set STAT[f] = LoadInteger(udg_CItem_Table, -ii-2000, f) * amount
if amount > 0 then
set STAT[f] = LoadInteger(udg_CItem_Table, -ii-2000, f) * amount
endif
set i = i + 1
endloop
endif
// ------------------------ Refine stuff--------------------------
if reflv > 0 then
if ( refv > 0 ) then
if sl == 3 then
if ( ilv >= 1000 ) then
set udg_Stat_SpellPower[cv] = udg_Stat_SpellPower[cv] + refv * x
else
set udg_Stat_Dmg[cv] = udg_Stat_Dmg[cv] + refv * x
endif
else
if sl == 6 or sl == 7 then
set udg_Stat_Mdef1[cv] = udg_Stat_Mdef1[cv] + refv * x
set udg_Stat_Mdef2[cv] = udg_Stat_Mdef2[cv] + refv * x
set udg_Stat_Mdef3[cv] = udg_Stat_Mdef3[cv] + refv * x
set udg_Stat_Mdef4[cv] = udg_Stat_Mdef4[cv] + refv * x
set udg_Stat_Mdef5[cv] = udg_Stat_Mdef5[cv] + refv * x
elseif sl == 8 then
set udg_Stat_Pdef[cv] = udg_Stat_Pdef[cv] + refv * x
elseif sl == 9 then
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + refv * x
set udg_Stat_DefLv[cv] = udg_Stat_DefLv[cv] + refv * x
elseif sl == 5 then
set udg_Stat_Pdef[cv] = udg_Stat_Pdef[cv] + refv * x
elseif sl == 1 or sl == 2 or sl == 4 then
set hp = hp + refv * x
endif
endif
endif
endif
//u would ask why i this long shit if can make/use a hashtable for save stats?
//the answer because golbal arrays faster than allways loading alot times from hashtable
//example when more unit attack on map and at each attack u load alot data from hash
set STAT[22] = STAT[22] + LoadInteger(udg_CItem_Table, id, 22) //exp bonus
set STAT[23] = STAT[23] + LoadInteger(udg_CItem_Table, id, 23) //drop bonus
set STAT[24] = STAT[24] + LoadInteger(udg_CItem_Table, id, 24) //gold drop rate
set STAT[26] = STAT[26] + LoadInteger(udg_CItem_Table, id, 26) //hp
set STAT[27] = STAT[27] + LoadInteger(udg_CItem_Table, id, 27) //hp regen
set STAT[28] = STAT[28] + LoadInteger(udg_CItem_Table, id, 28) //life steal
set STAT[29] = STAT[29] + LoadInteger(udg_CItem_Table, id, 29) //life per kill
set STAT[30] = STAT[30] + LoadInteger(udg_CItem_Table, id, 30) //mp
set STAT[31] = STAT[31] + LoadInteger(udg_CItem_Table, id, 31) //mp regen
set STAT[32] = STAT[32] + LoadInteger(udg_CItem_Table, id, 32) //mana steal
set STAT[33] = STAT[33] + LoadInteger(udg_CItem_Table, id, 33) //mana per kill
set STAT[34] = STAT[34] + LoadInteger(udg_CItem_Table, id, 34) //pdef
set STAT[35] = STAT[35] + LoadInteger(udg_CItem_Table, id, 35) //fire def
set STAT[36] = STAT[36] + LoadInteger(udg_CItem_Table, id, 36) //water def
set STAT[37] = STAT[37] + LoadInteger(udg_CItem_Table, id, 37) //lightning def
set STAT[38] = STAT[38] + LoadInteger(udg_CItem_Table, id, 38) //posion def
set STAT[39] = STAT[39] + LoadInteger(udg_CItem_Table, id, 39) //earth def
set STAT[40] = STAT[40] + LoadInteger(udg_CItem_Table, id, 40) //mov speed
set STAT[41] = STAT[41] + LoadInteger(udg_CItem_Table, id, 41) //acc
set STAT[42] = STAT[42] + LoadInteger(udg_CItem_Table, id, 42) //eva
set STAT[43] = STAT[43] + LoadInteger(udg_CItem_Table, id, 43) //block dmg
set STAT[44] = STAT[44] + LoadInteger(udg_CItem_Table, id, 44) //str
set STAT[45] = STAT[45] + LoadInteger(udg_CItem_Table, id, 45) //agi
set STAT[46] = STAT[46] + LoadInteger(udg_CItem_Table, id, 46) //int
set STAT[47] = STAT[47] + LoadInteger(udg_CItem_Table, id, 47) //attack speed
set STAT[48] = STAT[48] + LoadInteger(udg_CItem_Table, id, 48) //reflect dmg
set STAT[49] = STAT[49] + LoadInteger(udg_CItem_Table, id, 49) //armor penetration per kill
set STAT[50] = STAT[50] + LoadInteger(udg_CItem_Table, id, 50) //attack lv
set STAT[51] = STAT[51] + LoadInteger(udg_CItem_Table, id, 51) //def lv
set STAT[52] = STAT[52] + LoadInteger(udg_CItem_Table, id, 52) //pdmg
set STAT[53] = STAT[53] + LoadInteger(udg_CItem_Table, id, 53) //spellpower
set STAT[54] = STAT[54] + LoadInteger(udg_CItem_Table, id, 54) //crit
set STAT[55] = STAT[55] + LoadInteger(udg_CItem_Table, id, 55) //crit dmg
set STAT[56] = STAT[56] + LoadInteger(udg_CItem_Table, id, 56) //pet power
set STAT[57] = STAT[57] + LoadInteger(udg_CItem_Table, id, 57) //fire dmg
set STAT[58] = STAT[58] + LoadInteger(udg_CItem_Table, id, 58) //water dmg
set STAT[59] = STAT[59] + LoadInteger(udg_CItem_Table, id, 59) //lightning dmg
set STAT[60] = STAT[60] + LoadInteger(udg_CItem_Table, id, 60) //poison dmg
set STAT[61] = STAT[61] + LoadInteger(udg_CItem_Table, id, 61) //earth dmg
set STAT[62] = STAT[62] + LoadInteger(udg_CItem_Table, id, 62) //bonus crit dmg
set STAT[63] = STAT[63] + LoadInteger(udg_CItem_Table, id, 63) //spell power
set STAT[64] = STAT[64] + LoadInteger(udg_CItem_Table, id, 64) //bonus hp
set STAT[65] = STAT[65] + LoadInteger(udg_CItem_Table, id, 65) //bonus mp
set STAT[66] = STAT[66] + LoadInteger(udg_CItem_Table, id, 66) //bonus crit
//67 is duratibility bonus
//68 is five element defence
set STAT[68] = STAT[68] + LoadInteger(udg_CItem_Table, id, 68) //element defence
set STAT[70] = STAT[70] + LoadInteger(udg_CItem_Table, id, 70) //bonus def lv
set STAT[71] = STAT[71] + LoadInteger(udg_CItem_Table, id, 71) //bonus block dmg
//72 is level requiment reduction bonus so that we don't need to add anywhere because it is only item related properties
set STAT[73] = STAT[73] + LoadInteger(udg_CItem_Table, id, 73) //bonus acc
set STAT[74] = STAT[74] + LoadInteger(udg_CItem_Table, id, 74) //bonus eva
set STAT[75] = STAT[75] + LoadInteger(udg_CItem_Table, id, 75) //bonus pdef
set STAT[76] = STAT[76] + STAT[68] + LoadInteger(udg_CItem_Table, id, 76) //bonus fire def
set STAT[77] = STAT[77] + STAT[68] + LoadInteger(udg_CItem_Table, id, 77) //bonus water def
set STAT[78] = STAT[78] + STAT[68] + LoadInteger(udg_CItem_Table, id, 78) //bonus lightning def
set STAT[79] = STAT[79] + STAT[68] + LoadInteger(udg_CItem_Table, id, 79) //bonus poison def
set STAT[80] = STAT[80] + STAT[68] + LoadInteger(udg_CItem_Table, id, 80) //bonus earth def
set STAT[81] = STAT[81] + LoadInteger(udg_CItem_Table, id, 81) //shop discount
if subtype > 7 then
set STAT[53] = STAT[53] + STAT[82]
else
set STAT[52] = STAT[52] + STAT[82]
endif
set udg_Stat_Pet_Power[cv] = udg_Stat_Pet_Power[cv] + STAT[56] * x
set udg_Stat_SpellPower[cv] = udg_Stat_SpellPower[cv] + (STAT[53] + STAT[63]) * x
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + (STAT[50] + STAT[69]) * x
set udg_Stat_AttackSpeed[cv] = udg_Stat_AttackSpeed[cv] + STAT[47] * x
set udg_Stat_Reflect[cv] = udg_Stat_Reflect[cv] + STAT[48] * x
set udg_Stat_BlockDmg[cv] = udg_Stat_BlockDmg[cv] + (STAT[43] + STAT[71]) * x
set udg_Stat_Crit[cv] = udg_Stat_Crit[cv] + (STAT[54] + STAT[66]) * x
set udg_Stat_Dmg[cv] = udg_Stat_Dmg[cv] + (STAT[52] + STAT[62]) * x
set udg_Stat_CritDmg[cv] = udg_Stat_CritDmg[cv] + STAT[55] * x
set udg_Stat_Eva[cv] = udg_Stat_Eva[cv] + (STAT[42] + STAT[74]) * x
set udg_Stat_DefLv[cv] = udg_Stat_DefLv[cv] + (STAT[51] + STAT[70]) * x
set udg_Stat_HpRegen[cv] = udg_Stat_HpRegen[cv] + STAT[27] * x
set udg_Stat_LifeSteal[cv] = udg_Stat_LifeSteal[cv] + STAT[28] * x
set udg_Stat_Pdef[cv] = udg_Stat_Pdef[cv] + (STAT[34] + STAT[75]) * x
//here we need add 5 elemental def, hp per kill, mp per kill, drop chance, 5 elemental dmg
set udg_Stat_Mdef1[cv] = udg_Stat_Mdef1[cv] + (STAT[35] + STAT[76]) * x
set udg_Stat_Mdef2[cv] = udg_Stat_Mdef2[cv] + (STAT[36] + STAT[77]) * x
set udg_Stat_Mdef3[cv] = udg_Stat_Mdef3[cv] + (STAT[37] + STAT[78]) * x
set udg_Stat_Mdef4[cv] = udg_Stat_Mdef4[cv] + (STAT[38] + STAT[79]) * x
set udg_Stat_Mdef5[cv] = udg_Stat_Mdef5[cv] + (STAT[39] + STAT[80]) * x
set udg_Stat_ManaSteal[cv] = udg_Stat_ManaSteal[cv] + STAT[32] * x
set udg_Stat_MovSpeed[cv] = udg_Stat_MovSpeed[cv] + STAT[40] * x
set udg_Stat_MpRegen[cv] = udg_Stat_MpRegen[cv] + STAT[31] * x
set udg_Stat_Exp[cv] = udg_Stat_Exp[cv] + STAT[22] * x
set udg_Stat_Drop_Bonus[cv] = udg_Stat_Drop_Bonus[cv] + STAT[23] * x
set udg_Stat_Gold_Bonus[cv] = udg_Stat_Gold_Bonus[cv] + STAT[24] * x
set udg_Stat_Acc[cv] = udg_Stat_Acc[cv] + (STAT[41] + STAT[73]) * x
set udg_Global_Hp4Kill[cv] = udg_Global_Hp4Kill[cv] + STAT[29] * x
set udg_Global_Mp4Kill[cv] = udg_Global_Mp4Kill[cv] + STAT[33] * x
set udg_Global_ArmorBreak[cv] = udg_Global_ArmorBreak[cv] + STAT[49] * x
set udg_Global_MDmg1[cv] = udg_Global_MDmg1[cv] + STAT[57] * x
set udg_Global_MDmg2[cv] = udg_Global_MDmg2[cv] + STAT[58] * x
set udg_Global_MDmg3[cv] = udg_Global_MDmg3[cv] + STAT[59] * x
set udg_Global_MDmg4[cv] = udg_Global_MDmg4[cv] + STAT[60] * x
set udg_Global_MDmg5[cv] = udg_Global_MDmg5[cv] + STAT[61] * x
set hp = hp + (STAT[26] + STAT[64]) * x
set mp = mp + (STAT[30] + STAT[65]) * x
call SetHeroStr(u, GetHeroStr(u, true) + STAT[44] * x , true)
call SetHeroAgi(u, GetHeroAgi(u, true) + STAT[45] * x , true)
call SetHeroInt(u, GetHeroInt(u, true) + STAT[46] * x , true)
set udg_Global_Discount[cv] = udg_Global_Discount[cv] + STAT[81] * x
call AddHPMP(true, hp, u)
call AddHPMP(false, mp, u)
set udg_Total_Dmg[cv] = udg_Stat_Dmg[cv]
//if GetHeroStr(u, true) > GetHeroAgi(u, true) then
// set udg_Total_Dmg[cv] = udg_Stat_Dmg[cv] + udg_Stat_Dmg[cv] * (GetHeroStr(u, true) / 500)
//else
// set udg_Total_Dmg[cv] = udg_Stat_Dmg[cv] + udg_Stat_Dmg[cv] * (GetHeroAgi(u, true) / 500)
//endif
call AddDMG(false, cv, (udg_Stat_AttackSpeed[cv] + (GetHeroAgi(u, true) / 2)))
call AddDMG(true, cv, udg_Total_Dmg[cv])
call StatRefresh(cv)
if udg_Camera_Lock[pl] == 1 then
call ShowStat(pl)
endif
call UpdateGoldinShop (pl)
set itm2 = null
endfunction
function EquipItem takes integer cv, integer slot, boolean equip returns nothing
local item itm = LoadItemHandle(udg_Stat_Table, cv, slot)
local integer ilv = LoadInteger(udg_Stat_Table, cv, - slot )
if ilv > 0 then
if ilv != 111 then
call DummyVillagerAttachmentRefresh()
endif
call EquipAItem(cv, itm, equip)
endif
set itm = null
endfunction
function ForcedUnequip takes integer cv, integer slot returns nothing
local integer i = 100
local integer Quit = 0
local integer a = 0
local integer ilv = LoadInteger(udg_Stat_Table, cv, - slot)
local integer id
local integer dur = 1
local unit u = udg_UDexUnits[cv]
local integer uid = GetUnitTypeId(u)
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local item itm
if ilv > 0 then
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
set id = GetHandleId(itm)
call EquipItem(pl, slot, false)
//if non villager then don't need that stuffs
if uid == HERO_MELEE() or uid == HERO_RANGED() then
call SetAttackAnimation (cv)
call RemoveAttachment (cv, 3)
endif
call ClearSlot (cv, slot)
//if non villager then don't need that stuffs
if uid == HERO_MELEE() or uid == HERO_RANGED() then
call AddAttachment (cv, 3)
endif
set udg_Stop_Stack[cv] = true
set i = 100
loop
exitwhen i == 206 or Quit == 1
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)
set Quit = 1
endif
else
if UnitItemInSlot(u, i - 200) == null then
call AddItem2Slot (cv, itm, i - 200)
set Quit = 1
endif
endif
if i==119 then
set i = 199
endif
set i = i + 1
endloop
if Quit == 0 then
call SetItemVisible(itm, true)
call SetItemPosition(itm, x, y)
endif
endif
set udg_Stop_Stack[cv] = false
set itm = null
set u = null
endfunction
//-------------------------------------------------------------------------
// DROP FUNCTIONS
//-------------------------------------------------------------------------
function SetUnitDrop takes integer utype, real C1, real LvDrop, integer DSId, real C2 returns nothing
local integer a1 = R2I(C1 / 100)
local integer a2 = R2I(C2 / 100)
local integer aLvD = R2I(LvDrop / 100)
set C1 = C1 - a1 * 100
set C2 = C2 - a2 * 100
set LvDrop = LvDrop - aLvD * 100
call SaveInteger(udg_Drop_Table, utype, 701, a1) // default drop amount
call SaveInteger(udg_Drop_Table, utype, 702, a2) // shared drop amount
call SaveInteger(udg_Drop_Table, utype, 710, DSId) // shared drop id
call SaveInteger(udg_Drop_Table, utype, 703, aLvD) // general level drop amount
call SaveReal(udg_Drop_Table, utype, 711, C1) // default drop chance
call SaveReal(udg_Drop_Table, utype, 712, C2) // shared drop chance
call SaveReal(udg_Drop_Table, utype, 713, LvDrop) // general level drop chance
endfunction
function AddLevelDrop takes integer lv, integer itype, real chance returns nothing
local integer i = 0
local integer a = 1
local integer Index
if lv < 0 then
set lv = - lv
endif
set Index = LoadInteger(udg_Drop_Table, - lv, 0) // saved item count in level category
if chance > 0 then
loop
exitwhen i > Index or a == - 1
set a = LoadInteger(udg_Drop_Table, - lv, i)
if a == itype then
call SaveReal(udg_Drop_Table, - lv, - Index, chance)
set a = - 1
endif
set i = i + 1
endloop
endif
if Index < 512 then
if a != - 1 then
//increase the index
call SaveInteger(udg_Drop_Table, - lv, 0, Index + 1)
// save the itemtypeid and chance
call SaveInteger(udg_Drop_Table, - lv, Index + 1, itype)
call SaveReal(udg_Drop_Table, - lv, - Index - 1, chance)
endif
endif
endfunction
function AddUnitDrop takes integer utype, integer itype, real chance returns nothing
local integer Index = LoadInteger(udg_Drop_Table, utype, 0) // saved item count
local integer i = 1
local integer a = 1
//we check if the item already exist on list or no
//if yes then we just upgrade the drop chance
if chance > 0 then
loop
exitwhen i > Index or a == - 1
set a = LoadInteger(udg_Drop_Table, utype, i)
if a == itype then
call SaveReal(udg_Drop_Table, utype, - Index, chance)
set a = - 1
endif
set i = i + 1
endloop
//if we dont got the item in drop list then we add it
if Index < 512 then
if a != - 1 then
//increase the index
call SaveInteger(udg_Drop_Table, utype, 0, Index + 1)
// save the itemtypeid and chance
call SaveInteger(udg_Drop_Table, utype, Index + 1, itype)
call SaveReal(udg_Drop_Table, utype, - Index, chance)
endif
endif
endif
endfunction
function RemoveItemDropFromUnit takes integer utype, integer itype returns nothing
local integer i = 1
local integer Index = LoadInteger(udg_Drop_Table, utype, 0) // saved item count
local integer a = 1
loop
exitwhen i > Index or a == - 1
set a = LoadInteger(udg_Drop_Table, utype, i)
if a == itype then
if i != Index then
call SaveInteger(udg_Drop_Table, utype, i, LoadInteger(udg_Drop_Table, utype, Index))
call SaveReal(udg_Drop_Table, utype, - i, LoadReal(udg_Drop_Table, utype, - i))
endif
call SaveInteger(udg_Drop_Table, utype, 0, Index - 1 )
endif
set i = i + 1
endloop
endfunction
function GetDefaultDropItem takes integer utype returns integer
local integer i
local integer itemId = 0
local integer Index = LoadInteger(udg_Drop_Table, utype, 0) // saved item count
local integer rndI
local real rndC
if Index > 0 then
loop
exitwhen itemId > 0
set rndI = GetRandomInt(1, Index)
set rndC = GetRandomReal(0, 100)
if LoadReal(udg_Drop_Table, utype, - rndI) > rndC then
set itemId = LoadInteger(udg_Drop_Table, utype, rndI)
endif
endloop
endif
return itemId
endfunction
function GetLevelDropItem takes integer lv returns integer
local integer i
local integer itemId = 0
local integer Index = LoadInteger(udg_Drop_Table, - lv, 0) // saved item count
local integer rndI
local real rndC
if Index > 0 then
loop
exitwhen itemId != 0
set rndI = GetRandomInt(1, Index)
set rndC = GetRandomReal(0, 100)
if LoadReal(udg_Drop_Table, - lv, - rndI) > rndC then
set itemId = LoadInteger(udg_Drop_Table, - lv, rndI)
endif
endloop
endif
return itemId
endfunction
Name | Type | is_array | initial_value |
Abilities | integer | Yes | |
B_SP | integer | Yes | |
Borders | destructablecode | Yes | |
Buff_Count | integer | Yes | |
Buff_List | integer | Yes | |
Buff_Max | integer | No | |
Buff_Purge | integer | Yes | |
Buff_Table | hashtable | No | |
Cam1 | camerasetup | No | |
Cam2 | camerasetup | No | |
Cam_Index | integer | No | |
Cam_Pl | integer | Yes | |
Camera_Lock | integer | Yes | |
CItem_Table | hashtable | No | |
CombatI2CV | integer | Yes | |
CombatIndex | integer | No | |
CombatTimer | real | Yes | |
Difficulty | integer | No | |
Drop_Table | hashtable | No | |
DummyVillager | unitcode | No | |
FSS | hashtable | No | |
Global_Acc | integer | Yes | |
Global_Act_Id | integer | Yes | |
Global_ArmorBreak | integer | Yes | |
Global_AttLv | integer | Yes | |
Global_Block | integer | Yes | |
Global_Crit | integer | Yes | |
Global_CritDmg | integer | Yes | |
Global_DefLv | integer | Yes | |
Global_Discount | integer | Yes | |
Global_DmgInc | integer | Yes | |
Global_DmgRed | integer | Yes | |
Global_Eva | integer | Yes | |
Global_Exp | integer | Yes | |
Global_Hp4Kill | integer | Yes | |
Global_LifeSteal | integer | Yes | |
Global_ManaSteal | integer | Yes | |
Global_Mdef1 | integer | Yes | |
Global_Mdef2 | integer | Yes | |
Global_Mdef3 | integer | Yes | |
Global_Mdef4 | integer | Yes | |
Global_Mdef5 | integer | Yes | |
Global_MDmg1 | integer | Yes | |
Global_MDmg2 | integer | Yes | |
Global_MDmg3 | integer | Yes | |
Global_MDmg4 | integer | Yes | |
Global_MDmg5 | integer | Yes | |
Global_Mp4Kill | integer | Yes | |
Global_Pdef | integer | Yes | |
Global_Reflect | integer | Yes | |
H_I | integer | No | |
H_U | unit | Yes | |
Hero | unit | Yes | |
Icons | destructablecode | Yes | |
Inv_Bag | integer | Yes | |
Inv_Prev | integer | Yes | |
Inv_Sens | boolean | Yes | |
Inv_Target | integer | Yes | |
Inv_Unit | integer | Yes | |
Item_Id | integer | Yes | |
Item_Item | item | Yes | |
Item_Last | item | Yes | |
Item_Max | integer | No | |
Mb_Row | string | Yes | |
Mb_Table | multiboard | Yes | |
Mb_Type | integer | Yes | |
OT_Max | integer | No | |
OT_Source | unit | Yes | |
OT_Target | unit | Yes | |
OT_Timer | integer | Yes | |
OT_Type | integer | Yes | |
OT_Value | real | Yes | |
PDD_allocatedAttacks | integer | No | |
PDD_allocCounter | integer | No | |
PDD_amount | real | No | |
PDD_ATTACK_TYPE_UNIVERSAL | attacktype | No | |
PDD_CODE | integer | No | |
PDD_DAMAGE_TYPE_DETECTOR | integer | No | |
PDD_damageEvent | trigger | No | |
PDD_damageEventTrigger | real | No | |
PDD_damageHandler | trigger | No | |
PDD_damageType | integer | No | |
PDD_ETHEREAL_DAMAGE_FACTOR | real | No | |
PDD_h | hashtable | No | |
PDD_magicType | integer | No | |
PDD_PHYSICAL | integer | No | |
PDD_pureAmount | real | No | |
PDD_runAllocatedAttacks | trigger | No | |
PDD_SET_MAX_LIFE | integer | No | |
PDD_source | unit | No | |
PDD_SPELL | integer | No | |
PDD_SPELL_RESIST_AUTO_DETECT | boolean | No | |
PDD_target | unit | No | |
PDD_totalAllocs | integer | No | |
PDD_TRIGGER_CLEANUP_PERIOD | real | No | |
PDD_UNIT_MIN_LIFE | real | No | |
Pow2 | integer | Yes | |
Scan_Player | integer | Yes | |
Scan_Target | unit | Yes | |
Scan_Unit | unit | Yes | |
Selected_Slot | integer | Yes | |
Selector | destructable | Yes | |
Shop_Table | hashtable | No | |
SL_EQ_B_CODE1 | integer | No | |
SL_EQ_B_CODE2 | integer | No | |
SL_EQ_Count | integer | No | |
SL_EQC | string | Yes | |
SL_HASHTABLE | hashtable | No | |
Stat_Acc | integer | Yes | |
Stat_AttackLv | integer | Yes | |
Stat_AttackSpeed | integer | Yes | |
Stat_BlockDmg | integer | Yes | |
Stat_Crit | integer | Yes | |
Stat_CritDmg | integer | Yes | |
Stat_DefLv | integer | Yes | |
Stat_Dmg | integer | Yes | |
Stat_Drop_Bonus | integer | Yes | |
Stat_Eva | integer | Yes | |
Stat_Exp | integer | Yes | |
Stat_Gold_Bonus | integer | Yes | |
Stat_HpRegen | integer | Yes | |
Stat_LifeSteal | integer | Yes | |
Stat_ManaSteal | integer | Yes | |
Stat_Mdef1 | integer | Yes | |
Stat_Mdef2 | integer | Yes | |
Stat_Mdef3 | integer | Yes | |
Stat_Mdef4 | integer | Yes | |
Stat_Mdef5 | integer | Yes | |
Stat_MovSpeed | integer | Yes | |
Stat_MpRegen | integer | Yes | |
Stat_Pdef | integer | Yes | |
Stat_Pet_Power | integer | Yes | |
Stat_Point | integer | Yes | |
Stat_Reflect | integer | Yes | |
Stat_SpellPower | integer | Yes | |
Stat_Table | hashtable | No | |
Stop_Stack | boolean | Yes | |
TempUnit | unit | No | |
Time_Hour | integer | No | |
Time_Min | integer | No | |
Time_Sec | integer | No | |
Total_Dmg | integer | Yes | |
Total_HP_Regen | real | Yes | |
Total_MP_Regen | real | Yes | |
TotalSpellPower | integer | Yes | |
Trade_Req_Button | button | Yes | |
Trade_Req_Dialog | dialog | Yes | |
Trader | integer | Yes | |
TradeReq | integer | Yes | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
Unit_Last | unit | Yes | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UnitIndexLock | integer | Yes |
0 - unique id
1 - item type
2 - type (1=helm,2=amor,3=weapon,4=boot,5=shield,6=ring,8=amulet,9=wing,10=tome)
3 - sub type (if armor then heavy/light/robe, weapon: 1.short sword/2. mace/3. axe/4. spear/5. long sword/6. dagger/7. bow/8. wand/9.staff)
4 - quality (0-cracked,1-low quality,2=normal, 3=magical, 4=rare, 5=crafted, 6=excelent, 7=unique)
5 - set Id/duration for potions
6 - class (0 = villager, 1 = paladin tank, 2=warrior,3=archer,4=assassin, 5=mage class)
7 - grade -> SetItembaseData
8 - item lv requiment
9 - str requiment
10 - agi requiment
11 - int requiment
12 - price
13 - ethernal
14 - duratibility
15 - max duratibility
16 - refine level
17 - refine value
18 - socket amount
19 - Potion effect string
20 - max socket amount -
21 - crafter name
22 - experience gaining
23 - drop rate increase
24 - gold rate increase
25 - activation type
26 - hp
27 - hp regen
28 - hp steal
29 - hp per kill
30 - mp
31 - mp regen
32 - mp steal
33 - mp per kill
34 - physical defence
35 - fire defence
36 - water defence
37 - lightning defence
38 - poison defence
39 - earth defence
40 - movement speed
41 - accurancy
42 - evasion
43 - block damage rate
44 - bonus str
45 - bonus agi
46 - bonus int
47 - attack speed
48 - bonus reflect damage
49 - bonus armorpen
50 - attack level
51 - defence level
52 - physical damage
53 - magical damage
54 - critical strike chance
55 - critical strike damage
56 - pet power
57 - bonus fire damage
58 - bonus water damage
59 - bonus lightning damage
60 - bonus poison damage
61 - bonus earth damage
62 - bonus physical attack
63 - bonus magical attack
64 - bonus hp
65 - bonus mp
66 - bonus crit
67 - bonus duratibility
68 - all element defence (5 element)
69 - bonus att lv
70 - bonus def lv
71 - bonus block dmg
72 - bonus level req. reduction - RandomAttributes
73 - bonus acc - RandomAttributes
74 - bonus eva - RandomAttributes
75 - bonus physical def - RandomAttributes
76 - bonus fire def - RandomAttributes
77 - bonus water def - RandomAttributes
78 - bonus lightning def - RandomAttributes
79 - bonus poison def - RandomAttributes
80 - bonus earth def - RandomAttributes
81 - item shop discount
82 - attack (both)
100 - the item
101 - item index in rot list //not sure
102 - item owner
1000 + x - socket item type what is inserted
1500 + x - socket amount from 1000+x socket type
25:activation types:
1 - Sacrifical Strike - 5% chance for cause double damage but cost 5% max hp if ur hp lower then reduce to 1 hp - heavy weapons
2 - Bless - 5% chance for recover back 10% max hp in next 20 second - light armor class
3 - Bleed - 5% chance for cause bleeding to target, base equipment damage +50 damage in last 20 second.
4 - Rage - 5% chance for unit beign mad and deal & take +25% higher damage in last 5 second.
5 - Vampirism - 5% chance for add 5% life and mana steal for 6 second.
6 - Amplify - 5% chance for increase every damage dealt on target by 15% in last 5 second.
7 - Thorn - 5% chance for reflect back to attack the 100% damage in last 4 second
8 - Protection - 5% chance for add +60% equipment pdef and mdef in last 20 second
9 - Eagle-Eye - 5% chance for increase the critical strike damage by 50% 5 sec
[hidden=update history]
[b]v0.99b[/b]
- few minor changes (like RegHero function at "init hashtables and .." trigger automatical save hero type into save load hashtable)
- Save - Load code added:
Features:
- data saved directly into hard disc, you can copy paste the code (example u started the map, copy-paste with notepad)
- few thing customizable in header - constants "SL_" functions (SL=the function or variable is part of the save load system)
- saveable: gold/lumber/coord/stat (str/agi/int)/class/hero/level & exp (dynamic), craft skill progress
-stat saving: hero current stat - stat from items - start stat
- since we talk about random stat items, not constant items, code became long, so this
system support multi save/load lines like: -load code1 then -load code2 ...
(where code1 and code2 is the saved code)
- multiple code line limit is 39 line, each line could be around max 100 character
- added the equipment saves too but still don't got time to make the loading part aswell
*idk about inventory saveing worth to do or no*
[b]v0.99a[/b]
- fixed the bag system included with multiboard (ex. not was showed in multiboard the 1st item in bag)
and fixed when charm item bonus not was removed/added when u moved into bag, moved out
- summoner class stuffs
- several text fix with item properties in hover tool tip in shop (like if mouse on helm then its show buyable helm mdef/pdef)
- added timer to multiboard item tooltip, damage detection system - set damage part etc
- few minor changes
[b]v0.99[/b]
- New socket items added and now easier to register new socket gems
in "Item Registration at Map Init" you need refister like ever item for attach icon to it
then use: call RegSocketGem (ItemRawCode, GemType, Grade, ItemLevelRequiment, ItemStatInArmor1, StatValueInArmor1, ItemStatInWeapon2, StatValueInWeapon2, ItemStatInWings3, StatValueInWings3)
- New socket gems also added to shop for test
- Gems working
- Minor text fix at multiboard pager (when u are at socket view)
- Since items & gems can give critical dmg bonus i reduced the default critical dmg (if u want change then constant function in header DEFAULT_CRITICAL_DAMAGE())
- Minor fix at tooltip in shop about weapon dmg, weapon dmg now globally changeable in header easily
- added minimum damage to weapons, multiboard/stats in inventory (ratio easily changeable in header)
- gem icon showed if u check Socket/Set view and item got inserted gem
- added item stat 82 => this attack or damage but depend on weapon, if physical weapon then give pattak if magic then magic attack, only used for gems
[b]v0.98d[/b]
- replaced Damage detection system (see DamageEvent trigger, still using bribe unit indexer but now DDS by looking_for_help)
- at shop -> where is the wings added another 2 unique item, Hammer+Ring, they also a new set
you can combine the sets :)
- greatly decreased armor penetration effect becuase its op vs low hp and high defence boss
- reduced the mobs defence but increased the boss def lv by boss level/2
[b]v0.98c[/b]
- set bonus stuff totally changed
- multiboard now show different page the inserted sockets and set list
useing Up / Down arrow on keyboard for change multiboard page
- same time multiboard functions a bit reorganised same like equipment systems
- Set and Unique item datas is in "Item Registratration at Map Init" trigger
- you can set your own set bonus
Note: total set bonus, so if ex. 2 item is equiped from same unique set then you get 1 bonus totally not per piece
[b]v0.98b[/b]
- enabled the duratibility showing and reduced the value duratibility (200-500 at max level)
- disable the animation changes for non villager
- removed teh bonus socket slot (i don't see point in it)
- multiboard a bit changed (bonus thing in loop now)
- added 3 different icon to armor/ring/helmet/boot/amulet (depend on quality)
- fixed the bug when full screen player gold floating text dissappear when inventory was launched 2+ times and u equiped something
- bonus block damage add
[b]v0.98[/b]
- changes was in:
Header - GetCraftLevel
ClickToTrackable - AddItem2HeroExt, CraftShopItem, FadeSlot, Craft_Quality_Chance, BuyItemFromShop
OnTrackable - Tooltip
Create Interface
Harvester Timer
- changed the prfession/craft leveling formula, now work well
- in shop the tooltip in right bottom corner now show with
yellow that item for what we got sufficient craft skill level
and red what is required higher craft level than we got
- item stack fix when u buy item from shop and its stack with another item
- fixed the bug when the slot 2211/-17/-21 not was clickable :D
- now the life materia lv3-6 craftable too
- rearranged the craft a bit, so can't craft high craft requiment item than ur craft skill
few item like wing/tome need jewellery lv3, life materia and few potion need pahamacist lv1
- added refine stone with 20x stack into shop
- harvest speed is configurable in Harvest Timer trigger.
- harvest speed increased by total craft skill (if you level your crafting skill => harvest faster)
- fixed a minor bug in FadeSlot function (nearly never occured)
- in ClickToTrackable>BuyItemFromShop function settable the craft fail chance and crafted item quality chance
[b]v0.97[/b]
- minor fix with stat window border
- minor labels example at create item trigger
- minor fix of the icons when charged item used in old/regular wc3 inventory
- minor fix with multiboard when u click to potion/life materia etc what got description
- minor fix where any player hero can gain exp not only that one in hero variable array
[b]v0.96[/b]
- floating text bug fixed at harvisting
- path blocker changed to flying unit path blocker
- optionable the inventory sensibility when u reicive damage, use chat for toggle it, command: "-inv sens"
- disable the defence bonus per agility because useless if i use my own system
[b]v0.95b[/b]
- fix few trade problem (in normal 0.95 u was unable to leave or even u quited there was still the trade partner gold floating text)
- added ally function + replace the red startlocation function to native function what dont use location - in create heroes trigger
- also few indent thing
[b]v0.95[/b]
- scan now work different way, type in chat "-scan" then right click to target with your unit
- trade item/gold working again
[b]v0.94[/b]
- dummy.mdx added
- now dont need to create dummy units anymore for inventory hero, just at
register hero set your hero path, then system create a dummy unit
attach the hero model like special effect and set the unit pitch angle with animation index
- added the inventory gold icon for inventory too
- added few thing to inventory hero box for look like 3d box
[b]v0.93[/b]
- new design for inventory, dont flicker the destructibles anymore
- debug things remove, weapon activation and buffs tested
[b]v0.92[/b]
- buff system added - core part merged into timer trigger
- fixed the revive trigger because the action was attached in loop
[b]v0.91h[/b]
- fixed the bug when dummy villager disappear when u wear bow and reopen the inventory, also was few attachment problem after i introduced the non attachment heroes, but now all fixed
- added weapon activation/special skill what activated during u attack somebody
[b]v0.91g[/b]
- unit now unselectable during FSS
- dropped and bought items are invulnarable now
[b]v0.91f[/b]
- labels and function organizations, table description added
[b]v0.91e[/b]
- added few tooltip and minor things
- added potion and gold drop for treasure box
- trackable table removed, trackabls use a existing table
[b]v0.91d[/b]
- Bagpack system added, what is it? i added a item what could store 0-24 another item
- you can drop out this item and who pick up can open the bag and can swap item between items in bag and inventory
- when bag is sold to shop (full screen shop) then automatical destroyed all item what was inside with their data
- Treasure box
- Windows transition and close windows with ESC
-Window transition: change the current opened window to another, example from inventory to bag system
[b]v0.91c[/b]
- pharmacist craft requiment added for custom potions also gave chance for stronger potions
[b]v0.91b[/b]
- created hit function, for easily change the accurancy/eva=< hit rate formula
- added regen pots too
- scan changed, diff index
- mp regen changed to flat value and isnt % now (ty maker for tip about useing mana regen neutral unit ability)
- set bonus fix (was a bit problem if u equiped too fast the items, its fixed)
- few correction on shop: now if item not craftable then craftbox is hidden, double icon=deselect, now allways buy item if u click 1st to item and 2nd time to any other item in unit inventory what not craft materia of selected item or just no item.
- added the chance option for AddRandomBonus function (this function give random bonus to items)
also made few modification about bonuses, like magic weapon don't get pattack bonus etc
- super potion added [hp/mp], pharmacist depend crafting aswell
- level requiment potion with dynmic heal/mana restore amount
[b]v0.91a[/b]
- changed the life regen/mp regen to MUI
- added to drop/shop the [b]Charm[/b] item type, 3 rarity:
- Common Charm (1-2 random bonus stat) - 88% chance
- Uncommon Charm (3-5 random stat) - 10% chance
- Superior Charm (5-7 random stat) - 2% chance
- fixed few price
- accurancy/evasion random stat now fixed (was shifted with 1 properties)
[b]v0.9[/b]
- changed the item pick/attack so basically the right clicking
- 1st right click on item = item multiboard info, 2nd right click pick up
- 1st click on unit is scan unit, 2nd attack him
- lil fix on multiboard and added 5 materia into shop and into craft system
[b]v0.8[/b]
- class restriction text fixed for armors what viable for 2 class too
- scan now periodical check the target hp
- with ESC u can destroy the multiboards
[b]v0.7[/b]
- inventory work with non attachment heroes and with attachment heroes (like villager or just normal Paladin)
- inventory and shoping is MUI now, with simple
call RegHeroes ('unit raw code', 'unit raw code 2 for inventory', true/false (attachemnt unit or no), 1 (size, coz some hero could be bigger than inventory window, this way u can set it), 0 (hero class), 2 (unit type default damage without str))
- item class requiment added
- shop discount tiem properties added
[b]v0.6[/b]
- added MUI nateria items harvesting, its mean u cant simple just right click and pick up a iron ore, u ened dig out
and this need time, have floating text what show the digging process percentage
Note: - once u digged out something and drop out, dont ened dig out again
- cant 2 people dig same item
[b]v0.5[/b]
- added craft level system (higher level item need higher level craft skill)
- chance for getting better eq depend on craft level
[b]v0.4[/b]
- drop fix
- added the 4 craft job:
- Blacksmith (weapons)
- Tailor (armors)
- Jeweller (ring/amulet+wing+tome)
- Pharmacist (potions but not added yet)
[b]v0.3[/b]
- added info to multiboard tooltip and shop tooltip if mouse over a socket/refines stone/materia, atm u can assign +3 description for each item type
- equipments craft: now for higher level equipment need more craft materia (i use now a function what return with correct mat amount)
[b]v0.2[/b]
- at craft you can get enhanced item (20% chance and 80% for normal item)
- this will be changed when i will add the production skills
[b]v0.1[/b]
the starting map
[/hidden]
//--------------------------------------------------------------------//
//--- FSS - Hastable ---//
//--------------------------------------------------------------------//
pl = Gui Player number, example player 1 is 1, player 2 is 2 etc
//------------------------------------------------------------------------------------------------
// --- Trackables ---
id = GetHandleId(GetTriggeringTrackable())
-id, 1 = Player number who made connection with trackable (clicked to trackable or moved mouse over it) [integer]
-id, 2 = Related slot number for system 1 (if Camera_Lock=1 - inventory)
-id, 3 = Related slot number for system 2 (if Camera_Lock=2 - shop)
-id, 4 = Related slot number for system 3 (if Camera_Lock=3 - bag looking)
//------------------------------------------------------------------------------------------------
// --- Window and Item Data ---
0, 1 = X coordinate - Full screen system (left/bottom corner) [real]
0, 2 = Y coordinate - Full screen system (left/bottom corner) [real]
0, 3 = Rect/Region - Full screen system area [rect]
0, 4 = Width - Full screen system area width [real]
0, 5 = Height - Full screen system area height [real]
0, 200 - x = Borders - Full screen inventory border [destructable handle]
0, 2000 - x = Trade window bordes [destructable handle]
0, 800 + pl = Background image [image handle]
0, -pl * 20 - how many unit was created for unit window [integer]
0, -20 - -120 - every unit/special effect saved into this inteveral [unit/effecthandles]
0, -150-pl - trader units during the trade request [unit]
//------------------------------------------------------
// --- Inventory: Equipment slots ----
//------------------------------------------------------
1, 0 - Helm Slot - Full screen inventory - Helm [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
2, 0 - Armor Slot - Full screen inventory - Armor [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
3, 0 - Weapon Slot - Full screen inventory - Weapon [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
4, 0 - Boot Slot - Full screen inventory - Boot [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
5, 0 - Shield Slot - Full screen inventory - Shield [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
6, 0 - Ring Slot 1 - Full screen inventory - Ring 1 [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
7, 0 - Ring Slot 2 - Full screen inventory - Ring 2 [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
8, 0 - Amulet Slot - Full screen inventory - Amulet [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
9, 0 - Wing Slot - Full screen inventory - Wing [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
10, 0 - Tome Slot - Full screen inventory - Tome [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
11, 0 - Reserved Slot - Full screen inventory - Unused [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
// --- Inventory: New invetory slots ----
100-119, 0 - Free Slot Icon - Full screen inventory - Empty Slot[NEW] [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
// --- Inventory: Old invetory slots ----
200-205, 0 - Free Slot Icon - Full screen inventory - Empty Slot[OLD] [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
// --- Inventory icons and floating text for charged items; slot nr = 0-11 or 100-199 or 200-205 or 2201-2224
1000, pl*10000 + slot nr - Floating text what show the item charges in slot [texttag handle]
2409 + pl, slot nr - Icon in full screen inventory [destructable handle]
1000+pl, slot - Fade slot floating text [texttag handle]
2406,10000*pl+slot nr - faded image above the slot [image handle]
// --- Other buttons ---
300, 0 - Exit Icon - Full screen inventory - Command button [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
301, 0 - Repair Icon - Full screen inventory - Command button [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
302, 0 - Repair all Icon - Full screen inventory - Command button [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
303, 0 - Drop Icon - Full screen inventory - Command button [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
304, 0 - Restat Icon - Full screen inventory - Command button [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
305, 0 - Add STR Icon - Full screen inventory - Command button [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
306, 0 - Add AGI Icon - Full screen inventory - Command button [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
307, 0 - Add INT Icon - Full screen inventory - Command button [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
// --- Inventory: Dummy units
550, 0 - Dummy Villager for visualize the attachments when u wear a equipment [unit handle]
650 + pl, 1-9 - Dummy Villager special effect attachments [effect handle]
650 + pl, 1-9+100 - if double attachment (boot/dual weapon) [effect handle]
551, 0 - Dummy non Villager Hero; example: Paladin, Archer etc [unit handle]
551, 100 + pl - Scan enabler boolean [boolean]
630, UnitTypeId(=unit rawcode) - Transformed form or Inventory dummy unit type [integer]
631, UnitTypeId(=unit rawcode) - Attachment hero (true) or regular (false) [boolean]
632, UnitTypeId(=unit rawcode) - Dummy unit size for inventory [real]
633, UnitTypeId(=unit rawcode) - Class: 0= villager, 1=paladin,2=warrior etc [integer]
634, UnitTypeId(=unit rawcode) - Unit type damage without str/int/agi [integer]
635, UnitTypeId(=unit rawcode) - Hero model path (ending with .mdl)
636, UnitTypeId(=unit rawcode) - Hero starting str
637, UnitTypeId(=unit rawcode) - Hero starting agi
638, UnitTypeId(=unit rawcode) - Hero starting int
// --- Inventory: Trade ---
1200-1205, 0 - Free Slot Icon - Full screen inventory - Empty Slot[Your] [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
1206-1211, 0 - Free Slot Icon - Full screen inventory - Empty Slot[Partner] [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
1250 + pl, 1200 - 1205 - Integer (your items slot number from your inventory) [integer]
1250 + pl, 1206 - 1211 - Integer (your partner items slot number from his inventory) [integer]
1275 + pl, 1 - Trade lock (0=no lock, 1= lock 1, 2=final lock) [integer]
1275 + pl, 5-6 - Gold floating text [texttag]
1275 + pl, 7 - Traded gold amount [integer]
1300, 0 - Trade Lock1 Icon - Trade window - Lock trade[Your lock1] [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
1301, 0 - Trade Lock2 Icon - Trade window - Lock trade[Your lock2] [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
1302, 0 - Trade Lock1 Icon - Trade window - Lock trade[Parner lock1] [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
1303, 0 - Trade Lock2 Icon - Trade window - Lock trade[Parner lock2] [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
// --- Item type related data ---
600, ItemRawCode - Attached destructable RawCode to item RawCode [integer]
601, ItemRawCode - Attached model to item RawCode [string]
602, ItemRawCode - Attached Price to item RawCode [integer]
603, ItemRawCode - Attached level requiment to item RawCode [integer]
604, ItemRawCode - Attached shop tooltip to item RawCode [string]
605, ItemRawCode - Attached subtype to item RawCode [integer]
606, ItemRawCode - Attached craft materia1, item RawCode [integer]
607, ItemRawCode - Attached craft materia1, needed amount [integer]
608, ItemRawCode - Attached craft materia2, item RawCode [integer]
609, ItemRawCode - Attached craft materia2, needed amount [integer]
610, ItemRawCode - Attached craft materia3, item RawCode [integer]
611, ItemRawCode - Attached craft materia3, needed amount [integer]
647, ItemRawCode - Item description 1 [string]
648, ItemRawCode - Item description 2 [string]
649, ItemRawCode - Item description 3 [string]
// --- Dummy interface elements, what is inside the full screen inventory and what we must hide during FSS
1400, 0-x - all dummy destructible
1401, 0-x - all dummy unit
floating text position, hashtable 400
saved floating texts (12x), hashtable (501-512)
//------------------------------------------------------
// --- shop interface ---
//------------------------------------------------------
675, 0-x - Shop: destructible for progress bar window [destructable handle]
2000, 0-x - Shop: window borders [destructable handle]
2001-2099, 0 - shop: main category free slot icons [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
2100, 0-x - shop: main category icons [destructable handle]
2101-2199, 0 - shop: subcategory free slot icons [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
2200-2299, 0 - shop: listed item icons in selected main+subcategory [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
2300, 0 - shop: Quit button icon [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
2301, 0 - shop: ~reserved~ button icon [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
2302, 0 - shop: Craft button icon [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
2303-2305, 0 - shop: Craft materia icons [destructable handle]
1 - X coordinate for icon [real]
2 - Y coordinate for icon [real]
2400, 0-x - crafting materia box borders [destructable handle]
2402, pl - selected main category by player [integer]
2402, 20+pl - selected sub category by player [integer]
2402, 40+pl - selected item from item list by player [integer]
2402, 60+pl - player gold amount floating text [texttag handle]
2402, 100+pl - selected main category selector [destructable handle]
2402, 120+pl - selected sub category selector [destructable handle]
2402, 140+pl - selected item from list selecter [destructable handle]
2402, 180+pl - Shop Tooltip text 1 [texttag handle]
2402, 200+pl - Shop Tooltip text 1 [texttag handle]
2402, 220+pl - Shop Tooltip text 1 [texttag handle]
2402, 240+pl - Shop Tooltip text 1 [texttag handle]
2402, 260+pl - Shop Tooltip text 1 [texttag handle]
2402, 280+pl - Shop Tooltip text 1 [texttag handle]
2402, 300+pl - inventory selector [destructable handle]
2402, 320+pl - selected slot from inventory [integer]
2405, pl - craftability (0-item not craftable, 1-item craftable) [integer]
2405, 20+pl - crafting progress (number) [integer]
2405, 40+pl - craft materia icon 1 [destructable handle]
2405, 60+pl - craft materia icon 2 [destructable handle]
2405, 80+pl - craft materia icon 3 [destructable handle]
2405, 100+pl - need craft materia1 amount [integer]
2405, 120+pl - need craft materia2 amount [integer]
2405, 140+pl - need craft materia3 amount [integer]
2405, 160+pl - craft output item RawCode [integer]
2405, 180+pl - craft slot1 properties [integer]
2405, 200+pl - craft slot2 properties [integer]
2405, 220+pl - craft slot3 properties [integer]
2407, pl*100+x - craft progress bar, x = how much image need for 100% [image handle]
2408, TimerID - crafter player id (1-12) [integer]
2423, 0-x - loot box border [destructable handle]
//--------------------------------------------------------------------//
//--- FSS - Hastable ---//
//--------------------------------------------------------------------//
// --- info ---
pl = Gui Player number, example player 1 is 1, player 2 is 2 etc
cv = Unit custom value / unit user data
slot = 1-11, 100-119 etc
set_slot = 1 (=helm),2(=armor),4(=boot)
//--------------------------------------------------------------------//
// --- Item assing to unit ---
cv, slot - Equipment item or item in inventory [item handle]
cv, -slot - item level [integer]
//--------------------------------------------------------------------//
// --- unit harvesting data ---
cv, 8980 - Harvest progress (0-no action, 1-harvest started) [integer]
cv, 8981 - Harvest timer (-1 not started,0=started, 1-max) [integer]
cv, 8982 - Time what needed what need for harvest out the materia [integer]
cv, 8983 - Targeted harvestable item [item handle]
cv, 8984 - Floating text what show the harvesting progress [texttag handle]
cv, 8985 - Item X coordinate [real]
cv, 8986 - Item Y coordinate [real]
cv, 8987 - Instance index in harvesting array [integer]
8989, GetHandleId(itm) - assign unit custom value to item [integer]
(so u can know if item under harvesting or free for harvest)
//--------------------------------------------------------------------//
// --- Unit can wear item and Hero revive timer
8990, GetHandleId(unit) - Hero use the new inv, item system: true or false [boolean]
8991, GetHandleId(timer) - Save the reviveable hero assigned to his timer [unit]
//--------------------------------------------------------------------//
// --- Respawn ---
8999, cv = x coordinate
8998, cv = y coordinate
8997, cv = facing angle
9996, cv = hero level
//--------------------------------------------------------------------//
// --- Buffs ---
36000+cv, buff count = buff type id
36000+cv, buff type id * -1 = second left from buff associeted to buff type id
-36000-cv, buff type id * -1 = buff value associeted to buff type id
45000+cv, buff type id = effect id
45000+cv, buff type id * -1 = percentage amount
//--------------------------------------------------------------------//
// --- Attachments ---
9000+cv, slot - Normal attachment [effect handle]
-9000-cv, slot - Special attachments like quiver [effect handle]
9000+cv, -slot - Double attachments like boot or dual weapon [effect handle]
//--------------------------------------------------------------------//
// --- craft properties ---
27000+cv, 1 - Crafting experience with blacksmith skill [integer]
27000+cv, 2 - Crafting experience with tailor skill [integer]
27000+cv, 3 - Crafting experience with jeweller skill [integer]
27000+cv, 4 - Crafting experience with pharmacist skill [integer]
Used for save load system
SL_HASHTABLE, StringHash(s), 1 -2 - Encodeing alphabet string
SL_HASTABLE Key: 2, Key: integer index, Saveable hero index
Saveing process - work with timer:
SL_HASTABLE Key: 3, Key: timerid1, Save unit
SL_HASTABLE Key: 4, Key: timerid2, integer base str
SL_HASTABLE Key: 5, Key: timerid2, integer base agi
SL_HASTABLE Key: 6, Key: timerid2, integer base int
SL_HASTABLE Key: 7, Key: timerid2, integer itemid
SL_HASTABLE Key: 8 Key: timerid2, integer curent reading slot
SL_HASTABLE Key: 9, Key: timerid2, integer socket amount
SL_HASTABLE Key:10, Key: timerid2, player p
multiboard item tooptip info - work with timer:
id = expired timer handle id
SL_HASHTABLE, 11, id, itm - targeted item if not in inventory
SL_HASHTABLE, 12, id, cv - unit custom value with who compare
SL_HASHTABLE, 13, id, slot - if item in inventory then slot number
PDD set damage system - work with timer
id = expired timer handle id
SL_HASHTABLE, 14, id, a - attacker unit
SL_HASHTABLE, 15, id, t - attacked unit
SL_HASHTABLE, 16, id, dmg - dmg dealt
SL_HASHTABLE, 17, id, DmgRed - dmg reduction rate
SL_HASHTABLE, 18, id, DmgType - DDType (integer: 0physical, 1spell )
//------------------------------------------------------------------------
// Buffing system description and restrictions
//------------------------------------------------------------------------
// ------------- Base informations --------------
- unit custom value = if you use indexer then every unit have a different custom value/unituserdata we need this
for store at hashtable the data about buff system also indentify and handle the buffed unit
More information about the hastable storage is in Stat table trigger because buff system dont use a new hashtable
- buff index: - global: we save every buffed unit custom value into array even unit have more than 1 buff,
each buffed unit have a index number like Buff_List[1] = your unit custom value
- unit: we count and keep tracking how much buff got a unit, we use for this the Buff_Count[unit custom value] array
if unit get a enw buff then we increase by 1 this array, if unit lose buff then decrease by 1
- buff type id: its a number, you can use any positive number for this, but we must use different buff type id for different buffs
for identify at add or Removebuff function what we want do.
ex: if buff type id == 1 then add hp, if it is 2 then do something else
- buff value: integer value, its could be negative or positive but carefully if u use negative values because could be problems
if u example decrease unit hp more than his current hp and he will die :P
- buff duration: it is obviously another positive integer thing,
not surprise if i tell this value is the buff duration on unit in second, example 900
- buff effect: it is a integer, if we use EFFECT(id) function then we can get the special effect model path
because it is easier if we save only a number than the whole path
- buff percentage: this dont work yet
// -------- How to add or remove buffs? ---------
call RemoveUnitBuff (unit custom value, buff index on unit)
call RemoveUnitBuffs (unit number in Buff_list array)
call AddUnitBuff (unit, buff type id, buff value, duration, effect id, percentage)
// --------- Buff type id --------------
1 = Accurancy
2 = Attack level
3 = Defence level
4 = Critical strike chance
5 = Critical strike damage
6 = Amplify damage
7 = Damage reduction (if negative then increase the damage on target)
8 = Evasion
9 = Life steal
10 = Mana steal
11 = Reflect damage
12 = Experience bonus
13 = Temporary max hp
14 = Temporary max mp
15 = Physical defence
16 = Fire defence
17 = Water defence
18 = Lightning defence
19 = Poison defence
20 = Earth defence
function Trig_Ability_Preload_Actions takes nothing returns nothing
local integer i = 1
local integer a
local unit u
set udg_Abilities[0] = 'A003'
set udg_Abilities[1] = 'A004'
set udg_Abilities[2] = 'A00C'
set udg_Abilities[3] = 'A00G'
set udg_Abilities[4] = 'A00H'
set udg_Abilities[5] = 'A00B'
set udg_Abilities[6] = 'A00D'
set udg_Abilities[7] = 'A00E'
set udg_Abilities[8] = 'A001'
set udg_Abilities[9] = 'A005'
set udg_Abilities[10] = 'A006'
set udg_Abilities[11] = 'A002'
set udg_Abilities[12] = 'A007'
set udg_Abilities[13] = 'A008'
set udg_Abilities[14] = 'A009'
set udg_Abilities[15] = 'A00F'
set udg_Abilities[16] = 'A00J'
set udg_Abilities[17] = 'A00K'
set udg_Abilities[18] = 'A00L'
set udg_Abilities[19] = 'A00M'
set udg_Abilities[20] = 'A00N'
set udg_Abilities[21] = 'A00O'
set udg_Abilities[22] = 'A00P'
set udg_Abilities[23] = 'A00Q'
set udg_Abilities[24] = 'A00R'
set udg_Abilities[25] = 'A00S'
set udg_Abilities[26] = 'A00T'
set udg_Abilities[27] = 'A013'
set udg_Abilities[28] = 'A00X'
set udg_Abilities[39] = 'A00Y'
set udg_Abilities[30] = 'A00Z'
set udg_Abilities[31] = 'A010'
set udg_Abilities[32] = 'A011'
set udg_Abilities[33] = 'A012'
set udg_Abilities[34] = 'A00U'
set udg_Abilities[35] = 'A00V'
set udg_Abilities[36] = 'A014'
set udg_Abilities[37] = 'A015'
set udg_Abilities[38] = 'A016'
set udg_Abilities[39] = 'A00W'
set udg_Abilities[40] = 'A00I'
loop
exitwhen i > 12
if ( GetPlayerController(Player(i - 1)) == MAP_CONTROL_USER ) then
set u = CreateUnit(Player(i - 1), 'H000', GetStartLocationX(i - 1), GetStartLocationY(i - 1), bj_UNIT_FACING )
set a = 1
loop
exitwhen udg_Abilities[a] == 0
call UnitAddAbility( u, udg_Abilities[a])
call UnitRemoveAbility( u, udg_Abilities[a])
set a = a + 1
endloop
call RemoveUnit(u)
endif
set i = i + 1
endloop
set u = null
call DisableTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_Ability_Preload takes nothing returns nothing
set gg_trg_Ability_Preload = CreateTrigger( )
call TriggerAddAction( gg_trg_Ability_Preload, function Trig_Ability_Preload_Actions )
endfunction
//-----------------------------------------------------------
// Item / Shop item / Description and Craft / Heroes registration
//-----------------------------------------------------------
function RegItemCat4Shop takes integer c, integer id returns nothing
local integer i = LoadInteger(udg_Shop_Table, c, 0)
local integer a = LoadInteger(udg_Shop_Table, 0, 0)
if a < 1000 then
set a = 1000
endif
set a = a + 1
set i = i + 1
call SaveInteger(udg_Shop_Table, c, 0, i)
call SaveInteger(udg_Shop_Table, 0, 0, a)
call SaveInteger(udg_Shop_Table, c, i, id)
call SaveInteger(udg_Shop_Table, c, - i, a)
endfunction
function RegItem4Shop takes integer c, integer sc, integer itd, integer unique returns nothing
local integer id = LoadInteger(udg_Shop_Table, c, - sc)
local integer i = LoadInteger(udg_Shop_Table, id, 0) + 1
call SaveInteger(udg_Shop_Table, id, 0, i)
call SaveInteger(udg_Shop_Table, id, i, itd)
call SaveInteger(udg_Shop_Table, id, - i, unique)
endfunction
function RegisterItem takes integer id, integer icon, string path, integer price, integer lv, string descr, integer subtype returns nothing
if path != null then
call SaveStr(udg_FSS, 601, id, path)
endif
if descr != null then
call SaveStr(udg_FSS, 604, id, descr)
endif
call SaveInteger(udg_FSS, 600, id, icon)
call SaveInteger(udg_FSS, 602, id, price)
call SaveInteger(udg_FSS, 603, id, lv)
if subtype > 0 then
call SaveInteger(udg_FSS, 605, id, subtype)
endif
endfunction
function RegCraft takes integer id, integer d1, integer c1, integer d2, integer c2, integer d3, integer c3 returns nothing
call SaveInteger(udg_FSS, 606, id, d1)
call SaveInteger(udg_FSS, 607, id, c1)
call SaveInteger(udg_FSS, 608, id, d2)
call SaveInteger(udg_FSS, 609, id, c2)
call SaveInteger(udg_FSS, 610, id, d3)
call SaveInteger(udg_FSS, 611, id, c3)
endfunction
function AddDescription takes integer id, string s1, string s2, string s3 returns nothing
call SaveStr(udg_FSS, 647, id, s1)
call SaveStr(udg_FSS, 648, id, s2)
call SaveStr(udg_FSS, 649, id, s3)
endfunction
function RegHeroes takes integer id1, integer id2, boolean Attachment, real size, integer class, integer damage, string mpath returns nothing
local real x = LoadReal(udg_FSS, 0, 1)
local real y = LoadReal(udg_FSS, 0, 2)
local unit u
local integer i
call SaveInteger(udg_FSS, 630, id1, id2)
call SaveInteger(udg_FSS, 630, id2, id1)
call SaveBoolean(udg_FSS, 631, id2, Attachment)
call SaveBoolean(udg_FSS, 631, id1, Attachment)
call SaveReal(udg_FSS, 632, id1, size)
call SaveInteger(udg_FSS, 633, id1, class)
call SaveInteger(udg_FSS, 634, id1, damage)
if mpath != null then
call SaveStr(udg_FSS, 635, id1, mpath)
endif
set u = CreateUnit(Player(15),id1,x,y,0)
//call SaveInteger(udg_FSS, 636, id1, GetHeroStr(u, false))
//call SaveInteger(udg_FSS, 637, id1, GetHeroAgi(u, false))
//call SaveInteger(udg_FSS, 638, id1, GetHeroInt(u, false))
call SaveInteger(udg_FSS, 636, id1, 500)
call SaveInteger(udg_FSS, 637, id1, 500)
call SaveInteger(udg_FSS, 638, id1, 500)
call RemoveUnit(u)
set i = LoadInteger(udg_SL_HASHTABLE,2,0) + 1
call SaveInteger(udg_SL_HASHTABLE,2,0,i)
call SaveInteger(udg_SL_HASHTABLE,2,i,id1)
call SaveInteger(udg_SL_HASHTABLE,2,id1,i)
set u = null
endfunction
function RegSocketGem takes integer ItemRaw, integer GemType, integer Grade, integer LvReq, integer ItemStat1, integer Value1, integer ItemStat2, integer Value2, integer ItemStat3, integer Value3, integer Price returns nothing
local integer GI = 2000 //Gem saveing index in item table
local integer Index = LoadInteger(udg_CItem_Table, -GI, 0) + 1
local integer GemTypeIndex = LoadInteger(udg_CItem_Table, -GI, GemType) + 1
call SaveInteger(udg_CItem_Table, -GI, 0, Index)
call SaveInteger(udg_CItem_Table, -GI, GemType, GemTypeIndex)
//create data for gems
call SaveInteger(udg_CItem_Table, -GI-Index, 0, Index)
call SaveInteger(udg_CItem_Table, -GI-Index, 1, ItemRaw)
call SaveInteger(udg_CItem_Table, -GI-Index, 2, GemType)
call SaveInteger(udg_CItem_Table, -GI-Index, 7, Grade)
call SaveInteger(udg_CItem_Table, -GI-Index, 8, LvReq)
call SaveInteger(udg_CItem_Table, -GI-Index, 12, Price)
call SaveInteger(udg_CItem_Table, -GI-Index, 9, ItemStat1)
call SaveInteger(udg_CItem_Table, -GI-Index, 10, ItemStat2)
call SaveInteger(udg_CItem_Table, -GI-Index, 11, ItemStat3)
call SaveInteger(udg_CItem_Table, -GI-Index, ItemStat1, Value1)
call SaveInteger(udg_CItem_Table, -GI-Index, ItemStat2, Value2)
call SaveInteger(udg_CItem_Table, -GI-Index, ItemStat3, Value3)
endfunction
//-----------------------------------------------------------
// Registering the stuffs
//-----------------------------------------------------------
function Trig_map_init_Actions takes nothing returns nothing
local integer i = 1
call RegHeroes (HERO_MELEE(), HERO_RANGED(), true, 1, 0, 2, null)
call RegHeroes ('Hpal', 'Hpal', false, 1.5, 1, 2, "units\\human\\HeroPaladin\\HeroPaladin.mdx")
call RegHeroes ('Hvwd', 'Hvwd', false, 1.7, 3, 3, "units\\creeps\\SylvanusWindrunner\\SylvanusWindrunner.mdx")
call RegHeroes ('Hjai', 'Hjai', false, 1.5, 5, 3, "units\\human\\Jaina\\Jaina.mdx")
//call SetUnitDrop ('hpea', 225, 420, 5000, 335) set drop rate to unit type
// 2x25% for assigned drop, 4x20% for level drop, 3x35% for shared drop (in this example shared drop category is the 5000)
//call AddUnitDrop ('hpea', 'pman', 14)// assign specific item drop to a unit type, peasant have 14% chance for drop mana potion
//every 20 level we can set different drop
// call AddLevelDrop(1, 'I001', 5.7)
// call AddLevelDrop(1, 'I002', 0.31)
// call AddLevelDrop(2, 'I002', 5.7)
// call AddLevelDrop(2, 'I003', 0.31)
// call AddLevelDrop(3, 'I003', 5.7)
// call AddLevelDrop(3, 'I004', 0.31)
// call AddLevelDrop(4, 'I004', 5.7)
// call AddLevelDrop(4, 'I005', 0.31)
// call AddLevelDrop(5, 'I005', 5.7)
// call AddLevelDrop(5, 'I006', 0.31)
// call AddLevelDrop(6, 'I006', 50)
call SetUnitDrop ('nmrl', 0, 430, 5000, 0)
call SetUnitDrop ('nogr', 0, 370, 5000, 0)
//5000 cat = shared drop for every creep type
call AddLevelDrop(5000, 'I00M', 2) //leather
call AddLevelDrop(5000, 'I00O', 0.1) //feather
call AddLevelDrop(5000, 'I00P', 0.1) //tome page
call AddLevelDrop(5000, 'phea', 70.2) //hp pot
call AddLevelDrop(5000, 'pman', 70.2) //mp pot
call AddLevelDrop(5000, 'I000', 0.1) //refine stone
// shared drop for every boss
call AddLevelDrop(5001, 'I00M', 1.9) //leather
call AddLevelDrop(5001, 'I00O', 23) //feather
call AddLevelDrop(5001, 'I00P', 23) //tome page
call AddLevelDrop(5001, 'I000', 25) //refine stone
call AddLevelDrop(5001, 'phea', 1.2) //hp pot
call AddLevelDrop(5001, 'pman', 1.2) //mp pot
call AddDescription ('phea', "Glu... glu...", "Restore 250 hit point.", null)
call AddDescription ('pman', "A tasty magic bottle", "Restore 150 mana point.", null)
call AddDescription ('I000', "Feel the power!", "Tweak the equipments.", null)
// call AddDescription ('I001', "Weapon: 1 Attack lv", "Armor: 25 HP", "Wings: 2 HP/sec")
// call AddDescription ('I002', "Weapon: 2 Attack lv", "Armor: 50 HP", "Wings: 4 HP/sec")
// call AddDescription ('I003', "Weapon: 3 Attack lv", "Armor: 75 HP", "Wings: 6 HP/sec")
// call AddDescription ('I004', "Weapon: 4 Attack lv", "Armor: 100 HP", "Wings: 8 HP/sec")
// call AddDescription ('I005', "Weapon: 5 Attack lv", "Armor: 125 HP", "Wings: 10 HP/sec")
// call AddDescription ('I006', "Weapon: 7 Attack lv", "Armor: 175 HP", "Wings: 15 HP/sec")
call AddDescription ('I00A', "Wonderfull herbs..", "Used for potions", null)
call AddDescription ('I00B', "Secret of the nature", "Used for potions", null)
call AddDescription ('I00C', "Amazing plants", "Used for potions", null)
call AddDescription ('I00D', "Healer leafs", "Used for potions", null)
call AddDescription ('I00E', "From inside", "Used for potions", null)
call AddDescription ('I00F', "The green peace", "Used for potions", null)
call AddDescription ('I00G', "Strong like metal", "Used for equipments", null)
call AddDescription ('I00H', "Chop - chop", "Used for equipments", null)
call AddDescription ('I00I', "Just the rain", "Used for potions", null)
call AddDescription ('I00J', "Don't thrown away", "Used for potions", null)
call AddDescription ('I00K', "Ethernal sunshine", "Used for potions", null)
call AddDescription ('I00L', "Don't step to me", "Used for potions", null)
call AddDescription ('I00M', "Soft like the silk", "Used for armors", null)
call AddDescription ('I00N', "Feel the wind", "Used for potions", null)
call AddDescription ('I00O', "Where is my feather?", "Used for Wings", null)
call AddDescription ('I00P', "The Ancient script", "Used for Tomes.", null)
call AddDescription ('I007', "Somebody in, copper mine?", "Used for Shield", null)
call AddDescription ('I008', "Deep sea blue", "Used for Rainbow Stone", null)
call AddDescription ('I009', "Shiny lil' red jewel", "Used for Rainbow Stone", null)
call AddDescription ('I00Q', "Green like the grass", "Used for Rainbow Stone", null)
call AddDescription ('I00R', "Masterpiece", "Used for Jewels", null)
call AddDescription ('I00U', "Bag: Used for store items", "Storage capacity 24 item.", "Double click for open")
call AddDescription ('mcou', "It is a lottery box", "Could contain equipment,", "potion, gold or nothing!")
//few not about drop system
//call SetUnitDrop (unit type, default drop chance, shared drop chance, shared drop id, level drop chance)
//call AddUnitDrop (unit type, item type id, drop chance)
//call RemoveItemDropFromUnit (unit type, item type id)
//call AddLevelDrop (level (this will be * 20), item type id, chance)
// ------------- Register Socket Gem items ------------------
//call RegSocketGem (ItemRawCode, GemType, Grade, ItemLevelRequiment, ItemStat1, StatValue1, ItemStat2, StatValue2, ItemStat3, StatValue3)
//B02F - dark, B02D - fire, B02G - frost, B00F - lightning, B02E - red,B02H - Jade
//grade 1-7 for text tag: Chipped, Broken, Flawed, Normal, Flawless, Perfect, Super
//ItemsStat1 for armors, Stat2 for weapons, Stat3 for wings
//(64 hp, 62 pattack,76 fire def(all ele def),55 crit dmg,
//hp-damage-hp
call RegSocketGem ('I001', 1, 1, 1, 64, 5, 82, 3, 64, 8, 100)
call RegSocketGem ('I001', 1, 2, 10, 64, 10, 82, 7, 64, 16, 1000)
call RegSocketGem ('I001', 1, 3, 25, 64, 20, 82, 15, 64, 32, 2500)
call RegSocketGem ('I001', 1, 4, 40, 64, 40, 82, 33, 64, 48, 4000)
call RegSocketGem ('I001', 1, 5, 55, 64, 65, 82, 45, 64, 74, 5500)
call RegSocketGem ('I001', 1, 6, 70, 64, 95, 82, 60, 64, 110, 7000)
call RegSocketGem ('I001', 1, 7, 90, 64, 130, 82, 80, 64, 170, 9000)
//fire def - crit dmg - fire def
call RegSocketGem ('I002', 2, 1, 1, 68, 10, 55, 1, 68, 10, 100)
call RegSocketGem ('I002', 2, 2, 10, 68, 20, 55, 1, 68, 20, 1000)
call RegSocketGem ('I002', 2, 3, 25, 68, 40, 55, 2, 68, 40, 2500)
call RegSocketGem ('I002', 2, 4, 40, 68, 70, 55, 2, 68, 70, 4000)
call RegSocketGem ('I002', 2, 5, 55, 68, 110, 55, 3, 68, 110, 5500)
call RegSocketGem ('I002', 2, 6, 70, 68, 150, 55, 3, 68, 150, 7000)
call RegSocketGem ('I002', 2, 7, 90, 68, 200, 55, 4, 68, 200, 9000)
//pdef - crit dmg - pdef
call RegSocketGem ('I003', 3, 1, 1, 75, 10, 55, 1, 75, 10, 100)
call RegSocketGem ('I003', 3, 2, 10, 75, 20, 55, 1, 75, 20, 1000)
call RegSocketGem ('I003', 3, 3, 25, 75, 40, 55, 2, 75, 40, 2500)
call RegSocketGem ('I003', 3, 4, 40, 75, 70, 55, 2, 75, 70, 4000)
call RegSocketGem ('I003', 3, 5, 55, 75, 110, 55, 3, 75, 110, 5500)
call RegSocketGem ('I003', 3, 6, 70, 75, 150, 55, 3, 75, 150, 7000)
call RegSocketGem ('I003', 3, 7, 90, 75, 200, 55, 4, 75, 200, 9000)
//hp regen - crit chance - mp regen
call RegSocketGem ('I004', 4, 2, 15, 27, 1, 66, 1, 31, 1, 1500)
call RegSocketGem ('I004', 4, 4, 50, 27, 2, 66, 2, 31, 2, 5000)
//hp per kill - crit chance - mp per kill
call RegSocketGem ('I004', 4, 2, 15, 29, 2, 66, 1, 33, 2, 1500)
call RegSocketGem ('I004', 4, 4, 50, 29, 4, 66, 2, 33, 4, 5000)
//def lv - att lv - def lv
call RegSocketGem ('I005', 5, 3, 30, 70, 1, 69, 1, 70, 1, 3000)
call RegSocketGem ('I005', 5, 6, 70, 70, 2, 69, 2, 70, 2, 7000)
//special eva - life steal - acc
call RegSocketGem ('I006', 6, 6, 35, 74, 20, 28, 1, 73, 33, 3500)
// ------ Register socket gem types - 6 diff icon -----
call RegisterItem('I001', 'B02F', "ReplaceableTextures\\CommandButtons\\BTNOrbOfDarkness.blp", 100, 200, "Gems", 0)
call RegisterItem('I002', 'B02D', "ReplaceableTextures\\CommandButtons\\BTNOrbOfFire.blp", 100, 200, "Gems", 0)
call RegisterItem('I003', 'B02G', "ReplaceableTextures\\CommandButtons\\BTNOrbOfFrost.blp", 100, 200, "Gems", 0)
call RegisterItem('I004', 'B00F', "ReplaceableTextures\\CommandButtons\\BTNOrbOfLightning.blp", 100, 200, "Gems", 0)
call RegisterItem('I005', 'B02E', "ReplaceableTextures\\CommandButtons\\BTNOrbofSlowness.blp", 100, 200, "Gems", 0)
call RegisterItem('I006', 'B02H', "ReplaceableTextures\\CommandButtons\\BTNGem.blp", 100, 200, "Gems", 0)
// ------------- Register normal items --------
call RegisterItem('ckng', 'B00H', "Helm1.mdx", 11, 101, "Helmet", 0)
call RegisterItem('rde4', 'B027', "Helm1.mdx", 100, 101, "Helmet", 0)
call RegisterItem('ram3', 'B028', "Helm1.mdx", 1000, 101, "Helmet", 0)
call RegisterItem('rin1', 'B00K', "Armor1.mdx", 13, 102, "Armor", 0)
call RegisterItem('amrc', 'B025', "Armor1.mdx", 100, 102, "Armor", 0)
call RegisterItem('rnsp', 'B026', "Armor1.mdx", 1000, 102, "Armor", 0)
call RegisterItem('rag1', 'B00L', "Boot1.mdx", 10, 104, "Boot", 0)
call RegisterItem('ram2', 'B023', "Boot1.mdx", 100, 104, "Boot", 0)
call RegisterItem('ram1', 'B024', "Boot1.mdx", 1000, 104, "Boot", 0)
call RegisterItem('sbch', 'B00P', "Shield1.mdx", 15, 105, "Shield", 0)
call RegisterItem('ccmd', 'B00N', "Wing1.mdx", 99999, 109, "Wing", 0)
call RegisterItem('rlif', 'B00J', null, 9, 106, "Ring", 0)
call RegisterItem('jdrn', 'B02B', null, 100, 106, "Ring", 0)
call RegisterItem('rde0', 'B02C', null, 1000, 106, "Ring", 0)
call RegisterItem('spsh', 'B00M', null, 12, 108, "Amulet", 0)
call RegisterItem('axas', 'B029', null, 100, 108, "Amulet", 0)
call RegisterItem('ram4', 'B02A', null, 1000, 108, "Amulet", 0)
call RegisterItem('rat9', 'B00Q', "Sword1.mdx", 20, 103, "Short Sword", 1)
call RegisterItem('rde3', 'B016', "Mace.mdx", 20, 103, "Mace", 2)
call RegisterItem('rde1', 'B015', "Hammer.mdx", 20, 103, "Hammer", 3)
call RegisterItem('ofro', 'B00C', "Hammer.mdx", 20, 103, "Hammer", 3)
call RegisterItem('evtl', 'B014', "Quarterstaff.mdx", 20, 103, "Polearm", 4)
call RegisterItem('ajen', 'B013', "Longsword.mdx", 20, 103, "Long sword", 5)
call RegisterItem('lgdh', 'B00R', "Bow1.mdx", 20, 103, "Bow", 6)
call RegisterItem('desc', 'B00D', "Dagger1.mdx", 20, 103, "Dagger", 7)
call RegisterItem('ward', 'B011', "Wand.mdx", 20, 103, "Wand", 8)
call RegisterItem('brac', 'B012', "Staff.mdx", 20, 103, "Staff", 9)
call RegisterItem('hval', 'B00O', null, 50000, 110, "Tome", 0)
call RegisterItem('cnob', 'B01S', null, 500, 111, "Charm", 0)
call RegisterItem('I000', 'B00I', null, 1000, 1500, "Refine stone", 0)
call RegisterItem('phea', 'B00S', null, 50, 1900, "HP Potion", 0)
call RegisterItem('pman', 'B00T', null, 50, 1901, "Mana Potion", 0)
call RegisterItem('pghe', 'B01T', null, 100, 1902, "Super HP Potion", 0)
call RegisterItem('pgma', 'B01Y', null, 100, 1903, "Super MP Potion", 0)
call RegisterItem('I00S', 'B01Z', null, 2200, 1904, "Scrolls", 0) // scroll of healing
call RegisterItem('I00T', 'B020', null, 2200, 1905, null, 0) //scroll of mana
//Special items
call RegisterItem('I00U', 'B021', null, 900, BAG_LEVEL(), null, 0) //bag
call RegisterItem('mcou', 'B022', null, 1000, BOX_LEVEL(), "Bag & Box", 0) //surprise box
// craft materia + herbs
call RegisterItem('I00A', 'B01O', null, 10, 1200, null, 0)
call RegisterItem('I00B', 'B01B', null, 10, 1200, null, 0)
call RegisterItem('I00C', 'B01C', null, 10, 1200, null, 0)
call RegisterItem('I00D', 'B01L', null, 10, 1200, null, 0)
call RegisterItem('I00E', 'B01D', null, 10, 1200, null, 0)
call RegisterItem('I00F', 'B01N', null, 10, 1200, null, 0)
call RegisterItem('I00G', 'B01E', null, 10, 1200, null, 0) //iron
call RegisterItem('I00H', 'B01J', null, 10, 1200, null, 0) //lumber
call RegisterItem('I00I', 'B01F', null, 10, 1200, null, 0)
call RegisterItem('I00J', 'B01M', null, 10, 1200, "Materia", 0) //stone
call RegisterItem('I00K', 'B01I', null, 10, 1200, null, 0)
call RegisterItem('I00L', 'B01G', null, 10, 1200, null, 0)
call RegisterItem('I00M', 'B01A', null, 10, 1200, null, 0) //leather
call RegisterItem('I00N', 'B01H', null, 10, 1200, null, 0)
call RegisterItem('I00O', 'B01K', null, 100, 1200, null, 0) //feather
call RegisterItem('I00P', 'B01P', null, 100, 1200, null, 0) //tome page
call RegisterItem('I007', 'B01R', null, 100, 1201, null, 0) //copper ore
call RegisterItem('I008', 'B01U', null, 100, 1201, null, 0) //ametyst
call RegisterItem('I009', 'B01X', null, 100, 1201, null, 0) //ruby
call RegisterItem('I00Q', 'B01W', null, 100, 1201, null, 0) //emerald
call RegisterItem('I00R', 'B01V', null, 10000, 1200, null, 0) //Rainbow stone
call RegisterItem('gold', 'B01Q', null, 1, 0, null, 0) //gold
//shop settings
//we set the shop, this way: key1: main category, key2: order, saved value the itemtypeid
call RegItemCat4Shop (1, 'ckng')
call RegItemCat4Shop (1, 'ckng')
call RegItemCat4Shop (1, 'ckng')
call RegItemCat4Shop (1, 'rin1')
call RegItemCat4Shop (1, 'rin1')
call RegItemCat4Shop (1, 'rin1')
call RegItemCat4Shop (1, 'rag1')
call RegItemCat4Shop (1, 'rag1')
call RegItemCat4Shop (1, 'rag1')
call RegItemCat4Shop (1, 'sbch')
call RegItemCat4Shop (2, 'rat9')
call RegItemCat4Shop (2, 'rde3')
call RegItemCat4Shop (2, 'rde1')
call RegItemCat4Shop (2, 'evtl')
call RegItemCat4Shop (2, 'ajen')
call RegItemCat4Shop (2, 'lgdh')
call RegItemCat4Shop (2, 'desc')
call RegItemCat4Shop (2, 'ward')
call RegItemCat4Shop (2, 'brac')
call RegItemCat4Shop (3, 'rlif')
call RegItemCat4Shop (3, 'spsh')
call RegItemCat4Shop (3, 'cnob')
call RegItemCat4Shop (3, 'hval')
call RegItemCat4Shop (3, 'ccmd')
call RegItemCat4Shop (4, 'I000')
call RegItemCat4Shop (4, 'I00J')
call RegItemCat4Shop (4, 'I001') //socket gem menu1 icon registration
call RegItemCat4Shop (4, 'I005') //socket gem menu2 icon registration
call RegItemCat4Shop (5, 'phea')
call RegItemCat4Shop (5, 'pman')
call RegItemCat4Shop (5, 'pghe')
call RegItemCat4Shop (5, 'pgma')
call RegItemCat4Shop (5, 'I00S')
call RegItemCat4Shop (6, 'mcou')
loop
exitwhen i > 20
call RegItem4Shop (1, 1, 'ckng', 0)
call RegItem4Shop (1, 2, 'ckng', 0)
call RegItem4Shop (1, 3, 'ckng', 0)
call RegItem4Shop (1, 4, 'rin1', 0)
call RegItem4Shop (1, 5, 'rin1', 0)
call RegItem4Shop (1, 6, 'rin1', 0)
call RegItem4Shop (1, 7, 'rag1', 0)
call RegItem4Shop (1, 8, 'rag1', 0)
call RegItem4Shop (1, 9, 'rag1', 0)
call RegItem4Shop (1, 10, 'sbch', 0)
call RegItem4Shop (2, 1, 'rat9', 0)
call RegItem4Shop (2, 2, 'rde3', 0)
call RegItem4Shop (2, 3, 'rde1', 0)
call RegItem4Shop (2, 4, 'evtl', 0)
call RegItem4Shop (2, 5, 'ajen', 0)
call RegItem4Shop (2, 6, 'lgdh', 0)
call RegItem4Shop (2, 7, 'desc', 0)
call RegItem4Shop (2, 8, 'ward', 0)
call RegItem4Shop (2, 9, 'brac', 0)
call RegItem4Shop (3, 1, 'rlif', 0)
call RegItem4Shop (3, 2, 'spsh', 0)
call RegItem4Shop (3, 3, 'cnob', 0)
call RegItem4Shop (5, 3, 'pghe', 0)
call RegItem4Shop (5, 4, 'pgma', 0)
set i = i + 1
endloop
call RegItem4Shop (3, 4, 'hval', 4)
call RegItem4Shop (3, 5, 'ccmd', 1)
call RegItem4Shop (3, 5, 'ccmd', 2)
call RegItem4Shop (3, 5, 'ccmd', 3)
//unique set 1
call RegItem4Shop (3, 5, 'ram3', 5)
call RegItem4Shop (3, 5, 'rnsp', 6)
call RegItem4Shop (3, 5, 'ram1', 7)
call RegItem4Shop (3, 5, 'rde0', 8)
call RegItem4Shop (3, 5, 'rde0', 9)
call RegItem4Shop (3, 5, 'ram4', 10)
//unique set 2
call RegItem4Shop (3, 5, 'ofro', 11)
call RegItem4Shop (3, 5, 'rde0', 12)
call RegItem4Shop (4, 3, 'I001', 1) //socket gem 1
call RegItem4Shop (4, 3, 'I001', 2) //socket gem 1
call RegItem4Shop (4, 3, 'I001', 3) //socket gem 1
call RegItem4Shop (4, 3, 'I001', 4) //socket gem 1
call RegItem4Shop (4, 3, 'I001', 5) //socket gem 1
call RegItem4Shop (4, 3, 'I001', 6) //socket gem 1
call RegItem4Shop (4, 3, 'I001', 7) //socket gem 1
call RegItem4Shop (4, 3, 'I002', 8) //socket gem 1
call RegItem4Shop (4, 3, 'I002', 9) //socket gem 1
call RegItem4Shop (4, 3, 'I002', 10) //socket gem 1
call RegItem4Shop (4, 3, 'I002', 11) //socket gem 1
call RegItem4Shop (4, 3, 'I002', 12) //socket gem 1
call RegItem4Shop (4, 3, 'I002', 13) //socket gem 1
call RegItem4Shop (4, 3, 'I002', 14) //socket gem 1
call RegItem4Shop (4, 3, 'I003', 15) //socket gem 1
call RegItem4Shop (4, 3, 'I003', 16) //socket gem 1
call RegItem4Shop (4, 3, 'I003', 17) //socket gem 1
call RegItem4Shop (4, 3, 'I003', 18) //socket gem 1
call RegItem4Shop (4, 3, 'I003', 19) //socket gem 1
call RegItem4Shop (4, 3, 'I003', 20) //socket gem 1
call RegItem4Shop (4, 3, 'I003', 21) //socket gem 1
call RegItem4Shop (4, 4, 'I004', 22) //socket gem 1
call RegItem4Shop (4, 4, 'I004', 23) //socket gem 1
call RegItem4Shop (4, 4, 'I004', 24) //socket gem 1
call RegItem4Shop (4, 4, 'I004', 25) //socket gem 1
call RegItem4Shop (4, 4, 'I005', 26) //socket gem 1
call RegItem4Shop (4, 4, 'I005', 27) //socket gem 1
call RegItem4Shop (4, 4, 'I006', 28) //socket gem 1
// call RegItem4Shop (4, 1, 'I002', 1) //socket gem 2
// call RegItem4Shop (4, 1, 'I003', 1) //socket gem 3
// call RegItem4Shop (4, 1, 'I004', 1) //socket gem 4
// call RegItem4Shop (4, 1, 'I005', 1) //socket gem 5
// call RegItem4Shop (4, 1, 'I006', 1) //socket gem 6
call RegItem4Shop (4, 1, 'I000', 1)
call RegItem4Shop (4, 1, 'I000', 20)
call RegItem4Shop (4, 2, 'I00R', 0)
call RegItem4Shop (4, 2, 'I008', 0)
call RegItem4Shop (4, 2, 'I00Q', 0)
call RegItem4Shop (4, 2, 'I009', 0)
call RegItem4Shop (4, 2, 'I007', 0)
call RegItem4Shop (4, 2, 'I00G', 0)
call RegItem4Shop (4, 2, 'I00H', 0)
call RegItem4Shop (4, 2, 'I00M', 0)
call RegItem4Shop (4, 2, 'I00J', 0)
call RegItem4Shop (4, 2, 'I00A', 0)
call RegItem4Shop (4, 2, 'I00B', 0)
call RegItem4Shop (4, 2, 'I00C', 0)
call RegItem4Shop (4, 2, 'I00D', 0)
call RegItem4Shop (4, 2, 'I00E', 0)
call RegItem4Shop (4, 2, 'I00F', 0)
call RegItem4Shop (4, 2, 'I00I', 0)
call RegItem4Shop (4, 2, 'I00K', 0)
call RegItem4Shop (4, 2, 'I00L', 0)
call RegItem4Shop (4, 2, 'I00N', 0)
call RegItem4Shop (4, 2, 'I00O', 0)
call RegItem4Shop (4, 2, 'I00O', 30)
call RegItem4Shop (4, 2, 'I00P', 0)
call RegItem4Shop (4, 2, 'I00P', 20)
call RegItem4Shop (5, 1, 'phea', 1)
call RegItem4Shop (5, 1, 'phea', 10)
call RegItem4Shop (5, 1, 'phea', 50)
call RegItem4Shop (5, 2, 'pman', 1)
call RegItem4Shop (5, 2, 'pman', 10)
call RegItem4Shop (5, 2, 'pman', 50)
call RegItem4Shop (5, 5, 'I00S', 0)
call RegItem4Shop (5, 5, 'I00T', 0)
call RegItem4Shop (6, 1, 'mcou', 0)
call RegItem4Shop (6, 1, 'I00U', 0)
//call RegCraft('I002', 'I001', 3, 'I000', 2, 0, 0)
//call RegCraft('I003', 'I002', 3, 'I000', 2, 0, 0)
//call RegCraft('I004', 'I003', 3, 'I000', 2, 0, 0)
//call RegCraft('I005', 'I004', 3, 'I000', 2, 0, 0)
//call RegCraft('I006', 'I005', 3, 'I000', 2, 0, 0)
call RegCraft('ckng', 'I00M', 2, 'I00G', 1, 'I00H', 1)
call RegCraft('rin1', 'I00M', 3, 'I00G', 1, 'I00H', 1)
call RegCraft('rag1', 'I00M', 1, 'I00G', 1, 'I00H', 1)
call RegCraft('sbch', 'I007', 1, 'I00G', 1, 'I00J', 4)
call RegCraft('rlif', 'I00R', 1, 'I00J', 2, 0, 0)
call RegCraft('spsh', 'I00R', 1, 'I00J', 2, 0, 0)
call RegCraft('I00R', 'I008', 1, 'I00Q', 1, 'I009', 1)
call RegCraft('rat9', 'I00G', 3, 'I00H', 1, 'I00J', 2)
call RegCraft('rde3', 'I00G', 3, 'I00H', 1, 'I00J', 2)
call RegCraft('rde1', 'I00G', 2, 'I00H', 1, 'I00J', 3)
call RegCraft('evtl', 'I00G', 3, 'I00H', 2, 'I00J', 1)
call RegCraft('ajen', 'I00G', 3, 'I00H', 2, 'I00J', 1)
call RegCraft('lgdh', 'I00G', 1, 'I00H', 4, 'I00J', 1)
call RegCraft('desc', 'I00G', 2, 'I00H', 3, 'I00J', 1)
call RegCraft('ward', 'I00G', 1, 'I00H', 2, 'I00J', 3)
call RegCraft('brac', 'I00G', 1, 'I00H', 3, 'I00J', 2)
call RegCraft('ccmd', 'I00O', 99, 'I000', 20, 0, 0)
call RegCraft('hval', 'I00P', 20, 0, 0, 0, 0)
call RegCraft('pghe', 'I00E', 2, 'I00C', 1, 'I00D', 1)
call RegCraft('pgma', 'I00F', 1, 'I00I', 2, 'I00B', 1)
call RegCraft('I00S', 'I00L', 3, 'I00E', 3, 'I00A', 3)
call RegCraft('I00T', 'I00C', 3, 'I00F', 3, 'I00K', 3)
//Create Catalog for unique items, here the id got '-' sign
//wing 1
call SaveInteger(udg_CItem_Table, - 1, 2, 9) //itype
call SaveInteger(udg_CItem_Table, - 1, 3, 0) //subtype
call SaveInteger(udg_CItem_Table, - 1, 7, 30) //grade
call SaveInteger(udg_CItem_Table, - 1, 8, 30) //lv req
call SaveInteger(udg_CItem_Table, - 1, 20, 6) //socket
call SaveInteger(udg_CItem_Table, - 1, 50, 30) //attack lv
call SaveInteger(udg_CItem_Table, - 1, 51, 30) //def lv
//wing 2
call SaveInteger(udg_CItem_Table, - 2, 2, 9) //itype
call SaveInteger(udg_CItem_Table, - 2, 3, 0) //subtype
call SaveInteger(udg_CItem_Table, - 2, 7, 30) //grade
call SaveInteger(udg_CItem_Table, - 2, 8, 30) //lv req
call SaveInteger(udg_CItem_Table, - 2, 20, 6) //socket
call SaveInteger(udg_CItem_Table, - 2, 50, 45) //attack lv
call SaveInteger(udg_CItem_Table, - 2, 51, 15) //def lv
//wing3
call SaveInteger(udg_CItem_Table, - 3, 2, 9) //itype
call SaveInteger(udg_CItem_Table, - 3, 3, 0) //subtype
call SaveInteger(udg_CItem_Table, - 3, 7, 30) //grade
call SaveInteger(udg_CItem_Table, - 3, 8, 30) //lv req
call SaveInteger(udg_CItem_Table, - 3, 20, 6) //socket
call SaveInteger(udg_CItem_Table, - 3, 50, 15) //attack lv
call SaveInteger(udg_CItem_Table, - 3, 51, 45) //def lv
//---- this is the tome
call SaveInteger(udg_CItem_Table, - 4, 2, 10) //itype
call SaveInteger(udg_CItem_Table, - 4, 3, 0) //subtype
call SaveInteger(udg_CItem_Table, - 4, 7, 30) //grade
call SaveInteger(udg_CItem_Table, - 4, 22, 50) // better eq drop
call SaveInteger(udg_CItem_Table, - 4, 23, 50) // bonus exp
call SaveInteger(udg_CItem_Table, - 4, 24, 50) // gold drop rate
call SaveInteger(udg_CItem_Table, - 4, 81, 50) // shop discount
//------------------- unique armor sets ----------------------
// ---- Heavy Helmet ----
call SaveInteger(udg_CItem_Table, - 5, 5, 1) //set id
call SaveInteger(udg_CItem_Table, - 5, 2, 1) //itype
call SaveInteger(udg_CItem_Table, - 5, 3, 1) //subtype
call SaveInteger(udg_CItem_Table, - 5, 7, 100) //grade
call SaveInteger(udg_CItem_Table, - 5, 8, 5) //lv req
call SaveInteger(udg_CItem_Table, - 5, 20, 7) //socket
call SaveInteger(udg_CItem_Table, - 5, 66, 1) //crit
call SaveInteger(udg_CItem_Table, - 5, 77, 400) //bonus water defence
call SaveInteger(udg_CItem_Table, - 5, 73, 277) //bonus accurancy
call SaveInteger(udg_CItem_Table, - 5, 29, 30) //hp per kill
call SaveStr(udg_CItem_Table, - 5, 21, "Sky of the shadow's")
// ---- Heavy Armor ----
call SaveInteger(udg_CItem_Table, - 6, 5, 1) //set id
call SaveInteger(udg_CItem_Table, - 6, 2, 2) //itype
call SaveInteger(udg_CItem_Table, - 6, 3, 1) //subtype
call SaveInteger(udg_CItem_Table, - 6, 7, 100) //grade
call SaveInteger(udg_CItem_Table, - 6, 8, 5) //lv req
call SaveInteger(udg_CItem_Table, - 6, 20, 7) //socket
call SaveInteger(udg_CItem_Table, - 6, 27, 33) //hp regen
call SaveInteger(udg_CItem_Table, - 6, 75, 1000) //bonus physical defence
call SaveInteger(udg_CItem_Table, - 6, 76, 400) //bonus fire defence
call SaveInteger(udg_CItem_Table, - 6, 80, 400) //bonus earth defence
call SaveStr(udg_CItem_Table, - 6, 21, "Mail of the shadow's")
// ---- Heavy Boot ----
call SaveInteger(udg_CItem_Table, - 7, 5, 1) //set id
call SaveInteger(udg_CItem_Table, - 7, 2, 4) //itype
call SaveInteger(udg_CItem_Table, - 7, 3, 1) //subtype
call SaveInteger(udg_CItem_Table, - 7, 7, 100) //grade
call SaveInteger(udg_CItem_Table, - 7, 8, 5) //lv req
call SaveInteger(udg_CItem_Table, - 7, 20, 7) //socket
call SaveInteger(udg_CItem_Table, - 7, 40, 100) //movement speed
call SaveInteger(udg_CItem_Table, - 7, 74, 133) //evasion
call SaveInteger(udg_CItem_Table, - 7, 78, 400) //bonus litghning defence
call SaveInteger(udg_CItem_Table, - 7, 79, 400) //bonus poison defence
call SaveStr(udg_CItem_Table, - 7, 21, "Wind runner")
// ---- Ring 1 ----
call SaveInteger(udg_CItem_Table, - 8, 5, 1) //set id
call SaveInteger(udg_CItem_Table, - 8, 2, 6) //itype
call SaveInteger(udg_CItem_Table, - 8, 7, 100) //grade
call SaveInteger(udg_CItem_Table, - 8, 8, 5) //lv req
call SaveInteger(udg_CItem_Table, - 8, 73, 120) //bonus accurancy
call SaveInteger(udg_CItem_Table, - 8, 28, 2) //life steal
call SaveInteger(udg_CItem_Table, - 8, 69, 3) //att lv
call SaveInteger(udg_CItem_Table, - 8, 54, 5) //crit
call SaveStr(udg_CItem_Table, - 8, 21, "Eye of the shadow's")
// ---- Ring 2 ----
call SaveInteger(udg_CItem_Table, - 9, 5, 1) //set id
call SaveInteger(udg_CItem_Table, - 9, 2, 6) //itype
call SaveInteger(udg_CItem_Table, - 9, 7, 100) //grade
call SaveInteger(udg_CItem_Table, - 9, 8, 5) //lv req
call SaveInteger(udg_CItem_Table, - 9, 54, 5) //crit
call SaveInteger(udg_CItem_Table, - 9, 57, 128) //bonus fire dmg
call SaveInteger(udg_CItem_Table, - 9, 62, 100) //phys damage
call SaveInteger(udg_CItem_Table, - 9, 69, 3) //att lv
call SaveStr(udg_CItem_Table, - 9, 21, "Precious one")
// ---- Amulet ----
call SaveInteger(udg_CItem_Table, - 10, 5, 1) //set id
call SaveInteger(udg_CItem_Table, - 10, 2, 8) //itype
call SaveInteger(udg_CItem_Table, - 10, 7, 100) //grade
call SaveInteger(udg_CItem_Table, - 10, 8, 5) //lv req
call SaveInteger(udg_CItem_Table, - 10, 75, 250) //phys defence
call SaveInteger(udg_CItem_Table, - 10, 70, 5) //defence lv
call SaveInteger(udg_CItem_Table, - 10, 55, 25) //crit strike dmg
call SaveStr(udg_CItem_Table, - 10, 21, "Necklance of shadow's")
// ---- Hammer from set 2 ----
call SaveInteger(udg_CItem_Table, - 11, 5, 2) //set id
call SaveInteger(udg_CItem_Table, - 11, 2, 3) //itype
call SaveInteger(udg_CItem_Table, - 11, 3, 3) //subtype axe & hammer
call SaveInteger(udg_CItem_Table, - 11, 7, 100) //grade
call SaveInteger(udg_CItem_Table, - 11, 8, 5) //lv req
call SaveInteger(udg_CItem_Table, - 11, 66, 5) //+5% critical chance
call SaveInteger(udg_CItem_Table, - 11, 62, 250) //+250 physical attack
call SaveInteger(udg_CItem_Table, - 11, 44, 21) //+21 str
call SaveInteger(udg_CItem_Table, - 11, 25, 3) //bleed dmg weapon effect
call SaveInteger(udg_CItem_Table, - 11, 20, 7) //socket
call SaveStr(udg_CItem_Table, - 11, 21, "Thunder Hammer")
// ---- Ring from set 2 ----
call SaveInteger(udg_CItem_Table, - 12, 5, 2) //set id
call SaveInteger(udg_CItem_Table, - 12, 2, 6) //itype
call SaveInteger(udg_CItem_Table, - 12, 7, 100) //grade
call SaveInteger(udg_CItem_Table, - 12, 8, 5) //lv req
call SaveInteger(udg_CItem_Table, - 12, 54, 5) //crit
call SaveInteger(udg_CItem_Table, - 12, 78, 1000) //+1000 bonus lightning defence
call SaveInteger(udg_CItem_Table, - 12, 71, 7) //7% block damage chance
call SaveInteger(udg_CItem_Table, - 12, 69, 7) //att lv
call SaveInteger(udg_CItem_Table, - 12, 48, 10) //att lv
call SaveStr(udg_CItem_Table, - 12, 21, "Thunder Ring")
//------------------------------------------------------------------
// -------------------------- Sets ---------------------------------
//------------------------------------------------------------------
// -------------------------- Set 1 --------------------------------
call SaveStr(udg_CItem_Table, - 1001, 0, "Set of the Shadow's") //set name
call SaveInteger(udg_CItem_Table, - 1001, 1, 6) //how much part
call SaveInteger(udg_CItem_Table, - 1001, 2, 5) //1st part
call SaveInteger(udg_CItem_Table, - 1001, 3, 6) //2nd
call SaveInteger(udg_CItem_Table, - 1001, 4, 7) //3rd
call SaveInteger(udg_CItem_Table, - 1001, 5, 8) //4th
call SaveInteger(udg_CItem_Table, - 1001, 6, 9) //5th
call SaveInteger(udg_CItem_Table, - 1001, 7, 10) //6th
//after all part unique id was saved now we save the set options
//64 = bonus hp, following 2 line give 500 hp if have 2 piece,44 is bonus str
call SaveInteger(udg_CItem_Table, - 1001, 8, 64) //for 2 item we give item properties
call SaveInteger(udg_CItem_Table, - 1001, -8, 500) //properties value for 2 piece
call SaveInteger(udg_CItem_Table, - 1001, 9, 44) //for 3 item we give item properties
call SaveInteger(udg_CItem_Table, - 1001, -9, 50) //properties value for 3 piece
call SaveInteger(udg_CItem_Table, - 1001, 10, 55) //for 4 item we give item properties
call SaveInteger(udg_CItem_Table, - 1001, -10, 50) //properties value for 4 piece
call SaveInteger(udg_CItem_Table, - 1001, 11, 71) //for 5 item we give item properties
call SaveInteger(udg_CItem_Table, - 1001, -11, 10) //properties value for 5 piece
call SaveInteger(udg_CItem_Table, - 1001, 12, 49) //for 6 item we give item properties
call SaveInteger(udg_CItem_Table, - 1001, -12, 20) //properties value for 6 piece
// -------------------------- Set 2 --------------------------------
call SaveStr(udg_CItem_Table, - 1002, 0, "Set of the Thunder's") //set name
call SaveInteger(udg_CItem_Table, - 1002, 1, 2) //how much part
call SaveInteger(udg_CItem_Table, - 1002, 2, 11) //1st part
call SaveInteger(udg_CItem_Table, - 1002, 3, 12) //2nd
//after all part unique id was saved now we save the set options
//64 = bonus hp, following 2 line give 500 hp if have 2 piece,44 is bonus str
call SaveInteger(udg_CItem_Table, - 1002, 4, 66) //for 2 item we give item properties
call SaveInteger(udg_CItem_Table, - 1002, -4, 10) //+10% crit if it is set
set i = 1
set udg_Pow2[0] = 1
loop
exitwhen i > 24
set udg_Pow2[i] = udg_Pow2[i - 1] * 2
set i = i + 1
endloop
call DisableTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_Item_Registration_at_Map_Init takes nothing returns nothing
set gg_trg_Item_Registration_at_Map_Init = CreateTrigger()
call TriggerRegisterTimerEvent( gg_trg_Item_Registration_at_Map_Init, 0.01, false )
call TriggerAddAction( gg_trg_Item_Registration_at_Map_Init, function Trig_map_init_Actions )
endfunction
function CreateTrackableAll takes destructable d, integer slot1 returns nothing
local string path = ""
local real x = GetDestructableX(d)
local real y = GetDestructableY(d) // - 20
local real x1 = LoadReal(udg_FSS, 0, 1)
local real y1 = LoadReal(udg_FSS, 0, 2)
local real shiftY = (y - y1) / 64
local real z = 0
local real face = 0
local integer id
local integer a = 0
local integer slot2 = 0
local integer slot3 = 0
local player p
local trackable tr
loop
exitwhen a > 11
set p = Player(a)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
if GetLocalPlayer() == p then
set path = "CustomWindow\\Trackable.mdx"
endif
set tr = CreateTrackable( path, x, y + shiftY, face )
set id = GetHandleId(tr)
call SaveInteger(udg_FSS, - id, 1, a)
call SaveInteger(udg_FSS, - id, 2, slot1)
if (slot1 < 304 and slot1 >= 300) or (slot1 >= 1200 and slot1 < 1212) or slot1 == 1300 or slot1 == 1301 or slot1 < 100 then
set slot2 = 0
else
if slot1 > 119 then
if slot1 == 200 then
set slot2 = 2209
elseif slot1 == 201 then
set slot2 = 2210
elseif slot1 == 202 then
set slot2 = 2215
elseif slot1 == 203 then
set slot2 = 2216
elseif slot1 == 204 then
set slot2 = 2221
elseif slot1 == 205 then
set slot2 = 2222
elseif slot1 == 304 then
set slot2 = 2219
elseif slot1 == 305 then
set slot2 = 2213
elseif slot1 == 306 then
set slot2 = 2207
elseif slot1 == 307 then
set slot2 = 2201
else
set slot2 = slot1
endif
else
set slot2 = slot1
endif
endif
if (slot2 >= 2200 and slot2 < 2250) or (slot2 >= 100 and slot2 < 120) then
set slot3 = slot2
else
set slot3 = 0
endif
if slot2 > 0 then
call SaveInteger(udg_FSS, - id, 3, slot2)
endif
if slot3 > 0 then
call SaveInteger(udg_FSS, - id, 4, slot3)
endif
call TriggerRegisterTrackableHitEvent(gg_trg_ClickToTrackable, tr)
call TriggerRegisterTrackableTrackEvent(gg_trg_OnTrackable, tr)
endif
set a = a + 1
endloop
endfunction
function CreateBigTrackable takes nothing returns nothing
local string path = ""
local real x = LoadReal(udg_FSS, 0, 1)+512
local real y = LoadReal(udg_FSS, 0, 2)+256
local real z = 0
local integer pl = 0
local integer slot = 9999
local integer id
local player p
local trackable tr
loop
exitwhen pl > 11
set p = Player(pl)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
if GetLocalPlayer() == p then
set path = "CustomWindow\\BigTrackable.mdx"
endif
set tr = CreateTrackable( path, x, y , 0 )
set id = GetHandleId(tr)
call SaveInteger(udg_FSS, - id, 1, pl)
call SaveInteger(udg_FSS, - id, 2, slot)
call SaveInteger(udg_FSS, - id, 3, slot)
call SaveInteger(udg_FSS, - id, 4, slot)
call TriggerRegisterTrackableHitEvent(gg_trg_ClickToTrackable, tr)
call TriggerRegisterTrackableTrackEvent(gg_trg_OnTrackable, tr)
endif
set pl = pl + 1
endloop
endfunction
function Trig_Untitled_Trigger_003_Actions takes nothing returns nothing
local destructable d
local integer a = 0
local integer b = 0
local integer i = 0
local integer ii = 0
local real isize = 0.7
local real is
local real x1 = - 1000
local real y1 = - 1000
local real x2 = x1 + 1152
local real y2 = y1 + 512
local real bz = 0 //border Z - height
local real width = 1300 + 150
local real height = 530 + 150 + 100
local rect r = Rect(x1, y1, x1 + width, y1 + height)
//---------------------------
//we create path blockers
//YTpc - ground large path blocker.YTfc - ground+air path blocker
set i = R2I(x1) - 64
loop
exitwhen i > R2I(x2) + 64
call CreateDestructableZ('YTfc', i, y1 - 64, bz, 0, 1, 0)
call CreateDestructableZ('YTfc', i, y2 + 64, bz, 0, 1, 0)
set i = i + 128
endloop
set i = 0
set i = R2I(y1) - 64
loop
exitwhen i > R2I(y2) + 64
call CreateDestructableZ('YTfc', x1 - 64, i, bz, 0, 1, 0)
call CreateDestructableZ('YTfc', x2 + 64, i, bz, 0, 1, 0)
set i = i + 128
endloop
set i = 0
//create camera with jass
set udg_Cam1 = CreateCameraSetup()
call CameraSetupSetField(udg_Cam1 , CAMERA_FIELD_ZOFFSET , 0.0 , 0.0)
call CameraSetupSetField(udg_Cam1 , CAMERA_FIELD_ROTATION , 90.0 , 0.0)
call CameraSetupSetField(udg_Cam1 , CAMERA_FIELD_ANGLE_OF_ATTACK , 270.0 , 0.0)
call CameraSetupSetField(udg_Cam1 , CAMERA_FIELD_TARGET_DISTANCE , 1300.0 , 0.0)
call CameraSetupSetField(udg_Cam1 , CAMERA_FIELD_ROLL , 0.0 , 0.0)
call CameraSetupSetField(udg_Cam1 , CAMERA_FIELD_FIELD_OF_VIEW , 70.0 , 0.0)
call CameraSetupSetField(udg_Cam1 , CAMERA_FIELD_FARZ , 5000.0 , 0.0)
call CameraSetupSetDestPosition(udg_Cam1 , x1 + 1152 / 2 , y1 + 512 / 2 , 0.0)
set udg_Cam2 = CreateCameraSetup()
call CameraSetupSetField(udg_Cam2 , CAMERA_FIELD_ZOFFSET , 0.0 , 0.0)
call CameraSetupSetField(udg_Cam2 , CAMERA_FIELD_ROTATION , 90.0 , 0.0)
call CameraSetupSetField(udg_Cam2 , CAMERA_FIELD_ANGLE_OF_ATTACK , 270.0 , 0.0)
call CameraSetupSetField(udg_Cam2 , CAMERA_FIELD_TARGET_DISTANCE , 1300.0 , 0.0)
call CameraSetupSetField(udg_Cam2 , CAMERA_FIELD_ROLL , 0.0 , 0.0)
call CameraSetupSetField(udg_Cam2 , CAMERA_FIELD_FIELD_OF_VIEW , 70.0 , 0.0)
call CameraSetupSetField(udg_Cam2 , CAMERA_FIELD_FARZ , 5000.0 , 0.0)
call CameraSetupSetDestPosition(udg_Cam2 , x1 + 1152 / 2 - 0.1, y1 + 512 / 2 , 0.0)
//save the start position and region
call SaveReal(udg_FSS, 0, 1, x1)
call SaveReal(udg_FSS, 0, 2, y1)
call SaveRectHandle(udg_FSS, 0, 3, r)
call SaveReal(udg_FSS, 0, 4, width)
call SaveReal(udg_FSS, 0, 5, height)
set r = null
//create corners for big box
//call SaveDestructableHandle(udg_FSS, 0, 200, d)
//here the inventory+gold and item list borders
set a = 0
set is = 0.63
//we create a huge traxkable
call CreateBigTrackable()
// -------- inventory borders -------
set d = CreateDestructableZ(udg_Borders[0], x1 + 0, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 0, y1 + 256, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 0, y1 + 64, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 0, y1 + 128, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 256, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 256, y1 + 256, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 0, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 256, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + 64, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + 64, y1 + 256, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + 128, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + 128, y1 + 256, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + 192, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + 192, y1 + 256, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + 64, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + 128, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + 192, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 256, y1 + 64, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 256, y1 + 128, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 200 + a, d)
// ---- end of the inventory border
// ---- Dummy unit box where is the equipment slots too ----
set a = 0
set d = CreateDestructableZ(udg_Borders[0], x1 + 384, y1 + 572, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 384, y1 + 256, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 704, y1 + 572, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 704, y1 + 256, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set i = 384
loop
exitwhen i > 640
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i, y1 + 256, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i, y1 + 572, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set i = i + 64
endloop
set i = 256
loop
exitwhen i > 512
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 384, y1 + i, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 704, y1 + i, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set i = i + 64
endloop
//------ end dummy unit box ------
// ----- old inventory border ------
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 512, y1 + 128, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 512, y1, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 576, y1 + 128, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 576, y1, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 576, y1 + 64, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 512, y1 + 64, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
// ---- end old inventory border -----
// ----- command button box -------
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 0, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 0, y1 + 448, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 192, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 192, y1 + 448, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + 64, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + 64, y1 + 448, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + 128, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + 128, y1 + 448, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 300 + a, d)
// ---- end command button box ------
// ----- stat window --------
set a = 0
set d = CreateDestructableZ(udg_Borders[0], x1 + 832, y1 + 572, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 500 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 832, y1, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 500 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 1216, y1 + 572, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 500 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 1216, y1, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 500 + a, d)
set i = 896
loop
exitwhen i > 1152
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i, y1, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 500 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i, y1 + 572, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 500 + a, d)
set i = i + 64
endloop
set i = 0
loop
exitwhen i > 512
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 832, y1 + i, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 500 + a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 1216, y1 + i, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 0, 500 + a, d)
set i = i + 64
endloop
// ----- end stat window border -----
//inventory
set a = 0
set ii = 0
loop
exitwhen ii > 192
set i = 0
loop
exitwhen i > 256
//create empty slots - we save to hash
set d = CreateDestructableZ(udg_Icons[0], x1 + i, y1 + ii, 0, 0, isize, 0)
//save the item slot coordinate[row,column], X coord
call SaveDestructableHandle(udg_FSS, 100 + a, 0, d)
call SaveReal(udg_FSS, 100 + ((3 - ii / 64) * 5) + (i / 64), 1, x1 + i)
call SaveReal(udg_FSS, 100 + ((3 - ii / 64) * 5) + (i / 64), 2, y1 + ii)//100 + a
call CreateTrackableAll (d, 100 + ((3 - ii / 64) * 5) + (i / 64))
set i = i + 64
set a = a + 1
endloop
set ii = ii + 64
endloop
//we save the real inventory clone slot coords(that 6 slot, sub the dummy unit)
set i = 0
loop
exitwhen i > 128
//hero slot 1 will be slot 1 here too, so hashtable(1000,0-5)
set d = CreateDestructableZ(udg_Icons[0], x1 + 512, y1 + i, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 200 + (i / 64) * 2, 0, d)
call SaveReal(udg_FSS, 200 + (2 - i / 64) * 2, 1, x1 + 512)
call SaveReal(udg_FSS, 200 + (2 - i / 64) * 2, 2, y1 + i)
call CreateTrackableAll (d, 200 + (2 - i / 64) * 2)
set d = CreateDestructableZ(udg_Icons[0], x1 + 576, y1 + i, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 200 + (i / 64) * 2 + 1, 0, d)
call SaveReal(udg_FSS, 200 + (2 - i / 64) * 2 + 1, 1, x1 + 576)
call SaveReal(udg_FSS, 200 + (2 - i / 64) * 2 + 1, 2, y1 + i)
call CreateTrackableAll (d, 200 + (2 - i / 64) * 2 + 1)
set i = i + 64
endloop
//command buttons
//exit - drop - repair all - repair /
set i = 0
set a = 0
loop
exitwhen i > 192
set d = CreateDestructableZ(udg_Icons[20 + a], x1 + i, y1 + 512, 0, 0, 0.65, 0)
call SaveDestructableHandle(udg_FSS, 300 + a, 0, d)
call SaveReal(udg_FSS, 300 + a, 1, x1 + i)
call SaveReal(udg_FSS, 300 + a, 2, y1 + 512)
call CreateTrackableAll (d, 300 + a)
set a = a + 1
set i = i + 64
endloop
//command buttons
//restat - str - agi - int
set i = 192
loop
exitwhen i < 0
if a == 7 then
set d = CreateDestructableZ(udg_Icons[33 - a], x1 + i, y1 + 448, 0, 0, 0.63, 0)
else
set d = CreateDestructableZ(udg_Icons[33 - a], x1 + i + 5, y1 + 448, 0, 0, 0.7, 0)
endif
call SaveDestructableHandle(udg_FSS, 300 + a, 0, d)
call SaveReal(udg_FSS, 300 + a, 1, x1 + i)
call SaveReal(udg_FSS, 300 + a, 2, y1 + 448)
call CreateTrackableAll (d, 300 + a)
set a = a + 1
set i = i - 64
endloop
//helm slot
set d = CreateDestructableZ(udg_Icons[1], x1 + 384, y1 + 576, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 1, 0, d)
call SaveReal(udg_FSS, 1, 1, x1 + 384)
call SaveReal(udg_FSS, 1, 2, y1 + 576)
call CreateTrackableAll (d, 1)
//armor slot
set d = CreateDestructableZ(udg_Icons[2], x1 + 384, y1 + 512, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 2, 0, d)
call SaveReal(udg_FSS, 2, 1, x1 + 384)
call SaveReal(udg_FSS, 2, 2, y1 + 512)
call CreateTrackableAll (d, 2)
//weapon slot
set d = CreateDestructableZ(udg_Icons[3], x1 + 384, y1 + 448, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 3, 0, d)
call SaveReal(udg_FSS, 3, 1, x1 + 384)
call SaveReal(udg_FSS, 3, 2, y1 + 448)
call CreateTrackableAll (d, 3)
//shield slot
set d = CreateDestructableZ(udg_Icons[5], x1 + 384, y1 + 384, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 5, 0, d)
call SaveReal(udg_FSS, 5, 1, x1 + 384)
call SaveReal(udg_FSS, 5, 2, y1 + 384)
call CreateTrackableAll (d, 5)
//boot slot
set d = CreateDestructableZ(udg_Icons[4], x1 + 384, y1 + 320, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 4, 0, d)
call SaveReal(udg_FSS, 4, 1, x1 + 384)
call SaveReal(udg_FSS, 4, 2, y1 + 320)
call CreateTrackableAll (d, 4)
//amulet slot
set d = CreateDestructableZ(udg_Icons[6], x1 + 448, y1 + 572, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 8, 0, d)
call SaveReal(udg_FSS, 8, 1, x1 + 448)
call SaveReal(udg_FSS, 8, 2, y1 + 572)
call CreateTrackableAll (d, 8)
//ring1 slot
set d = CreateDestructableZ(udg_Icons[7], x1 + 512, y1 + 572, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 6, 0, d)
call SaveReal(udg_FSS, 6, 1, x1 + 512)
call SaveReal(udg_FSS, 6, 2, y1 + 572)
call CreateTrackableAll (d, 6)
//ring2 slot
set d = CreateDestructableZ(udg_Icons[8], x1 + 576, y1 + 572, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 7, 0, d)
call SaveReal(udg_FSS, 7, 1, x1 + 576)
call SaveReal(udg_FSS, 7, 2, y1 + 572)
call CreateTrackableAll (d, 7)
//wing slot
set d = CreateDestructableZ(udg_Icons[9], x1 + 640, y1 + 572, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 9, 0, d)
call SaveReal(udg_FSS, 9, 1, x1 + 640)
call SaveReal(udg_FSS, 9, 2, y1 + 572)
call CreateTrackableAll (d, 9)
//tome slot
set d = CreateDestructableZ(udg_Icons[10], x1 + 704, y1 + 572, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 10, 0, d)
call SaveReal(udg_FSS, 10, 1, x1 + 704)
call SaveReal(udg_FSS, 10, 2, y1 + 572)
call CreateTrackableAll (d, 10)
//special
set d = CreateDestructableZ(udg_Icons[33], x1 + 384, y1 + 256, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 11, 0, d)
call SaveReal(udg_FSS, 11, 1, x1 + 384)
call SaveReal(udg_FSS, 11, 2, y1 + 256)
call CreateTrackableAll (d, 11)
//create trader window borders
// set i = 768
// set a = 0
// loop
// exitwhen i > 1152
// set d = CreateDestructableZ(udg_Borders[5], x1 + i, y1 + 196 + 64, bz, 0, 1, 0)
// call SaveDestructableHandle(udg_FSS, 0, 2000 + a, d)
// set i = i + 64
// set a = a + 1
// endloop
// set i = 768
//set a = 0
// loop
// exitwhen i > 1152
// set d = CreateDestructableZ(udg_Borders[4], x1 + i, y1 + 196, bz, 0, 1, 0)
// call SaveDestructableHandle(udg_FSS, 0, 2000 + a, d)
// set i = i + 64
// set a = a + 1
// endloop
// set i = 0
//set a = 0
// loop
// exitwhen i > 196
// set d = CreateDestructableZ(udg_Borders[6], x1 + 1024 + 16, y1 + i, bz, 0, 1, 0)
// call SaveDestructableHandle(udg_FSS, 0, 2000 + a, d)
// set i = i + 64
// set a = a + 1
// endloop
set a = 0
set i = - 5
set ii = R2I(x1) + 780
loop
exitwhen i > 128
set d = CreateDestructableZ(udg_Icons[0], ii, y1 + i, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 1200 + a * 2, 0, d)
call SaveReal(udg_FSS, 1200 + a * 2, 1, ii)
call SaveReal(udg_FSS, 1200 + a * 2, 2, y1 + i)
call CreateTrackableAll (d, 1200 + a * 2)
set d = CreateDestructableZ(udg_Icons[0], ii + 64, y1 + i, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 1200 + a * 2 + 1, 0, d)
call SaveReal(udg_FSS, 1200 + a * 2 + 1, 1, ii + 64)
call SaveReal(udg_FSS, 1200 + a * 2 + 1, 2, y1 + i)
call CreateTrackableAll (d, 1200 + a * 2 + 1)
set d = CreateDestructableZ(udg_Icons[0], ii + 390 - 64, y1 + i, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 1200 + a * 2 + 6, 0, d)
call SaveReal(udg_FSS, 1200 + a * 2 + 6, 1, ii + 390 - 64)
call SaveReal(udg_FSS, 1200 + a * 2 + 6, 2, y1 + i)
call CreateTrackableAll (d, 1200 + a * 2 + 6)
set d = CreateDestructableZ(udg_Icons[0], ii + 390, y1 + i, 0, 0, isize, 0)
call SaveDestructableHandle(udg_FSS, 1200 + a * 2 + 7, 0, d)
call SaveReal(udg_FSS, 1200 + a * 2 + 7, 1, ii + 390)
call SaveReal(udg_FSS, 1200 + a * 2 + 7, 2, y1 + i)
call CreateTrackableAll (d, 1200 + a * 2 + 7)
set a = a + 1
set i = i + 64
endloop
set a = 12
set d = CreateDestructableZ(udg_Icons[31], x1 + 760+64, y1 + 220, bz, 0, 0.3, 0)
call SaveDestructableHandle(udg_FSS, 1200 + a, 0, d)
set a = a + 1
set d = CreateDestructableZ(udg_Icons[31], x1 + 1020+64, y1 + 220, bz, 0, 0.3, 0)
call SaveDestructableHandle(udg_FSS, 1200 + a, 0, d)
//create icon for tradelock (self)
set d = CreateDestructableZ(udg_Icons[25], ii + 128, y1 + 96, bz, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 1300, 0, d)
call CreateTrackableAll (d, 1300)
set d = CreateDestructableZ(udg_Icons[25], ii + 128, y1 + 32, bz, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 1301, 0, d)
call CreateTrackableAll (d, 1301)
//create icon for tradelock (for dummy player)
set d = CreateDestructableZ(udg_Icons[25], ii + 262, y1 + 96, bz, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 1302, 0, d)
set d = CreateDestructableZ(udg_Icons[25], ii + 262, y1 + 32, bz, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 1303, 0, d)
set d = CreateDestructableZ(udg_Icons[30], ii + 128, y1 + 96, bz, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 1310, 0, d)
set d = CreateDestructableZ(udg_Icons[30], ii + 128, y1 + 32, bz, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 1311, 0, d)
set d = CreateDestructableZ(udg_Icons[30], ii + 262, y1 + 96, bz, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 1312, 0, d)
set d = CreateDestructableZ(udg_Icons[30], ii + 262, y1 + 32, bz, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 1313, 0, d)
call SaveUnitHandle(udg_FSS, 550, 0, CreateUnit(Player(13), udg_DummyVillager, x1 + 600, y1 + 250, 90))
//------------------------------------------------------
// shop interface
//------------------------------------------------------
set a = 0
set i = 0
set is = 0.62
//lu
//this the main category borders
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 800, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 800, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 1120, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 1120, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
//sub category borders
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 480, y1 + 384, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 480, y1 + 384, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 1120, y1 + 384, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 1120, y1 + 384, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
//right bottom - tooltip box corner
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 864, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 864, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 1184, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 1184, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
//here the inventory+gold and item list borders
set b = - a
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 384, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, a + b, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 704, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, a + b, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 384, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, a + b, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 704, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, a + b, d)
set b = a + b
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 0, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 0, y1 + 256, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 256, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 256, y1 + 256, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 0, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 256, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 256, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 0, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 256, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[0], x1 + 0, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set i = 64
loop
exitwhen i > 192
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set b = b + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i + 384, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, b, d)
set a = a + 1
set b = b + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i + 384, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, b, d)
set i = i + 64
endloop
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i + 384, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, b + 1, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i + 384, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, b + 2, d)
set i = 800
loop
exitwhen i > 1120
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i + 64, y1 + 192, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i + 64, y1 + 0, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set i = i + 64
endloop
set i = 480
loop
exitwhen i > 1120
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i, y1 + 384, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i, y1 + 384, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set i = i + 64
endloop
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 384, y1 + 64, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, b + 3, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 384, y1 + 128, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, b + 4, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 704, y1 + 64, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, b + 5, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 704, y1 + 128, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
call SaveDestructableHandle(udg_FSS, 2423, b + 6, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 864, y1 + 64, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[6], x1 + 864, y1 + 128, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 1184, y1 + 64, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[7], x1 + 1184, y1 + 128, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000, a, d)
//create category icons and trackables 2001-2100
set a = 0
set i = 800
loop
exitwhen i > 1120
set a = a + 1
set d = CreateDestructableZ(udg_Icons[0], x1 + i, y1 + 512, 0, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2000 + a, 0, d)
call SaveReal(udg_FSS, 2000 + a, 1, x1 + i)
call SaveReal(udg_FSS, 2000 + a, 2, y1 + 512)
call CreateTrackableAll (d, 2000 + a)
set i = i + 64
endloop
//---------------------------------------------------------------
// ----- create global category, what same to every shopper -----
//---------------------------------------------------------------
set d = CreateDestructableZ('B00H', x1 + 800, y1 + 512, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2100, 0, d)
set d = CreateDestructableZ('B013', x1 + 864, y1 + 512, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2100, 1, d)
set d = CreateDestructableZ('B00J', x1 + 928, y1 + 512, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2100, 2, d)
set d = CreateDestructableZ('B02F', x1 + 996, y1 + 512, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2100, 3, d)
set d = CreateDestructableZ('B00S', x1 + 1060, y1 + 512, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2100, 4, d)
set d = CreateDestructableZ('B019', x1 + 1124, y1 + 512, bz + 1, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2100, 5, d)
//dummy gold icon for inventory
set d = CreateDestructableZ(udg_Icons[31], x1, y1 + 270, bz, 0, 0.3, 0)
call SaveDestructableHandle(udg_FSS, 2100, 6, d)
//create subcategory icons and trackables 2101-2200
set a = 0
set i = 480
loop
exitwhen i > 1120
set a = a + 1
set d = CreateDestructableZ(udg_Icons[0], x1 + i, y1 + 384, 0, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2100 + a, 0, d)
call SaveReal(udg_FSS, 2100 + a, 1, x1 + i)
call SaveReal(udg_FSS, 2100 + a, 2, y1 + 384)
call CreateTrackableAll (d, 2100 + a)
set i = i + 64
endloop
//create item lists
set a = 0
//set a = a + 1
set d = CreateDestructableZ(udg_Icons[0], x1 + 384, y1 + 192, 0, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2200 + a, 0, d)
call SaveReal(udg_FSS, 2200 + a, 1, x1 + 384 + 64)
call SaveReal(udg_FSS, 2200 + a, 2, y1 + 128)
//call CreateTrackableAll (d, 2200+a a=1-24)
set ii = 192
loop
set i = 384
exitwhen ii < 0
loop
exitwhen i > 704
set a = a + 1
set d = CreateDestructableZ(udg_Icons[0], x1 + i, y1 + ii, 0, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2200 + a, 0, d)
call SaveReal(udg_FSS, 2200 + a, 1, x1 + i)
call SaveReal(udg_FSS, 2200 + a, 2, y1 + ii)
if not ((i == 448 + 64 and ii < 129) or (i == 576 and ii < 129)) then
call CreateTrackableAll (d, 2200 + a)
endif
set i = i + 64
endloop
set ii = ii - 64
endloop
//create buy button
set d = CreateDestructableZ(udg_Icons[20], x1 + 512, y1 + 288, 0, 0, 0.5, 0)
call SaveDestructableHandle(udg_FSS, 2301, 0, d)
call SaveReal(udg_FSS, 2301, 1, x1 + 512)
call SaveReal(udg_FSS, 2301, 2, y1 + 288)
call CreateTrackableAll (d, 2301)
//create craft button
set d = CreateDestructableZ(udg_Icons[21], x1 + 576, y1 + 288, 0, 0, 0.5, 0)
call SaveDestructableHandle(udg_FSS, 2302, 0, d)
call SaveReal(udg_FSS, 2302, 1, x1 + 576)
call SaveReal(udg_FSS, 2302, 2, y1 + 288)
call CreateTrackableAll (d, 2302)
//create quit button
set d = CreateDestructableZ(udg_Icons[23], x1 + 640, y1 + 288, 0, 0, 0.5, 0)
call SaveDestructableHandle(udg_FSS, 2300, 0, d)
call SaveReal(udg_FSS, 2300, 1, x1 + 640)
call SaveReal(udg_FSS, 2300, 2, y1 + 288)
call CreateTrackableAll (d, 2300)
//crafter box corners
set d = CreateDestructableZ(udg_Borders[0], x1 + 512, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2400, 0, d)
set d = CreateDestructableZ(udg_Borders[1], x1 + 512, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2400, 1, d)
set d = CreateDestructableZ(udg_Borders[2], x1 + 640, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2400, 2, d)
set d = CreateDestructableZ(udg_Borders[3], x1 + 640, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2400, 3, d)
set d = CreateDestructableZ(udg_Borders[5], x1 + 576, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2400, 4, d)
set d = CreateDestructableZ(udg_Borders[4], x1 + 576, y1 + 512, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 2400, 5, d)
//create craft materia slot 1
set d = CreateDestructableZ(udg_Icons[0], x1 + 512, y1 + 512, 0, 0, 0.5, 0)
call SaveDestructableHandle(udg_FSS, 2303, 0, d)
call SaveReal(udg_FSS, 2303, 1, x1 + 512)
call SaveReal(udg_FSS, 2303, 2, y1 + 512)
call CreateTrackableAll (d, 2303)
//create craft materia slot 2
set d = CreateDestructableZ(udg_Icons[0], x1 + 576, y1 + 512, 0, 0, 0.5, 0)
call SaveDestructableHandle(udg_FSS, 2304, 0, d)
call SaveReal(udg_FSS, 2304, 1, x1 + 576)
call SaveReal(udg_FSS, 2304, 2, y1 + 512)
call CreateTrackableAll (d, 2304)
//create craft materia slot 3
set d = CreateDestructableZ(udg_Icons[0], x1 + 640, y1 + 512, 0, 0, 0.5, 0)
call SaveDestructableHandle(udg_FSS, 2305, 0, d)
call SaveReal(udg_FSS, 2305, 1, x1 + 640)
call SaveReal(udg_FSS, 2305, 2, y1 + 512)
call CreateTrackableAll (d, 2305)
//craft prgress bar borders
set is = 0.25
set a = 0
set d = CreateDestructableZ(udg_Borders[0], x1 + 873, y1 + 288, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 675, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[1], x1 + 873, y1 + 288, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 675, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[2], x1 + 1173, y1 + 288, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 675, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[3], x1 + 1173, y1 + 288, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 675, a, d)
set i = 873
loop
exitwhen i > 1173
set a = a + 1
set d = CreateDestructableZ(udg_Borders[4], x1 + i, y1 + 288, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 675, a, d)
set a = a + 1
set d = CreateDestructableZ(udg_Borders[5], x1 + i, y1 + 288, bz, 0, is, 0)
call SaveDestructableHandle(udg_FSS, 675, a, d)
set i = i + 25
endloop
set d = null
call DisableTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_Create_Interface takes nothing returns nothing
set gg_trg_Create_Interface = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Create_Interface, 1.00 )
call TriggerAddAction( gg_trg_Create_Interface, function Trig_Untitled_Trigger_003_Actions )
endfunction
function AddRandomBonus takes integer id, integer grade, integer itype, integer amount returns nothing
local integer i = 1
local integer a
local integer rnd
local integer array index //real index
local integer array bonus //bonus attached to index
local integer maxindex //max index for loop
local real array c //chance array, assigned to indexs
local real rc // random chance (0,99)
local integer st
local integer l
if itype == 1 or itype == 2 or itype == 4 or itype == 5 then
set st = LoadInteger(udg_CItem_Table, id, 3)
set index[0] = 22 // experience bonus after a kill
set index[1] = 23 // drop rate for rare item
set index[2] = 24 // gold rate
set index[3] = 27 // hp reg
set index[4] = 31 // mp reg
set index[5] = 73 // accurancy bonus
set index[6] = 74 // evasion bonus
set index[7] = 72 // level req decrease
set index[8] = 44 // bonus str
set index[9] = 45 // bonus agi
set index[10] = 46 // bonus int
set index[11] = 40 // bonus movment speed
set index[12] = 47 // bonus attack speed
set index[13] = 48 // reflect damage
set index[14] = 70 // defence level
set index[15] = 75 // pdef
set index[16] = 76 // fire def
set index[17] = 77 // water def
set index[18] = 78 // lightning def
set index[19] = 79 // poison def
set index[20] = 80 // earth def
set index[21] = 64 // hp
set index[22] = 65 // mp
set index[23] = 67 // bonus duratibility
set index[24] = 28 // hp steal
set index[25] = 29 // hp per kill
set index[26] = 32 // mp steal
set index[27] = 33 // mp per kill
set index[28] = 81 // shop discount
set index[29] = 13 // ethernal
set c[0] = 10 // experience bonus after a kill
set c[1] = 5 // drop rate for rare item
set c[2] = 7 // gold rate
set c[3] = 20 // hp reg
set c[4] = 20 // mp reg
if st == 3 then
set c[5] = 0 // accurancy bonus
set c[6] = 0 // evasion bonus
else
set c[5] = 10 // accurancy bonus
set c[6] = 10 // evasion bonus
endif
set c[7] = 7 // level req decrease
if st == 3 then
set c[8] = 3 // bonus str
set c[9] = 1 // bonus agi
set c[10] = 10 // bonus int
else
set c[8] = 7 // bonus str
set c[9] = 7 // bonus agi
set c[10] = 1 // bonus int
endif
if st == 2 then
set c[11] = 6 // bonus movment speed
set c[12] = 4 // bonus attack speed
else
set c[11] = 1 // bonus movment speed
set c[12] = 1 // bonus attack speed
endif
set c[13] = 3 // reflect damage
set c[14] = 2 // defence level
set c[15] = 15 // pdef
set c[16] = 15 // fire def
set c[17] = 15 // water def
set c[18] = 15 // lightning def
set c[19] = 15 // poison def
set c[20] = 15 // earth def
set c[21] = 13 // hp
set c[22] = 13 // mp
set c[23] = 12 // bonus duratibility
set c[24] = 2 // hp steal
set c[25] = 6 // hp per kill
set c[26] = 3 // mp steal
set c[27] = 6 // mp per kill
set c[28] = 2 // shop discount
set c[29] = 51-grade/2 // ethernal
set bonus[0] = GetRandomInt(grade / 10 + 1, grade / 5 + 7) // experience bonus after a kill
set bonus[1] = GetRandomInt(grade / 20 + 1, grade / 10 + 5) // drop rate for rare item
set bonus[2] = GetRandomInt(grade / 10 + 1, grade / 5 + 12) // gold rate
set bonus[3] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // hp reg
set bonus[4] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // mp reg
set bonus[5] = GetRandomInt(grade / 2 + 1, grade * 3) // accurancy bonus
set bonus[6] = GetRandomInt(grade / 3 + 1, grade * 2) // evasion bonus
set bonus[7] = GetRandomInt(1, 2) // level req decrease
set bonus[8] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus str
set bonus[9] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus agi
set bonus[10] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus int
set bonus[11] = GetRandomInt(grade / 10 + 1, grade / 2 + 15) // bonus movment speed
set bonus[12] = GetRandomInt(grade / 10 + 1, grade / 2 + 10) // bonus attack speed
set bonus[13] = GetRandomInt(grade / 50 + 1, grade / 30 + 2) // reflect damage
set bonus[14] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // defence level
set bonus[15] = GetRandomInt(grade + 1, grade * 3 + 3) // pdef
set bonus[16] = GetRandomInt(grade + 1, grade * 3 + 3) // fire def
set bonus[17] = GetRandomInt(grade + 1, grade * 3 + 3) // water def
set bonus[18] = GetRandomInt(grade + 1, grade * 3 + 3) // lightning def
set bonus[19] = GetRandomInt(grade + 1, grade * 3 + 3) // poison def
set bonus[20] = GetRandomInt(grade + 1, grade * 3 + 3) // earth def
set bonus[21] = GetRandomInt(grade + 5, grade * 2 + 10) // hp
set bonus[22] = GetRandomInt(grade + 5, grade * 2 + 10) // mp
set bonus[23] = GetRandomInt(grade / 2 + 10, grade * 2 + 15) // inc duratibility
set bonus[24] = GetRandomInt(grade / 20 + 1, grade / 15 + 2) // hp steal
set bonus[25] = GetRandomInt(grade / 2 + 1, grade + 5) // hp per kill
set bonus[26] = GetRandomInt(grade / 20 + 1, grade / 15 + 2) // mp steal
set bonus[27] = GetRandomInt(grade / 2 + 1, grade + 5) // mp per kill
set bonus[28] = GetRandomInt(1, 3) // //shop discount
set bonus[29] = 1
set maxindex = 29
elseif itype == 3 then
set st = LoadInteger(udg_CItem_Table, id, 3)
set index[0] = 22 // experience bonus after a kill
set index[1] = 23 // drop rate for rare item
set index[2] = 24 // gold rate
set index[3] = 28 // hp steal
set index[4] = 29 // hp per kill
set index[5] = 32 // mp steal
set index[6] = 33 // mp per kill
set index[7] = 73 // accurancy bonus
set index[8] = 72 // level req decrease
set index[9] = 44 // bonus str
set index[10] = 45 // bonus agi
set index[11] = 46 // bonus int
set index[12] = 47 // bonus attack speed
set index[13] = 49 // chance for armor penetration
set index[14] = 69 // attack level
set index[15] = 66 // critical chance
set index[16] = 55 // critical damage
set index[17] = 56 // pet power
set index[18] = 57 // bonus fire damage
set index[19] = 58 // bonus water damage
set index[20] = 59 // bonus lightning damage
set index[21] = 60 // bonus poison damage
set index[22] = 61 // bonus earth damage
set index[23] = 75 // pdef
set index[24] = 76 // fire def
set index[25] = 77 // water def
set index[26] = 78 // lightning def
set index[27] = 79 // poison def
set index[28] = 80 // earth def
set index[29] = 64 // hp
set index[30] = 65 // mp
set index[31] = 67 // bonus duratibility
set index[32] = 62 // pattack
set index[33] = 63 // mattack
set index[34] = 70 // defence level
set index[35] = 81 // shop discount
set index[36] = 27 // hp reg
set index[37] = 31 // mp reg
set index[38] = 25 // activation id
set index[39] = 13 // ethernal
set c[0] = 4 // experience bonus after a kill
set c[1] = 9 // drop rate for rare item
set c[2] = 9 // gold rate
set c[3] = 11 // hp steal
set c[4] = 7 // hp per kill
set c[5] = 11 // mp steal
set c[6] = 7 // mp per kill
if st < 8 then
set c[7] = 10 // accurancy bonus
set c[12] = 10 // bonus attack speed
set c[18] = 3 // bonus fire damage
set c[19] = 3 // bonus water damage
set c[20] = 3 // bonus lightning damage
set c[21] = 3 // bonus poison damage
set c[22] = 3 // bonus earth damage
set c[32] = 17 // pattack
set c[32] = 0 // mattack
else
set c[7] = 0 // accurancy bonus
set c[12] = 0 // bonus attack speed
set c[18] = 0 // bonus fire damage
set c[19] = 0 // bonus water damage
set c[20] = 0 // bonus lightning damage
set c[21] = 0 // bonus poison damage
set c[22] = 0 // bonus earth damage
set c[32] = 0 // pattack
set c[33] = 17 // mattack
endif
set c[8] = 9 // level req decrease
set c[9] = 5 // bonus str
set c[10] = 5 // bonus agi
set c[11] = 5 // bonus int
set c[13] = 2 // chance for armor penetration
set c[14] = 9 // attack level
set c[15] = 12 // critical chance
set c[16] = 5 // critical damage
set c[17] = 1 // pet power
set c[23] = 4 // pdef
set c[24] = 4 // fire def
set c[25] = 4 // water def
set c[26] = 4 // lightning def
set c[27] = 4 // poison def
set c[28] = 4 // earth def
set c[29] = 5 // hp
set c[30] = 5 // mp
set c[31] = 12 // bonus duratibility
set c[34] = 5 // defence level
set c[35] = 3 // shop discount
set c[36] = 4 // hp reg
set c[37] = 4 // mp reg
set c[38] = 3 // activation id
set c[39] = 51-grade/2 // ethernal
set bonus[0] = GetRandomInt(grade / 10 + 1, grade / 5 + 7) // experience bonus after a kill
set bonus[1] = GetRandomInt(grade / 20 + 1, grade / 10 + 5) // drop rate for rare item
set bonus[2] = GetRandomInt(grade / 10 + 1, grade / 5 + 12) // gold rate
set bonus[3] = GetRandomInt(grade / 20 + 1, grade / 15 + 2) // hp steal
set bonus[4] = GetRandomInt(grade / 2 + 1, grade + 5) // hp per kill
set bonus[5] = GetRandomInt(grade / 20 + 1, grade / 15 + 2) // mp steal
set bonus[6] = GetRandomInt(grade / 2 + 1, grade + 5) // mp per kill
set bonus[7] = GetRandomInt(grade + 1, grade * 5 + 5) // accurancy bonus
set bonus[8] = GetRandomInt( 1, 2) // level req decrease
set bonus[9] = GetRandomInt(grade / 30 + 1, grade / 10 + 2) // bonus str
set bonus[10] = GetRandomInt(grade / 30 + 1, grade / 10 + 2) // bonus agi
set bonus[11] = GetRandomInt(grade / 30 + 1, grade / 10 + 2) // bonus int
set bonus[12] = GetRandomInt(grade / 20 + 1, grade) // bonus attack speed
set bonus[13] = GetRandomInt(grade / 50 + 1, grade / 50 + 3) // chance for armor penetration
set bonus[14] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // attack level
set bonus[15] = GetRandomInt(1, grade / 25 + 1) // critical chance
set bonus[16] = GetRandomInt(grade / 20+1, grade / 20 + 10) // critical damage
set bonus[17] = GetRandomInt(3, grade / 10 + 10) // pet power
set bonus[18] = GetRandomInt(grade, grade * 3) // bonus fire damage
set bonus[19] = GetRandomInt(grade, grade * 3) // bonus water damage
set bonus[20] = GetRandomInt(grade, grade * 3) // bonus lightning damage
set bonus[21] = GetRandomInt(grade+5, grade * 3+5) // bonus poison damage
set bonus[22] = GetRandomInt(grade, grade * 3) // bonus earth damage
set bonus[23] = GetRandomInt(grade + 1, grade * 3 + 3) // pdef
set bonus[24] = GetRandomInt(grade + 1, grade * 3 + 3) // fire def
set bonus[25] = GetRandomInt(grade + 1, grade * 3 + 3) // water def
set bonus[26] = GetRandomInt(grade + 1, grade * 3 + 3) // lightning def
set bonus[27] = GetRandomInt(grade + 1, grade * 3 + 3) // poison def
set bonus[28] = GetRandomInt(grade + 1, grade * 3 + 3) // earth def
set bonus[29] = GetRandomInt(grade + 5, grade * 2 + 10) // hp
set bonus[30] = GetRandomInt(grade + 5, grade * 2 + 10) // mp
set bonus[31] = GetRandomInt(grade / 2 + 10, grade * 2 + 15) // inc duratibility
set bonus[32] = GetRandomInt(grade + 3, grade * 2 + 5) // pattack
set bonus[33] = GetRandomInt(grade + 3, grade * 2 + 5) // mattack
set bonus[34] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // defence level
set bonus[35] = GetRandomInt(2, 5) // //shop discount
set bonus[36] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // hp reg
set bonus[37] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // mp reg
set bonus[38] = GetRandomInt(1, 9) // activation id
set bonus[39] = 1
set maxindex = 39
elseif itype == 9 then
set index[0] = 22 // experience bonus after a kill
set index[1] = 23 // drop rate for rare item
set index[2] = 24 // gold rate
set index[3] = 27 // hp reg
set index[4] = 28 // hp steal
set index[5] = 29 // hp per kill
set index[6] = 31 // mp reg
set index[7] = 32 // mp steal
set index[8] = 33 // mp per kill
set index[9] = 44 // bonus str
set index[10] = 45 // bonus agi
set index[11] = 46 // bonus int
set index[12] = 48 // reflect damage
set index[13] = 49 // chance for armor penetration
set index[14] = 75 // pdef
set index[15] = 76 // fire def
set index[16] = 77 // water def
set index[17] = 78 // lightning def
set index[18] = 79 // poison def
set index[19] = 80 // earth def
set index[20] = 64 // hp
set index[21] = 65 // mp
set index[22] = 67 // bonus duratibility
set index[23] = 62 // pattack
set index[24] = 63 // mattack
set index[25] = 69 // attack level
set index[26] = 70 // defence level
set index[27] = 66 // critical chance
set index[28] = 55 // critical damage
set index[29] = 81 // shop discount
set index[30] = 74 // evasion
set index[31] = 13 // ethernal
set c[0] = 10 // experience bonus after a kill
set c[1] = 10 // drop rate for rare item
set c[2] = 10 // gold rate
set c[3] = 7 // hp reg
set c[4] = 10 // hp steal
set c[5] = 7 // hp per kill
set c[6] = 7 // mp reg
set c[7] = 8 // mp steal
set c[8] = 7 // mp per kill
set c[9] = 3 // bonus str
set c[10] = 3 // bonus agi
set c[11] = 3 // bonus int
set c[12] = 3 // reflect damage
set c[13] = 2 // chance for armor penetration
set c[14] = 2 // pdef
set c[15] = 2 // fire def
set c[16] = 2 // water def
set c[17] = 2 // lightning def
set c[18] = 2 // poison def
set c[19] = 2 // earth def
set c[20] = 11 // hp
set c[21] = 11 // mp
set c[22] = 4 // bonus duratibility
set c[23] = 3 // pattack
set c[24] = 3 // mattack
set c[25] = 10 // attack level
set c[26] = 10 // defence level
set c[27] = 6 // critical chance
set c[28] = 5 // critical damage
set c[29] = 7 // shop discount
set c[30] = 1 // evasion
set c[31] = 51-grade/2 // ethernal
set bonus[0] = GetRandomInt(grade / 10 + 1, grade / 5 + 7) // experience bonus after a kill
set bonus[1] = GetRandomInt(grade / 20 + 1, grade / 10 + 5) // drop rate for rare item
set bonus[2] = GetRandomInt(grade / 10 + 1, grade / 5 + 12) // gold rate
set bonus[3] = GetRandomInt(grade / 15 + 1, grade / 8 + 5) // hp reg
set bonus[4] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // hp steal
set bonus[5] = GetRandomInt(grade / 2 + 1, grade * 2 + 1) // hp per kill
set bonus[6] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // mp reg
set bonus[7] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // mp steal
set bonus[8] = GetRandomInt(grade / 2 + 1, grade * 2 + 5) // mp per kill
set bonus[9] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus str
set bonus[10] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus agi
set bonus[11] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus int
set bonus[12] = GetRandomInt(grade / 30 + 1, grade / 30 + 2) // reflect damage
set bonus[13] = GetRandomInt(grade / 50 + 1, grade / 50 + 3) // chance for armor penetration
set bonus[14] = GetRandomInt(grade + 1, grade * 3 + 3) // pdef
set bonus[15] = GetRandomInt(grade + 1, grade * 3 + 3) // fire def
set bonus[16] = GetRandomInt(grade + 1, grade * 3 + 3) // water def
set bonus[17] = GetRandomInt(grade + 1, grade * 3 + 3) // lightning def
set bonus[18] = GetRandomInt(grade + 1, grade * 3 + 3) // poison def
set bonus[19] = GetRandomInt(grade + 1, grade * 3 + 3) // earth def
set bonus[20] = GetRandomInt(grade + 5, grade * 2 + 10) // hp
set bonus[21] = GetRandomInt(grade + 5, grade * 2 + 10) // mp
set bonus[22] = GetRandomInt(grade / 2 + 10, grade * 2 + 15) // inc duratibility
set bonus[23] = GetRandomInt(grade + 3, grade * 2 + 5) // pattack
set bonus[24] = GetRandomInt(grade + 3, grade * 2 + 5) // mattack
set bonus[25] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // attack level
set bonus[26] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // defence level
set bonus[27] = GetRandomInt(1, grade / 20 + 1) // critical chance
set bonus[28] = GetRandomInt(3, grade / 10 + 10) // critical damage
set bonus[29] = GetRandomInt(3, 7) // //shop discount
set bonus[30] = GetRandomInt(grade + 1, grade * 2 + 10) // evasion
set bonus[31] = 1
set maxindex = 31
elseif itype == 6 or itype == 8 then
set index[1] = 69 // attack level
set index[2] = 66 // critical chance
set index[3] = 55 // critical damage
set index[4] = 48 // reflect damage
set index[5] = 70 // defence level
set index[6] = 22 // experience bonus after a kill
set index[7] = 23 // drop rate for rare item
set index[8] = 24 // gold rate
set index[9] = 44 // bonus str
set index[10] = 45 // bonus agi
set index[11] = 46 // bonus int
set index[12] = 27 // hp reg
set index[13] = 28 // hp steal
set index[14] = 29 // hp per kill
set index[15] = 31 // mp reg
set index[16] = 32 // mp steal
set index[17] = 33 // mp per kill
set index[18] = 67 // bonus duratibility
set index[19] = 62 // pattack
set index[20] = 63 // mattack
set index[21] = 75 // pdef
set index[22] = 76 // fire def
set index[23] = 77 // water def
set index[24] = 78 // lightning def
set index[25] = 79 // poison def
set index[26] = 80 // earth def
set index[27] = 64 // hp
set index[28] = 65 // mp
set index[29] = 81 // shop discount
set index[30] = 73 // accurancy bonus
set index[31] = 74 // evasion bonus
set index[32] = 13 // ethernal
set index[33] = 72 // ethernal
set c[1] = 9 // attack level
set c[2] = 12 // critical chance
set c[3] = 10 // critical damage
set c[4] = 5 // reflect damage
set c[5] = 5 // defence level
set c[6] = 6 // experience bonus after a kill
set c[7] = 4 // drop rate for rare item
set c[8] = 5 // gold rate
set c[9] = 3 // bonus str
set c[10] = 3 // bonus agi
set c[11] = 3 // bonus int
set c[12] = 8 // hp reg
set c[13] = 8 // hp steal
set c[14] = 8 // hp per kill
set c[15] = 8 // mp reg
set c[16] = 8 // mp steal
set c[17] = 8 // mp per kill
set c[18] = 11 // bonus duratibility
if itype == 8 then
set c[19] = 13 // pattack
set c[20] = 13 // mattack
else
set c[19] = 13 // pattack
set c[20] = 13 // mattack
endif
set c[21] = 4 // pdef
set c[22] = 4 // fire def
set c[23] = 4 // water def
set c[24] = 4 // lightning def
set c[25] = 4 // poison def
set c[26] = 4 // earth def
set c[27] = 7 // hp
set c[28] = 7 // mp
set c[29] = 3 // shop discount
set c[30] = 6 // accurancy bonus
set c[31] = 6 // evasion bonus
set c[32] = 51-grade/2 // ethernal
set c[33] = 3 // level req
set bonus[1] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // attack level
set bonus[2] = GetRandomInt(1, grade / 25 + 1) // critical chance
set bonus[3] = GetRandomInt(grade / 20 + 2, grade / 20 + 5) // critical damage
set bonus[4] = GetRandomInt(grade / 50 + 1, grade / 30 + 2) // reflect damage
set bonus[5] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // defence level
set bonus[6] = GetRandomInt(grade / 10 + 1, grade / 5 + 7) // experience bonus after a kill
set bonus[7] = GetRandomInt(grade / 20 + 1, grade / 10 + 5) // drop rate for rare item
set bonus[8] = GetRandomInt(grade / 10 + 1, grade / 5 + 12) // gold rate
set bonus[9] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus str
set bonus[10] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus agi
set bonus[11] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus int
set bonus[12] = GetRandomInt(grade / 15 + 1, grade / 8 + 5) // hp reg
set bonus[13] = GetRandomInt(grade / 20 + 1, grade / 15 + 2) // hp steal
set bonus[14] = GetRandomInt(grade / 2 + 1, grade + 2) // hp per kill
set bonus[15] = GetRandomInt(grade / 15 + 1, grade / 8 + 2) // mp reg
set bonus[16] = GetRandomInt(grade / 20 + 1, grade / 15 + 2) // mp steal
set bonus[17] = GetRandomInt(grade / 2 + 1, grade + 5) // mp per kill
set bonus[18] = GetRandomInt(grade / 2 + 10, grade * 2 + 15) // inc duratibility
set bonus[19] = GetRandomInt(grade + 3, grade * 2 + 5) // pattack
set bonus[20] = GetRandomInt(grade + 3, grade * 2 + 5) // mattack
set bonus[21] = GetRandomInt(grade + 1, grade * 3 + 3) // pdef
set bonus[22] = GetRandomInt(grade + 1, grade * 3 + 3) // fire def
set bonus[23] = GetRandomInt(grade + 1, grade * 3 + 3) // water def
set bonus[24] = GetRandomInt(grade + 1, grade * 3 + 3) // lightning def
set bonus[25] = GetRandomInt(grade + 1, grade * 3 + 3) // poison def
set bonus[26] = GetRandomInt(grade + 1, grade * 3 + 3) // earth def
set bonus[27] = GetRandomInt(grade + 5, grade * 2 + 10) // hp
set bonus[28] = GetRandomInt(grade + 5, grade * 2 + 10) // mp
set bonus[29] = GetRandomInt(2, 5) // //shop discount
set bonus[30] = GetRandomInt(grade / 2 + 1, grade * 3) // accurancy bonus
set bonus[31] = GetRandomInt(grade / 3 + 1, grade * 2) // evasion bonus
set bonus[32] = 1
set bonus[33] = GetRandomInt( 1, 2) // level req decrease
set maxindex = 33
elseif itype == 11 then
set index[0] = 22 // experience bonus after a kill
set index[1] = 23 // drop rate for rare item
set index[2] = 24 // gold rate
set index[3] = 29 // hp per kill
set index[4] = 33 // mp per kill
set index[5] = 44 // bonus str
set index[6] = 45 // bonus agi
set index[7] = 46 // bonus int
set index[8] = 69 // attack level
set index[9] = 70 // defence level
set index[10] = 66 // critical chance
set index[11] = 55 // critical damage
set index[12] = 81 // shop discount
set index[13] = 27 // hp reg
set index[14] = 31 // mp reg
set index[15] = 73 // accurancy bonus
set index[16] = 74 // evasion bonus
set c[0] = 15 // experience bonus after a kill
set c[1] = 10 // drop rate for rare item
set c[2] = 20 // gold rate
set c[3] = 8 // hp per kill
set c[4] = 8 // mp per kill
set c[5] = 9 // bonus str
set c[6] = 9 // bonus agi
set c[7] = 9 // bonus int
set c[8] = 4 // attack level
set c[9] = 4 // defence level
set c[10] = 3 // critical chance
set c[11] = 2 // critical damage
set c[12] = 7 // shop discount
set c[13] = 5 // hp reg
set c[14] = 5 // mp reg
set c[15] = 3 // accurancy bonus
set c[16] = 3 // evasion bonus
set bonus[0] = GetRandomInt(grade / 30 + 1, grade / 15 + 2) // experience bonus after a kill
set bonus[1] = GetRandomInt(grade / 50 + 1, grade / 30 + 2) // drop rate for rare item
set bonus[2] = GetRandomInt(grade / 30 + 1, grade / 15 + 5) // gold rate
set bonus[3] = GetRandomInt(grade / 10 + 1, grade/3 + 1) // hp per kill
set bonus[4] = GetRandomInt(grade / 10 + 1, grade/3 + 5) // mp per kill
set bonus[5] = GetRandomInt(grade / 50 + 1, grade / 25 + 1) // bonus str
set bonus[6] = GetRandomInt(grade / 50 + 1, grade / 25 + 1) // bonus agi
set bonus[7] = GetRandomInt(grade / 50 + 1, grade / 25 + 1) // bonus int
set bonus[8] = GetRandomInt(grade / 50 + 1, grade / 20 + 2) // attack level
set bonus[9] = GetRandomInt(grade / 50 + 1, grade / 20 + 2) // defence level
set bonus[10] = GetRandomInt(1, grade / 50 + 1) // critical chance
set bonus[11] = GetRandomInt(1, grade / 33 + 3) // critical damage
set bonus[12] = GetRandomInt(1, grade / 30) // //shop discount
set bonus[13] = GetRandomInt(grade / 25 + 1, grade / 15 + 2) // hp reg
set bonus[14] = GetRandomInt(grade / 25 + 1, grade / 15 + 2) // mp reg
set bonus[15] = GetRandomInt(grade / 2 + 1, grade +1) // accurancy bonus
set bonus[16] = GetRandomInt(grade / 3 + 1, grade +1) // evasion bonus
set maxindex = 16
endif
set l = StringLength(SL_CODE())
loop
exitwhen i > amount
set rnd = GetRandomInt(0, maxindex)
set rc = GetRandomReal(0,99)
loop
exitwhen c[rnd] > rc
set rnd = GetRandomInt(0, maxindex)
set rc = GetRandomReal(0,99)
if index[rnd] == 25 and LoadInteger(udg_CItem_Table, id, 25) > 0 then
set rc = 9999
endif
endloop
if not (index[rnd] == 25 and itype != 3) then
set a = Inline_Item_Bonus_Stat_Length(index[rnd])
set bonus[rnd] = ModuloInteger(bonus[rnd], R2I(Pow(l,a)) )
if index[rnd] == 67 then
call SaveInteger(udg_CItem_Table, id, 67, bonus[rnd])
call SaveReal(udg_CItem_Table, id, 15, LoadReal(udg_CItem_Table, id, 15) + bonus[rnd])
call SaveReal(udg_CItem_Table, id, 14, LoadReal(udg_CItem_Table, id, 14) + bonus[rnd])
else
call SaveInteger(udg_CItem_Table, id, index[rnd], LoadInteger(udg_CItem_Table, id, index[rnd]) + bonus[rnd])
endif
endif
set i = i + 1
endloop
endfunction
function CreatePotion takes integer itype, real x, real y, integer lvreq, integer btype, integer value, integer dur, integer eff returns integer
local item itm
local integer id = 0
local integer it
if itype > 0 and btype > 0 and value > 0 then
set it = 0
if itype == 1 then
set it = 'pghe'
elseif itype == 2 then
set it = 'pgma'
elseif itype == 3 then
set it = 'I00S'
elseif itype == 4 then
set it = 'I00T'
endif
if it != 0 then
set itm = CreateItem(it, x, y)
set id = GetHandleId(itm)
call SaveInteger(udg_CItem_Table, id, btype, value)
call SaveInteger(udg_CItem_Table, id, 8, lvreq)
call SaveInteger(udg_CItem_Table, id, 5, dur)
call SaveInteger(udg_CItem_Table, id, 2, itype)
call SaveInteger(udg_CItem_Table, id, 3, btype)
call SaveInteger(udg_CItem_Table, id, 19, eff)
call SaveItemHandle(udg_CItem_Table, id, 100, itm)
endif
set itm = null
endif
return id
endfunction
function GenerateEQ takes integer itype, integer subtype, integer quality, integer grade, integer lv, real x, real y, boolean rndDef, integer maxsocket returns integer
local integer rnd = GetRandomInt(0, 99)
local integer mingrade = 1
local integer ethernal = 0
local integer pdef
local integer mdef
local integer mdef1 = 0
local integer mdef2 = 0
local integer mdef3 = 0
local integer mdef4 = 0
local integer mdef5 = 0
local real wm = WEP_MOD() //weapon modifier
local integer i
local integer tmdef
local integer id
local real m
local real m2
local item itm
if itype == 7 then
set itype = 3
set subtype = GetRandomInt(0, 9)
endif
if grade == - 1 and rnd < 10 then
set ethernal = 1
endif
set rnd = GetRandomInt(0, 99)
if grade == - 1 then
if lv < 1 then
set lv = 1
endif
if lv > 10 then
set mingrade = lv - 10
endif
set grade = GetRandomInt(mingrade, lv)
if lv > grade then
set lv = grade
endif
endif
if itype == - 1 or subtype == -1 then
if itype == -1 then
set itype = GetRandomInt(1, 9)
endif
if itype == 7 then
set itype = 3
set subtype = GetRandomInt(1, 9)
elseif itype == 9 then
set itype = 11
endif
if itype == 1 or itype == 2 or itype == 4 then
set subtype = GetRandomInt(1, 3)
elseif itype == 3 then
set subtype = GetRandomInt(1, 9)
else
set subtype = 1
endif
endif
if itype == 11 then
if quality == -1 then
set rnd = GetRandomInt(0, 99)
if rnd < 2 then
set quality = 3
elseif rnd < 10 then
set quality = 2
else
set quality = 1
endif
endif
endif
set itm = AddCustomItem (x, y, itype, subtype, quality)
call SetItemBaseData (itm, itype, subtype, quality, grade, lv, ethernal, 0, 0, maxsocket, 0)
set id = GetHandleId(itm)
call SaveItemHandle(udg_CItem_Table, id, 100, itm)
if itype == 1 or itype == 2 or itype == 4 then
if itype == 1 then
set m = 0.45
elseif itype == 2 then
set m = 0.55
elseif itype == 4 then
set m = 0.40
endif
if subtype == 1 then
set m2 = 1.25
set pdef = R2I((10.00 * 3.33 * grade * ((8 + quality) / 10.00)) * m) + 30
set mdef = R2I((3 * 3.33 * grade * ((8 + quality) / 10.00)) * m) + 10
elseif subtype == 2 then
set m2 = 1.10
set pdef = R2I((5.00 * 3.33 * grade * ((8 + quality) / 10.00)) * m) + 15
set mdef = R2I((5 * 3.33 * grade * ((8 + quality) / 10.00)) * m) + 15
elseif subtype == 3 then
set m2 = 1.00
set pdef = R2I((3.00 * 3.33 * grade * ((8 + quality) / 10.00)) * m) + 10
set mdef = R2I((10 * 3.33 * grade * ((8 + quality) / 10.00)) * m) + 30
endif
if rndDef then
set tmdef = mdef * 5
set i = GetRandomInt(0, mdef * 2)
set tmdef = tmdef - i
set mdef1 = i
set i = GetRandomInt(0, mdef * 2)
set tmdef = tmdef - i
set mdef2 = i
set i = GetRandomInt(0, mdef * 2)
if i > tmdef then
set mdef3 = tmdef
set tmdef = 0
else
set tmdef = tmdef - i
set mdef3 = i
endif
set i = GetRandomInt(0, mdef * 2)
if i > tmdef then
set mdef4 = tmdef
set tmdef = 0
else
set tmdef = tmdef - i
set mdef4 = i
endif
set i = GetRandomInt(0, mdef * 2)
if i > tmdef then
set mdef4 = tmdef
set tmdef = 0
else
set tmdef = tmdef - i
set mdef4 = i
endif
else
set mdef1 = mdef
set mdef2 = mdef
set mdef3 = mdef
set mdef4 = mdef
set mdef5 = mdef
endif
call SaveInteger(udg_CItem_Table, id, 26, R2I(m2 * m * 10.00 * grade * ((8 + quality) / 10.00)))
call SaveInteger(udg_CItem_Table, id, 34, R2I(pdef))
call SaveInteger(udg_CItem_Table, id, 35, R2I(mdef1))
call SaveInteger(udg_CItem_Table, id, 36, R2I(mdef2))
call SaveInteger(udg_CItem_Table, id, 37, R2I(mdef3))
call SaveInteger(udg_CItem_Table, id, 38, R2I(mdef4))
call SaveInteger(udg_CItem_Table, id, 39, R2I(mdef5))
if rndDef then
call SaveInteger(udg_CItem_Table, id, 25, 1)
endif
elseif itype == 3 then
if subtype < 8 then
call SaveInteger(udg_CItem_Table, id, 52, R2I((grade * (8 + quality) / wm) * WeaponDamageModifier(subtype)/1.5) )
else
call SaveInteger(udg_CItem_Table, id, 53, R2I((grade * (8 + quality) / wm) * WeaponDamageModifier(subtype)/1.5) )
endif
elseif itype == 9 then
call SaveInteger(udg_CItem_Table, id, 50, R2I((grade * (8 + quality) / 10.00) / 3 + 1))
call SaveInteger(udg_CItem_Table, id, 51, R2I((grade * (8 + quality) / 10.00) / 3 + 1) )
elseif itype == 5 then
call SaveInteger(udg_CItem_Table, id, 34, R2I((grade * (8 + quality) / 10.00) * 8.77 + 30))
call SaveInteger(udg_CItem_Table, id, 43, R2I((grade * (8 + quality) / 10.00) / 10 + 5))
elseif itype == 8 then
call SaveInteger(udg_CItem_Table, id, 34, R2I((grade * (8 + quality) / 10.00) * 5.75 + 30))
call SaveInteger(udg_CItem_Table, id, 41, R2I((grade * (8 + quality) / 10.00) * 1.5 + 10))
call SaveInteger(udg_CItem_Table, id, 42, R2I((grade * (8 + quality) / 10.00) * 1 + 10))
elseif itype == 6 then
call SaveInteger(udg_CItem_Table, id, 52, R2I((grade * (8 + quality) * 0.135) + 1))
call SaveInteger(udg_CItem_Table, id, 53, R2I((grade * (8 + quality) * 0.135) + 1))
call SaveInteger(udg_CItem_Table, id, 54, R2I((grade * (8 + quality) / 330.00) + 1))
endif
if quality == 1 then
if itype == 11 then
call AddRandomBonus (id, grade, itype, GetRandomInt(1,2))
endif
elseif quality == 2 then
if itype == 11 then
call AddRandomBonus (id, grade, itype, GetRandomInt(3,4))
endif
elseif quality == 3 then
if itype == 11 then
call AddRandomBonus (id, grade, itype, GetRandomInt(5,7))
else
set rnd = GetRandomInt(0, 9)
if rnd < 9 then
call AddRandomBonus (id, grade, itype, 1)
endif
endif
elseif quality == 4 then
set rnd = GetRandomInt(0, 9)
if rnd < 9 then
call AddRandomBonus (id, grade, itype, 1)
elseif rnd == 9 then
call AddRandomBonus (id, grade, itype, 2)
endif
elseif quality == 5 then
set rnd = GetRandomInt(0, 9)
if rnd < 9 then
call AddRandomBonus (id, grade, itype, 2)
elseif rnd == 9 then
call AddRandomBonus (id, grade, itype, 3)
endif
elseif quality == 6 then
set rnd = GetRandomInt(0, 9)
if rnd < 9 then
call AddRandomBonus (id, grade, itype, 3)
elseif rnd == 9 then
call AddRandomBonus (id, grade, itype, 4)
endif
elseif quality == 7 then
call AddRandomBonus (id, grade, itype, 7)
endif
set itm = null
return id
endfunction
function CreateSocketGem takes integer u, real x, real y returns integer
local integer itype = LoadInteger(udg_CItem_Table, -u-2000, 1)
local integer i = 0
local integer id
local integer imax = 99
local item itm
set itm = CreateItem(itype, x, y)
set id = GetHandleId(itm)
call SaveItemHandle(udg_CItem_Table, id, 100, itm)
set itm = null
call SaveInteger(udg_CItem_Table, id, 0, u)
set u = u + 2000
//copy the predefinied data
loop
exitwhen i > imax
set i = i + 1
if HaveSavedString(udg_CItem_Table, - u, i) then
call SaveStr(udg_CItem_Table, id, i, LoadStr(udg_CItem_Table, - u, i))
elseif HaveSavedInteger(udg_CItem_Table, - u, i) then
call SaveInteger(udg_CItem_Table, id, i, LoadInteger(udg_CItem_Table, - u, i))
elseif HaveSavedReal(udg_CItem_Table, - u, i) then
call SaveReal(udg_CItem_Table, id, i, LoadReal(udg_CItem_Table, - u, i))
endif
endloop
return id
endfunction
function GenerateUnique takes integer u, real x, real y returns integer
local integer itype = LoadInteger(udg_CItem_Table, -u, 2)
local integer subtype = LoadInteger(udg_CItem_Table, -u, 3)
local integer quality = 7
local integer grade = LoadInteger(udg_CItem_Table, -u, 7)
local integer lv = LoadInteger(udg_CItem_Table, -u, 8)
local integer ethernal = LoadInteger(udg_CItem_Table, -u, 13)
local integer maxsocket = LoadInteger(udg_CItem_Table, -u, 20)
local integer id
local real um = 1.5 //unique modificator, example if its is 1.2 then its mean 1.2x bigger than compared the normal item
local integer pdef
local integer mdef
local real wm = WEP_MOD() //weapon modifier
local real m
local real m2
local item itm
local integer i = 21
if itype > 0 and u > 0 then
if itype != 1 and itype != 2 and itype != 3 and itype != 4 and itype != 9 then
set maxsocket = 0
endif
set itm = AddCustomItem (x, y, itype, subtype, quality)
call SetItemBaseData (itm, itype, subtype, quality, grade, lv, ethernal, 0, 0, maxsocket, 0)
set id = GetHandleId(itm)
call SaveItemHandle(udg_CItem_Table, id, 100, itm)
set itm = null
call SaveInteger(udg_CItem_Table, id, 0, u)
if itype == 1 or itype == 2 or itype == 4 then
if itype == 1 then
set m = 0.45
elseif itype == 2 then
set m = 0.55
elseif itype == 4 then
set m = 0.40
endif
if subtype == 1 then
set m2 = 1.5
set pdef = R2I((10.00 * 3.33 * grade * um) * m) + 30
set mdef = R2I((3 * 3.33 * grade * um) * m) + 10
elseif subtype == 2 then
set m2 = 1.25
set pdef = R2I((5.00 * 3.33 * grade * um) * m) + 15
set mdef = R2I((5 * 3.33 * grade * um) * m) + 15
elseif subtype == 3 then
set m2 = 1
set pdef = R2I((3.00 * 3.33 * grade * um) * m) + 10
set mdef = R2I((10 * 3.33 * grade * um) * m) + 30
endif
call SaveInteger(udg_CItem_Table, id, 26, R2I(m2 * m * 10.00 * grade * um))
call SaveInteger(udg_CItem_Table, id, 34, R2I(pdef))
call SaveInteger(udg_CItem_Table, id, 35, R2I(mdef))
call SaveInteger(udg_CItem_Table, id, 36, R2I(mdef))
call SaveInteger(udg_CItem_Table, id, 37, R2I(mdef))
call SaveInteger(udg_CItem_Table, id, 38, R2I(mdef))
call SaveInteger(udg_CItem_Table, id, 39, R2I(mdef))
elseif itype == 3 then
if subtype < 8 then
call SaveInteger(udg_CItem_Table, id, 52, R2I((grade * (8 + quality) / wm) * WeaponDamageModifier(subtype)/1.5) )
else
call SaveInteger(udg_CItem_Table, id, 53, R2I((grade * (8 + quality) / wm) * WeaponDamageModifier(subtype)/1.5) )
endif
elseif itype == 5 then
call SaveInteger(udg_CItem_Table, id, 34, R2I((grade * um) * 3 + 30))
call SaveInteger(udg_CItem_Table, id, 43, R2I((grade * um) / 10 + 5))
elseif itype == 8 then
call SaveInteger(udg_CItem_Table, id, 34, R2I((grade * um) * 8.75 + 30))
call SaveInteger(udg_CItem_Table, id, 41, R2I((grade * um) * 1.5 + 10))
call SaveInteger(udg_CItem_Table, id, 42, R2I((grade * um) * 1 + 10))
elseif itype == 6 then
call SaveInteger(udg_CItem_Table, id, 52, R2I((grade * um) + 1))
call SaveInteger(udg_CItem_Table, id, 53, R2I((grade * um) + 1))
call SaveInteger(udg_CItem_Table, id, 54, R2I((grade * um/25.00) + 1))
endif
//we save set id if it was saved
if HaveSavedInteger(udg_CItem_Table, -u, 5) then
call SaveInteger(udg_CItem_Table, id, 5, LoadInteger(udg_CItem_Table, -u, 5))
endif
//save other datas
loop
exitwhen i > 99
if HaveSavedString(udg_CItem_Table, -u, i) then
call SaveStr(udg_CItem_Table, id, i, LoadStr(udg_CItem_Table, -u, i))
elseif HaveSavedInteger(udg_CItem_Table, -u, i) then
call SaveInteger(udg_CItem_Table, id, i, LoadInteger(udg_CItem_Table, -u, i))
elseif HaveSavedReal(udg_CItem_Table, -u, i) then
call SaveReal(udg_CItem_Table, id, i, LoadReal(udg_CItem_Table, -u, i))
endif
set i = i + 1
endloop
return id
else
return 0
endif
endfunction
function GenerateEQDrop takes integer cv, unit du returns integer
local integer boss = 0
local integer lv
local integer drop = udg_Stat_Drop_Bonus[cv]
local integer rnd
local integer quality = 0
local integer bbonus = 0
local integer id
if IsUnitType(du, UNIT_TYPE_HERO) then
set boss = 500
set quality = 2
set lv = GetHeroLevel(du)
else
set lv = GetUnitLevel(du)
endif
set rnd = GetRandomInt(boss,((100+drop)/100) * (((udg_Difficulty - 1) * 50 + boss)+600))
if rnd < 200 then
elseif rnd < 400 then
set quality = quality+1
elseif rnd < 500 then
set quality = quality+2
elseif rnd < 750 then
set quality = quality+3
else
set quality = quality+4
endif
set id = GenerateEQ (-1, -1, quality, -1, lv, GetUnitX(du), GetUnitY(du), true, -1)
call AddItemRot (LoadItemHandle(udg_CItem_Table, id, 100), GetPlayerId(GetOwningPlayer(udg_UDexUnits[cv]))+1)
return id
endfunction
function Trig_create_item_Actions takes nothing returns nothing
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
local unit u = udg_Hero[pl]
//call GenerateEQ (- 1, - 1, -1, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), false, - 1)
call GenerateEQ (-1, -1, 6, 100, 5, GetUnitX(u), GetUnitY(u), false, - 1)
//call SetItemBaseData (itm, itype, subtype, quality, grade, lvreq, ethernal, dur, maxdur, maxsocket, setid)
//call SetItemProperties1 (id, hp, hpreg, hpsteal, hpkill, mp, mpreg, mpsteal, mpkill, phydef, fdef, wdef, ldef, pdef, edef)
//call SetItemProperties2 (id, mspeed, acc, eva, str, agi, int, attspd, block, exp, gold, drop)
//call SetItemProperties3 (id, refl, armpen, attlv, deflv, pdmg, mdmg, crit, cdmg, pp, bdmg1, bdmg2, bdmg3, bdmg4, bdmg5)
set u = null
endfunction
//===========================================================================
function InitTrig_Create_item takes nothing returns nothing
set gg_trg_Create_item = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_Create_item, Player(0) )
call TriggerAddAction( gg_trg_Create_item, function Trig_create_item_Actions )
endfunction
// 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 ItIsStackingType(itm) 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 ItIsStackingItems (itm, itm2) then
set a = GetItemCharges(itm2)
if amount + a > 99 then
call SetItemCharges(itm2, 99)
set amount = amount + a - 99
call SetItemCharges(itm, amount)
else
call SetItemCharges(itm2, amount + a)
if HaveSavedHandle(udg_CItem_Table, GetHandleId(itm), 100) then
call FlushChildHashtable(udg_CItem_Table, GetHandleId(itm))
endif
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 ItIsStackingItems (itm, itm2) 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)
if HaveSavedHandle(udg_CItem_Table, GetHandleId(itm), 100) then
call FlushChildHashtable(udg_CItem_Table, GetHandleId(itm))
endif
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 GemId 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 Uid
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
local integer i = 0
local integer a
local integer id
local integer hp
local integer mp
local integer lvR
local integer Grade
local integer StatType = 0
local integer array STAT
local integer subtype
local boolean out = false
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)
set Uid = LoadInteger(udg_CItem_Table, GemId, 0)
set Grade = LoadInteger(udg_CItem_Table, itmId, 7)
set lvR = LoadInteger(udg_CItem_Table, GemId, 8)
set subtype = LoadInteger(udg_CItem_Table, itmId, 3)
if place == 1 or place == 2 or place == 4 then
set StatType = 1
elseif place == 3 then
set StatType = 2
elseif place == 9 then
set StatType = 3
endif
if lvR <= Grade then
if amount > 0 then
if maxsocket != 0 then
if socket + amount <= maxsocket then
set socket = socket + amount
if StatType != 0 then
if slot < 100 then
set hp = 0
set mp = 0
//if we reference to null variable then thread crashing, so we put 0
set i = 22
loop
exitwhen i > 99
set STAT[i] = 0
set i = i + 1
endloop
set id = GemId
//8+1 or 2 or 3=>9=armor,10=weapon,11=wings
set i = LoadInteger(udg_CItem_Table, id, 8 + StatType)
set STAT[i] = LoadInteger(udg_CItem_Table, id, i) * amount
set STAT[76] = STAT[76] + STAT[68] //bonus fire def
set STAT[77] = STAT[77] + STAT[68] //bonus water def
set STAT[78] = STAT[78] + STAT[68] //bonus lightning def
set STAT[79] = STAT[79] + STAT[68] //bonus poison def
set STAT[80] = STAT[80] + STAT[68] //bonus earth def
if subtype > 7 then
set STAT[63] = STAT[63] + STAT[82] //bonus earth def
else
set STAT[62] = STAT[62] + STAT[82] //bonus earth def
endif
set udg_Stat_Pet_Power[cv] = udg_Stat_Pet_Power[cv] + STAT[56]
set udg_Stat_SpellPower[cv] = udg_Stat_SpellPower[cv] + (STAT[53] + STAT[63])
set udg_Stat_AttackLv[cv] = udg_Stat_AttackLv[cv] + (STAT[50] + STAT[69])
set udg_Stat_AttackSpeed[cv] = udg_Stat_AttackSpeed[cv] + STAT[47]
set udg_Stat_Reflect[cv] = udg_Stat_Reflect[cv] + STAT[48]
set udg_Stat_BlockDmg[cv] = udg_Stat_BlockDmg[cv] + (STAT[43] + STAT[71])
set udg_Stat_Crit[cv] = udg_Stat_Crit[cv] + (STAT[54] + STAT[66])
set udg_Stat_Dmg[cv] = udg_Stat_Dmg[cv] + (STAT[52] + STAT[62])
set udg_Stat_CritDmg[cv] = udg_Stat_CritDmg[cv] + STAT[55]
set udg_Stat_Eva[cv] = udg_Stat_Eva[cv] + (STAT[42] + STAT[74])
set udg_Stat_DefLv[cv] = udg_Stat_DefLv[cv] + (STAT[51] + STAT[70])
set udg_Stat_HpRegen[cv] = udg_Stat_HpRegen[cv] + STAT[27]
set udg_Stat_LifeSteal[cv] = udg_Stat_LifeSteal[cv] + STAT[28]
set udg_Stat_Pdef[cv] = udg_Stat_Pdef[cv] + (STAT[34] + STAT[75])
//here we need add 5 elemental def, hp per kill, mp per kill, drop chance, 5 elemental dmg
set udg_Stat_Mdef1[cv] = udg_Stat_Mdef1[cv] + (STAT[35] + STAT[76])
set udg_Stat_Mdef2[cv] = udg_Stat_Mdef2[cv] + (STAT[36] + STAT[77])
set udg_Stat_Mdef3[cv] = udg_Stat_Mdef3[cv] + (STAT[37] + STAT[78])
set udg_Stat_Mdef4[cv] = udg_Stat_Mdef4[cv] + (STAT[38] + STAT[79])
set udg_Stat_Mdef5[cv] = udg_Stat_Mdef5[cv] + (STAT[39] + STAT[80])
set udg_Stat_ManaSteal[cv] = udg_Stat_ManaSteal[cv] + STAT[32]
set udg_Stat_MovSpeed[cv] = udg_Stat_MovSpeed[cv] + STAT[40]
set udg_Stat_MpRegen[cv] = udg_Stat_MpRegen[cv] + STAT[31]
set udg_Stat_Exp[cv] = udg_Stat_Exp[cv] + STAT[22]
set udg_Stat_Drop_Bonus[cv] = udg_Stat_Drop_Bonus[cv] + STAT[23]
set udg_Stat_Gold_Bonus[cv] = udg_Stat_Gold_Bonus[cv] + STAT[24]
set udg_Stat_Acc[cv] = udg_Stat_Acc[cv] + (STAT[41] + STAT[73])
set udg_Global_Hp4Kill[cv] = udg_Global_Hp4Kill[cv] + STAT[29]
set udg_Global_Mp4Kill[cv] = udg_Global_Mp4Kill[cv] + STAT[33]
set udg_Global_ArmorBreak[cv] = udg_Global_ArmorBreak[cv] + STAT[49]
set udg_Global_MDmg1[cv] = udg_Global_MDmg1[cv] + STAT[57]
set udg_Global_MDmg2[cv] = udg_Global_MDmg2[cv] + STAT[58]
set udg_Global_MDmg3[cv] = udg_Global_MDmg3[cv] + STAT[59]
set udg_Global_MDmg4[cv] = udg_Global_MDmg4[cv] + STAT[60]
set udg_Global_MDmg5[cv] = udg_Global_MDmg5[cv] + STAT[61]
set hp = hp + (STAT[26] + STAT[64])
set mp = mp + (STAT[30] + STAT[65])
call SetHeroStr(u, GetHeroStr(u, true) + STAT[44] , true)
call SetHeroAgi(u, GetHeroAgi(u, true) + STAT[45] , true)
call SetHeroInt(u, GetHeroInt(u, true) + STAT[46] , true)
set udg_Global_Discount[cv] = udg_Global_Discount[cv] + STAT[81]
if hp != 0 then
call AddHPMP(true, hp, u)
endif
if mp != 0 then
call AddHPMP(false, mp, u)
endif
if STAT[52] != 0 or STAT[62] != 0 then
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
endif
if STAT[47] != 0 then
call AddDMG(false, cv, (udg_Stat_AttackSpeed[cv] + (GetHeroAgi(u, true) / 2)))
endif
if STAT[52] != 0 or STAT[62] != 0 then
call AddDMG(true, cv, udg_Total_Dmg[cv])
endif
call StatRefresh(cv)
if udg_Camera_Lock[pl] == 1 then
call ShowStat(pl)
endif
endif
call SaveInteger(udg_CItem_Table, itmId, 18, socket)
set i = 0
loop
exitwhen i > socket or out
set a = LoadInteger(udg_CItem_Table, itmId, 1000 + i)
if LoadInteger(udg_CItem_Table, itmId, 1500 + i) == Uid then
call SaveInteger(udg_CItem_Table, itmId, 1000 + i, a + amount)
set out = true
elseif a == 0 then
call SaveInteger(udg_CItem_Table, itmId, 1500 + i, Uid)
call SaveInteger(udg_CItem_Table, itmId, 1000 + i, amount)
set out = true
endif
set i = i + 1
endloop
set ok = 1
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm) + "|r not socketable.")
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm) + "|r if filled with gems, you can't add more gem.")
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm) + "|r don't have socket.")
endif
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm) + "|r lower grade than need for this gem.")
endif
set u = null
set itm = 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 MaxRefine = MAX_REFINE()+1
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 place > 0 and place < 10 then
if reflv + amount < MaxRefine 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 * amount
else
set o = grade * amount
endif
elseif place == 6 or place == 7 then
if place == 6 then
set o = grade * amount
else
set o = grade * amount
endif
elseif place == 9 then
set o = 2 * amount
endif
set ok = 1
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00"+GetFullItemName(itm, false)+"|r is reached the |cffff0000maximum|r refine level.")
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00"+GetFullItemName(itm, false)+"|r isn't refineable.")
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" + GetFullItemName(itm, false) + " 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)-LoadInteger(udg_CItem_Table, id, 72)
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 id
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)
set id = GetHandleId(itm1)
if HaveSavedHandle(udg_CItem_Table, id, 100) then
call FlushChildHashtable(udg_CItem_Table, id)
endif
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
if HaveSavedHandle(udg_FSS, 2406, 10000 * pl + slot) then
call DestroyImage(LoadImageHandle(udg_FSS, 2406, 10000 * pl + slot))
call RemoveSavedHandle(udg_FSS, 2406, 10000 * pl + slot)
endif
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
if Img != null then
call DestroyImage(Img)
call RemoveSavedHandle(udg_FSS, 2406, 10000 * pl + slot)
endif
call DestroyTextTag(tt)
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
function Craft_Quality_Chance takes integer q2, integer q3, integer q4, integer q5, integer q6 returns integer
local integer i = q2 + q3 + q4 + q5 + q6
local integer rnd = GetRandomInt(0, i)
if rnd < q6 then
return 6
elseif rnd < q5 then
return 5
elseif rnd < q4 then
return 4
elseif rnd < q3 then
return 3
elseif rnd < q2 then
return 2
endif
return 2
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
//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 //default quality = normal
local integer rnd
local integer greq
local integer ui
local integer ctype = 0//craft type / profesion skill type (1 = bs, 2 = tailor etc)
local integer clv = 0 //craft skill level
local integer cv = udg_Inv_Unit[pl]
local integer rnd
local boolean CraftFail = true
local integer CraftFailChance = 33
local integer CQCE_Normal = 80 // 80% quality chance equipment: normal
local integer CQCE_Magic = 10 // 10% quality chance equipment: magic
local integer CQCE_Rare = 6 // 6% quality chance equipment: rare
local integer CQCE_VeryRare = 3 // 3% quality chance equipment: very rare
local integer CQCE_Excelent = 1 // 1% quality chance equipment: excelent
local integer CQCE_CSE = 1 //how much effectiveness give the craft skill if higher
//if 0 then disable, else give chance for like
//normal + skill lv * 0 (+0%), magic + skill lv * cse * 2 (+20%)
//rare + skill * cse * 1.3 (13%), very rare + skill * cse * 0.9 (9%)
//excelent + skill * cse / 5 (+5%)
local integer CQCE = 0 //quality chance value
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 == 200 and ui != 0 then
set price = LoadInteger(udg_CItem_Table, -2000-ui, 12)
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)
set i = 0
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 CQCE = Craft_Quality_Chance(CQCE_Normal, CQCE_Magic + clv * CQCE_CSE * 2, CQCE_Rare + R2I(clv * CQCE_CSE * 1.3), CQCE_VeryRare + R2I(clv * CQCE_CSE * 0.9), CQCE_Excelent + R2I(clv * CQCE_CSE * 0.5))
set quality = CQCE
endif
set rnd = GetRandomInt(0, 100)
if CraftFail and rnd < CraftFailChance and craft then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff3333Craft failed!|r")
set i = 0
else
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
endif
else
set i = GenerateUnique (ui, x, y)
endif
if craft and i != 0 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00Craft is done|r")
call SaveStr(udg_CItem_Table, i, 21, GetPlayerName(Player(pl - 1)))
endif
if i != 0 then
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
set itm = null
endif
elseif ilv == GEM_LEVEL() and ui != 0 then
set i = CreateSocketGem(ui, x, y)
if i != 0 then
set itm = LoadItemHandle(udg_CItem_Table, i, 100)
call SetItemCharges(itm, 1)
endif
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
//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 RemoveSavedHandle(udg_FSS, 2407, 100 * pl + i)
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 array craft_xp
local integer array craft_lv
local integer req_craft_lv
local integer prof_skill
local integer exp_per_craft = 1
local integer max_craft_lv = 10
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
//get the craft levels
set req_craft_lv = 10
set prof_skill = 0
set i = 1
loop
set craft_xp[i] = LoadInteger(udg_Stat_Table, 27000 + cv, i)
set craft_lv[i] = GetCraftLv(craft_xp[i], true)
set i = i + 1
exitwhen i == 5
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) or (ilv > 1500 and ilv < 1506) then
set count = 3
set req_craft_lv = R2I(ls / 2.00 + 0.5)
set i = R2I(ls / 2.00 + 0.5)
if ilv == 109 or ilv == 110 then
set req_craft_lv = 3
set prof_skill = 3
elseif ilv > 1500 and ilv < 1506 then
set prof_skill = 4
set req_craft_lv = 0
elseif ilv > 100 and ilv < 106 and ilv != 103 then
set count = 0
set prof_skill = 2
if craft_lv[2] - req_craft_lv < 3 and craft_lv[2] < max_craft_lv then
call SaveInteger(udg_Stat_Table, 27000 + cv, 2, LoadInteger(udg_Stat_Table, 27000 + cv, 2) + exp_per_craft)
endif
elseif ilv == 103 and craft_lv[1] - req_craft_lv < 3 then
set count = 0
set prof_skill = 1
if craft_lv[1] - req_craft_lv < 3 and craft_lv[1] < max_craft_lv then
call SaveInteger(udg_Stat_Table, 27000 + cv, 1, LoadInteger(udg_Stat_Table, 27000 + cv, 1) + exp_per_craft)
endif
elseif (ilv == 106 or ilv == 108) then
set count = 0
set prof_skill = 3
if (ilv == 106 or ilv == 108) and (craft_lv[3] - req_craft_lv < 3) and (craft_lv[3] < max_craft_lv) then
call SaveInteger(udg_Stat_Table, 27000 + cv, 3, LoadInteger(udg_Stat_Table, 27000 + cv, 3) + exp_per_craft)
endif
elseif (ilv == 1900 or ilv == 1901) and craft_lv[4] < max_craft_lv then
set prof_skill = 4
set count = 0
call SaveInteger(udg_Stat_Table, 27000 + cv, 4, LoadInteger(udg_Stat_Table, 27000 + cv, 4) + exp_per_craft)
elseif (ilv == 1902 or ilv == 1903) then
set count = 0
set prof_skill = 4
if craft_lv[4] - req_craft_lv < 3 and craft_lv[4] < max_craft_lv then
call SaveInteger(udg_Stat_Table, 27000 + cv, 4, LoadInteger(udg_Stat_Table, 27000 + cv, 4) + exp_per_craft)
endif
elseif (ilv == 1904 or ilv == 1905) and craft_lv[4] > 3 then
set count = 0
set prof_skill = 4
if craft_lv[4] < max_craft_lv then
call SaveInteger(udg_Stat_Table, 27000 + cv, 4, LoadInteger(udg_Stat_Table, 27000 + cv, 4) + exp_per_craft)
endif
endif
else
set count = 0
endif
if req_craft_lv <= GetCraftLv(craft_xp[prof_skill], true) 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
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 RemoveSavedHandle(udg_FSS, pl + 1000, i)
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 RemoveSavedHandle(udg_FSS, 1250 + pl, 6)
call RemoveSavedHandle(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))
call RemoveSavedHandle(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))
call RemoveSavedHandle(udg_FSS, 650 + pl, i)
call RemoveSavedHandle(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 RemoveSavedHandle(udg_FSS, 551, pl)
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))
call RemoveSavedHandle(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))
call RemoveSavedHandle(udg_FSS, 2402, 60 + pl)
call RemoveSavedHandle(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))
call RemoveSavedHandle(udg_FSS, 2402, 100 + pl)
call RemoveSavedHandle(udg_FSS, 2402, 120 + pl)
call RemoveSavedHandle(udg_FSS, 2402, 140 + pl)
call RemoveSavedHandle(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)
call RemoveSavedHandle(udg_FSS, 2403, 100 * pl + i)
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 RemoveSavedHandle(udg_FSS, 2403, 180 + pl)
call RemoveSavedHandle(udg_FSS, 2403, 200 + pl)
call RemoveSavedHandle(udg_FSS, 2403, 220 + pl)
call RemoveSavedHandle(udg_FSS, 2403, 240 + pl)
call RemoveSavedHandle(udg_FSS, 2403, 260 + pl)
call RemoveSavedHandle(udg_FSS, 2403, 280 + pl)
call RemoveSavedHandle(udg_FSS, 2403, 300 + pl)
set i = 2200
loop
exitwhen i > 2230
call DestroyTextTag (LoadTextTagHandle(udg_FSS, 1000 + pl, i))
call RemoveSavedHandle(udg_FSS, 1000 + pl, i)
set i = i + 1
endloop
set i = 100
loop
exitwhen i > 119
call DestroyTextTag (LoadTextTagHandle(udg_FSS, 1000 + pl, i))
call RemoveSavedHandle(udg_FSS, 1000 + pl, i)
set i = i + 1
endloop
elseif w1 == 3 then
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 2402, 60 + pl))
call RemoveSavedHandle(udg_FSS, 2402, 60 + pl)
set i = 2201
loop
exitwhen i > 2224
call DestroyTextTag (LoadTextTagHandle(udg_FSS, 1000 + pl, i))
call RemoveSavedHandle(udg_FSS, 1000 + pl, i)
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
set ilv2 = GetItemLevel(itm2)
endif
if slot1 < 200 then
set itm1 = LoadItemHandle(udg_Stat_Table, cv, slot1)
set ilv1 = GetItemLevel(itm1)
elseif slot1 < 300 then
set itm1 = UnitItemInSlot(u, slot1 - 200)
set ilv1 = GetItemLevel(itm1)
endif
if slot1 == 301 then
if ilv2 >= 100 and ilv2 < 200 then
if slot2 >= 200 then
set itm1 = UnitItemInSlot(u, slot2 - 200)
else
set itm1 = LoadItemHandle(udg_Stat_Table, cv, slot2)
endif
set id = GetHandleId(itm1)
set n2 = R2I(LoadReal(udg_CItem_Table, id, 14))
set n3 = GetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD)
set n4 = R2I(LoadReal(udg_CItem_Table, id, 15))
set n1 = n4 - n2
if LoadInteger(udg_CItem_Table, id, 13) == 0 then
if n1 > 0.8 then
if n3 >= n1 then
call SetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD, n3 - n1)
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Repaired - |cffffff00" + GetItemName(itm1) + "|r")
call SaveReal(udg_CItem_Table, id, 14, n4)
call BumpSlot (pl, slot2, 3)
elseif n3 == 0 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Need |cffff0000" + I2S(n1) + "|r gold for repair it.")
else
set n1 = n2 + n3
call SetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD, 0)
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Still need " + I2S(n4 - n1) + " gold for repair |cffffff00" + GetItemName(itm1) + "|r.")
call SaveReal(udg_CItem_Table, id, 14, n1)
call BumpSlot (pl, slot2, 3)
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm1) + "|r isn't damaged.")
endif
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(itm1) + "|r is ethernal item, can't repair it.")
endif
else
set abort = true
endif
elseif slot1 == 300 then
if ilv2 > 0 then
if slot2 >= 200 then
set itm2 = UnitItemInSlot(u, slot2 - 200)
call UnitRemoveItem(u, itm2)
call RemoveIcon(pl, slot2)
elseif slot2 >= 100 then
set itm2 = LoadItemHandle(udg_Stat_Table, cv, slot2)
if ilv2 == 111 then
call EquipAItem (cv, itm2, false)
endif
call SetItemPosition(itm2, GetUnitX(u), GetUnitY(u))
call SetItemVisible(itm2, true)
call RemoveIcon(pl, slot2)
call ClearSlot(cv, slot2)
elseif slot2 >= 0 then
set itm2 = LoadItemHandle(udg_Stat_Table, cv, slot2)
call SetItemPosition(itm2, GetUnitX(u), GetUnitY(u))
call SetItemVisible(itm2, true)
call EquipItem (pl, slot2, false)
call RemoveIcon(pl, slot2)
call ClearSlot(cv, slot2)
endif
if itm2 != null then
call AddItemRot (itm2, pl)
endif
else
set abort = true
endif
elseif slot1 == slot2 then
set udg_Selected_Slot[pl] = 0
if udg_Trader[pl] == 0 then
if ilv1 >= 100 and ilv1 < 200 and ilv1 != BOX_LEVEL() then
if ilv1 == BAG_LEVEL() then
call RemoveIcon (pl, slot1)
set udg_Inv_Bag[pl] = GetHandleId(itm1)
call WindowTransition (pl, 1, 3)
set abort = true
elseif ilv1 == BOX_LEVEL() then
else
if slot1 < 100 then
call UnEquip (cv, slot1)
set abort = true
else
set n1 = ilv1 - 100
if n1 == 6 then
if LoadInteger(udg_Stat_Table, cv, - 6) > 0 and LoadInteger(udg_Stat_Table, cv, - 7) == 0 then
set n1 = 7
endif
endif
set slot2 = n1
if slot1 < 200 then
set ilv2 = LoadInteger(udg_Stat_Table, cv, - slot2)
else
set ilv2 = GetItemLevel(UnitItemInSlot(u, slot2 - 200))
endif
endif
endif
elseif (ilv1 > 10 and ilv1 != 1500 and slot1 < 300 and (ilv1 < 100 or ilv1 > 200)) or ilv1 == BOX_LEVEL() then
call UseItem(cv, slot1)
set abort = true
set udg_Selected_Slot[pl] = 0
else
set abort = true
set udg_Selected_Slot[pl] = 0
endif
endif
//stacking items, max 99 each stack
elseif ilv1 == ilv2 and ItIsStackingType (itm1) then
if ItIsStackingItems (itm1, itm2) then
set n1 = GetItemCharges(itm1)
set n2 = GetItemCharges(itm2)
if n2 + n1 > 99 then
call SetItemCharges(itm2, 99)
call SetItemCharges(itm1, n2 + n1 - 99)
else
call SetItemCharges(itm2, n2 + n1)
call RemoveIcon (pl, slot1)
call ClearSlot(cv, slot1)
if HaveSavedHandle(udg_CItem_Table, GetHandleId(itm1), 100) then
call FlushChildHashtable(udg_CItem_Table, GetHandleId(itm1))
endif
call RemoveItem(itm1)
endif
call BumpSlot (pl, slot2, 1)
call Mb_ToolTip(pl, pl, slot2)
endif
set udg_Selected_Slot[pl] = 0
set abort = true
elseif (ilv1 == GEM_LEVEL() or ilv1 == 1500) and ilv2 >= 100 and ilv2 < 112 then
if slot2 < 300 then
set n1 = 0
if ilv1 == 1500 then
set n1 = AddRefine (cv, slot2, 1, false)
else
set id = GetHandleId(itm2)
set n2 = GetHandleId(itm1)
set n3 = LoadInteger(udg_CItem_Table, n2, 8)
if LoadInteger(udg_CItem_Table, id, 7) >= n1 then
set n1 = AddSocket (cv, slot2, 1, n2)
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff7777Required:|r atleast |cffffff77" + I2S(n3) + "|r grade equipment..")
endif
endif
if n1 > 0 then
if n1 == 1 then
call BumpSlot (pl, slot2, 2)
endif
set n2 = GetItemCharges(itm1)
set n3 = GetHandleId(itm1)
if n2 == 1 then
if HaveSavedHandle(udg_CItem_Table, n3, 100) then
call FlushChildHashtable(udg_CItem_Table, n3)
endif
call RemoveItem(itm1)
call RemoveIcon (pl, slot1)
call ClearSlot(cv, slot1)
else
call SetItemCharges(itm1, n2 - 1)
endif
endif
call SetChargesText(pl)
call Mb_ToolTip(pl, pl, slot2)
endif
set abort = true
set udg_Selected_Slot[pl] = 0
elseif ilv2 == BAG_LEVEL() and ilv1 > 0 and ilv1 != ilv2 then
if ilv1 == 111 then
call EquipAItem (cv, itm1, false)
endif
if AddItemToBag(u, itm2, itm1) then
call RemoveIcon (pl, slot1)
call ClearSlot(cv, slot1)
endif
set abort = true
set udg_Selected_Slot[pl] = 0
call Mb_ToolTip(pl, pl, slot2)
endif
// ---------------end of the click type checking-------------------
if udg_Trader[pl] > 0 then
set abort = true
endif
//-------- if ilv1 > 0 => 1st click not a blank click
if ilv1 > 0 and not abort then
if slot1 < 100 then
//-----------if 1st click to equipments
set ilv1 = LoadInteger(udg_Stat_Table, cv, - slot1)
if slot2 < 100 then
if (slot1 == 6 and slot2 == 7) or (slot1 == 7 and slot2 == 6) then
call SwapIcon (pl, slot1, slot2)
call SwapItem2Slot (cv, slot1, slot2)
endif
elseif slot2 < 200 then
if ilv2 == 0 then
call SwapIcon (pl, slot1, slot2)
call EquipItem (cv, slot1, false)
call SwapItem2Slot (cv, slot1, slot2)
endif
elseif slot2 < 300 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Can't put to |cffffff77external|r inventory the equiped item.")
endif
elseif slot1 < 200 then
//-----------if 1st click to inventory
set ilv1 = LoadInteger(udg_Stat_Table, cv, - slot1)
if slot2 < 100 then
//-----------if we want equip a item from new inventory
//--------------------------EQUIP blocks-------------------------------
if CheckRequiment(cv, slot1, slot2) then
call SwapIcon (pl, slot1, slot2)
call EquipItem (cv, slot2, false)
call SwapItem2Slot (cv, slot1, slot2)
call EquipItem (cv, slot2, true)
endif
set udg_Selected_Slot[pl] = 0
elseif slot2 < 300 then
// -------------- if u clicked to inventory then clicked to another inventory slot
call SwapIcon (pl, slot1, slot2)
call SwapItem2Slot (cv, slot1, slot2)
endif
elseif slot1 < 300 then
// ------- if 1st clicked item was from old inventory
set itm1 = UnitItemInSlot(u, slot1 - 200)
set ilv1 = GetItemLevel(itm1)
if slot2 < 100 then
//-----------if we want equip a item from old inventory
//--------------------------EQUIP if blocks-------------------------------
if CheckRequiment(cv, slot1, slot2) then
call SwapIcon (pl, slot1, slot2)
call EquipItem (cv, slot2, false)
call SwapItem2Slot(cv, slot1, slot2)
call EquipItem (cv, slot2, true)
else
set udg_Selected_Slot[pl] = 0
endif
elseif slot2 < 300 then
call SwapIcon (pl, slot1, slot2)
call SwapItem2Slot(cv, slot1, slot2)
endif
endif
endif
if slot1 < 100 or slot2 < 100 then
call ShowStat(pl)
call SetAttackAnimation (cv)
call DummyVillagerAttachmentRefresh()
endif
call SetChargesText(pl)
call Mb_ToolTip(pl, pl, slot2)
set udg_Selected_Slot[pl] = 0
set udg_Stop_Stack[cv] = false
set itm1 = null
set itm2 = null
set u = null
endfunction
//create selector destructible to a slot
function SelectSlot takes integer pl, integer slot returns nothing
local real x = LoadReal(udg_FSS, slot, 1)
local real y = LoadReal(udg_FSS, slot, 2)
local real x1 = LoadReal(udg_FSS, 0, 1)
local real shiftY = 0
local real shiftX = 0
if x - x1 < 100 then
set shiftX = 10
elseif x - x1 < 200 then
set shiftX = 7
elseif x - x1 < 300 then
set shiftX = 5
endif
if udg_Selector[pl] != null then
call RemoveDestructable (udg_Selector[pl])
endif
set udg_Selector[pl] = CreateDestructableZ(udg_Icons[24], x + shiftX, y + shiftY, 30, 0, 0.6, 0)
call ShowDestructable(udg_Selector[pl], false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(udg_Selector[pl], true)
endif
endfunction
//repair all equipment function
function RepairAll takes integer pl returns nothing
local integer i = 1
local integer id
local integer Gold = GetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD)
local integer Dur
local integer MaxDur
local integer Price = 0
local integer cv = udg_Inv_Unit[pl]
loop
exitwhen i > 9 or Gold < Price
set id = GetHandleId(LoadItemHandle(udg_Stat_Table, cv, i))
if id > 0 then
set Dur = R2I(LoadReal(udg_CItem_Table, id, 14))
set MaxDur = R2I(LoadReal(udg_CItem_Table, id, 15))
set Price = MaxDur - Dur
if LoadInteger(udg_CItem_Table, id, 13) == 0 then
if Price > 0 then
if Price <= Gold then
set Gold = Gold - Price
call SaveReal(udg_CItem_Table, id, 14, MaxDur)
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetItemName(LoadItemHandle(udg_Stat_Table, cv, i)) + "|r fixed!")
elseif Gold > 0 then
call SaveReal(udg_CItem_Table, id, 14, Dur + Gold)
set Gold = 0
endif
call SetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD, Gold)
endif
endif
endif
set i = i + 1
endloop
endfunction
//restat str,agi,int points to default (5)
function Restat takes integer pl returns nothing
local integer i = 1
local integer cv = udg_Inv_Unit[pl]
local unit u = udg_UDexUnits[cv]
local integer id
local integer utype = GetUnitTypeId(u)
local integer Str = GetHeroStr(u, true)
local integer Agi = GetHeroAgi(u, true)
local integer Int = GetHeroInt(u, true)
local integer BonusStr = 0
local integer BonusAgi = 0
local integer BonusInt = 0
local integer StartStr = LoadInteger(udg_FSS, 636, utype)
local integer StartAgi = LoadInteger(udg_FSS, 637, utype)
local integer StartInt = LoadInteger(udg_FSS, 638, utype)
local integer ilv = 0
//unequip every stat depend gear and check the stat bonuss from items
loop
exitwhen i > 10
set ilv = LoadInteger(udg_Stat_Table, cv, - i)
if ilv > 0 then
if i < 6 or i == 9 then
call UnEquip (cv, i)
else
set id = GetHandleId(LoadItemHandle(udg_Stat_Table, cv, i))
set BonusStr = BonusStr + LoadInteger(udg_CItem_Table, id, 44)
set BonusAgi = BonusAgi + LoadInteger(udg_CItem_Table, id, 45)
set BonusInt = BonusInt + LoadInteger(udg_CItem_Table, id, 46)
endif
endif
set i = i + 1
endloop
set udg_Stat_Point[cv] = udg_Stat_Point[cv] + Str - StartStr - BonusStr + Agi - StartAgi - BonusAgi + Int - StartInt - BonusInt
call SetHeroStr(u, StartStr + BonusStr, true)
call SetHeroAgi(u, StartAgi + BonusAgi, true)
call SetHeroInt(u, StartInt + BonusInt, true)
call ShowStat(pl)
set u = null
endfunction
//handle the clicking if u are opened a bag and u see the bag window interface
function BagOrganise takes integer pl, integer slot1, integer slot2 returns nothing
local item itm1
local item itm2
local integer ilv1 = 0
local integer ilv2
local integer cv = udg_Inv_Unit[pl]
if slot1 < 200 then
set itm1 = LoadItemHandle(udg_Stat_Table, cv, slot1)
else
set itm1 = LoadItemHandle(udg_CItem_Table, udg_Inv_Bag[pl], slot1 - 2200)
endif
if slot2 < 200 then
set itm2 = LoadItemHandle(udg_Stat_Table, cv, slot2)
else
set itm2 = LoadItemHandle(udg_CItem_Table, udg_Inv_Bag[pl], slot2 - 2200)
endif
if itm2 != null then
set udg_Selected_Slot[pl] = slot2
call SelectSlot(pl, slot2)
endif
if itm2 != null then
set ilv2 = GetItemLevel(itm2)
else
set ilv2 = 0
endif
if itm1 != null then
set ilv1 = GetItemLevel(itm1)
if slot2 != slot1 then
if ilv2 == BAG_LEVEL() and ilv1 != BAG_LEVEL() then
if GetHandleId(itm2) != udg_Inv_Bag[pl] or slot1 < 200 then
if AddItemToBag(udg_UDexUnits[cv], itm2, itm1) then
if ilv1 == 111 then
call EquipAItem (cv, itm1, false)
endif
call RemoveIcon (pl, slot1)
call BJDebugMsg("be")
call ClearSlot(cv, slot1)
call RemoveDestructable (udg_Selector[pl])
set udg_Selected_Slot[pl] = 0
call SetChargesText(pl)
endif
endif
elseif not (slot2 > 2200 and ilv1 == BAG_LEVEL()) then
if slot1 < 120 and slot2 > 120 then
if itm2 == null then
call SaveInteger(udg_CItem_Table, udg_Inv_Bag[pl], 0,LoadInteger(udg_CItem_Table, udg_Inv_Bag[pl], 0)+1)
endif
if ilv1 == 111 then
call EquipAItem (cv, itm1, false)
endif
if ilv2 == 111 then
call EquipAItem (cv, itm2, true)
endif
else
if itm1 == null then
call SaveInteger(udg_CItem_Table, udg_Inv_Bag[pl], 0,LoadInteger(udg_CItem_Table, udg_Inv_Bag[pl], 0)-1)
endif
if ilv1 == 111 then
call EquipAItem (cv, itm1, true)
endif
if ilv2 == 111 then
call EquipAItem (cv, itm2, false)
endif
endif
call SwapItem2Slot (cv, slot1, slot2)
call SwapIcon (pl, slot1, slot2)
call RemoveDestructable (udg_Selector[pl])
set udg_Selected_Slot[pl] = 0
call SetChargesText(pl)
else
call RemoveDestructable (udg_Selector[pl])
set udg_Selected_Slot[pl] = 0
endif
else
if ilv1 == BAG_LEVEL() and GetHandleId(itm1) != udg_Inv_Bag[pl] then
set udg_Inv_Bag[pl] = GetHandleId(itm1)
call WindowTransition (pl, 3, 3)
call BumpSlot (pl, slot1, 2)
endif
endif
endif
set itm1 = null
set itm2 = null
endfunction
function RemoveTradeSlot takes integer pl, integer slot returns nothing
if LoadInteger(udg_FSS, 1249 + pl, slot) > 0 then
//call DisplayTextToPlayer(Player(pl - 1), 0, 0, "slot:"+I2S(slot)+ " = "+I2S(LoadInteger(udg_FSS, 1249 + pl, slot)))
call FadeSlot (pl, LoadInteger(udg_FSS, 1249 + pl, slot), 255, false)
call RemoveIcon(pl, slot)
call RemoveIcon(udg_Trader[pl], slot + 6)
call SaveInteger(udg_FSS, 1249 + pl, slot, 0)
endif
endfunction
//add icon and save the slot into crap
function AddToTradeSlot takes integer pl, integer slot, integer slot2 returns nothing
local integer plt = udg_Trader[pl]
local integer i = 0
local integer ilv = 0
local integer DummySlot = - 1
local integer cv = udg_Inv_Unit[pl]
local unit u = udg_UDexUnits[cv]
local destructable d
local real x1 = LoadReal(udg_FSS, slot2, 1)
local real y1 = LoadReal(udg_FSS, slot2, 2)
local real x2 = LoadReal(udg_FSS, slot2 + 6, 1)
local real y2 = LoadReal(udg_FSS, slot2 + 6, 2)
local item itm
if slot < 200 then
set itm = LoadItemHandle(udg_Stat_Table, cv, slot)
elseif slot < 300 then
set itm = UnitItemInSlot(u, slot - 200)
endif
if itm != null and slot2 >= 1200 and slot2 < 1206 then
set ilv = GetItemLevel(itm)
if LoadInteger(udg_FSS, 1249 + pl, slot2) == 0 then
//call DisplayTextToPlayer(Player(pl - 1), 0, 0, "slot is empty, we fill it with data")
//call DisplayTextToPlayer(Player(pl - 1), 0, 0, "hashtable "+I2S(1249+pl)+", "+I2S(slot2)+" = "+I2S(slot))
call SaveInteger(udg_FSS, 1249 + pl, slot2, slot)
call FadeSlot (pl, slot, 155, true)
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, GetItemTypeId(itm)), x1, y1, 5, 0, 0.6, 0)
//call DisplayTextToPlayer(Player(pl - 1), 0, 0, "hashtable "+I2S(2409+pl)+", "+I2S(slot2)+" = icon")
call SaveDestructableHandle(udg_FSS, 2409 + pl, slot2, d)
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
//call DisplayTextToPlayer(Player(pl - 1), 0, 0, "hashtable "+I2S(2409+plt)+", "+I2S(slot2+6)+" = icon")
set d = CreateDestructableZ(LoadInteger(udg_FSS, 600, GetItemTypeId(itm)), x2, y2, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + plt, slot2 + 6, d)
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(plt - 1) then
call ShowDestructable(d, true)
endif
//else
//call DisplayTextToPlayer(Player(pl - 1), 0, 0, "slot contain item")
endif
endif
set itm = null
set d = null
set u = null
endfunction
function LockTradeSlots takes integer pl, integer slot returns nothing
local integer lock = LoadInteger(udg_FSS, 1275 + pl, 1)
local integer tlock = LoadInteger(udg_FSS, 1275 + udg_Trader[pl], 1)
local integer Trader = udg_Trader[pl]
local real x = LoadReal(udg_FSS, 0, 1)
local real y = LoadReal(udg_FSS, 0, 2)
local destructable d
if slot == 1300 then
if lock == 0 then
//now lock
call SaveInteger(udg_FSS, 1275 + pl, 1, 1)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1310, 0), true)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1300, 0), false)
endif
if GetLocalPlayer() == Player(Trader - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1312, 0), true)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1302, 0), false)
endif
elseif lock == 1 then
//now unlock
call SaveInteger(udg_FSS, 1275 + pl, 1, 0)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1300, 0), true)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1310, 0), false)
endif
if GetLocalPlayer() == Player(Trader - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1312, 0), false)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1302, 0), true)
endif
endif
elseif slot==1301 then
if lock == 1 then
//now unlock
call SaveInteger(udg_FSS, 1275 + pl, 1, 2)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1301, 0), false)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1311, 0), true)
endif
if GetLocalPlayer() == Player(Trader - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1313, 0), true)
call ShowDestructable( LoadDestructableHandle(udg_FSS, 1303, 0), false)
endif
elseif lock==2 and tlock < 2 then
//now lock
call SaveInteger(udg_FSS, 1275 + pl, 1, 1)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1301, 0), true)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1311, 0), false)
endif
if GetLocalPlayer() == Player(Trader - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1313, 0), false)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1303, 0), true)
endif
elseif lock==2 and tlock == 2 then
endif
endif
set d = null
endfunction
function FreeInventorySlotCount takes integer pl returns integer
local integer i = 100
local integer freeslot = 0
local integer cv = udg_Inv_Unit[pl]
loop
exitwhen i > 119
if LoadItemHandle(udg_Stat_Table, cv, i) == null then
set freeslot = freeslot + 1
endif
set i = i + 1
endloop
return freeslot
endfunction
function TradeSlotCount takes integer pl returns integer
local integer i = 0
local integer TradeItem = 0
loop
exitwhen i > 5
if LoadInteger(udg_FSS, 1249 + pl, 1200 + i) > 0 then
set TradeItem = TradeItem + 1
endif
set i = i + 1
endloop
return TradeItem
endfunction
function TradeSlots takes integer pl returns nothing
local integer i = 1200
local integer pl1 = pl
local integer pl2 = udg_Trader[pl]
local integer cv1 = udg_Inv_Unit[pl1]
local integer cv2 = udg_Inv_Unit[pl2]
local integer array slot1
local integer array slot2
local integer slot
local integer slotCount2
local integer data1
local integer data2
local integer data3
local integer data4
local integer data5
local integer data6
local integer gold1 = LoadInteger(udg_FSS, 1250 + pl1, 7)
local integer gold2 = LoadInteger(udg_FSS, 1250 + pl2, 7)
local item itm
local unit u1 = udg_UDexUnits[cv1]
local unit u2 = udg_UDexUnits[cv2]
local integer itmId
local texttag tt
local real x
local real y
call SetPlayerState(Player(pl1 - 1), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(pl1 - 1), PLAYER_STATE_RESOURCE_GOLD) + gold2)
call SetPlayerState(Player(pl2 - 1), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(pl2 - 1), PLAYER_STATE_RESOURCE_GOLD) + gold1)
call UpdateGoldinShop (pl1)
call UpdateGoldinShop (pl2)
call SaveInteger(udg_FSS, 1250 + pl1, 7, 0)
call SaveInteger(udg_FSS, 1250 + pl2, 7, 0)
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00Tradeing!")
call DisplayTextToPlayer(Player(udg_Trader[pl] - 1), 0, 0, "|cffffff00Tradeing!")
if GetLocalPlayer() == Player(pl - 1) or GetLocalPlayer() == Player(udg_Trader[pl] - 1) then
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1300, 0), true)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1301, 0), true)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1302, 0), true)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1303, 0), true)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1310, 0), false)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1311, 0), false)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1312, 0), false)
call ShowDestructable(LoadDestructableHandle(udg_FSS, 1313, 0), false)
endif
if GetLocalPlayer() == Player(pl1 - 1) then
set x = LoadReal(udg_FSS, 0, 1) + 778 + 64
elseif GetLocalPlayer() == Player(pl2 - 1) then
set x = LoadReal(udg_FSS, 0, 1) + 1020 + 64
endif
set y = LoadReal(udg_FSS, 0, 2) + 215
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 1250 + pl1, 6))
set tt = CreateTextTag( )
call SetTextTagText( tt, I2S(LoadInteger(udg_FSS, 1250 + pl1, 7)), 0.8 * 0.023 )
call SetTextTagPos( tt, x , y, 100.00 )
call SetTextTagPermanent( tt, true )
call SetTextTagColor(tt, 200, 200, 200, 100)
call SaveTextTagHandle(udg_FSS, 1250 + pl1, 6, tt)
if GetLocalPlayer() == Player(pl1 - 1) then
set x = LoadReal(udg_FSS, 0, 1) + 1020 + 64
elseif GetLocalPlayer() == Player(pl2 - 1) then
set x = LoadReal(udg_FSS, 0, 1) + 778 + 64
endif
call DestroyTextTag(LoadTextTagHandle(udg_FSS, 1250 + pl2, 6))
set tt = CreateTextTag( )
call SetTextTagText( tt, I2S(LoadInteger(udg_FSS, 1250 + pl2, 7)), 0.8 * 0.023 )
call SetTextTagPos( tt, x , y, 100.00 )
call SetTextTagPermanent( tt, true )
call SetTextTagColor(tt, 200, 200, 200, 100)
call SaveTextTagHandle(udg_FSS, 1250 + pl2, 6, tt)
set tt = null
set i = 1200
loop
exitwhen i > 1205
set slot = LoadInteger(udg_FSS, 1249 + pl, i)
if slot > 0 then
call FadeSlot (pl1, slot, 255, false)
call SaveInteger(udg_FSS, 1249 + pl, i, 0)
call RemoveIcon(pl, i)
call RemoveIcon(pl, slot)
if slot < 200 then
set itm = LoadItemHandle(udg_Stat_Table, cv1, slot)
call SetItemVisible(itm, true)
call AddItem2HeroExt (cv2, itm, false)
call ClearSlot(cv1, slot)
else
set itm = UnitItemInSlot(u1, slot - 200)
call UnitRemoveItem(u1, itm)
call AddItem2HeroExt (cv2, itm, false)
endif
endif
set slot = LoadInteger(udg_FSS, 1249 + pl2, i)
if slot > 0 then
call FadeSlot (pl2, slot, 255, false)
call SaveInteger(udg_FSS, 1249 + pl2, i, 0)
call RemoveIcon(pl2, i)
call RemoveIcon(pl2, slot)
if slot < 200 then
set itm = LoadItemHandle(udg_Stat_Table, cv2, slot)
call SetItemVisible(itm, true)
call AddItem2HeroExt (cv1, itm, false)
call ClearSlot(cv2, slot)
else
set itm = UnitItemInSlot(u2, slot - 200)
call UnitRemoveItem(u1, itm)
call AddItem2HeroExt (pl, itm, false)
endif
endif
call RemoveIcon(pl, i + 6)
call RemoveIcon(udg_Trader[pl], i + 6)
set i = i + 1
endloop
call SaveInteger(udg_FSS, 1275 + pl, 1, 0)
call SaveInteger(udg_FSS, 1275 + pl2, 1, 0)
call SetChargesText(pl)
call SetChargesText(pl2)
set itm = null
set u1 = null
set u2 = null
endfunction
function TradeHandle takes integer pl, integer slot returns nothing
local integer lock = LoadInteger(udg_FSS, 1275 + pl, 1)
//call DisplayTextToPlayer(Player(0), 0, 0, "slot: "+I2S(slot)+" pl"+I2S(pl))
if slot == 1301 then
if lock == 0 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00Lock|r the tradeing!")
elseif lock == 1 then
if LoadInteger(udg_FSS, 1275 + udg_Trader[pl], 1) == 1 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetPlayerName(Player(udg_Trader[pl] - 1)) + "|r must lock again for tradeing!")
call LockTradeSlots(pl, slot)
elseif LoadInteger(udg_FSS, 1275 + udg_Trader[pl], 1) == 0 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetPlayerName(Player(udg_Trader[pl] - 1)) + "|r must lock for tradeing!")
elseif LoadInteger(udg_FSS, 1275 + udg_Trader[pl], 1) == 2 then
if TradeSlotCount(pl) + FreeInventorySlotCount(pl) < TradeSlotCount(udg_Trader[pl]) then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Need |cffffff00" + I2S(TradeSlotCount(udg_Trader[pl])) + " free slot|r!")
call DisplayTextToPlayer(Player(udg_Trader[pl] - 1), 0, 0, "|cffffff00" + GetPlayerName(Player(pl - 1)) + "|r inventory is full!")
else
if TradeSlotCount(udg_Trader[pl]) + FreeInventorySlotCount(udg_Trader[pl]) < TradeSlotCount(pl) then
call DisplayTextToPlayer(Player(udg_Trader[pl] - 1), 0, 0, "Need |cffffff00" + I2S(TradeSlotCount(pl)) + " free slot|r!")
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00" + GetPlayerName(Player(udg_Trader[pl] - 1)) + "|r inventory is full!")
else
call TradeSlots(pl)
endif
endif
endif
elseif lock == 2 and LoadInteger(udg_FSS, 1275 + udg_Trader[pl], 1) < 2 then
call LockTradeSlots(pl, slot)
endif
elseif slot == 1300 and udg_Trader[pl] > 0 then
//call DisplayTextToPlayer(Player(0), 0, 0, "trade lock: "+I2S(slot)+" pl"+I2S(pl))
call LockTradeSlots(pl, slot)
call Mb_ToolTip(pl, pl, slot)
elseif slot >= 1200 and slot < 1206 and lock == 0 then
if udg_Selected_Slot[pl] == 0 and lock == 0 and LoadInteger(udg_FSS, 1249 + pl, slot) > 0 then
//call DisplayTextToPlayer(Player(0), 0, 0, "remove from trade: slot: "+I2S(slot)+" pl"+I2S(pl))
call RemoveTradeSlot(pl, slot)
set udg_Selected_Slot[pl] = 0
else
if udg_Selected_Slot[pl] > 99 and udg_Selected_Slot[pl] < 199 and lock == 0 then
//call DisplayTextToPlayer(Player(0), 0, 0, "add item to trade slot: "+I2S(slot)+" pl"+I2S(pl))
call AddToTradeSlot(pl, udg_Selected_Slot[pl], slot)
set udg_Selected_Slot[pl] = 0
endif
endif
endif
endfunction
function Click_To_Trackable takes nothing returns nothing
local integer id = GetHandleId(GetTriggeringTrackable())
local integer slot = LoadInteger(udg_FSS, - id, 2)
local integer pl = LoadInteger(udg_FSS, - id, 1) + 1
local integer cv = udg_Inv_Unit[pl]
local unit u = udg_UDexUnits[cv]
local integer i
local boolean SlotEmpty = false
if slot != 0 then
if udg_Camera_Lock[pl] == 1 then
call RemoveDestructable (udg_Selector[pl])
if slot == 303 then
call WindowTransition (pl, 1, 0)
elseif slot == 302 then
call RepairAll(pl)
set udg_Selected_Slot[pl] = 0
elseif slot == 304 then
if udg_Stat_Point[cv] > 0 then
set udg_Stat_Point[cv] = udg_Stat_Point[cv] - 1
call SetHeroInt(u, GetHeroInt(u, true) + 1, true)
call ShowStat(pl)
call BumpSlot (pl, slot, 4)
endif
set udg_Selected_Slot[pl] = 0
elseif slot == 305 then
if udg_Stat_Point[cv] > 0 then
set udg_Stat_Point[cv] = udg_Stat_Point[cv] - 1
call SetHeroAgi(u, GetHeroAgi(u, true) + 1, true)
call ShowStat(pl)
call BumpSlot (pl, slot, 4)
endif
set udg_Selected_Slot[pl] = 0
elseif slot == 306 then
if udg_Stat_Point[cv] > 0 then
set udg_Stat_Point[cv] = udg_Stat_Point[cv] - 1
call SetHeroStr(u, GetHeroStr(u, true) + 1, true)
call ShowStat(pl)
call BumpSlot (pl, slot, 4)
endif
set udg_Selected_Slot[pl] = 0
elseif slot == 307 then
call Restat (pl)
elseif ((slot >= 1200 and slot < 1206 and LoadInteger(udg_FSS, 1275 + pl, 1) == 0) or slot == 1300 or slot == 1301) and udg_Trader[pl] > 0 then
call TradeHandle (pl, slot)
elseif slot < 400 then
if udg_Selected_Slot[pl] == 0 then
if slot < 200 then
set i = LoadInteger(udg_Stat_Table, cv, - slot)
if i > 0 then
else
set SlotEmpty = true
endif
elseif slot < 300 then
if UnitItemInSlot(u, slot - 200) != null then
set i = GetItemLevel(UnitItemInSlot(u, slot - 200))
if i >= 100 and i < 111 then
call BumpSlot (pl, i - 100, 5)
endif
else
set SlotEmpty = true
endif
elseif slot < 400 and slot >= 300 and udg_Selected_Slot[pl] > 0 then
set udg_Selected_Slot[pl] = 0
set SlotEmpty = true
endif
if not SlotEmpty then
set udg_Selected_Slot[pl] = slot
call SelectSlot(pl, slot)
else
set udg_Selected_Slot[pl] = 0
endif
else
call SwitchItem (pl, udg_Selected_Slot[pl], slot)
set udg_Selected_Slot[pl] = 0
endif
endif
elseif udg_Camera_Lock[pl] == 2 then
set slot = LoadInteger(udg_FSS, - id, 3)
if LoadInteger(udg_FSS, 2405, 20 + pl) == 0 then
if slot == 2300 then //quit
call WindowTransition (pl, 2, 0)
elseif slot == 2302 then //craft
if LoadInteger(udg_FSS, 2405, pl) == 1 then
call CraftShopItem(pl)
endif
else
call SelectShopSlot (pl, slot)
endif
endif
elseif udg_Camera_Lock[pl] == 3 then
set slot = LoadInteger(udg_FSS, - id, 4)
if slot > 0 then
if (slot < 120 and slot >= 100) or (slot > 2200 and slot < 2225) then
call RemoveDestructable (udg_Selector[pl])
call BagOrganise (pl, udg_Selected_Slot[pl], slot)
elseif slot > 0 then
//command button
call DisplayTextToPlayer(Player(0), 0, 0, "command")
endif
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
//create tooltip for shop tooltip box (right bottom corner)
function CreateToolTip takes integer pl, string txt, real size, real x, real y, integer hkey returns nothing
local texttag tt = null
local real px = LoadReal(udg_FSS, 0, 1) + x
local real py = LoadReal(udg_FSS, 0, 2) + y
if GetLocalPlayer() == Player(pl - 1) then
set tt = CreateTextTag( )
call SetTextTagText( tt, txt, size * 0.023 )
call SetTextTagPos( tt, px, py, 100.00 )
call SetTextTagPermanent( tt, true )
endif
call SaveTextTagHandle(udg_FSS, 2402, hkey, tt)
set tt = null
endfunction
function UpdateToolTip takes integer pl, integer t, integer slot returns nothing
local integer id
local integer price = 0
local integer ilv = 0
local integer mc = 0
local integer sc = 0
local integer ls = 0
local string s = ""
local integer i = 0
local integer i1 = 0
local integer i2 = 0
local integer i3 = 0
local integer v1
local integer v2
local integer v3
local integer array craft_xp
local integer array craft_lv
local integer array craft_perc
local integer prof_skill
local integer req_prof_skill
local string c = "|cffffff00"
local string r = "|cffff0000"
local string rc = r
local real m = 0
local real m2 = 0
local string array de
local integer d1 = 0
local integer lv
local integer rlv = 0
local integer pgold
local integer ui = 0
local integer cv = udg_Inv_Unit[pl]
local unit u = udg_UDexUnits[cv]
local string craftlvr
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 RemoveSavedHandle(udg_FSS, 2402, 180 + pl)
call RemoveSavedHandle(udg_FSS, 2402, 200 + pl)
call RemoveSavedHandle(udg_FSS, 2402, 220 + pl)
call RemoveSavedHandle(udg_FSS, 2402, 240 + pl)
call RemoveSavedHandle(udg_FSS, 2402, 260 + pl)
call RemoveSavedHandle(udg_FSS, 2402, 280 + pl)
if udg_Camera_Lock[pl] == 2 then
set craftlvr = ""
if slot < 2000 then
set slot = 0
endif
set mc = LoadInteger(udg_FSS, 2402, pl) - 2000
if t == 1 then
set sc = slot - 2100
elseif t == 2 then
set sc = LoadInteger(udg_FSS, 2402, 20 + pl) - 2100
set ls = slot - 2200
endif
if t == 0 then
set id = 0
elseif t == 1 and mc > 0 and sc > 0 then
set id = LoadInteger(udg_Shop_Table, mc, sc)
elseif t == 2 then
set id = GetItemIdFromShop (pl, mc, sc, ls)
endif
if id != 0 then
set ilv = LoadInteger(udg_FSS, 603, id)
set lv = GetHeroLevel(u)
if ls > 0 then
set pgold = GetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD)
set ui = GetShopUniqueId (mc, sc, ls)
set price = LoadInteger(udg_FSS, 602, id)
if (ilv < 100 or ilv > 200) and ui > 0 then
set price = price * ui
endif
if pgold >= price then
set rc = c
else
set rc = r
endif
endif
if LoadInteger(udg_FSS, 606, id) != 0 and LoadInteger(udg_FSS, 607, id) > 0 then
if ilv > 100 and ilv < 109 then
set req_prof_skill = R2I(ls / 2.00 + 0.5)
elseif ilv == 109 or ilv == 110 then
set req_prof_skill = 3
else
if ilv == 1902 or ilv == 1903 then
set req_prof_skill = R2I(ls / 2.00 + 0.5)
elseif ilv == 1904 or ilv == 1905 then
set req_prof_skill = 4
else
set req_prof_skill = 1
endif
endif
if ilv > 100 and ilv < 106 and ilv != 103 then
set craftlvr = " - Tailor: " + I2S(req_prof_skill)
set prof_skill = 1
elseif ilv == 103 then
set craftlvr = " - Blacksmith: " + I2S(req_prof_skill)
set prof_skill = 2
elseif ilv > 105 and ilv < 111 then
set craftlvr = " - Jeweller: " + I2S(req_prof_skill)
set prof_skill = 3
elseif ilv >= 1900 and ilv < 1910 then
set craftlvr = " - Pharmacist: " + I2S(req_prof_skill)
set prof_skill = 4
else
set craftlvr = ""
endif
set i = 0
endif
if ilv >= 100 and ilv < 112 then
if ui > 0 then //unique id (changed for price)
set price = LoadInteger(udg_FSS, 602, id)
else
set price = price * ls * 5
endif
if ilv < 109 and ui > 0 then
set s = "Unique "
set d1 = d1 + 1
set de[d1] = StringColoring(" Unique set piece ", 85, 85, 255, 180, 180, 255)
set d1 = d1 + 1
set de[d1] = StringColoring(" Stat are hidden ", 85, 55, 255, 180, 180, 255)
set d1 = d1 + 1
set de[d1] = StringColoring(" until you buy it. ", 85, 55, 255, 180, 180, 255)
elseif (ilv == 101 or ilv == 102 or ilv == 104) and ui == 0 then
if sc < 10 then
if sc < 4 then
set m = 0.45
elseif sc < 7 then
set m = 55
else
set m = 0.40
endif
set i = sc - ((sc / 3) * 3)
if i == 1 then
set s = "Heavy "
set m2 = 1.5
set i2 = R2I(10 * 3.33 * ls * 5 * m) + 30
set i3 = R2I(3 * 3.33 * ls * 5 * m) + 10
elseif i == 2 then
set s = "Light "
set m2 = 1.25
set i2 = R2I(5 * 3.33 * ls * 5 * m) + 15
set i3 = R2I(5 * 3.33 * ls * 5 * m) + 15
set m = 1
elseif i == 0 then
set s = "Mage "
set m2 = 1.0
set i2 = R2I(3.00 * 3.33 * ls * 5 * m) + 10
set i3 = R2I(10 * 3.33 * ls * 5 * m) + 30
endif
set d1 = d1 + 1
set de[d1] = StringColoring("HP: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(m2 * m * 10.00 * ls * 5)) + "|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Physical Defence: ", 85, 55, 255, 180, 180, 255) + c + I2S(i2) + "|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Five El. Defence: ", 85, 55, 255, 180, 180, 255) + c + I2S(i3) + "|r"
endif
elseif ilv == 103 then
set i = LoadInteger(udg_FSS, 605, id)
set i2 = R2I(ls * 5 * WeaponDamageModifier(i)*10/WEP_MOD()/1.5)
set i1 = R2I(WeaponMinDamageModifier(i) * i2)
set d1 = d1 + 1
if i < 8 then
set de[d1] = StringColoring("Physical Attack: ", 85, 85, 255, 180, 180, 255) + c + I2S(i1)+"-"+I2S(i2) + "|r"
else
set de[d1] = StringColoring("Magical Attack: ", 85, 85, 255, 180, 180, 255) + c + I2S(i1)+"-"+I2S(i2) + "|r"
endif
set i2 = 0
elseif ilv == 109 then
if ls == 1 then
set i1 = 30
set i2 = 30
elseif ls == 2 then
set i1 = 45
set i2 = 15
elseif ls == 3 then
set i1 = 10
set i2 = 45
endif
set d1 = d1 + 1
set de[d1] = StringColoring("Attack level: ", 85, 85, 255, 180, 180, 255) + c + I2S(i1) + "|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Defence level: ", 85, 85, 255, 180, 180, 255) + c + I2S(i2) + "|r"
elseif ilv == 106 then
set d1 = d1 + 1
set de[d1] = StringColoring("Physical Attack: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I((ls * 5 * 10 * 0.135) + 1)) + "|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Magical Attack: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I((ls * 5 * 10 * 0.135) + 1)) + "|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Critical chance: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I((ls * 5 * 10 / 250.00) + 1)) + "%|r"
elseif ilv == 108 then
set d1 = d1 + 1
set de[d1] = StringColoring("Physical Defence: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 * 5.75 + 30)) + "|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Accurancy: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 * 1.5 + 10)) + "|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Evasion: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 * 1 + 10)) + "|r"
elseif ilv == 105 then
set d1 = d1 + 1
set de[d1] = StringColoring("Physical Defence: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 * 3 + 30)) + "|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Block chance: ", 85, 85, 255, 180, 180, 255) + c + I2S(R2I(ls * 5 / 10 + 5)) + "%|r"
elseif ilv == 110 then
set d1 = d1 + 1
set de[d1] = StringColoring("Exp/Discount: ", 85, 85, 255, 180, 180, 255) + c + I2S(50) + "%|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Gold drop rate: ", 85, 85, 255, 180, 180, 255) + c + I2S(50) + "%|r"
set d1 = d1 + 1
set de[d1] = StringColoring("Item drop luck: ", 85, 85, 255, 180, 180, 255) + c + I2S(50) + "%|r"
elseif ilv == 111 then
set d1 = d1 + 1
set de[d1] = StringColoring("Stone filled with magic.", 200, 200, 150, 255, 255, 255)
set d1 = d1 + 1
set de[d1] = StringColoring(" (Random stat) ", 200, 200, 150, 255, 255, 255)
set d1 = d1 + 1
set de[d1] = StringColoring("Do you want try your luck? ", 200, 200, 150, 255, 255, 255)
endif
if ilv >= 100 and ilv < 112 and ls > 0 and ls < 21 then
if ui > 0 then
set rlv = LoadInteger(udg_CItem_Table, - ui, 8)
elseif ilv == 109 then
set rlv = 30
elseif ilv == 111 then
set rlv = 1
else
set rlv = ls * 5
endif
set lv = GetHeroLevel(u)
endif
elseif ilv == 200 then
set ui = GetShopUniqueId (mc, sc, ls)
if ui != 0 then
set ui = 2000 + ui
set i1 = LoadInteger(udg_CItem_Table, - ui, 9)
set i2 = LoadInteger(udg_CItem_Table, - ui, 10)
set i3 = LoadInteger(udg_CItem_Table, - ui, 11)
set v1 = LoadInteger(udg_CItem_Table, - ui, i1)
set v2 = LoadInteger(udg_CItem_Table, - ui, i2)
set v3 = LoadInteger(udg_CItem_Table, - ui, i3)
set rlv = LoadInteger(udg_CItem_Table, - ui, 8)
set s = GetGemGradeName(LoadInteger(udg_CItem_Table, - ui, 7)) + " "
set d1 = d1 + 1
set de[d1] = StringColoring("Armor: +" + I2S(v1)+ GetItemStatName(i1, false, true) + " " + GetItemStatName(i1, false, false), 200, 200, 150, 255, 255, 255)
set d1 = d1 + 1
set de[d1] = StringColoring("Weapon: +" + I2S(v2)+ GetItemStatName(i2, false, true) + " " + GetItemStatName(i2, false, false), 200, 200, 150, 255, 255, 255)
set d1 = d1 + 1
set de[d1] = StringColoring("Wings: +" + I2S(v3)+ GetItemStatName(i3, false, true) + " " + GetItemStatName(i3, false, false), 200, 200, 150, 255, 255, 255)
set price = LoadInteger(udg_CItem_Table, - ui, 12)
endif
else
if ilv > 1901 and ilv < 1906 then
if ilv == 1902 or ilv == 1904 then
set s = "hit point"
else
set s = "mana point"
endif
if ilv < 1904 then
set rlv = ls * 5
set price = LoadInteger(udg_FSS, 602, id) * ls
set d1 = d1 + 2
set de[d1] = StringColoring("Restore " + I2S(ls * 25 + 250) + " " + s, 200, 200, 150, 255, 255, 255)
else
set rlv = 0
set price = LoadInteger(udg_FSS, 602, id)
set d1 = d1 + 2
set de[d1] = StringColoring("Regenerate 2000 " + s, 200, 200, 150, 255, 255, 255)
set d1 = d1 + 1
set de[d1] = StringColoring("In last 30 second.", 200, 200, 150, 255, 255, 255)
endif
set s = ""
else
if LoadStr(udg_FSS, 647, id) != null then
set d1 = d1 + 1
set de[d1] = StringColoring(LoadStr(udg_FSS, 647, id), 200, 200, 150, 255, 255, 255)
if LoadStr(udg_FSS, 648, id) != null then
set d1 = d1 + 1
set de[d1] = StringColoring(LoadStr(udg_FSS, 648, id), 200, 200, 150, 255, 255, 255)
if LoadStr(udg_FSS, 649, id) != null then
set d1 = d1 + 1
set de[d1] = StringColoring(LoadStr(udg_FSS, 649, id), 200, 200, 150, 255, 255, 255)
endif
endif
endif
endif
endif
set m = 144
if t == 1 then
set s = StringColoring("Item Type: ", 85, 85, 255, 180, 180, 255) + StringColoring(s + LoadStr(udg_FSS, 604, id), 255, 255, 55, 255, 255, 200)
else
set s = StringColoring("Item Type: ", 85, 85, 255, 180, 180, 255) + StringColoring(s + GetObjectName(id), 255, 255, 55, 255, 255, 200)
endif
call CreateToolTip (pl, s, 1.1, 830, 192, 180 + pl)
set s = c
if price > 0 and ls > 0 then
if LoadInteger(udg_FSS, 606, id) != 0 and LoadInteger(udg_FSS, 607, id) > 0 then
if ((ilv > 99 and ilv < 111) or (ilv > 1901 and ilv < 1906)) then
set craft_xp[prof_skill] = LoadInteger(udg_Stat_Table, 27000 + cv, prof_skill)
set craft_lv[prof_skill] = GetCraftLv(craft_xp[prof_skill], true)
if req_prof_skill > craft_lv[prof_skill] then
set s = r
endif
endif
set s = "|cffffffffPrice:|r " + rc + I2S(R2I(price * (100 - udg_Global_Discount[cv]) / 100.00)) + "|r |cffffff77gold|r" + s + craftlvr + "|r"
else
set s = "|cffffffffPrice:|r " + rc + I2S(R2I(price * (100 - udg_Global_Discount[cv]) / 100.00)) + "|r |cffffff77gold|r"
endif
call CreateToolTip (pl, s, 1, 850, 0, 200 + pl)
elseif ls > 0 and price == - 1 then
set s = StringColoring(" - Not buyable - ", 150, 150, 150, 75, 75, 75) + craftlvr
call CreateToolTip (pl, s, 1, 850, 0, 200 + pl)
endif
if rlv > 0 and ls > 0 then
set m = 144 - 30
if rlv > lv then
set rc = r
else
set rc = c
endif
set s = StringColoring("Required level: ", 55, 55, 255, 150, 150, 255) + rc + I2S(rlv) + " level|r"
call CreateToolTip (pl, s, 1, 850, 144, 220 + pl)
endif
if ls > 0 then
set i = 1
loop
exitwhen i > d1
if de[i] != null then
call CreateToolTip (pl, de[i], 1, 850, m, 220 + (i * 20) + pl)
set de[i] = null
endif
set m = m - 30
set i = i + 1
endloop
endif
else
set craft_xp[1] = LoadInteger(udg_Stat_Table, 27000 + cv, 1)
set craft_xp[2] = LoadInteger(udg_Stat_Table, 27000 + cv, 2)
set craft_xp[3] = LoadInteger(udg_Stat_Table, 27000 + cv, 3)
set craft_xp[4] = LoadInteger(udg_Stat_Table, 27000 + cv, 4)
set craft_lv[1] = GetCraftLv(craft_xp[1], true)
set craft_lv[2] = GetCraftLv(craft_xp[2], true)
set craft_lv[3] = GetCraftLv(craft_xp[3], true)
set craft_lv[4] = GetCraftLv(craft_xp[4], true)
set craft_perc[1] = GetCraftLv(craft_xp[1], false)
set craft_perc[2] = GetCraftLv(craft_xp[2], false)
set craft_perc[3] = GetCraftLv(craft_xp[3], false)
set craft_perc[4] = GetCraftLv(craft_xp[4], false)
set s = StringColoring("Production Skills: ", 255, 85, 85, 200, 200, 255)
call CreateToolTip (pl, s, 1.2, 850, 170, 180 + pl)
set s = StringColoring("Blacksmith: ", 85, 85, 255, 180, 180, 255) + " " + StringColoring("Level: " + I2S(craft_lv[1]) + " (" + I2S(craft_perc[1]) + " %)", 255, 255, 55, 255, 255, 250)
call CreateToolTip (pl, s, 1.1, 850, 144 - 35, 200 + pl)
set s = StringColoring("Tailor: ", 85, 85, 255, 180, 180, 255) + " " + StringColoring("Level: " + I2S(craft_lv[2]) + " (" + I2S(craft_perc[2]) + " %)", 255, 255, 55, 255, 255, 250)
call CreateToolTip (pl, s, 1.1, 850, 144 - 65, 220 + pl)
set s = StringColoring("Jeweller: ", 85, 85, 255, 180, 180, 255) + " " + StringColoring("Level: " + I2S(craft_lv[3]) + " (" + I2S(craft_perc[3]) + " %)", 255, 255, 55, 255, 255, 250)
call CreateToolTip (pl, s, 1.1, 850, 144 - 100, 240 + pl)
set s = StringColoring("Pharmacist: ", 85, 85, 255, 180, 180, 255) + " " + StringColoring("Level: " + I2S(craft_lv[4]) + " (" + I2S(craft_perc[4]) + " %)", 255, 255, 55, 255, 255, 250)
call CreateToolTip (pl, s, 1.1, 850, 144 - 130, 260 + pl)
endif
set craftlvr = null
endif
set s = null
set r = null
set c = null
set rc = null
set u = null
endfunction
function On_Trackable takes nothing returns nothing
local integer id = GetHandleId(GetTriggeringTrackable())
local integer pl = LoadInteger(udg_FSS, - id, 1) + 1
local integer slot = LoadInteger(udg_FSS, - id, 1 + udg_Camera_Lock[pl])
local integer cv = udg_Inv_Unit[pl]
local integer i
if udg_Camera_Lock[pl] > 0 then
//call DisplayTimedTextToForce( GetPlayersAll(), 30,"slot "+I2S(slot))
if udg_Camera_Lock[pl] == 1 then
if slot < 1100 then
if slot >= 100 and slot < 200 and udg_Trader[pl] == 0 then
set i = LoadInteger(udg_Stat_Table, cv, - slot)
if i >= 100 and i < 111 then
if LoadInteger(udg_Stat_Table, cv, - i + 100) == 0 then
call BumpSlot (pl, i - 100, 5)
elseif LoadInteger(udg_Stat_Table, cv, - 6) > 0 and LoadInteger(udg_Stat_Table, cv, - 7) == 0 then
call BumpSlot (pl, 7, 5)
endif
endif
endif
call Mb_ToolTip(pl, pl, slot)
elseif udg_Trader[pl] > 0 then
if slot < 1206 then
set i = LoadInteger(udg_FSS, 1249 + pl, slot)
if i > 0 then
call Mb_ToolTip(pl, pl, i)
endif
elseif slot < 1212 then
set i = LoadInteger(udg_FSS, 1249 + udg_Trader[pl], slot - 6)
if LoadItemHandle(udg_Stat_Table, udg_Inv_Unit[udg_Trader[pl]], i) != null then
call Mb_Item_ToolTip (LoadItemHandle(udg_Stat_Table, udg_Inv_Unit[udg_Trader[pl]], i), 0, 0)
endif
else
call Mb_ToolTip(pl, pl, slot)
endif
endif
elseif udg_Camera_Lock[pl] == 2 then
if LoadInteger(udg_FSS, 2405, 20 + pl) == 0 then
if slot != 0 then
if slot < 200 then
call Mb_ToolTip(pl, pl, slot)
else
if udg_Mb_Type[pl] == 1 then
set udg_Mb_Type[pl] = 0
call DestroyMultiboard(udg_Mb_Table[pl])
endif
if slot >= 2000 then
if slot < 2100 then
//call UpdateToolTip(pl, 0, slot)
elseif slot < 2200 then
call UpdateToolTip(pl, 1, slot)
elseif slot < 2300 then
call UpdateToolTip(pl, 2, slot)
elseif slot > 2302 and slot < 2306 then
if LoadInteger(udg_FSS, 2405, pl) == 1 then
set i = LoadInteger(udg_FSS, 2405, 160 + pl) //craft target item
if LoadInteger(udg_FSS, 606 + ((slot - 2303) * 2), i) != 0 and LoadInteger(udg_FSS, 607 + ((slot - 2303) * 2), i) > 0 then
call MultiboardClear(udg_Mb_Table[pl])
call DestroyMultiboard(udg_Mb_Table[pl])
set udg_Mb_Table[pl] = CreateMultiboard()
set udg_Mb_Type[pl] = 1
call MultiboardSetRowCount(udg_Mb_Table[pl], 0)
call MultiboardSetColumnCount(udg_Mb_Table[pl], 0)
call MultiboardSetTitleText(udg_Mb_Table[pl], (StringColoring(GetObjectName(LoadInteger(udg_FSS, 606 + ((slot - 2303) * 2), i)), 125, 125, 255, 200, 200, 255) + " |cffbbbbffx " + I2S(GetCraftMatAmount (pl, LoadInteger(udg_FSS, 2402, pl) - 2000, LoadInteger(udg_FSS, 2402, 20 + pl) - 2100, LoadInteger(udg_FSS, 2402, 40 + pl) - 2200, slot - 2302))) + "|r")
call MultiboardSetTitleTextColor(udg_Mb_Table[pl], 255, 200, 200, 255)
call MultiboardDisplay(udg_Mb_Table[pl], false)
call MultiboardMinimize(udg_Mb_Table[pl], true)
if ( GetLocalPlayer() == Player(pl - 1) ) then
call MultiboardDisplay(udg_Mb_Table[pl], true)
endif
endif
endif
endif
endif
endif
endif
endif
elseif udg_Camera_Lock[pl] == 3 then
if (slot >= 100 and slot < 119) or (slot >= 2200 and slot < 2225) then
call Mb_ToolTip(pl, pl, slot)
endif
endif
endif
endfunction
//===========================================================================
function InitTrig_OnTrackable takes nothing returns nothing
set gg_trg_OnTrackable = CreateTrigger()
call TriggerAddAction( gg_trg_OnTrackable, function On_Trackable )
endfunction
function Trig_InventoryItemAction_Conditions takes nothing returns boolean
return udg_Camera_Lock[GetPlayerId(GetTriggerPlayer())+1] == 1 and GetOrderTargetItem() != null and UnitHasItem(GetTriggerUnit(), GetOrderTargetItem())
endfunction
function Trig_InventoryItemAction_Actions takes nothing returns nothing
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
local integer i = 200
local destructable d
local real x
local real y
local integer ilv
local integer dt
local item itm
local unit u = GetTriggerUnit()
call TriggerSleepAction(0.27)
loop
exitwhen i > 205
set itm = UnitItemInSlot(u, i - 200)
set d = LoadDestructableHandle(udg_FSS, 2409 + pl, i)
if d != null then
call RemoveDestructable(d)
endif
if itm != null then
set ilv = GetItemLevel(itm)
set dt = LoadInteger(udg_FSS, 600, GetItemTypeId(itm))
set x = LoadReal(udg_FSS, i, 1)
set y = LoadReal(udg_FSS, i, 2)
if dt > 0 then
set d = CreateDestructableZ(dt, x, y, 5, 0, 0.6, 0)
call SaveDestructableHandle(udg_FSS, 2409 + pl, i, d)
call ShowDestructable(d, false)
if GetLocalPlayer() == Player(pl - 1) then
call ShowDestructable(d, true)
endif
endif
endif
set i = i + 1
endloop
call SetChargesText(pl)
set itm = null
set u = null
endfunction
//===========================================================================
function InitTrig_Inventory_Item_Action takes nothing returns nothing
set gg_trg_Inventory_Item_Action = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Inventory_Item_Action, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( gg_trg_Inventory_Item_Action, Condition( function Trig_InventoryItemAction_Conditions ) )
call TriggerAddAction( gg_trg_Inventory_Item_Action, function Trig_InventoryItemAction_Actions )
endfunction
function Unit_Use_Item takes nothing returns boolean
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
local item itm1 = GetManipulatedItem()
local integer i = GetHandleId(itm1)
local integer ilv = GetItemLevel(itm1)
local item itm2
local integer c
local integer it
local destructable d
local unit u = GetTriggerUnit()
if ilv > 1901 and ilv < 1906 then
set it = LoadInteger(udg_CItem_Table, i, 2)
set c = LoadInteger(udg_CItem_Table, i, 3)
set c = LoadInteger(udg_CItem_Table, i, c)
if GetHeroLevel(u) >= LoadInteger(udg_CItem_Table, i, 8) then
call DestroyEffect(AddSpecialEffectTarget(EFFECT(LoadInteger(udg_CItem_Table, i, 19)), u, "chest"))
if it == 1 then
call SetWidgetLife(u, GetWidgetLife(u) + c)
elseif it == 2 then
call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA) + c)
elseif it == 3 then
call AddOT (u, u, - 1, R2I(c / 30.00), 30)
elseif it == 4 then
call AddOT (u, u, - 2, R2I(c / 30.00), 30)
endif
call FlushChildHashtable(udg_CItem_Table, i)
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff3333Your level is too low for this potion, you get back the potion!|r")
set ilv = CreatePotion(it, GetUnitX(u), GetUnitY(u), LoadInteger(udg_CItem_Table, i, 8), c, LoadInteger(udg_CItem_Table, i, c), LoadInteger(udg_CItem_Table, i, 5), LoadInteger(udg_CItem_Table, i, 19))
call SaveInteger(udg_CItem_Table, ilv, 12, LoadInteger(udg_CItem_Table, i, 12))
call FlushChildHashtable(udg_CItem_Table, i)
set itm2 = LoadItemHandle(udg_CItem_Table, ilv, 100)
if udg_Camera_Lock[pl] > 0 then
call AddItem2HeroExt (GetUnitUserData(u), itm2, false)
else
set i = GetUnitUserData(u)
set udg_Stop_Stack[i] = true
call UnitAddItem(u, itm2)
set udg_Stop_Stack[i] = false
endif
set itm2 = null
endif
elseif ilv == BAG_LEVEL() then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffff00You must open from inventory|r")
set udg_Inv_Bag[pl] = i
set udg_Inv_Unit[pl] = GetUnitUserData(u)
set c = GetUnitUserData(u)
if udg_Inv_Unit[pl] == 0 or udg_Inv_Unit[pl] == c then
set udg_Inv_Bag[pl] = i
set udg_Inv_Unit[pl] = c
if udg_Camera_Lock[pl] > 0 then
call WindowTransition(pl, udg_Camera_Lock[pl], 3)
else
set udg_Inv_Prev[pl] = 1
call EnableCamLock(pl, 3)
endif
endif
elseif ilv == BOX_LEVEL() then
set c = GetRandomInt(0, 999)
set itm2 = null
if c < 1 then
set c = GenerateEQ ( - 1, - 1, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), false, - 1)
set itm2 = LoadItemHandle(udg_CItem_Table, c, 100)
elseif c < 10 then
set c = GenerateEQ ( - 1, - 1, 5, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), false, - 1)
set itm2 = LoadItemHandle(udg_CItem_Table, c, 100)
elseif c < 30 then
set c = GenerateEQ ( - 1, - 1, 4, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), false, - 1)
set itm2 = LoadItemHandle(udg_CItem_Table, c, 100)
elseif c < 80 then
set c = GenerateEQ ( - 1, - 1, 3, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), false, - 1)
set itm2 = LoadItemHandle(udg_CItem_Table, c, 100)
elseif c < 160 then
set c = CreatePotion(1, GetUnitX(u), GetUnitY(u), 0, 26, GetHeroLevel(u) * 5 + 50, 0, 26)
set itm2 = LoadItemHandle(udg_CItem_Table, c, 100)
elseif c < 220 then
set c = CreatePotion(2, GetUnitX(u), GetUnitY(u), 0, 30, GetHeroLevel(u) * 5 + 50, 0, 30)
set itm2 = LoadItemHandle(udg_CItem_Table, c, 100)
elseif c < 250 then
set c = CreatePotion(3, GetUnitX(u), GetUnitY(u), 0, 26, (GetHeroLevel(u) - 1) * 20 + 100, 0, 26)
set itm2 = LoadItemHandle(udg_CItem_Table, c, 100)
elseif c < 280 then
set c = CreatePotion(3, GetUnitX(u), GetUnitY(u), 0, 30, (GetHeroLevel(u) - 1) * 20 + 100, 0, 30)
set itm2 = LoadItemHandle(udg_CItem_Table, c, 100)
elseif c < 350 then
set itm2 = CreateItem('gold', GetUnitX(u), GetUnitY(u))
call SetItemUserData(itm2, GetRandomInt(GetHeroLevel(u) * 2 + 10, GetHeroLevel(u) * 5 + 17))
set c = - 1
endif
if itm2 != null then
if udg_Camera_Lock[pl] > 0 and c != - 1 then
call AddItem2HeroExt (GetUnitUserData(u), itm2, false)
else
call UnitAddItem(u, itm2)
endif
if GetItemTypeId(itm2) != 'gold' then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffffaaAcquired|r " + GetFullItemName(itm2, true) + "|r")
endif
set itm2 = null
else
set c = GetRandomInt(0, 3)
if c == 0 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff0000Bad luck|r")
elseif c == 1 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff0000Better luck next time|r")
elseif c == 2 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff0000Empty|r")
elseif c == 3 then
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffff0000Try again next time|r")
endif
endif
if HaveSavedHandle(udg_CItem_Table, i, 100) then
call FlushChildHashtable(udg_CItem_Table, i)
endif
call RemoveItem(itm1)
endif
if udg_Camera_Lock[pl] > 0 then
// if udg_Camera_Lock[pl] == 1 then
set i = 0
set c = GetItemCharges(itm1)
if c == 0 then
loop
exitwhen i > 5
set itm2 = UnitItemInSlot(u, i)
if itm1 == itm2 then
call RemoveIcon(pl, 200+i)
endif
if itm2 == null then
set d = LoadDestructableHandle(udg_FSS, 2409 + pl, 200 + i)
if d != null then
call RemoveDestructable(d)
endif
endif
set i = i + 1
endloop
endif
call SetChargesText(pl)
set itm2 = null
set d = null
endif
set itm1 = null
set u = null
return false
endfunction
//===========================================================================
function InitTrig_Unit_Use_Item takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_USE_ITEM, null)
set i = i + 1
exitwhen i == 15
endloop
call TriggerAddCondition( t, Condition( function Unit_Use_Item ) )
set t = null
endfunction
function Trig_Unit_Sell_Item_Actions takes nothing returns nothing
call RemoveItemRot(GetManipulatedItem(),true)
endfunction
//===========================================================================
function InitTrig_Unit_Sell_Item takes nothing returns nothing
set gg_trg_Unit_Sell_Item = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Sell_Item, EVENT_PLAYER_UNIT_PAWN_ITEM )
call TriggerAddAction( gg_trg_Unit_Sell_Item, function Trig_Unit_Sell_Item_Actions )
endfunction
function Trig_Hero_deselection_during_FSS_Conditions takes nothing returns boolean
local integer pl = GetPlayerId(GetTriggerPlayer())+1
if udg_Camera_Lock[pl] > 0 then
if GetLocalPlayer() == GetTriggerPlayer() then
call ClearSelection()
call SelectUnit(udg_UDexUnits[udg_Inv_Unit[pl]],true)
endif
endif
return false
endfunction
//===========================================================================
function InitTrig_Hero_deselection_during_FSS takes nothing returns nothing
set gg_trg_Hero_deselection_during_FSS = CreateTrigger( )
call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Hero_deselection_during_FSS, Player(0), true )
call TriggerAddCondition( gg_trg_Hero_deselection_during_FSS, Condition( function Trig_Hero_deselection_during_FSS_Conditions ) )
endfunction
function Trig_Player_leave_so_close_the_windows_Actions takes nothing returns nothing
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
if udg_Camera_Lock[pl] > 0 then
call WindowTransition (pl, udg_Camera_Lock[pl], 0)
endif
endfunction
//===========================================================================
function InitTrig_Player_leave_so_close_the_windows takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i > 11
call TriggerRegisterPlayerEventLeave( t, Player(i) )
set i = i + 1
endloop
call TriggerAddAction( t, function Trig_Player_leave_so_close_the_windows_Actions )
set t = null
endfunction
function Trig_Open_Inventory_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00B'
endfunction
function Trig_Open_Inventory_Actions takes nothing returns nothing
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
if udg_Camera_Lock[pl] == 0 then
set udg_Inv_Unit[pl] = GetUnitUserData(GetTriggerUnit())
call EnableCamLock(pl, 1)
endif
endfunction
//===========================================================================
function InitTrig_Start_Inventory takes nothing returns nothing
set gg_trg_Start_Inventory = CreateTrigger( )
call TriggerAddCondition( gg_trg_Start_Inventory, Condition( function Trig_Open_Inventory_Conditions ) )
call TriggerAddAction( gg_trg_Start_Inventory, function Trig_Open_Inventory_Actions )
endfunction
function Trig_Start_Shop_Conditions takes nothing returns boolean
local unit u = GetEnteringUnit()
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
local integer cv
if GetPlayerController(Player(pl-1)) == MAP_CONTROL_USER then
set cv = GetUnitUserData(u)
if udg_Camera_Lock[pl] == 0 then
set udg_Inv_Unit[pl] = cv
call EnableCamLock(pl, 2)
endif
endif
set u = null
return false
endfunction
//===========================================================================
function InitTrig_Start_Shop takes nothing returns nothing
set gg_trg_Start_Shop = CreateTrigger( )
call TriggerRegisterUnitInRangeSimple( gg_trg_Start_Shop, 500.00, gg_unit_ngme_0001 )
call TriggerAddCondition( gg_trg_Start_Shop, Condition( function Trig_Start_Shop_Conditions ) )
endfunction
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local item itm = GetManipulatedItem()
call TriggerSleepAction(1)
call AddItemRot (itm, 0)
set itm = null
endfunction
//===========================================================================
function InitTrig_Unit_Drop_Item takes nothing returns nothing
set gg_trg_Unit_Drop_Item = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Drop_Item, EVENT_PLAYER_UNIT_DROP_ITEM )
call TriggerAddAction( gg_trg_Unit_Drop_Item, function Trig_Untitled_Trigger_001_Actions )
endfunction
function Trig_Periodic_camera_lock_Actions takes nothing returns nothing
local integer i = 1
local integer pl
loop
exitwhen i > udg_Cam_Index
set pl = udg_Cam_Pl[i]
if udg_Camera_Lock[pl] > 0 then
if (GetLocalPlayer() == Player(pl - 1)) then
call CameraSetupApplyForceDuration(udg_Cam2, true, 0.00)
call CameraSetupApplyForceDuration(udg_Cam1, true, 1.00)
endif
endif
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_Periodic_camera_lock takes nothing returns nothing
set gg_trg_Periodic_camera_lock = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Periodic_camera_lock, 0.03 )
call TriggerAddAction( gg_trg_Periodic_camera_lock, function Trig_Periodic_camera_lock_Actions )
endfunction
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' and GetHeroLevel(u) < MAX_HERO_LEVEL() 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
set a = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
if a < MAX_GOLD() then
if a + gold > MAX_GOLD() then
set gold = MAX_GOLD() - a
endif
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
else
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "|cffffaaaaWarning|r |cffffff00Max gold limit reached, can't reicive more gold!|r")
endif
set a = 0
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 ItIsStackingType (itm) 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 ItIsStackingItems (itm, itm2) 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
if HaveSavedHandle(udg_CItem_Table, GetHandleId(itm), 100) then
call FlushChildHashtable(udg_CItem_Table, GetHandleId(itm))
endif
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 ItIsStackingItems (itm, itm2) 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
if HaveSavedHandle(udg_CItem_Table, i, 100) then
call FlushChildHashtable(udg_CItem_Table, i)
endif
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 |cffffff00" + 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
function Trig_AddBuffToTest_Actions takes nothing returns nothing
local integer bt = S2I(GetEventPlayerChatString())
local integer dur = 15
local integer eff = 0
local integer perc = 0
local integer bv = GetRandomInt (-99, 99)
local unit u = udg_Hero[GetPlayerId(GetTriggerPlayer())+1]
call AddUnitBuff (u, bt, bv, dur, eff, perc)
set u = null
endfunction
//===========================================================================
function InitTrig_AddBuffToTest takes nothing returns nothing
set gg_trg_AddBuffToTest = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_AddBuffToTest, Player(0), "", true )
call TriggerAddAction( gg_trg_AddBuffToTest, function Trig_AddBuffToTest_Actions )
endfunction
function Trig_Inventory_sensivility_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local integer pl = GetPlayerId(p)+1
if udg_Inv_Sens[pl] then
set udg_Inv_Sens[pl] = false
call DisplayTextToPlayer(p, 0, 0, "Inventory sensibility: |cffffff00 Off |r")
else
set udg_Inv_Sens[pl] = true
call DisplayTextToPlayer(p, 0, 0, "Inventory sensibility: |cffffff00 On |r")
endif
set p = null
endfunction
//===========================================================================
function InitTrig_Inventory_sensivility takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i > 11
call TriggerRegisterPlayerChatEvent( t, Player(i), "-inv sens", true )
set i = i + 1
endloop
call TriggerAddAction( t, function Trig_Inventory_sensivility_Actions )
set t = null
endfunction
function Trig_ESC_destroy_MB_Actions takes nothing returns nothing
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
if udg_Camera_Lock[pl] > 0 then
if udg_Inv_Prev[pl] == 0 then
if udg_Camera_Lock[pl] > 0 then
call WindowTransition (pl, udg_Camera_Lock[pl], 0)
endif
elseif udg_Inv_Prev[pl] != udg_Camera_Lock[pl] then
call WindowTransition(pl, udg_Camera_Lock[pl], udg_Inv_Prev[pl])
else
call WindowTransition (pl, udg_Camera_Lock[pl], 0)
endif
else
//nothing
endif
if udg_Mb_Type[pl] > 0 then
call DestroyMultiboard(udg_Mb_Table[pl])
set udg_Mb_Table[pl] = null
set udg_Mb_Type[pl] = 0
elseif udg_Camera_Lock[pl] == 0 then
set udg_Mb_Table[pl] = CreateMultiboard()
set udg_Mb_Type[pl] = 3
call MultiboardSetRowCount(udg_Mb_Table[pl], 0)
call MultiboardSetColumnCount(udg_Mb_Table[pl], 0)
call MultiboardSetTitleText(udg_Mb_Table[pl], "Time board")
call MultiboardSetTitleTextColor(udg_Mb_Table[pl], 100, 100, 250, 255)
call MultiboardMinimize(udg_Mb_Table[pl], false)
call MultiboardDisplay( udg_Mb_Table[pl], false )
if GetLocalPlayer() == Player(pl - 1) then
call MultiboardDisplay( udg_Mb_Table[pl], true )
endif
endif
endfunction
//===========================================================================
function InitTrig_ESC_close_window_and_destroy_MB takes nothing returns nothing
set gg_trg_ESC_close_window_and_destroy_MB = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(0) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(1) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(2) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(3) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(4) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(5) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(6) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(7) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(8) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(9) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(10) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(11) )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_ESC_close_window_and_destroy_MB, Player(12) )
call TriggerAddAction( gg_trg_ESC_close_window_and_destroy_MB, function Trig_ESC_destroy_MB_Actions )
endfunction
function Mb_Arrow_Down takes nothing returns boolean
local integer RRPPL = 100 //reserved row per player
local integer sh = 2 //shift because 0 is counter, 1 is title so start from 2
local integer RPP = 29 //row limit per page
local integer pl = GetPlayerId(GetTriggerPlayer())+1
local integer a = (pl - 1) * RRPPL + 1 * (RPP+sh) //that index hold how much text is in 2nd page
if udg_Mb_Type[pl] == 1 and udg_Mb_Table[pl] != null and S2I(udg_Mb_Row[a]) > 2 then
call Mb_Pager(pl, 2)
endif
return false
endfunction
function Mb_Arrow_Up takes nothing returns boolean
local integer pl = GetPlayerId(GetTriggerPlayer())+1
if udg_Mb_Type[pl] == 1 and udg_Mb_Table[pl] != null then
call Mb_Pager(pl, 1)
endif
return false
endfunction
//===========================================================================
function InitTrig_MultiboardArrowUpDown takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i == 12
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
call TriggerAddCondition( t, Condition( function Mb_Arrow_Down ) )
set i = i + 1
endloop
set t = CreateTrigger()
set i = 0
loop
exitwhen i == 12
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
call TriggerAddCondition( t, Condition( function Mb_Arrow_Up ) )
set i = i + 1
endloop
set t = null
endfunction
function HarvestFT takes unit u returns nothing
local integer cv = GetUnitUserData(u)
local texttag tt = null
local integer t = R2I(LoadInteger(udg_Stat_Table, 8981, cv) * 100 / LoadInteger(udg_Stat_Table, 8982, cv))
local real x = LoadReal(udg_Stat_Table, 8985, cv) - 8
local real y = LoadReal(udg_Stat_Table, 8986, cv)
if t > 9 then
set x = x - 8
endif
call DestroyTextTag (LoadTextTagHandle(udg_Stat_Table, 8984, cv))
call SaveTextTagHandle(udg_Stat_Table, 8984, cv, tt)
if LoadInteger(udg_Stat_Table, 8980, cv) == 1 then
if GetLocalPlayer() == GetOwningPlayer(u) then
set tt = CreateTextTag( )
call SetTextTagText( tt, I2S(t) + "%", 1 * 0.023 )
call SetTextTagPos( tt, x, y, 100.00 )
call SetTextTagColor( tt, 255, 255, 0, 100 )
call SetTextTagPermanent( tt, true )
endif
call SaveTextTagHandle(udg_Stat_Table, 8984, cv, tt)
endif
set tt = null
endfunction
function Trig_Start_Harvest_Actions takes nothing returns nothing
local integer ilv
local item itm = GetOrderTargetItem()
local unit u = GetOrderedUnit()
local unit ut = GetOrderTargetUnit()
local integer cv = GetUnitUserData(u)
local integer i
local integer n
local integer pl
local real minRange = MIN_RANGE()
local real r
if GetPlayerController(GetTriggerPlayer()) == MAP_CONTROL_USER then
set pl = GetPlayerId(GetOwningPlayer(u)) + 1
if itm != null then
set ilv = GetItemLevel(itm)
set r = (GetUnitX(u)-GetItemX(itm))*(GetUnitX(u)-GetItemX(itm))+(GetUnitY(u)-GetItemY(itm))*(GetUnitY(u)-GetItemY(itm))
if r < minRange then
if (itm != udg_Item_Last[pl] and udg_Item_Last[pl] != null) then
set r = GetUnitFacing(u)
call IssuePointOrder (u, "move", GetUnitX(u), GetUnitY(u))
call SetUnitFacing(u, r)
endif
endif
if itm != udg_Item_Last[pl] then
call Mb_Item_ToolTip (itm, cv, 0)
endif
if (itm == udg_Item_Last[pl] and udg_Item_Last[pl] != null) or (ilv > 1200 and ilv < 1203) or GetItemTypeId(itm) == 'gold' then
if ilv > 1200 and ilv < 1203 and GetItemUserData(itm) == 0 then
call IssueImmediateOrder( u, "stop" )
if GetIssuedOrderId() == OrderId("smart") then
if LoadTextTagHandle(udg_Stat_Table, 8984, cv) != null then
call DestroyTextTag (LoadTextTagHandle(udg_Stat_Table, 8984, cv))
call RemoveSavedHandle(udg_Stat_Table, 8984, cv)
endif
set i = LoadInteger(udg_Stat_Table, 8989, GetHandleId(itm))
if LoadItemHandle(udg_Stat_Table, 8983, cv) != null then
if cv == i then
call SaveInteger(udg_Stat_Table, 8989, GetHandleId(LoadItemHandle(udg_Stat_Table, 8983, cv)), 0)
set i = 0
endif
call DestroyTextTag(LoadTextTagHandle(udg_Stat_Table, 9984, cv))
call SaveTextTagHandle(udg_Stat_Table, 8984, cv, null)
call SaveItemHandle(udg_Stat_Table, 8983, cv, null)
endif
if LoadInteger(udg_Stat_Table, 8987, cv) != 0 or LoadInteger(udg_Stat_Table, 8980, cv) == 1 then
call SaveInteger(udg_Stat_Table, 8980, cv, 0)
call SaveInteger(udg_Stat_Table, 8981, cv, -1)
call SaveInteger(udg_Stat_Table, 8982, cv, 0)
call SaveReal(udg_Stat_Table, 8985, cv, 0)
call SaveReal(udg_Stat_Table, 8986, cv, 0)
if LoadInteger(udg_Stat_Table, 8987, cv) != 0 then
set udg_H_U[LoadInteger(udg_Stat_Table, 8987, cv)] = udg_H_U[udg_H_I]
call SaveInteger(udg_Stat_Table, 8987, cv, 0)
set udg_H_I = udg_H_I - 1
endif
endif
if i == 0 then
set udg_H_I = udg_H_I + 1
set udg_H_U[udg_H_I] = u
if ilv == 1201 then
set n = 80 - R2I((GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 1), true) + GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 2), true) + GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 3), true)) / 3.00 * 4)
else
set n = 60 - (GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 4), true) * 4)
endif
call SaveInteger(udg_Stat_Table, 8980, cv, 1)
call SaveInteger(udg_Stat_Table, 8981, cv, - 1)
call SaveInteger(udg_Stat_Table, 8982, cv, n)
call SaveItemHandle(udg_Stat_Table, 8983, cv, itm)
call SaveTextTagHandle(udg_Stat_Table, 8984, cv, null)
call SaveReal(udg_Stat_Table, 8985, cv, GetItemX(itm))
call SaveReal(udg_Stat_Table, 8986, cv, GetItemY(itm))
call SaveInteger(udg_Stat_Table, 8987, cv, udg_H_I)
call SaveInteger(udg_Stat_Table, 8989, GetHandleId(itm), cv)
call IssuePointOrder (u, "unloadall", GetItemX(itm), GetItemY(itm))
if udg_H_I == 1 then
call EnableTrigger( gg_trg_Harvester_Timer )
endif
else
call IssuePointOrder (u, "move", GetItemX(itm), GetItemY(itm))
endif
endif
endif
endif
set udg_Item_Last[pl] = itm
else
set udg_Item_Last[pl] = null
if ut != null then
if not IsUnitType(ut, UNIT_TYPE_STRUCTURE) and LoadBoolean(udg_FSS, 551, 100 + pl) then
if GetUnitTypeId(ut) == 'h004' and IsUnitType(u, UNIT_TYPE_HERO) then
//call IssueImmediateOrder( u, "stop" )
//call IssueTargetOrder( u, "repair", ut )
elseif GetOwningPlayer(u) != GetOwningPlayer(ut) then
if udg_Unit_Last[pl] != ut then
if udg_Mb_Type[pl] == 0 then
call scaning (u, ut, GetTriggerPlayer())
set udg_Scan_Player[pl] = 1
set udg_Scan_Unit[pl] = u
set udg_Scan_Target[pl] = ut
else
call DestroyMultiboard(udg_Mb_Table[pl])
set udg_Mb_Type[pl] = 0
call scaning (u, ut, GetTriggerPlayer())
set udg_Scan_Player[pl] = 1
set udg_Scan_Unit[pl] = u
set udg_Scan_Target[pl] = ut
endif
set udg_Unit_Last[pl] = ut
set r = GetUnitFacing(u)
if IsUnitType(u, UNIT_TYPE_RANGED_ATTACKER) then
call IssuePointOrder (u, "move", GetUnitX(u), GetUnitY(u))
call SetUnitFacing(u, r)
endif
endif
endif
endif
else
set udg_Unit_Last[pl] = null
endif
endif
endif
set itm = null
set u = null
set ut = null
endfunction
//===========================================================================
function InitTrig_Start_Harvest_and_Item_Scan takes nothing returns nothing
set gg_trg_Start_Harvest_and_Item_Scan = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Start_Harvest_and_Item_Scan, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddAction( gg_trg_Start_Harvest_and_Item_Scan, function Trig_Start_Harvest_Actions )
endfunction
function Trig_Start_Harvest_ability_Conditions takes nothing returns boolean
if GetSpellAbilityId() == HARVEST_ID() then
call SaveInteger(udg_Stat_Table, 8981, GetUnitUserData(GetTriggerUnit()), 0)
endif
return false
endfunction
//===========================================================================
function InitTrig_Start_Harvest_ability takes nothing returns nothing
set gg_trg_Start_Harvest_ability = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Start_Harvest_ability, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Start_Harvest_ability, Condition( function Trig_Start_Harvest_ability_Conditions ) )
endfunction
function Trig_Harvester_Timer_Actions takes nothing returns nothing
local integer i = 1
local integer d
local integer cv
local integer harvesting_speed = 3 //1=slow, 10=fast
local integer ch //current harvest amount
local integer mh // maximum harvest amount
loop
exitwhen i > udg_H_I
set d = 0
if GetWidgetLife(udg_H_U[i]) < 0.2 then
set d = 1
endif
if OrderId2String(GetUnitCurrentOrder(udg_H_U[i])) != "unloadall" then
set d = 1
endif
set cv = GetUnitUserData(udg_H_U[i])
if LoadItemHandle(udg_Stat_Table, 8983, cv) == null then
set d = 1
endif
//LoadInteger(udg_Stat_Table, 8981, cv) = harvest progress on item
//LoadInteger(udg_Stat_Table, 8982, cv) = maximum harvest amount, if above line reach this limit then item harvested
set ch = LoadInteger(udg_Stat_Table, 8981, cv)
set mh = LoadInteger(udg_Stat_Table, 8982, cv)
if ch >= mh and d == 0 then
set d = 2
endif
if d == 0 then
if ch > - 1 and ch < mh then
set harvesting_speed = harvesting_speed + (GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 1),true)+GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 2),true)+GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 3),true)+GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 4),true))/5
call SaveInteger(udg_Stat_Table, 8981, cv, ch + harvesting_speed)
if ch + harvesting_speed < mh then
call SaveInteger(udg_Stat_Table, 8981, cv, ch + harvesting_speed)
else
call SaveInteger(udg_Stat_Table, 8981, cv, mh)
endif
call HarvestFT(udg_H_U[i])
endif
else
if d == 2 then
call IssueImmediateOrder( udg_H_U[i], "stop" )
call SetItemUserData(LoadItemHandle(udg_Stat_Table, 8983, cv), 1)
call UnitAddItem(udg_H_U[i], LoadItemHandle(udg_Stat_Table, 8983, cv))
endif
if udg_H_I == i then
set udg_H_U[i] = null
else
set udg_H_U[i] = udg_H_U[udg_H_I]
endif
set udg_H_I = udg_H_I - 1
if LoadItemHandle(udg_Stat_Table, 8983, cv) != null then
call SaveInteger(udg_Stat_Table, 8989, GetHandleId(LoadItemHandle(udg_Stat_Table, 8983, cv)), 0)
endif
call SaveInteger(udg_Stat_Table, 8980, cv, 0)
call SaveInteger(udg_Stat_Table, 8981, cv, 0)
call SaveInteger(udg_Stat_Table, 8982, cv, 0)
call SaveItemHandle(udg_Stat_Table, 8983, cv, null)
call SaveReal(udg_Stat_Table, 8985, cv, 0)
call SaveReal(udg_Stat_Table, 8986, cv, 0)
call DestroyTextTag (LoadTextTagHandle(udg_Stat_Table, 8984, cv))
call RemoveSavedHandle(udg_Stat_Table, 8984, cv)
call SaveInteger(udg_Stat_Table, 8987, cv, 0)
endif
set i = i + 1
endloop
if udg_H_I == 0 then
call DisableTrigger( gg_trg_Harvester_Timer )
endif
endfunction
//===========================================================================
function InitTrig_Harvester_Timer takes nothing returns nothing
set gg_trg_Harvester_Timer = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Harvester_Timer, 0.50 )
call TriggerAddAction( gg_trg_Harvester_Timer, function Trig_Harvester_Timer_Actions )
endfunction
function Trig_Scan_Actions takes nothing returns nothing
call SaveBoolean(udg_FSS, 551, 100 + GetPlayerId(GetTriggerPlayer())+1, true)
endfunction
//===========================================================================
function InitTrig_Scan takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i > 11
call TriggerRegisterPlayerChatEvent( t, Player(i), "-scan", true )
set i = i + 1
endloop
call TriggerAddAction( t, function Trig_Scan_Actions )
set t = null
endfunction
function Trig_Scan_timer_Actions takes nothing returns nothing
local integer i = 1
local integer a = 0
loop
exitwhen i > 12
if udg_Scan_Player[i] == 1 then
set a = a + 1
if GetWidgetLife(udg_Scan_Unit[udg_Scan_Player[i]]) > 0.2 and GetWidgetLife(udg_Scan_Target[udg_Scan_Player[i]]) > 0.2 and udg_Mb_Type[udg_Scan_Player[i]] == 2 and udg_Mb_Table[udg_Scan_Player[i]] != null then
call UpdateMb (udg_Mb_Table[udg_Scan_Player[i]], 3, 1, "|cffffff00" + I2S(R2I(GetWidgetLife(udg_Scan_Target[udg_Scan_Player[i]]))) + "|r / |cffff3300" + I2S(R2I(GetUnitState(udg_Scan_Target[udg_Scan_Player[i]], UNIT_STATE_MAX_LIFE))) + "|r")
else
set udg_Scan_Unit[udg_Scan_Player[i]] = null
set udg_Scan_Target[udg_Scan_Player[i]] = null
call DestroyMultiboard(udg_Mb_Table[udg_Scan_Player[i]])
set udg_Mb_Table[udg_Scan_Player[i]] = null
set udg_Mb_Type[udg_Scan_Player[i]] = 0
set udg_Scan_Player[i] = 0
endif
if a == 0 then
call DisableTrigger( GetTriggeringTrigger() )
endif
endif
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_Scan_timer takes nothing returns nothing
set gg_trg_Scan_timer = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Scan_timer, 0.50 )
call TriggerAddAction( gg_trg_Scan_timer, function Trig_Scan_timer_Actions )
endfunction
function AddZero takes integer i returns string
if i < 10 then
return "0" + I2S(i)
else
return I2S(i)
endif
endfunction
function Trig_Global_1sec_Timer_Actions takes nothing returns nothing
local integer i = 1
local integer cv
local integer bt // buff type
local integer bc // buff count
local integer tl // second left from timer
local integer bv // buff value
local integer b // just a number
//call DisplayTextToForce( GetPlayersAll(), "out max:"+I2S(udg_OT_Max)+" i:"+I2S(i)+" timer"+I2S(udg_OT_Timer[i]) )
set udg_Time_Sec = udg_Time_Sec + 1
if udg_Time_Sec == 60 then
set udg_Time_Sec = 0
set udg_Time_Min = udg_Time_Min + 1
if udg_Time_Min == 60 then
set udg_Time_Min = 0
set udg_Time_Hour = udg_Time_Hour + 1
endif
endif
loop
exitwhen i > 12
if udg_Mb_Type[i] == 3 then
call MultiboardSetTitleText(udg_Mb_Table[i], "Timer: " + AddZero(udg_Time_Hour) + ":" + AddZero(udg_Time_Min) + ":" + AddZero(udg_Time_Sec))
endif
set i = i + 1
endloop
//---------------------------------------------------
// buff timer part
//---------------------------------------------------
set i = 1
if udg_Buff_Max > 0 then
loop
exitwhen i > udg_Buff_Max
set cv = udg_Buff_List[i]
set b = 36000 + udg_Buff_List[i]
if GetWidgetLife(udg_UDexUnits[cv]) > 0.3 then
set bc = 1
loop
exitwhen bc > udg_Buff_Count[cv]
set bt = LoadInteger(udg_Stat_Table, b, bc)
set bv = LoadInteger(udg_Stat_Table, - b, - bt)
set tl = LoadInteger(udg_Stat_Table, b, - bt) - 1
if tl < 1 or udg_Buff_Purge[cv] == 3 or (udg_Buff_Purge[cv] == 1 and bv > 0) or (udg_Buff_Purge[cv] == 2 and bv < 0) then
//call DisplayTextToForce( GetPlayersAll(), "|cffffff00"+GetUnitName(udg_UDexUnits[cv]) + ":|r buff type |cff0000ff" + I2S(bt) + ", buffs on unit " + I2S(udg_Buff_Count[cv]) + ", current buff is:" + I2S(bc)+" buff amount "+I2S(bv) + " expired or removed|r" )
set bc = RemoveUnitBuff(cv, bc)
else
call SaveInteger(udg_Stat_Table, b, - bt, tl)
//call DisplayTextToForce( GetPlayersAll(), "|cffffff00"+GetUnitName(udg_UDexUnits[cv]) + ":|r buff type |cffaaaaff" + I2S(bt) + "|r " + ", buffs on unit "+ I2S(udg_Buff_Count[cv]) +" buff amount " + I2S(bc) + " buff value "+I2S(bv)+ ", left |cffff4444" + I2S(tl) + "|r second" )
endif
set bc = bc + 1
endloop
set udg_Buff_Purge[cv] = 0 //set purge off to unit
if udg_Buff_Count[cv] == 0 then
//call DisplayTextToForce( GetPlayersAll(), "|cffffff00"+GetUnitName(udg_UDexUnits[cv]) + ":|r all buff expired" )
if i != udg_Buff_Max then
set udg_Buff_List[i] = udg_Buff_List[udg_Buff_Max]
endif
set udg_Buff_List[udg_Buff_Max] = 0
set udg_Buff_Max = udg_Buff_Max - 1
set bc = - 1
endif
else
//call DisplayTextToForce( GetPlayersAll(), "|cffffff00"+GetUnitName(udg_UDexUnits[cv]) + ":|r i am died, lost all buff")
call RemoveUnitBuffs(i)
set udg_Buff_Max = udg_Buff_Max - 1
if udg_Buff_Max == 0 then
//call DisplayTextToForce( GetPlayersAll(), "dont have any buffed unit" )
endif
endif
set i = i + 1
endloop
endif
//---------------------------------------------------
// combat timer part
//---------------------------------------------------
//I2CV -> index to custom value
if udg_CombatIndex > 0 then
set i = 1
loop
exitwhen i > udg_CombatIndex
set cv = udg_CombatI2CV[i]
set udg_CombatTimer[cv] = udg_CombatTimer[cv] - 1
if udg_CombatTimer[cv] < 1 then
set udg_CombatTimer[cv] = 0
call StatRefresh (cv)
set cv = GetPlayerId(GetOwningPlayer(udg_UDexUnits[cv])) + 1
if udg_Camera_Lock[cv] == 1 then
call ShowStat (cv)
endif
if i != udg_CombatIndex then
set udg_CombatI2CV[i] = udg_CombatI2CV[udg_CombatIndex]
set udg_CombatTimer[udg_CombatI2CV[i]] = udg_CombatTimer[udg_CombatI2CV[udg_CombatIndex]]
endif
set udg_CombatIndex = udg_CombatIndex - 1
set i = i - 1
endif
set i = i + 1
endloop
endif
//---------------------------------------------------
// over time things like Dot and regen stuffs
//---------------------------------------------------
if udg_OT_Max > 0 then
set i = 1
loop
exitwhen i > udg_OT_Max
if GetWidgetLife(udg_OT_Source[i]) > 0.4 and GetWidgetLife(udg_OT_Target[i]) > 0.4 and udg_OT_Timer[i] > 0 then
//call DisplayTextToForce( GetPlayersAll(), "max:"+I2S(udg_OT_Max)+" i:"+I2S(i)+" timer"+I2S(udg_OT_Timer[i]) )
set udg_OT_Timer[i] = udg_OT_Timer[i] - 1
if udg_OT_Type[i] < 0 then
if udg_OT_Type[i] == - 1 then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", udg_OT_Source[i], "origin"))
call SetWidgetLife(udg_OT_Source[i], GetWidgetLife(udg_OT_Source[i]) + udg_OT_Value[i])
elseif udg_OT_Type[i] == - 2 then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\ReplenishMana\\SpiritTouchTarget.mdl", udg_OT_Source[i], "origin"))
call SetUnitState(udg_OT_Source[i], UNIT_STATE_MANA, GetUnitState(udg_OT_Source[i], UNIT_STATE_MANA) + udg_OT_Value[i])
endif
else
//set udg_DamageEventType = udg_OT_Type[i]
//set udg_DamageTypeDOT = 1
set udg_PDD_magicType = udg_OT_Type[i]+100
call UnitDamageTarget(udg_OT_Source[i], udg_OT_Target[i], udg_OT_Value[i], true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\shadowstrike\\shadowstrike.mdl", udg_OT_Target[i], "overhead"))
endif
else
if i != udg_OT_Max then
set udg_OT_Source[i] = udg_OT_Source[udg_OT_Max]
set udg_OT_Target[i] = udg_OT_Target[udg_OT_Max]
set udg_OT_Type[i] = udg_OT_Type[udg_OT_Max]
set udg_OT_Value[i] = udg_OT_Value[udg_OT_Max]
set udg_OT_Timer[i] = udg_OT_Timer[udg_OT_Max]
endif
set udg_OT_Source[udg_OT_Max] = null
set udg_OT_Target[udg_OT_Max] = null
set udg_OT_Max = udg_OT_Max - 1
set i = i - 1
endif
set i = i + 1
endloop
endif
endfunction
//===========================================================================
function InitTrig_Global_1sec_Timer takes nothing returns nothing
set gg_trg_Global_1sec_Timer = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Global_1sec_Timer, 1.00 )
call TriggerAddAction( gg_trg_Global_1sec_Timer, function Trig_Global_1sec_Timer_Actions )
endfunction
function Trig_Hero_Stat_Point_Conditions takes nothing returns boolean
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
local integer cv = GetUnitUserData(GetLevelingUnit())
set udg_Stat_Point[cv] = udg_Stat_Point[cv] + STAT_PER_LV()
if udg_Camera_Lock[pl] == 1 and udg_Trader[pl] == 0 then
call ShowStat(pl)
endif
return false
endfunction
function AddStatEquipmentToHero takes unit u returns nothing
local integer class = LoadInteger(udg_FSS, 633, GetUnitTypeId(u))
local integer rnd
local integer w = 1
local item itm
if class == 0 then
set rnd = GetRandomInt(1, 3)
elseif class == 1 or class == 2 then
set rnd = 1
elseif class == 3 or class == 4 then
set rnd = 2
elseif class == 5 then
set rnd = 3
endif
if rnd == 1 then
if class == 1 then
set w = 3
else
loop
exitwhen w != 3
set w = GetRandomInt(1, 5)
endloop
endif
set itm = CreateItem('I00G',0,0)
call SetItemCharges(itm, 98)
call UnitAddItem(u, itm)
set itm = CreateItem('I00M',0,0)
call SetItemCharges(itm, 98)
call UnitAddItem(u, itm)
set itm = CreateItem('I00H',0,0)
call SetItemCharges(itm, 98)
call UnitAddItem(u, itm)
set itm = null
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (3, w, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
//call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (3, w, 2, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 2), 100))
if w < 3 then
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (5, 1, 2, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 2), 100))
endif
elseif rnd == 2 then
if class == 3 then
set w = 6
else
set w = 7
endif
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (3, w, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
//call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (3, w, 2, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 2), 100))
elseif rnd == 3 then
set w = GetRandomInt(7, 8)
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (3, w, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
// call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (3, w, 2, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 2), 100))
endif
//call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (1, rnd, 2, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 2), 100))
//call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (2, rnd, 2, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 2), 100))
//call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (4, rnd, 2, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 2), 100))
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (1, rnd, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (2, rnd, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
// call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (3, rnd, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (4, rnd, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (6, rnd, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (6, rnd, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
call UnitAddItem(u, LoadItemHandle(udg_CItem_Table, GenerateEQ (8, rnd, 6, GetHeroLevel(u), GetHeroLevel(u), GetUnitX(u), GetUnitY(u), true, 6), 100))
set itm = LoadItemHandle(udg_CItem_Table,CreateSocketGem(1,GetUnitX(u), GetUnitY(u)),100)
call SetItemCharges(itm, 98)
call UnitAddItem(u, itm)
set itm = CreateItem('I000',0,0)
call SetItemCharges(itm, 98)
call UnitAddItem(u, itm)
set itm = null
//add bag
call UnitAddItem(u, CreateItem('I00U', GetUnitX(u), GetUnitY(u)))
endfunction
function TestStuff2Hero takes unit u returns nothing
local integer cv
local integer i = GetPlayerId(GetOwningPlayer(u)) + 1
local integer StartLevel = 100
local integer utype = GetUnitTypeId(u)
local integer StartPoint = START_POINT() + (StartLevel-1)*5
call SelectUnitAddForPlayer( u, Player(i - 1) )
call SetHeroLevel( u, StartLevel, false )
call SetHeroStr(u,LoadInteger(udg_FSS, 636, utype), true)
call SetHeroAgi(u,LoadInteger(udg_FSS, 637, utype), true)
call SetHeroInt(u,LoadInteger(udg_FSS, 638, utype), true)
set cv = GetUnitUserData(u)
set udg_Stat_Point[cv] = StartPoint
call AddAbiltityStatPoint2Hero (u)
call AddStatEquipmentToHero (u)
endfunction
function MakeAllyFromPlayer takes integer p returns nothing
local integer i = 0
loop
exitwhen i > 11
if p != i then
call SetPlayerAlliance(Player(p), Player(i), ALLIANCE_PASSIVE, true)
endif
set i = i + 1
endloop
endfunction
function Trig_Create_Heroes_and_gold_for_test_Actions takes nothing returns nothing
local integer i = 1
local real x
local real y
local trigger t1 = CreateTrigger()
local unit u
local integer id
call TriggerAddCondition( t1, Condition( function Trig_Hero_Stat_Point_Conditions ) )
loop
exitwhen i > 12
if ( GetPlayerSlotState(Player(i - 1)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i - 1)) == MAP_CONTROL_USER ) then
set x = GetStartLocationX(i - 1)
set y = GetStartLocationY(i - 1)
set u = CreateUnit( Player(i - 1), 'H000', x, y, bj_UNIT_FACING )
call TriggerRegisterUnitEvent( t1, u, EVENT_UNIT_HERO_LEVEL )
set udg_Hero[i] = u
call TestStuff2Hero(u)
set u = CreateUnit( Player(i - 1), 'Hpal', x + 100, y, bj_UNIT_FACING )
call TriggerRegisterUnitEvent( t1, u, EVENT_UNIT_HERO_LEVEL )
call TestStuff2Hero(u)
set u = CreateUnit( Player(i - 1), 'Hvwd', x + 100, y + 100, bj_UNIT_FACING )
call TriggerRegisterUnitEvent( t1, u, EVENT_UNIT_HERO_LEVEL )
call TestStuff2Hero(u)
set u = CreateUnit( Player(i - 1), 'Hjai', x + 100, y + 200, bj_UNIT_FACING )
call TriggerRegisterUnitEvent( t1, u, EVENT_UNIT_HERO_LEVEL )
call TestStuff2Hero(u)
call TriggerRegisterPlayerChatEvent( gg_trg_Trade_Gold_amount, Player(i - 1), GetEventPlayerChatString(), true )
call SetPlayerState( Player(i - 1), PLAYER_STATE_RESOURCE_GOLD, 1000000 )
if GetLocalPlayer() == Player(i - 1) then
call ClearSelection()
endif
call MakeAllyFromPlayer(i - 1)
endif
call FlushFT_Stat(i)
set i = i + 1
endloop
set t1 = null
set u = null
call CWInterface()
call ShowTradeWindow()
endfunction
//===========================================================================
function InitTrig_Create_Heroes_and_gold_for_test_and_Lv_up_func takes nothing returns nothing
set gg_trg_Create_Heroes_and_gold_for_test_and_Lv_up_func = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Create_Heroes_and_gold_for_test_and_Lv_up_func, 1.00 )
call TriggerAddAction( gg_trg_Create_Heroes_and_gold_for_test_and_Lv_up_func, function Trig_Create_Heroes_and_gold_for_test_Actions )
endfunction
function Trig_Create_Dummy_Interface_Actions takes nothing returns nothing
local real x1 = LoadReal(udg_FSS, 0, 1)
local real y1 = LoadReal(udg_FSS, 0, 2)
local real x2 = x1 + 1152
local real y2 = y1 + 512
local real bz = 1
local integer i = R2I(x1)
local integer c = 0
local destructable d
local unit u
loop
exitwhen i > R2I(x2) + 64
set d = CreateDestructableZ('B017', i, y1 - 64, bz, 0, 1, 0)
call SaveDestructableHandle(udg_FSS, 1400, c, d)
set c = c + 1
set d = CreateDestructableZ('B017', i, y2 + 64, bz, 0, 1, 0)
call SaveDestructableHandle(udg_FSS, 1400, c, d)
set c = c + 1
set i = i + 196
endloop
set i = 0
set i = R2I(y1)
loop
exitwhen i > R2I(y2) + 64
set d = CreateDestructableZ('B018', x1 - 96, i + 32, bz, 0, 1, 0)
call SaveDestructableHandle(udg_FSS, 1400, c, d)
set c = c + 1
set d = CreateDestructableZ('B018', x2 + 96, i + 32, bz, 0, 1, 0)
call SaveDestructableHandle(udg_FSS, 1400, c, d)
set c = c + 1
set i = i + 196
endloop
set i = 0
set c = 0
loop
exitwhen i > 20
set u = CreateUnit(Player(15), 'nshe', GetRandomReal(x1 + 64, x2 - 64), GetRandomReal(y1 + 64, y2 - 64), GetRandomReal(0, 360))
call UnitAddAbility (u, 'Aloc')
call SaveUnitHandle(udg_FSS, 1401, c, u)
set c = c + 1
set i = i + 1
endloop
set u = CreateUnit(Player(15), 'nvlw', (x1 + x2) / 2, (y1 + y2) / 2, GetRandomReal(0, 360))
call UnitAddAbility (u, 'Aloc')
call SaveUnitHandle(udg_FSS, 1401, c, u)
set d = null
set u = null
endfunction
//===========================================================================
function InitTrig_Create_Fake_Interface takes nothing returns nothing
set gg_trg_Create_Fake_Interface = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Create_Fake_Interface, 2.00 )
call TriggerAddAction( gg_trg_Create_Fake_Interface, function Trig_Create_Dummy_Interface_Actions )
endfunction
function Trig_Trade_Gold_amount_Conditions takes nothing returns boolean
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
local integer tgold
local integer gold
if udg_Trader[pl] > 0 then
if LoadInteger(udg_FSS, 1275 + pl, 1) == 0 then
set gold = S2I(GetEventPlayerChatString())
if GetEventPlayerChatString() == I2S(gold) then
set tgold = LoadInteger(udg_FSS, 1250+pl,7) + GetPlayerState(Player(pl-1), PLAYER_STATE_RESOURCE_GOLD)
if tgold >= gold then
call SetPlayerState(Player(pl - 1), PLAYER_STATE_RESOURCE_GOLD, tgold - gold)
call SaveInteger(udg_FSS, 1250+pl,7, gold)
call SetTextTagText(LoadTextTagHandle(udg_FSS, 1250+pl,6), I2S(gold), 0.8 * 0.023)
endif
endif
call UpdateGoldinShop (pl)
endif
endif
return false
endfunction
//===========================================================================
function InitTrig_Trade_Gold_amount takes nothing returns nothing
set gg_trg_Trade_Gold_amount = CreateTrigger( )
call TriggerAddCondition( gg_trg_Trade_Gold_amount, Condition( function Trig_Trade_Gold_amount_Conditions ) )
endfunction
function Trig_Trade_Request_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00E'
endfunction
function Trig_Trade_Request_Actions takes nothing returns nothing
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local integer plt = GetPlayerId(GetOwningPlayer(t)) + 1
local dialog d = udg_Trade_Req_Dialog[1]
if udg_TradeReq[pl] == 0 and plt != pl then
call DialogClear( d )
call DialogSetMessage ( d, GetPlayerName(Player(pl - 1)) + " want trade")
set udg_Trade_Req_Button[pl] = DialogAddButton(d, "Accept", 0)
set udg_Trade_Req_Button[0] = DialogAddButton(d, "Cancel", 0)
call DialogDisplay(Player(plt - 1), d, true)
call SaveUnitHandle(udg_FSS, 0, - 150 - pl, u)
call SaveUnitHandle(udg_FSS, 0, - 150 - plt, t)
endif
set d = null
set t = null
set u = null
endfunction
//===========================================================================
function InitTrig_Trade_Request takes nothing returns nothing
set gg_trg_Trade_Request = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Trade_Request, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Trade_Request, Condition( function Trig_Trade_Request_Conditions ) )
call TriggerAddAction( gg_trg_Trade_Request, function Trig_Trade_Request_Actions )
endfunction
function Trig_Trade_Request_Response_Actions takes nothing returns nothing
local integer i = 0
local integer plt
local integer pl = GetPlayerId(GetTriggerPlayer()) + 1
local integer ok = 0
loop
exitwhen i > 12
if udg_Trade_Req_Button[i] == GetClickedButton() then
set plt = i
endif
set i = i + 1
endloop
if plt > 0 then
if udg_Camera_Lock[pl] == 0 or udg_Camera_Lock[pl] == 1 then
if udg_Trader[plt] == 0 and udg_Trader[pl] == 0 and (udg_Camera_Lock[plt] == 0 or udg_Camera_Lock[plt] == 1) then
set ok = 1
set udg_Trader[pl] = plt
set udg_Trader[plt] = pl
set udg_Inv_Unit[pl] = GetUnitUserData(LoadUnitHandle(udg_FSS, 0, - 150 - pl))
set udg_Inv_Unit[plt] = GetUnitUserData(LoadUnitHandle(udg_FSS, 0, - 150 - plt))
if udg_Camera_Lock[pl] > 0 then
call WindowTransition (pl, udg_Camera_Lock[pl], 0)
endif
if udg_Camera_Lock[plt] > 0 then
call WindowTransition (plt, udg_Camera_Lock[plt], 0)
endif
call TriggerSleepAction(0.5)
call EnableCamLock (pl, 1)
call EnableCamLock (plt, 1)
endif
endif
if ok == 0 then
set udg_TradeReq[pl] = 0
set udg_TradeReq[plt] = 0
call RemoveSavedHandle(udg_FSS, 0, - 150 - pl)
call RemoveSavedHandle(udg_FSS, 0, - 150 - plt)
call DisplayTextToPlayer(Player(plt - 1), 0, 0, "Trade with |cffffff00" + GetPlayerName(Player(pl - 1)) + ":|r failed.")
call DisplayTextToPlayer(Player(pl - 1), 0, 0, "Trade with |cffffff00" + GetPlayerName(Player(plt - 1)) + ":|r failed.")
endif
endif
set udg_TradeReq[plt] = 0
endfunction
//===========================================================================
function InitTrig_Trade_Request_Response takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[1] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[2] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[3] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[4] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[5] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[6] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[7] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[8] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[9] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[10] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[11] )
call TriggerRegisterDialogEvent( t, udg_Trade_Req_Dialog[12] )
call TriggerAddAction( t, function Trig_Trade_Request_Response_Actions )
set t = null
endfunction
function Indexing_Settings takes nothing returns boolean
local unit u = udg_UDexUnits[udg_UDex]
local integer lv
local integer pv
local integer prate = 1
local integer mrate = 1
local integer exprate = 1
local integer rnd
local integer cv = GetUnitUserData(u)
if GetPlayerController(GetOwningPlayer(u)) != MAP_CONTROL_USER and not IsUnitType(u, UNIT_TYPE_SUMMONED) then
//call BJDebugMsg(GetUnitName(u) + " 0=" + I2S(udg_UDex) + " pv:" + I2S(0))
set pv = GetUnitPointValue(u)
set rnd = GetRandomInt(0, 99)
call SaveReal(udg_Stat_Table, 8999, cv, GetUnitX(u))
call SaveReal(udg_Stat_Table, 8998, cv, GetUnitY(u))
call SaveReal(udg_Stat_Table, 8997, cv, GetUnitFacing(u))
set udg_Global_Crit[cv] = 1
if pv >= 50 and pv < 55 then
set mrate = 2
elseif pv == 100 then
set prate = 2
elseif pv == 75 then
set udg_Global_Crit[cv] = 15
endif
set udg_Global_DmgRed[cv] = 0
set udg_Global_LifeSteal[cv] = 0
set udg_Global_ManaSteal[cv] = 0
if ( IsUnitType(u, UNIT_TYPE_HERO)) then
set lv = GetHeroLevel(u)
call SaveInteger(udg_Stat_Table, 8996, cv, lv)
set udg_Global_Pdef[cv] = lv * lv * 3 * prate
set udg_Global_Mdef1[cv] = lv * lv * 3 * mrate
set udg_Global_Mdef2[cv] = lv * lv * 3 * mrate
set udg_Global_Mdef3[cv] = lv * lv * 3 * mrate
set udg_Global_Mdef4[cv] = lv * lv * 3 * mrate
set udg_Global_Mdef5[cv] = lv * lv * 3 * mrate
set udg_Global_Acc[cv] = lv * 300
set udg_Global_Eva[cv] = lv * 60
set udg_Global_Block[cv] = udg_Difficulty * 5 - 2
set udg_Global_DefLv[cv] = R2I((((udg_Difficulty - 1) * 10) / 10 + 1) * lv)
set udg_Global_Crit[cv] = udg_Global_Crit[cv] + R2I(lv / 20)
set udg_Global_DmgInc[cv] = lv * 3
set udg_Global_DmgRed[cv] = 50
set udg_Global_LifeSteal[cv] = R2I(lv / 10)
set exprate = 2
call SetUnitDrop (GetUnitTypeId(u), 110, 125, 5001, 125)
else
set lv = GetUnitLevel(u)
set udg_Global_Pdef[cv] = lv * lv * prate
set udg_Global_Mdef1[cv] = lv * lv * mrate
set udg_Global_Mdef2[cv] = lv * lv * mrate
set udg_Global_Mdef3[cv] = lv * lv * mrate
set udg_Global_Mdef4[cv] = lv * lv * mrate
set udg_Global_Mdef5[cv] = lv * lv * mrate
set udg_Global_Acc[cv] = lv * 100
set udg_Global_Eva[cv] = lv * 20
set udg_Global_Block[cv] = udg_Difficulty * 3 - 2
set udg_Global_DefLv[cv] = R2I((((udg_Difficulty - 1) * 10) / 10 + 1) * lv / 2)
set udg_Global_Crit[cv] = udg_Global_Crit[cv] + R2I(lv / 50)
set udg_Global_DmgInc[cv] = lv
call SetUnitDrop (GetUnitTypeId(u), 105, 101, 5000, 120)
endif
set udg_Global_AttLv[udg_UDex] = lv * 2 + udg_Difficulty * 25 - 25
if pv >= 50 and pv < 55 then
if pv == 50 then
set udg_Global_Mdef1[cv] = udg_Global_Mdef1[cv] * 2
set udg_Global_Mdef2[cv] = udg_Global_Mdef2[cv] / 2
elseif pv == 51 then
set udg_Global_Mdef2[cv] = udg_Global_Mdef2[cv] * 2
set udg_Global_Mdef5[cv] = udg_Global_Mdef5[cv] / 2
elseif pv == 52 then
set udg_Global_Mdef3[cv] = udg_Global_Mdef3[cv] * 2
set udg_Global_Mdef1[cv] = udg_Global_Mdef1[cv] / 2
elseif pv == 53 then
set udg_Global_Mdef4[cv] = udg_Global_Mdef4[cv] * 2
set udg_Global_Mdef3[cv] = udg_Global_Mdef3[cv] / 2
elseif pv == 54 then
set udg_Global_Mdef5[cv] = udg_Global_Mdef5[cv] * 2
set udg_Global_Mdef3[cv] = udg_Global_Mdef3[cv] / 2
endif
endif
if rnd < (10 * udg_Difficulty) then
if rnd == 0 then
set udg_Global_Pdef[cv] = udg_Global_Pdef[cv] * 3 / 5
elseif rnd == 1 then
set udg_Global_Mdef1[cv] = udg_Global_Mdef1[cv] * 3 / 5
set udg_Global_Mdef2[cv] = udg_Global_Mdef2[cv] * 3 / 5
set udg_Global_Mdef3[cv] = udg_Global_Mdef3[cv] * 3 / 5
set udg_Global_Mdef4[cv] = udg_Global_Mdef4[cv] * 3 / 5
set udg_Global_Mdef5[cv] = udg_Global_Mdef5[cv] * 3 / 5
elseif rnd == 2 then
set udg_Global_Crit[cv] = udg_Global_Crit[cv] + 10
elseif rnd == 3 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + 50
elseif rnd == 4 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + 100
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] - 50
elseif rnd == 5 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + 35
elseif rnd == 6 then
set udg_Global_LifeSteal[cv] = udg_Global_LifeSteal[cv] + 5
elseif rnd == 7 then
call SetUnitMoveSpeed (u, GetUnitMoveSpeed(u) + 75)
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] - 25
elseif rnd == 8 then
set udg_Global_LifeSteal[cv] = udg_Global_LifeSteal[cv] + 10
elseif rnd == 9 then
set udg_Global_Eva[cv] = udg_Global_Eva[cv] * 2
endif
set udg_Global_Exp[cv] = lv * 8 * exprate
else
set udg_Global_Exp[cv] = lv * 5 * exprate
endif
set u = null
endif
return false
endfunction
//===========================================================================
function InitTrig_Indexer_event takes nothing returns nothing
set gg_trg_Indexer_event = CreateTrigger( )
call TriggerRegisterVariableEvent( gg_trg_Indexer_event, "udg_UnitIndexEvent", EQUAL, 1.00 )
call TriggerAddCondition( gg_trg_Indexer_event, Condition( function Indexing_Settings ) )
endfunction
function CreateDrop takes unit u, unit k returns nothing
local integer ut = GetUnitTypeId(u)
local integer boss = 0
local integer lv = 0
local integer da = LoadInteger(udg_Drop_Table, ut, 701) //drop amount
local real dc = LoadReal(udg_Drop_Table, ut, 711) //drop chance
local integer di
local integer m = (udg_Difficulty / 2) + 1 //drop multiplier
local integer i = 0
local integer itemId
local real rnd
local item Gold
local integer cvk = GetUnitUserData(k)
local integer ic = 0//item drop count
local item array it // item array
if IsUnitType(u, UNIT_TYPE_HERO) then
set lv = GetHeroLevel(u)
else
set lv = GetUnitLevel(u)
endif
//---default drop---
loop
exitwhen i > da * m
set rnd = GetRandomReal(0, 99.9999)
if rnd < dc then
set itemId = GetDefaultDropItem(ut)
if itemId > 0 then
set ic = ic + 1
set it[ic] = CreateItem(itemId, GetUnitX(u), GetUnitY(u))
endif
endif
set i = i + 1
endloop
//---level depend drop---
set da = LoadInteger(udg_Drop_Table, ut, 703) //drop amount
set dc = LoadReal(udg_Drop_Table, ut, 713) //drop chance
set i = 0
if da == 0 then
set da = 3
set dc = 33
endif
loop
exitwhen i > da * m
set rnd = GetRandomReal(0, 99.9999)
if rnd < dc then
set itemId = GetLevelDropItem(lv / 20 + 1)
if itemId > 0 then
set ic = ic + 1
set it[ic] = CreateItem(itemId, GetUnitX(u), GetUnitY(u))
endif
endif
set i = i + 1
endloop
//---specific cat drop, work like level depend just you can add same category for more different level unit
// basic example add if u add same category for all murloc unit so this could be commun drop betrween murlocs
//but here we add same categroy for peasant+murloc+ogre
set da = LoadInteger(udg_Drop_Table, ut, 702) //drop amount
set di = LoadInteger(udg_Drop_Table, ut, 710) //drop amount
set dc = LoadReal(udg_Drop_Table, ut, 712) //drop chance
set i = 0
if da == 0 then
set da = 3
set dc = 33
endif
loop
exitwhen i > da * m
set rnd = GetRandomReal(0, 99.9999)
if rnd < dc then
set itemId = GetLevelDropItem(di)
if itemId > 0 then
set ic = ic + 1
set it[ic] = CreateItem(itemId, GetUnitX(u), GetUnitY(u))
endif
endif
set i = i + 1
endloop
set rnd = GetRandomReal(0, 99.9999)
if rnd < 35 and IsUnitType(u, UNIT_TYPE_HERO) then
call GenerateEQDrop (cvk, u)
endif
if rnd < 15 then
set ic = ic + 1
set Gold = CreateItem('gold', GetUnitX(u), GetUnitY(u))
set i = R2I(GetRandomInt(lv, lv * lv + 5) * ((100 + udg_Stat_Gold_Bonus[GetUnitUserData(k)]) / 100.00) * m)
call SetItemUserData(Gold, i)
set it[ic] = Gold
set Gold = null
elseif rnd < 22 then
call GenerateEQDrop (cvk, u)
endif
set i = 1
loop
exitwhen i > ic
call AddItemRot (it[i], GetPlayerId(GetOwningPlayer(k)) + 1)
call SetItemInvulnerable(it[i], true)
set it[i] = null
set i = i + 1
endloop
endfunction
function Revive_Hero takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit u = LoadUnitHandle(udg_Stat_Table, 8991, id)
local player p = GetOwningPlayer(u)
local integer pl = GetPlayerId(p) + 1
local integer cv = GetUnitUserData(u)
local integer w
call RemoveSavedHandle(udg_Stat_Table, 8991, id)
if GetPlayerController(p) != MAP_CONTROL_USER then
set pl = GetHeroLevel(u)
set w = GetUnitUserData(u)
if pl > LoadInteger(udg_Stat_Table, 8996, w) then
call UnitStripHeroLevel(u, pl-1)
call SetHeroLevel(u, LoadInteger(udg_Stat_Table, 8996, w), false)
endif
call ReviveHero(u, LoadReal(udg_Stat_Table, 8999, w), LoadReal(udg_Stat_Table, 8998, w), true)
else
call ReviveHero(u, GetUnitX(u), GetUnitY(u), true)
// we select the hero after he revived
if IsUnitSelected(u, p) then
if GetLocalPlayer() == p then
call ClearSelection()
call SelectUnit(u, true)
endif
endif
//--------------------------- here we must change to ranged if our hero was ranged before he died
if LoadBoolean(udg_FSS, 631, GetUnitTypeId(u)) then
set w = LoadInteger(udg_CItem_Table, GetHandleId(LoadItemHandle(udg_Stat_Table, cv, 3)), 3)
if ( w==6 ) then
if ( GetUnitTypeId( u ) == HERO_MELEE() ) then
call SetPlayerAbilityAvailable( p, MELEE2RANGED_ID(), true )
call IssueImmediateOrder( u, "metamorphosis" )
call SetPlayerAbilityAvailable( p, MELEE2RANGED_ID(), false )
endif
else
if ( GetUnitTypeId( u ) == HERO_RANGED() ) then
call SetPlayerAbilityAvailable( p, MELEE2RANGED_ID(), true )
call IssueImmediateOrder( u, "metamorphosis" )
call SetPlayerAbilityAvailable( p, MELEE2RANGED_ID(), false )
endif
endif
endif
endif
call PauseTimer(t)
call DestroyTimer(t)
set p = null
set u = null
set t = null
endfunction
function Revive_and_Respawn takes nothing returns nothing
local unit du = GetDyingUnit()
local unit ku = GetKillingUnit()
local integer dutype = GetUnitTypeId(du)
local integer dLv
local real x = GetUnitX(du)
local real y = GetUnitY(du)
local real ang = GetUnitFacing(du)
local player pd = GetOwningPlayer(du)
local player pk = GetOwningPlayer(ku)
local integer pld = GetPlayerId(pd) + 1
local integer plk = GetPlayerId(pk) + 1
local integer cvd = GetUnitUserData(du)
local integer cvk = GetUnitUserData(ku)
local integer exp
local integer boss = 0
local real rtime = 10 //respawn time
local timer t
set udg_CombatTimer[cvd] = 1
if GetPlayerController(pd) == MAP_CONTROL_USER then
if IsUnitType(du, UNIT_TYPE_HERO) then
if udg_Inv_Unit[pld] == cvd then
if udg_Camera_Lock[pld] > 0 then
if udg_Trader[pld] < 0 then
call WindowTransition (udg_Trader[pld], udg_Camera_Lock[udg_Trader[pld]], 0)
endif
call WindowTransition (pld, udg_Camera_Lock[pld], 0)
endif
endif
set t = CreateTimer()
call SaveUnitHandle(udg_Stat_Table, 8991, GetHandleId(t), du)
call TimerStart(t, 5, false, function Revive_Hero)
set t = null
endif
else
//get the dying unit lv
if not IsUnitType(du, UNIT_TYPE_HERO) then
set dLv = GetUnitLevel(du)
else
set dLv = GetHeroLevel(du)
set boss = 1
set t = CreateTimer()
call SaveUnitHandle(udg_Stat_Table, 8991, GetHandleId(t), du)
call TimerStart(t, rtime, false, function Revive_Hero)
set t = null
endif
//add exp
if GetPlayerController(pk) == MAP_CONTROL_USER and IsUnitType(ku, UNIT_TYPE_HERO) then
if MAX_HERO_LEVEL() > GetHeroLevel(ku) then
set exp = R2I((udg_Global_Exp[cvd] * ((100.00 + udg_Stat_Exp[cvk]) / 100.00)))
call SuspendHeroXP(ku, false)
call AddHeroXP(ku, exp, true)
call SuspendHeroXP(ku, true)
call FT_Ex (pk, pk, "+" + I2S(exp) + " exp", 2, du, 13, 0, 0, 255, 255, 90)
endif
if udg_Global_Hp4Kill[cvk] > 0 then
call SetWidgetLife(ku, GetWidgetLife(ku) + udg_Global_Hp4Kill[cvk])
endif
if udg_Global_Mp4Kill[cvk] > 0 then
call SetUnitState(ku, UNIT_STATE_MANA, GetUnitState(ku, UNIT_STATE_MANA) + udg_Global_Mp4Kill[cvk])
endif
endif
if not IsUnitType(du, UNIT_TYPE_SUMMONED) and not IsUnitType(du, UNIT_TYPE_HERO) then
call CreateDrop(du, ku)
call TriggerSleepAction(rtime)
call RemoveUnit(du)
call CreateUnit(pd, dutype, LoadReal(udg_Stat_Table, 8999, cvd), LoadReal(udg_Stat_Table, 8998, cvd), bj_RADTODEG * LoadReal(udg_Stat_Table, 8997, cvd))
endif
endif
set du = null
set ku = null
set pd = null
set pk = null
endfunction
//===========================================================================
function InitTrig_Revive_Respawn_Drop takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
set i = i + 1
exitwhen i == 15
endloop
call TriggerAddAction( t, function Revive_and_Respawn )
set t = null
endfunction
function Summon_Unit_Setup takes nothing returns nothing
local unit u1 = GetSummoningUnit()
local unit u2 = GetSummonedUnit()
local player p = GetOwningPlayer(u1)
local integer pv
local integer cv1 = GetUnitUserData(u1)
local integer cv2 = GetUnitUserData(u2)
local real prate = 0.5
local real mrate = 0.5
local real r //refine
local real g //grade
local real q //quality
local integer c
local integer array Id
local integer i
local integer lv
local real AccEva = 1
if GetPlayerController(p) == MAP_CONTROL_USER then
if IsUnitType(u1, UNIT_TYPE_HERO) then
set lv = GetHeroLevel(u1)
set pv = GetUnitPointValue(u2)
if pv >= 50 and pv < 55 then
set mrate = 1
elseif pv == 100 then
set prate = 1
elseif pv == 75 then
set AccEva = 1.5
endif
set udg_Global_Crit[cv2] = udg_Global_Crit[cv1]
set udg_Global_CritDmg[cv2] = udg_Global_CritDmg[cv1]
set udg_Global_AttLv[cv2] = udg_Global_AttLv[cv1]
set udg_Global_DefLv[cv2] = udg_Global_DefLv[cv1]
set udg_Global_Acc[cv2] = R2I((lv * 10 + 50) * AccEva)
set udg_Global_Eva[cv2] = R2I((lv * 7 + 35) * AccEva)
set udg_Global_Block[cv2] = udg_Global_Block[cv1]
set i = 0
set r = 0
set q = 0
set g = 0
set c = 0
//calculate the defence for unit
loop
set i = i + 1
exitwhen i == 9
set c = c + 1
if i == 3 or i == 5 then
set i = i + 1
endif
if HaveSavedHandle(udg_Stat_Table, cv1, i) then
set Id[i] = GetHandleId(LoadItemHandle(udg_Stat_Table, cv1, i))
if Id[i] != 0 then
set r = r + LoadInteger(udg_CItem_Table, Id[i], 16)
set q = q + LoadInteger(udg_CItem_Table, Id[i], 4) + 1
set g = g + LoadInteger(udg_CItem_Table, Id[i], 7)
endif
endif
endloop
// (quality +1)*6 ----(6 piece for caculate the armor)
set q = q / 48.00 + 1
set r = r / (MAX_REFINE() * 6.00) + 1
set g = g / 6
set udg_Global_DmgRed[cv2] = R2I(g * 0.25)
set udg_Global_Pdef[cv2] = R2I(g * g * prate * q * r)
set udg_Global_Mdef1[cv2] = R2I(g * g * mrate * q * r)
set udg_Global_Mdef2[cv2] = R2I(g * g * mrate * q * r)
set udg_Global_Mdef3[cv2] = R2I(g * g * mrate * q * r)
set udg_Global_Mdef4[cv2] = R2I(g * g * mrate * q * r)
set udg_Global_Mdef5[cv2] = R2I(g * g * mrate * q * r)
// ----- weapon checking and setting the dmg increase amount -----
if HaveSavedHandle(udg_Stat_Table, cv1, 3) then
set Id[3] = GetHandleId(LoadItemHandle(udg_Stat_Table, cv1, 3))
set r = LoadInteger(udg_CItem_Table, Id[3], 16) / MAX_REFINE() + 1
set q = (LoadInteger(udg_CItem_Table, Id[3], 4) + 1) / 8 + 1
set g = LoadInteger(udg_CItem_Table, Id[3], 7)
set udg_Global_DmgInc[cv2] = R2I(g * q * r)
endif
endif
endif
set p = null
set u1 = null
set u2 = null
endfunction
//===========================================================================
function InitTrig_Summon_unit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SUMMON, null)
call TriggerAddAction( t, function Summon_Unit_Setup )
set i = i + 1
exitwhen i == 16
endloop
set t = null
endfunction
function Trig_Create_Key_Actions takes nothing returns nothing
local integer i = 0
local integer i2 = 0
local integer l = StringLength(SL_CODE())
local location loc
local string array Key
local string s
local unit u
local integer MaxExp
local integer MaxLvExp
local integer MaxHeroLevel = MAX_HERO_LEVEL()
local integer a1 //lv
local integer a2 //exp
local integer a3 //str
local integer a4 //agi
local integer a5 //int
local integer a6 //gold
local integer a7 //lumber
local integer b1 = 0 //minimum lv code length
local integer b2 = 0 //minimum exp code length
local integer b3 = 1 //minimum str code length
local integer b4 = 1 //minimum agi code length
local integer b5 = 1 //minimum int code length
local integer b6 = 0 //minimum gold code length
local integer b7 = 0 //minimum lumber code length
local integer c1 = 2 //maximum lv code length
local integer c2 = 4 //maximum exp code length
local integer c3 = 2 //maximum str code length
local integer c4 = 2 //maximum agi code length
local integer c5 = 2 //maximum int code length
local integer c6 = 4 //maximum gold code length
local integer c7 = 4 //maximum lumber code length
local integer c2_1
set i = 0
loop
exitwhen i == l
set s = SubString(SL_CODE(), i, i + 1)
if s != StringCase(s, true) then
call SaveInteger(udg_SL_HASHTABLE, StringHash(s), 2, i)
else
call SaveInteger(udg_SL_HASHTABLE, StringHash(s), 1, i)
endif
//call SaveStr(h, 2, i, s)
set i = i + 1
endloop
set loc = GetStartLocationLoc(GetPlayerStartLocation(Player(0)))
set u = CreateUnit(Player(15), 'Hpal', GetLocationX(loc), GetLocationY(loc), 0)
call AddHeroXP(u, 2147483647, false)
set MaxExp = GetHeroXP(u)
set i = GetHeroLevel(u)
if i > 1 then
call UnitStripHeroLevel(u, - i)
call SetHeroLevel(u, i - 1, false)
endif
set MaxLvExp = MaxExp - GetHeroXP(u) - 1
call RemoveLocation(loc)
call RemoveUnit(u)
//checking if max gold could be lower code length than max
set i = 1
set c1 = SL_GetIntegerSize(MaxHeroLevel)
set c2 = SL_GetIntegerSize(MaxExp)
set c2_1 = SL_GetIntegerSize(MaxLvExp)
set c6 = SL_GetIntegerSize(MAX_GOLD())
set c7 = SL_GetIntegerSize(MAX_GOLD())
call DisplayTextToPlayer ( GetLocalPlayer(), 0, 0, "|cffffff00Notice:|r Loading save-load system done." )
set u = null
set loc = null
set s = null
endfunction
//===========================================================================
function InitTrig_Prepare_few_save_load_data takes nothing returns nothing
set gg_trg_Prepare_few_save_load_data = CreateTrigger( )
call TriggerAddAction( gg_trg_Prepare_few_save_load_data, function Trig_Create_Key_Actions )
endfunction
function BuildFinalCode takes nothing returns nothing
local integer i = 1
local integer l = StringLength(SL_CODE())//get the string length of the alphabet string
local integer MAX_CHAR = 100 //maximum character in row
local integer a1
local integer a2
local integer a3
local integer a4
local string s1
local string s2
local string s3
local timer t = GetExpiredTimer()
local integer tid = GetHandleId(t)
local unit u = LoadUnitHandle(udg_SL_HASHTABLE, 3, tid)
local integer cv = GetUnitUserData(u)
local string CODE = ""
local player p = LoadPlayerHandle(udg_SL_HASHTABLE, 10, tid)
local string HERO_NAME = GetHeroProperName(u)
local string HERO_LV = I2S(GetHeroLevel(u))
local string PATH = SL_FOLDER() + "\\" + HERO_NAME + " - " + HERO_LV + " by " + GetPlayerName(p) + ".txt"
local string array CODE_Row //line with eq codes
local integer CODE_Row_Count = 1 //count how much line needed for write down all equipment
local unit d //dummy unit
local location loc //just for location
local string Key ="" //this is a key for saveing lv, exp, stats into 1 character, we will search thsi string in VAR array for get a index
local integer id
local boolean SAVE_COORD = SL_SAVE_COORD()
local integer array PowL
local integer MinExp // that exp what was needed for your hero current level
local integer MaxExp // that exp what needed for your hero for level up
local integer CurExp // with how much exp hero passed the last level up
local integer CLASS // the hero unit type index in SL_HERO_TYPE array
local integer LV // hero level
local integer EXP // hero exp
local integer STR // hero strength
local integer AGI // hero agility
local integer INT // hero intelligence
local integer GOLD // player gold
local integer LUMBER // player lumber
local integer X // hero x coordinate
local integer Y // hero y coordinate
local integer COORD_LEN_X // how much character needed for save hero location
local integer COORD_LEN_Y // how much character needed for save hero location
local boolean ERROR = true
local integer MAX_X = R2I(GetRectMaxX(bj_mapInitialPlayableArea))//highest X coordinate on map
local integer MAX_Y = R2I(GetRectMaxY(bj_mapInitialPlayableArea))//highest Y coordinate on map
local integer MAX_HERO = LoadInteger(udg_SL_HASHTABLE, 2, 0)
// local integer MAX_VAR
local integer BLACKSMITH = LoadInteger(udg_Stat_Table, 27000 + cv, 1)
local integer TAILOR = LoadInteger(udg_Stat_Table, 27000 + cv, 2)
local integer JEWELLER = LoadInteger(udg_Stat_Table, 27000 + cv, 3)
local integer PHARMACIST = LoadInteger(udg_Stat_Table, 27000 + cv, 4)
call RemoveSavedHandle(udg_SL_HASHTABLE, 3, tid)
call RemoveSavedHandle(udg_SL_HASHTABLE, 10, tid)
//----------- just preload the string bases with max values like 1char length till length-1 ----
set i = 1
loop
set PowL[i] = R2I(Pow(l, i)) - 1
set i = i + 1
exitwhen i == 5
endloop
//-------------------------------------------------------------------------------
//set s3 = ""
//---------- check if 2 character length would be sufficient for hero coord or no ----
set COORD_LEN_X = SL_GetIntegerSize(MAX_X * 2)
set COORD_LEN_Y = SL_GetIntegerSize(MAX_Y * 2)
// ----- we get the hero index from hashtable, if it will be 0, then not found
set CLASS = LoadInteger(udg_SL_HASHTABLE, 2, GetUnitTypeId(u))
// --- if isn't 0 then Hero was stored into array and we continue -----
if CLASS != 0 then
// --- we get every data, what we will use that not sure yet ----
set LV = GetHeroLevel(u)
set EXP = GetHeroXP(u)
set STR = LoadInteger(udg_SL_HASHTABLE, 4, cv)
set AGI = LoadInteger(udg_SL_HASHTABLE, 5, cv)
set INT = LoadInteger(udg_SL_HASHTABLE, 6, cv)
set GOLD = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
set LUMBER = GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER)
//formating the stuff to max value if maybe it is higher
set LV = ModuloInteger(LV, PowL[2] + 1)
set EXP = ModuloInteger(EXP, PowL[4] + 1)
set STR = ModuloInteger(STR, PowL[2] + 1)
set AGI = ModuloInteger(AGI, PowL[2] + 1)
set INT = ModuloInteger(INT, PowL[2] + 1)
set GOLD = ModuloInteger(GOLD, MAX_GOLD() + 1)
set LUMBER = ModuloInteger(LUMBER, MAX_GOLD() + 1)
//if your hero not maxed level then
if MAX_HERO_LEVEL() != LV then
// -- we get the MinExp, MaxExp, CurExp with createing a dummy unit at player 1 start location
set loc = GetStartLocationLoc(GetPlayerStartLocation(Player(0)))
set d = CreateUnit(Player(0), GetUnitTypeId(u), GetLocationX(loc), GetLocationY(loc), 0)
call RemoveLocation(loc)
if LV == 1 then
set MinExp = 0
else
call SetHeroLevel(d, LV, false)
set MinExp = GetHeroXP(d)
endif
call SetHeroLevel(d, LV + 1, false)
set MaxExp = GetHeroXP(d) - 1
call RemoveUnit(d)
set CurExp = EXP - MinExp
else
set MinExp = EXP
set MaxExp = EXP
set CurExp = 0
endif
//lets start build the H_CODE with class then with level
//lets check if max class is higher than the Alpahabet string base
set a1 = SL_GetIntegerSize(MAX_HERO)
set CODE = SL_IntegerToCode(CLASS, a1)
//we must figure out what better, if we save LV+CurExp or total EXP
if CurExp > 0 then
set s1 = SL_IntegerToCode(LV, - 1) + SL_IntegerToCode(CurExp, - 1)
else
set s1 = SL_IntegerToCode(LV, - 1)
endif
set s2 = SL_IntegerToCode(EXP, - 1)
set a1 = StringLength(s1)
set a2 = StringLength(s2)
if a1 > a2 then
set s3 = SL_IntegerToCode(a2,1)+s2
else
if CurExp == 0 then
set s3 = SL_IntegerToCode(a1*10,1)+s1
else
set a1 = StringLength(SL_IntegerToCode(LV, - 1))
set a2 = StringLength(SL_IntegerToCode(CurExp, - 1))
set s3 = SL_IntegerToCode(a1*10+a2,1)+s1
endif
endif
set CODE = CODE + s3
//next piece what we save is the stats
if SL_SAVE_STAT() then
set s1 = SL_IntegerToCode(STR, - 1)
set s2 = SL_IntegerToCode(AGI, - 1)
set s3 = SL_IntegerToCode(INT, - 1)
set a1 = StringLength(s1)
set a2 = StringLength(s2)
set a3 = StringLength(s3)
set a4 = 0
if STR > 0 then
set a4 = a4 + 1
if STR > PowL[1] then
set a4 = a4 + 2
endif
endif
if AGI > 0 then
set a4 = a4 + 4
if AGI > PowL[1] then
set a4 = a4 + 8
endif
endif
if INT > 0 then
set a4 = a4 + 16
if INT > PowL[1] then
set a4 = a4 + 32
endif
endif
set CODE = CODE + SL_IntegerToCode(a4, 1) + s1 + s2 + s3
endif
//saveing resource part: gold and lumber
if SL_SAVE_GOLD() and SL_SAVE_LUMBER() and GOLD > 0 and LUMBER > 0 then
set s1 = SL_IntegerToCode(GOLD, - 1)
set s2 = SL_IntegerToCode(LUMBER, - 1)
set a1 = StringLength(s1)
set a2 = StringLength(s2)
set CODE = CODE + SL_IntegerToCode((a1 * 10 + a2), 1) + s1 + s2
elseif not (SL_SAVE_GOLD() and SL_SAVE_LUMBER()) then
//don't save nothing if both disabled
else
if SL_SAVE_GOLD() and GOLD > 0 then
set s1 = SL_IntegerToCode(GOLD, - 1)
set a1 = StringLength(s1)
set CODE = CODE + SL_IntegerToCode(a1 * 10, 1) + s1
elseif SL_SAVE_LUMBER() and LUMBER > 0 then
set s2 = SL_IntegerToCode(LUMBER, - 1)
set a2 = StringLength(s2)
set CODE = CODE + SL_IntegerToCode(a2, 1) + s2
else
set CODE = CODE + SL_IntegerToCode(0, 1)
endif
endif
//we save hero coordinates (X,Y) with shift
if SAVE_COORD then
set a1 = R2I(GetUnitX(u)) + MAX_X //x coordinate with shift for don't be negative number
set a2 = R2I(GetUnitY(u)) + MAX_Y //y coordinate with shift for don't be negative number
set CODE = CODE + SL_IntegerToCode(a1, COORD_LEN_X) + SL_IntegerToCode(a2, COORD_LEN_Y)
endif
endif
//we save the craft progress and check if unit got equiped stuff, got item in inventory
set a1 = 0
if BLACKSMITH >= l then
set a1 = a1 + 1
endif
if TAILOR >= l then
set a1 = a1 + 2
endif
if JEWELLER >= l then
set a1 = a1 + 4
endif
if PHARMACIST >= l then
set a1 = a1 + 8
endif
if udg_SL_EQ_Count > 0 then
set a1 = a1 + 16
endif
// if INV_Count > 0 then
// set a1 = a1+32
// endif
set CODE = CODE + SL_IntegerToCode(a1, 1) + SL_IntegerToCode(BLACKSMITH, - 1) + SL_IntegerToCode(TAILOR, - 1) + SL_IntegerToCode(JEWELLER, - 1) + SL_IntegerToCode(PHARMACIST, - 1)
set CODE_Row[CODE_Row_Count] = CODE
loop
exitwhen i > 10
if udg_SL_EQC[i] != null then
set udg_SL_EQC[i] = udg_SL_EQC[i]
set a1 = StringLength(udg_SL_EQC[i])
set a2 = StringLength(CODE_Row[CODE_Row_Count])
if a1 + a2 > MAX_CHAR then
if CODE_Row_Count != 1 then
set CODE_Row[CODE_Row_Count] = SL_IntegerToCode(CODE_Row_Count, 1) + CODE_Row[CODE_Row_Count]
set s2 = SL_CodeCheckSum(CODE_Row[CODE_Row_Count], p)
set CODE_Row[CODE_Row_Count] = s1 + CODE_Row[CODE_Row_Count] + s2
else
set s3 = SL_IntegerToCode(udg_SL_EQ_B_CODE1, - 1)
if udg_SL_EQ_B_CODE1 > 31 then
set s3 = s3 + SL_IntegerToCode(udg_SL_EQ_B_CODE2, - 1)
endif
set CODE_Row[CODE_Row_Count] = s3 + CODE_Row[CODE_Row_Count]
set s1 = SL_CodeCheckSum(CODE_Row[1], p)
set CODE_Row[CODE_Row_Count] = s1 + CODE_Row[CODE_Row_Count] + s1
endif
set CODE_Row_Count = CODE_Row_Count + 1
set CODE_Row[CODE_Row_Count] = udg_SL_EQC[i]
else
if i == 10 then
if CODE_Row_Count > 1 then
set CODE_Row[CODE_Row_Count] = SL_IntegerToCode(40+CODE_Row_Count, 1) + CODE_Row[CODE_Row_Count] + udg_SL_EQC[i]
set s2 = SL_CodeCheckSum(CODE_Row[CODE_Row_Count], p)
if s1 == null then
set s1 = s2
endif
set CODE_Row[CODE_Row_Count] = s1 + CODE_Row[CODE_Row_Count] + s2
else
if udg_SL_EQ_B_CODE1 < 32 then
set udg_SL_EQ_B_CODE1 = udg_SL_EQ_B_CODE1 + 32
endif
set s3 = SL_IntegerToCode(udg_SL_EQ_B_CODE1, - 1) + SL_IntegerToCode((udg_SL_EQ_B_CODE2 + 32), - 1)
set CODE_Row[CODE_Row_Count] = s3 + CODE_Row[CODE_Row_Count] + udg_SL_EQC[i]
set s1 = SL_CodeCheckSum(CODE_Row[1], p)
set CODE_Row[CODE_Row_Count] = s1 + CODE_Row[CODE_Row_Count] + s1
endif
else
set CODE_Row[CODE_Row_Count] = CODE_Row[CODE_Row_Count] + udg_SL_EQC[i]
endif
endif
endif
set i = i + 1
endloop
call DisplayTextToPlayer ( p, 0, 0, "|cff7777ffNote:|r Code saved into |cffff8888" + PATH + "|r")
set i = 1
if GetLocalPlayer() == p then
call PreloadGenClear()
call PreloadGenStart()
call Preload("\r\n\t\t\t\tHero: " + HERO_NAME + "\r\n\t\t\t\t" + "Level: " + HERO_LV + "\t\t\r\n\t\t\t\t" + "Name: " + GetPlayerName(p) + "\t\t\r\n" )
loop
exitwhen i > CODE_Row_Count
call Preload("Code " + I2S(i) + ": -load " + CODE_Row[i] )
set i = i + 1
endloop
call PreloadGenEnd(PATH)
set i = 1
endif
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set u = null
set p = null
set loc = null
set d = null
endfunction
function ReadOutTheSockets takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tid = GetHandleId(t)
local integer id = LoadInteger(udg_SL_HASHTABLE, 7, tid)
local integer i = LoadInteger(udg_SL_HASHTABLE, 8, tid)
local integer a1 = LoadInteger(udg_SL_HASHTABLE, 9, tid)
local integer a2
local integer a3
local integer a4
local integer b1
local integer b2
local integer b3
local integer b4
local unit u = LoadUnitHandle(udg_SL_HASHTABLE, 3, tid)
local integer cv = GetUnitUserData(u)
local integer ii
set u = null
call RemoveSavedHandle(udg_SL_HASHTABLE, 3, tid)
//read out the socket bonus stat and its value too
set ii = 0
loop
exitwhen ii > a1
set a2 = LoadInteger(udg_CItem_Table, id, 1500 + ii)
set b3 = LoadInteger(udg_CItem_Table, id, 1000 + ii)
//if socket was filled then add socket unique id to code
set b4 = 1
loop
exitwhen b4 > b3
set udg_SL_EQC[i] = udg_SL_EQC[i] + SL_IntegerToCode(a2, 1)
set b4 = b4 + 1
endloop
//we check if sockets give bonus stat too
if a2 == 0 then
set ii = a1 + 1 //break out from loop
else
set a3 = LoadInteger(udg_CItem_Table, id, 2)
set a4 = ItemType2GemType(a3)
if a4 != 0 then
set b1 = LoadInteger(udg_CItem_Table, - 2000 - a2, 8 + a4)
set b2 = LoadInteger(udg_CItem_Table, - 2000 - a2, b1)
set b4 = b2 * b3
if b1 == 44 then
call SaveInteger(udg_SL_HASHTABLE, 4, cv, LoadInteger(udg_SL_HASHTABLE, 4, cv)-b4)
elseif b1 == 45 then
call SaveInteger(udg_SL_HASHTABLE, 5, cv, LoadInteger(udg_SL_HASHTABLE, 5, cv)-b4)
elseif b1 == 46 then
call SaveInteger(udg_SL_HASHTABLE, 6, cv, LoadInteger(udg_SL_HASHTABLE, 6, cv)-b4)
endif
endif
endif
set ii = ii + 1
endloop
call PauseTimer(t)
call DestroyTimer(t)
set t = null
endfunction
function EquipmentsToCode takes nothing returns nothing
local integer ITEM_STR = 0
local integer ITEM_AGI = 0
local integer ITEM_INT = 0
local timer t1 = GetExpiredTimer()
local integer tid1 = GetHandleId(t1)
local timer t2
local integer tid2
local unit u = LoadUnitHandle(udg_SL_HASHTABLE, 3, tid1)
local integer ut = GetUnitTypeId(u)
local integer START_STR = LoadInteger(udg_FSS, 636, ut)
local integer START_AGI = LoadInteger(udg_FSS, 637, ut)
local integer START_INT = LoadInteger(udg_FSS, 638, ut)
local integer DURATIBILITY
local integer MAX_INVENTORY = 20 //our inventory capacity is 20 item
local integer GEM_LEN = SL_GetIntegerSize(LoadInteger(udg_CItem_Table, - 2000, 0))
local integer cv = GetUnitUserData(u)
local item itm
local integer id
local integer l = StringLength(SL_CODE())
local integer i
local integer ii
local integer a1
local integer a2
local integer a3
local integer a4
local integer b1
local integer b2
local integer b3
local integer b4
local integer BONUS //predefined bonus stat index's from items
local integer BONUS_LEN //predefined bonus stats length from items (1 = 0 - 82, 2 = 0 - 6400)
local integer BONUS_COUNT
local string BONUS_STRING
call RemoveSavedHandle(udg_SL_HASHTABLE, 0, tid1)
set udg_SL_EQ_B_CODE1 = 0
set udg_SL_EQ_B_CODE2 = 0
call SaveInteger(udg_SL_HASHTABLE, 4, cv, 0)
call SaveInteger(udg_SL_HASHTABLE, 5, cv, 0)
call SaveInteger(udg_SL_HASHTABLE, 6, cv, 0)
//we calculate how much str, agi, int coming from items - directly and from sockets
//we start in inventory - we check the charms
set i = 1
loop
exitwhen i > MAX_INVENTORY
if HaveSavedHandle(udg_Stat_Table, cv, i + 99) then
set itm = LoadItemHandle(udg_Stat_Table, cv, i + 99)
if GetItemLevel(itm) == 111 then //if item level is 111 then item is charm
set id = GetHandleId(itm)
set ITEM_STR = ITEM_STR + LoadInteger(udg_CItem_Table, id, 44)
set ITEM_AGI = ITEM_AGI + LoadInteger(udg_CItem_Table, id, 45)
set ITEM_INT = ITEM_INT + LoadInteger(udg_CItem_Table, id, 46)
endif
endif
set i = i + 1
endloop
set itm = null
//we start build the code for equipments, each equipment individually and at end combine to a large row
//equipment slots: 1 - 10
set udg_SL_EQ_Count = 0
set i = 1
loop
exitwhen i == 11
set udg_SL_EQC[i] = ""
//if in equipment slot have saved item then
if HaveSavedHandle(udg_Stat_Table, cv, i) then
if i < 6 then
set udg_SL_EQ_B_CODE1 = udg_SL_EQ_B_CODE1 + udg_Pow2[i - 1]
else
if udg_SL_EQ_B_CODE1 < 32 then
set udg_SL_EQ_B_CODE1 = udg_SL_EQ_B_CODE1 + 32
endif
set udg_SL_EQ_B_CODE2 = udg_SL_EQ_B_CODE2 + udg_Pow2[i - 6]
endif
set udg_SL_EQ_Count = udg_SL_EQ_Count + 1
set id = GetHandleId(LoadItemHandle(udg_Stat_Table, cv, i))
set ITEM_STR = ITEM_STR + LoadInteger(udg_CItem_Table, id, 44)
set ITEM_AGI = ITEM_AGI + LoadInteger(udg_CItem_Table, id, 45)
set ITEM_INT = ITEM_INT + LoadInteger(udg_CItem_Table, id, 46)
set DURATIBILITY = R2I(LoadReal(udg_CItem_Table, id, 15) - LoadReal(udg_CItem_Table, id, 14)) //maxdur - duratibility
//we build a number, what store 6 boolean:
//unique id, refined, socketed, ethernal, rnd def(armor)/activation(weapon), duratibility length(1 or 2)
set a1 = 0
if LoadInteger(udg_CItem_Table, id, 0) > 0 then
set a1 = a1 + 1
endif
if LoadInteger(udg_CItem_Table, id, 16) > 0 then
set a1 = a1 + 2
endif
if LoadInteger(udg_CItem_Table, id, 18) > 0 then
set a1 = a1 + 4
endif
if LoadInteger(udg_CItem_Table, id, 13) > 0 then
set a1 = a1 + 8
endif
if LoadInteger(udg_CItem_Table, id, 25) > 0 then
set a1 = a1 + 16
endif
if DURATIBILITY >= l then
set a1 = a1 + 32
endif
set udg_SL_EQC[i] = SL_IntegerToCode(a1, 1)
// --- end of boolean and we create from number a character ---
// lets if was unique id then add that
set a1 = LoadInteger(udg_CItem_Table, id, 0)
if a1 > 0 then
set udg_SL_EQC[i] = udg_SL_EQC[i] + SL_IntegerToCode(a1, 1)
else
//lets check base stats: subtype, quality, grade, lv req
set udg_SL_EQC[i] = udg_SL_EQC[i] + SL_IntegerToCode(LoadInteger(udg_CItem_Table, id, 3), 1) + SL_IntegerToCode(LoadInteger(udg_CItem_Table, id, 4), 1) + SL_IntegerToCode(LoadInteger(udg_CItem_Table, id, 7), 2) + SL_IntegerToCode(LoadInteger(udg_CItem_Table, id, 8), 2)
//lets add the bonus item stats
set ii = 0
set a2 = 0
set BONUS_COUNT = 0
set BONUS_STRING = ""
loop
set BONUS = Inline_Item_Bonus_Stat(ii)
set BONUS_LEN = Inline_Item_Bonus_Stat_Length(BONUS)
exitwhen BONUS == 0
set a1 = LoadInteger(udg_CItem_Table, id, BONUS)
if a1 > 0 then
set BONUS_STRING = BONUS_STRING + SL_IntegerToCode(BONUS, GEM_LEN) + SL_IntegerToCode(a1, BONUS_LEN)
set BONUS_COUNT = BONUS_COUNT + 1
endif
set ii = ii + 1
endloop
set udg_SL_EQC[i] = udg_SL_EQC[i] + SL_IntegerToCode(BONUS_COUNT, 1)+ BONUS_STRING
endif
if i < 10 then
//check if defence is random on armor or no
if LoadInteger(udg_CItem_Table, id, 25) > 0 then
if (i == 1 or i == 2 or i == 4) and LoadInteger(udg_CItem_Table, id, 25) == 1 then
set ii = 0
loop
exitwhen ii > 4
set a1 = LoadInteger(udg_CItem_Table, id, 35 + ii)
set udg_SL_EQC[i] = udg_SL_EQC[i] + SL_IntegerToCode(a1, 2)
set ii = ii + 1
endloop
elseif i == 3 then
set udg_SL_EQC[i] = udg_SL_EQC[i] + SL_IntegerToCode(LoadInteger(udg_CItem_Table, id, 25), 1)
endif
endif
//save duratibility
set udg_SL_EQC[i] = udg_SL_EQC[i] + SL_IntegerToCode(DURATIBILITY, - 1)
//check if item is refined
if LoadInteger(udg_CItem_Table, id, 16) > 0 then
set udg_SL_EQC[i] = udg_SL_EQC[i] + SL_IntegerToCode(LoadInteger(udg_CItem_Table, id, 16), 1)
endif
set a1 = LoadInteger(udg_CItem_Table, id, 18)
if a1 > 0 then
set t2 = CreateTimer()
set tid2 = GetHandleId(t2)
call SaveUnitHandle(udg_SL_HASHTABLE, 3, tid2, u)
call SaveInteger(udg_SL_HASHTABLE, 7, tid2, id)
call SaveInteger(udg_SL_HASHTABLE, 8, tid2, i)
call SaveInteger(udg_SL_HASHTABLE, 9, tid2, a1)
call TimerStart(t2, 0.00, false, function ReadOutTheSockets)
set t2 = null
endif
endif
endif
set i = i + 1
endloop
call PauseTimer(t1)
call DestroyTimer(t1)
set t1 = CreateTimer()
set i = GetHandleId(t1)
call SaveUnitHandle(udg_SL_HASHTABLE, 3, i, u)
call SaveInteger(udg_SL_HASHTABLE, 4, cv, LoadInteger(udg_SL_HASHTABLE, 4, cv)+GetHeroStr(u, false) - ITEM_STR - START_STR)
call SaveInteger(udg_SL_HASHTABLE, 5, cv, LoadInteger(udg_SL_HASHTABLE, 5, cv)+GetHeroAgi(u, false) - ITEM_AGI - START_AGI)
call SaveInteger(udg_SL_HASHTABLE, 6, cv, LoadInteger(udg_SL_HASHTABLE, 6, cv)+GetHeroInt(u, false) - ITEM_INT - START_INT)
call SavePlayerHandle(udg_SL_HASHTABLE, 10, i, GetOwningPlayer(u))
call TimerStart(t1, 0.00, false, function BuildFinalCode)
set u = null
set t1 = null
set itm = null
endfunction
function Create_Save_Load_Code takes nothing returns boolean
local timer t
if GetSpellAbilityId() == 'A018' then
set t = CreateTimer()
call SaveUnitHandle(udg_SL_HASHTABLE, 3, GetHandleId(t), GetTriggerUnit())
call TimerStart(t, 0.00, false, function EquipmentsToCode)
set t = null
endif
return false
endfunction
//===========================================================================
function InitTrig_Save_Game_ability takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
//EVENT_PLAYER_UNIT_SPELL_CAST - EVENT_PLAYER_UNIT_SPELL_FINISH
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i + 1
exitwhen i == 16
endloop
call TriggerAddCondition( t, Condition( function Create_Save_Load_Code ) )
set t = null
endfunction
function Read_Load_Code takes nothing returns nothing
local player p // = GetTriggerPlayer()
local integer pl
local integer i
local string c = GetEventPlayerChatString() //your input code
local string lc1
local string lc2
local string cs1 //checksum1
local string cs2 //checksum2
local string cs3 //checksum3
local integer l //length
local integer a1
local integer a2
local integer a3
local integer a4
local integer b1
local integer b2
local integer b3
local integer b4
local integer cv
local integer row
local boolean VALIDATE
local boolean READY
local boolean SAVED_EQ
local boolean array SavedEQ
local integer cs_len
local integer EQC //saved equipment count
local real X
local real Y
local location loc
local unit u
local integer MAX_X
local integer MAX_Y
if StringCase(SubString(c, 0, 6), false) == "-load " then
set READY = false
set SAVED_EQ = false
set p = GetTriggerPlayer()
set pl = GetPlayerId(p) + 1
set cs_len = SL_CRC_LEN()
set l = StringLength(c)
set c = SubString(c, 6, StringLength(c))
set l = l - 6
set cs1 = SubString(c, 0, cs_len)
set cs2 = SubString(c, l - cs_len, l)
set c = SubString(c, cs_len, l - cs_len)
set VALIDATE = (SL_CodeCheckSum(c, p) == cs2)
set a3 = 0
if l > (cs_len * 2) then
if VALIDATE then
call DisplayTextToPlayer ( p, 0, 0, "|cffffff00Note:|r Valid code")
if cs1 == cs2 then //if 1st checksum = last one then its 1st code, we flush previously loaded stuff
call FlushChildHashtable(udg_SL_HASHTABLE, - pl)
call SaveStr(udg_SL_HASHTABLE, - pl, 1, cs1 + c + cs2)
set a1 = SL_CodeToInteger(SubString(c, 0, 1))
set a2 = SL_CodeToInteger(SubString(c, 1, 2))
if a1 >= 32 and a2 >= 32 then
set READY = true
set row = 1
endif
else
if HaveSavedString(udg_SL_HASHTABLE, - pl, 1) then
set lc1 = LoadStr(udg_SL_HASHTABLE, - pl, 1) //1st line
set a1 = StringLength(lc1)
set cs3 = SubString(lc1, a1 - cs_len, a1) //1st code checksum code
if cs1 == cs3 then //if current code 1st checksum==checksum from 1st code
//c = the current code without checksums (cs1=1st checksum, cs2=last)
//1st character is the curent line index, if it is last line then it is 40+curent line
set a2 = SL_CodeToInteger(SubString(c, 0, 1)) //current line index
if a2 > 40 then
set a2 = a2 - 40
endif
call DisplayTextToPlayer ( p, 0, 0, "|cffffff00Note:|r Code line " + I2S(2) + " has saved.")
//we save current line
call SaveStr(udg_SL_HASHTABLE, - pl, a2, cs1 + c + cs2)
//we check each line until no more saved code, if we got that one who got 40+ value then we found last line
set row = 1
set i = 2
loop
exitwhen not HaveSavedString(udg_SL_HASHTABLE, - pl, i) or READY
set lc2 = LoadStr(udg_SL_HASHTABLE, - pl, i)
set cs2 = SubString(lc2, 0, cs_len)
if cs2 == cs3 then
set row = row + 1
set a4 = SL_CodeToInteger(SubString(lc2, cs_len, cs_len + 1))
if a4 > 40 then
set READY = true
endif
endif
set i = i + 1
endloop
else
call DisplayTextToPlayer ( p, 0, 0, "|cffffff00Warning:|r Code isn't part of the main code, use the correct code")
endif
else
call DisplayTextToPlayer ( p, 0, 0, "|cffffff00Warning:|r Use Code 1 first time.")
endif
endif
endif
if READY then
//we save how much line was the code
call SaveInteger(udg_SL_HASHTABLE, - pl, 0, row)
set EQC = 0
//we formating, cut down the checksum from saved codes and resave them
set i = 1
loop
exitwhen i > row
set c = LoadStr(udg_SL_HASHTABLE, - pl, i)
set l = StringLength(c)
set c = SubString(c, cs_len, l - cs_len)
if i == 1 then
set a1 = SL_CodeToInteger(SubString(c, 0, 1))
set a2 = 5
set a3 = 0
loop
set SavedEQ[a2 + 1] = false
exitwhen a2 < 0
if a1 >= udg_Pow2[a2] then
set a1 = a1 - udg_Pow2[a2]
if a2 == 5 then
set a3 = 5
else
set SavedEQ[a2 + 1] = true
call BJDebugMsg("eq on:" + I2S(a2 + 1))
set EQC = EQC + 1
endif
endif
set a2 = a2 - 1
endloop
set c = SubString(c, 1, StringLength(c))
if a3 == 5 then
set a1 = SL_CodeToInteger(SubString(c, 0, 1))
set a2 = 5
set a3 = 0
loop
set SavedEQ[a2 + 1 + 5] = false
exitwhen a2 < 0
if a1 >= udg_Pow2[a2] then
set a1 = a1 - udg_Pow2[a2]
if a2 != 5 then
set EQC = EQC + 1
set SavedEQ[a2 + 1 + 5] = true
call BJDebugMsg("eq on:" + I2S(a2 + 1 + 5))
endif
endif
set a2 = a2 - 1
endloop
set c = SubString(c, 1, StringLength(c))
else
set SavedEQ[6] = false
set SavedEQ[7] = false
set SavedEQ[8] = false
set SavedEQ[9] = false
set SavedEQ[10] = false
endif
//we done with checking with equipment booleans (eq[slot number]=true if there item)
//read max hero length(a2) - then class(a1)
set a2 = SL_GetIntegerSize(LoadInteger(udg_SL_HASHTABLE, 2, 0))
set a1 = SL_CodeToInteger(SubString(c, 0, a2))
set c = SubString(c, a2, StringLength(c))
//get unit id and create unit at player start location
set loc = GetStartLocationLoc(GetPlayerStartLocation(p))
set X = GetLocationX(loc)
set Y = GetLocationY(loc)
call RemoveLocation(loc)
set loc = null
set a1 = LoadInteger(udg_SL_HASHTABLE, 2, a1)
set u = CreateUnit(p, a1, X, Y, 0)
set a2 = 0
set a3 = 0
//get lv and exp and add to unit then set default stat
set a1 = SL_CodeToInteger(SubString(c, 0, 1))
set c = SubString(c, 1, StringLength(c))
set b1 = a1 / 10 //lv length
set b2 = a1 - (b1 * 10) //exp length
set a2 = 0
set a3 = 0
if b1 == 0 then
set a2 = SL_CodeToInteger(SubString(c, 0, b2))
set c = SubString(c, b2, StringLength(c))
call SetHeroXP(u, a2, false)
else
if b2 == 0 then
set a2 = SL_CodeToInteger(SubString(c, 0, b1))
set c = SubString(c, b1, StringLength(c))
if a2 > 1 then
call SetHeroLevel(u, a2, false)
endif
else
set a2 = SL_CodeToInteger(SubString(c, 0, b1))
set a3 = SL_CodeToInteger(SubString(c, b1, b1 + b2))
set c = SubString(c, b1 + b2, StringLength(c))
if a2 > 1 then
call SetHeroLevel(u, a2, false)
endif
set b1 = GetHeroXP(u)
call SetHeroXP(u, b1 + a3, false)
endif
endif
set a4 = GetUnitTypeId(u)
call SetHeroStr(u, LoadInteger(udg_FSS, 636, a4), true)
call SetHeroAgi(u, LoadInteger(udg_FSS, 637, a4), true)
call SetHeroInt(u, LoadInteger(udg_FSS, 638, a4), true)
set b4 = 0
if SL_SAVE_STAT() then
//number what tell if stat is 1 or 2 or 3 char long so max limit is encode string length^3
set a1 = SL_CodeToInteger(SubString(c, 0, 1))
set c = SubString(c, 1, StringLength(c))
set b1 = 1
set b2 = 1
set b3 = 1
set a2 = 5
loop
exitwhen a2 < 0
if a1 >= udg_Pow2[a2] then
if a2 > 3 and b3 == 0 then
set b3 = a2 - 3
elseif a2 > 1 and a2 < 4 and b2 == 0 then
set b2 = a2 - 1
elseif a2 >= 0 and a2 < 2 and b1 == 0 then
set b1 = a2 + 1
endif
set a1 = a1 - udg_Pow2[a2]
endif
set a2 = a2 - 1
endloop
if b1 > 0 then
set a1 = SL_CodeToInteger(SubString(c, 0, b1))
set c = SubString(c, b1, StringLength(c))
call SetHeroStr(u, a1 + GetHeroStr(u, false), true)
set b4 = b4 + a1
endif
if b2 > 0 then
set a1 = SL_CodeToInteger(SubString(c, 0, b2))
set c = SubString(c, b2, StringLength(c))
call SetHeroAgi(u, a1 + GetHeroAgi(u, false), true)
set b4 = b4 + a1
endif
if b3 > 0 then
set a1 = SL_CodeToInteger(SubString(c, 0, b3))
set c = SubString(c, b3, StringLength(c))
call SetHeroInt(u, a1 + GetHeroInt(u, false), true)
set b4 = b4 + a1
endif
endif
//add inventory ability and set stat points
call AddAbiltityStatPoint2Hero(u)
set a1 = GetUnitUserData(u)
set udg_Stat_Point[a1] = udg_Stat_Point[a1] - b4
//we read the gold or-and lumber
if SL_SAVE_GOLD() or SL_SAVE_LUMBER() then
set a1 = SL_CodeToInteger(SubString(c, 0, 1))
set b1 = a1 / 10
set b2 = a1 - (b1 * 10)
set c = SubString(c, 1, StringLength(c))
if SL_SAVE_GOLD() then
if b1 > 0 then
set a2 = SL_CodeToInteger(SubString(c, 0, b1))
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, a2)
set c = SubString(c, b1, StringLength(c))
endif
endif
if SL_SAVE_LUMBER() then
if b2 > 0 then
set a2 = SL_CodeToInteger(SubString(c, 0, b2))
call SetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER, a2)
set c = SubString(c, b2, StringLength(c))
endif
endif
endif
if SL_SAVE_COORD() then
set MAX_X = R2I(GetRectMaxX(bj_mapInitialPlayableArea))//highest X coordinate on map
set MAX_Y = R2I(GetRectMaxY(bj_mapInitialPlayableArea))//highest Y coordinate on map
set b1 = SL_GetIntegerSize(MAX_X * 2)
set b2 = SL_GetIntegerSize(MAX_Y * 2)
set X = R2I(SL_CodeToInteger(SubString(c, 0, b1)) - MAX_X)
set Y = R2I(SL_CodeToInteger(SubString(c, b1, b1 + b2)) - MAX_Y)
call BJDebugMsg(I2S(SL_CodeToInteger(SubString(c, 0, b1))))
call BJDebugMsg(I2S(SL_CodeToInteger(SubString(c, b1, b1 + b2))))
call SetUnitX(u, X)
call SetUnitY(u, Y)
set c = SubString(c, b1 + b2, StringLength(c))
endif
//read out if craft skill length are 2 or 1, eq or inv is saved or no
set a1 = SL_CodeToInteger(SubString(c, 0, 1))
set c = SubString(c, 1, StringLength(c))
set a2 = 5
set b1 = 1
set b2 = 1
set b3 = 1
set b4 = 1
loop
exitwhen a2 < 0
if a1 >= udg_Pow2[a2] then
set a1 = a1 - udg_Pow2[a2]
if a2 == 5 then
//enable SAVED_INV(entory) boolean
elseif a2 == 4 then
set SAVED_EQ = true
elseif a2 == 3 then
set b4 = 2
elseif a2 == 2 then
set b3 = 2
elseif a2 == 1 then
set b2 = 2
elseif a2 == 0 then
set b1 = 2
endif
endif
set a2 = a2 - 1
endloop
set a1 = SL_CodeToInteger(SubString(c, 0, b1))
set c = SubString(c, b1, StringLength(c))
set a2 = SL_CodeToInteger(SubString(c, 0, b2))
set c = SubString(c, b2, StringLength(c))
set a3 = SL_CodeToInteger(SubString(c, 0, b3))
set c = SubString(c, b3, StringLength(c))
set a4 = SL_CodeToInteger(SubString(c, 0, b4))
set c = SubString(c, b4, StringLength(c))
set cv = GetUnitUserData(u)
call SaveInteger(udg_Stat_Table, 27000 + cv, 1, a1)
call SaveInteger(udg_Stat_Table, 27000 + cv, 2, a2)
call SaveInteger(udg_Stat_Table, 27000 + cv, 3, a3)
call SaveInteger(udg_Stat_Table, 27000 + cv, 4, a4)
endif
set i = i + 1
endloop
call DisplayTextToPlayer ( p, 0, 0, "|cffffff00Note:|r Everything fine, ready to load, total line is " + I2S(row))
endif
endif
endif
endfunction
//===========================================================================
function InitTrig_Load_Game takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
loop
exitwhen i == 12
call TriggerRegisterPlayerChatEvent( t, Player(i), "-Load ", false )
set i = i + 1
endloop
call TriggerAddCondition( t, Condition( function Read_Load_Code ) )
set t = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
////////////////////////////////////////////////////////////////////////////////////
//
// Physical Damage Detection Engine GUI v 1.2.0.1
// ----------------------------------------------
// By looking_for_help aka eey
//
// This system is able to detect, modify and deal damage. It can differentiate
// between physical and spell damage, as well as block, reduce or increase the
// applied damage to a desired value. You can also allocate damage events from
// running damage events.
//
// This is the GUI version of the system, meaning that you can use this with the
// standard editor and basically without any knowledge of JASS.
//
////////////////////////////////////////////////////////////////////////////////////
//
// Implementation
// --------------
// 1. Create all variables that this system uses (compare the variable editor).
// You don't have to set them to specific values, they get initialized
// automatically by the system so just create them.
// 2. Copy this trigger to your map. You can then add damage handlers by using
// the event "value of real variable becomes equal to 1" with the variable
// udg_PDD_damageEventTrigger. Compare the OnDamage trigger for an example usage.
// 3. Copy the two custom abilities to your map and make sure they have the
// correct ID. You can specify the ID in the function InitGlobalVariables
// above.
// 4. Go to the locust swarm ability and invert its damage return portion
// from (default) 0.75 to -0.75.
// 5. Remove the spell damage reduction ability from the spell damage reduction
// items you use (runed bracers). You can configure the resistance of this
// item in the InitGlobalVariables function, modifying the global variable
// udg_PDD_BRACERS_SPELL_DMG_RED.
//
////////////////////////////////////////////////////////////////////////////////////
//
// Important Notes
// ---------------
// 1. Life Drain does not work with this system, so you should use a triggered
// version of this spell if you want to use it.
// 2. Same for Finger of Death, if you want to use this spell bug free with this
// system, you should use a triggered version of it.
// 3. If you use damage modifiers by setting the damage amount variable, you have
// to use GetUnitLife, GetUnitMaxLife and SetUnitLife instead of GetWidgetLife,
// GetUnitState for UNIT_STATE_MAX_LIFE and SetWidgetLife in your whole map to
// ensure there occure no bugs.
// 4. The boolean udg_PDD_SPELL_RESIST_AUTO_DETECT is only neccessary set to true
// if you want to use a customized damage table with spell damage resistance
// above 100%. If this is not the case, it should be set to false, as the
// system is faster then and still works correct.
// 5. As already mentioned you can't use the spell reduction ability when using this
// system (runed bracers and elunes grace). If you want to use them, you can
// trigger them by using the damage modifiers. Runed bracers is already considered
// in this system, so you don't have to code it.
//
////////////////////////////////////////////////////////////////////////////////////
//
// System API
// ----------
// real damageEventTrigger
// - Use the event "value of real variable becomes equal to 1" to detect a damage
// event. In this event you can use the following API. Compare the OnDamage
// trigger for an example usage.
//
// unit target
// - In this global unit variable, the damaged unit is saved. Don't write any-
// thing into this variable, use it as readonly.
//
// unit source
// - In this global unit variable, the damage source is saved. Don't write any-
// thing into this variable, use it as readonly.
//
// real amount
// - In this global real variable, the amount of damage is saved. This amount
// can be modified by simply setting it to the desired amount that should be
// applied to the target. Set the amount to 0.0 to block the damage completly.
// Negative values will result in heal.
//
// integer damageType
// - In this global integer variable, the damage type of the current damage is
// saved. Use it to differentiate between physical, spell and code damage. The
// variable can takes the values PHYSICAL == 0, SPELL == 1 and CODE == 2. Don't
// write anything into this variable, use it as readonly.
//
// function GetUnitLife takes unit u returns real
// - Use this function instead of the GetWidgetLife native. It ensures that you
// get the correct health value, even when damage modifiers are applied. If
// you don't use damage modifiers at all, you don't need this function.
//
// function GetUnitMaxLife takes unit u returns real
// - Use this function instead of the GetUnitState(u, UNIT_STATE_MAX_LIFE) native.
// It will return the correct value, even when damage modifiers are applied. If
// you don't use damage modifiers at all, you don't need this function.
//
// function SetUnitLife takes unit u, real newLife returns nothing
// - Use this function instead of the SetWidgetLife(u, newLife) native if you use
// damage modifiers in your map. Same rules as for the GetUnitMaxLife and the
// GetUnitMaxLife functions.
//
// function UnitDamageTargetEx takes unit localSource, unit localTarget, real localAmount, boolean attack, boolean ranged, attacktype localAttackType, damagetype localDamageType, weapontype localWeaponType returns boolean
// - Use this function to deal damage from a running damage event. It works exactly
// the same as the native UnitDamageTarget but is recursion safe so that you can
// realize damage reflection for example with this. Don't ever use this function
// outside of an onDamage event.
//
// function AddDamageHandler takes code damageHandler returns nothing
// - Allows you to add a damage handler function to the system. This is not
// required for GUI users, only for vanilla JASS users. GUI users should
// use the real variable damageEventTrigger to add damage handlers to this
// system as explained above.
//
// function RemoveDamageHandler takes code damageHandler returns nothing
// - Allows you to remove a damage handler function from the system dynamic-
// ally. If you added the same handler function multiple times to the sys-
// tem, this function will remove all of these equal functions. This is not
// required for GUI users, only for vanilla JASS users.
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Configurable globals
//////////////////////////////////////////////////////////////////////////////////
function InitGlobalVariables takes nothing returns nothing
// Put here the correct ability IDs
set udg_PDD_DAMAGE_TYPE_DETECTOR = 'A017'
set udg_PDD_SET_MAX_LIFE = 'A000'
// Here you can configure some stuff, read the documentation for further info
set udg_PDD_SPELL_RESIST_AUTO_DETECT = false
set udg_PDD_ETHEREAL_DAMAGE_FACTOR = 1.66
set udg_PDD_TRIGGER_CLEANUP_PERIOD = 60.0
endfunction
//////////////////////////////////////////////////////////////////////////////////
// End of configurable globals
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// User functions
//////////////////////////////////////////////////////////////////////////////////
function AddDamageHandler takes code func returns nothing
local integer id = GetHandleId(Condition(func))
local integer index = 0
// Loop to manage equal damage handlers
loop
exitwhen ( LoadTriggerConditionHandle(udg_PDD_h, id, index) == null )
set index = index + 1
endloop
// Store the desired damage handler function
call SaveTriggerConditionHandle(udg_PDD_h, id, index, TriggerAddCondition(udg_PDD_damageHandler, Filter(func)))
endfunction
function RemoveDamageHandler takes code func returns nothing
local integer id = GetHandleId(Condition(func))
local integer index = 0
// Loop through all equal damage handlers
loop
exitwhen ( LoadTriggerConditionHandle(udg_PDD_h, id, index) == null )
call TriggerRemoveCondition(udg_PDD_damageHandler, LoadTriggerConditionHandle(udg_PDD_h, id, index))
set index = index + 1
endloop
// Clean things up
call FlushChildHashtable(udg_PDD_h, id)
endfunction
////////////////////////////////////////////////////////////////////////////////////
// Sub functions
////////////////////////////////////////////////////////////////////////////////////
function DealFixDamage takes unit source, unit target, real pureAmount returns nothing
local real MAX_DAMAGE = 1000000.0
local real beforeHitpoints
local real newHitpoints
// Ensure the amount is positive
if pureAmount < 0 then
set pureAmount = -pureAmount
endif
// Save the targets hitpoints
set beforeHitpoints = GetWidgetLife(target)
set newHitpoints = beforeHitpoints - pureAmount
// Apply the desired, fixed amount
if newHitpoints >= udg_PDD_UNIT_MIN_LIFE then
call SetUnitState(target, UNIT_STATE_LIFE, newHitpoints)
else
if ( IsUnitType(target, UNIT_TYPE_ETHEREAL) == false ) then
call SetWidgetLife(target, 1.0)
call UnitDamageTarget(source, target, MAX_DAMAGE, true, false, udg_PDD_ATTACK_TYPE_UNIVERSAL, DAMAGE_TYPE_UNIVERSAL, null)
call SetWidgetLife(target, 0.0)
else
call UnitRemoveAbility(target, udg_PDD_DAMAGE_TYPE_DETECTOR)
call SetWidgetLife(target, 1.0)
call UnitDamageTarget(source, target, MAX_DAMAGE, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
call SetWidgetLife(target, 0.0)
endif
endif
endfunction
function GetUnitSpellResistance takes unit u returns real
local real originalHP
local real beforeHP
local real afterHP
local real resistance
local real DUMMY_DAMAGE = 100
local real DUMMY_FACTOR = 0.01
// Deal spell damage in order to get the units resistance
call UnitRemoveAbility(udg_PDD_target, udg_PDD_DAMAGE_TYPE_DETECTOR)
set originalHP = GetWidgetLife(udg_PDD_target)
call UnitAddAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(udg_PDD_target, 20000.0)
set beforeHP = GetWidgetLife(udg_PDD_target)
call DisableTrigger(udg_PDD_damageEvent)
call UnitDamageTarget(udg_PDD_source, udg_PDD_target, DUMMY_DAMAGE, true, false, null, DAMAGE_TYPE_UNIVERSAL, null)
call EnableTrigger(udg_PDD_damageEvent)
set afterHP = GetWidgetLife(udg_PDD_target)
call UnitRemoveAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(udg_PDD_target, originalHP)
call UnitAddAbility(udg_PDD_target, udg_PDD_DAMAGE_TYPE_DETECTOR)
call UnitMakeAbilityPermanent(udg_PDD_target, true, udg_PDD_DAMAGE_TYPE_DETECTOR)
// Calculate this resistance
set resistance = DUMMY_FACTOR*(beforeHP - afterHP)
// If the resistance was greater than 100%, return it
if resistance > 1.0 then
return resistance
else
return 1.0
endif
endfunction
////////////////////////////////////////////////////////////////////////////////////
// Damage Engine
////////////////////////////////////////////////////////////////////////////////////
function AfterDamage takes nothing returns nothing
local timer time = GetExpiredTimer()
local integer id = GetHandleId(time)
local unit localSource = LoadUnitHandle(udg_PDD_h, id, 0)
local unit localTarget = LoadUnitHandle(udg_PDD_h, id, 1)
local real pureAmount = LoadReal(udg_PDD_h, id, 2)
local real amount = LoadReal(udg_PDD_h, id, 3)
local real originalHealth = LoadReal(udg_PDD_h, id, 4)
// If the damage was modified, restore units health
if originalHealth != 0.0 then
call UnitRemoveAbility(localTarget, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(localTarget, originalHealth)
endif
// Apply the desired amount of damage
if amount > 0.0 then
call DisableTrigger(udg_PDD_damageEvent)
call DealFixDamage(localSource, localTarget, amount)
call EnableTrigger(udg_PDD_damageEvent)
else
call SetWidgetLife(localTarget, originalHealth - amount)
endif
// Clean things up
call FlushChildHashtable(udg_PDD_h, id)
call FlushChildHashtable(udg_PDD_h, GetHandleId(localTarget))
call DestroyTimer(time)
set time = null
set localSource = null
set localTarget = null
endfunction
function DamageEngine takes nothing returns nothing
local timer time
local integer id
local real health
local real rawAmount
local real originalHealth
local integer targetId
local integer oldTimerId
local real oldHealth
local real oldOriginalHealth
local real oldAmount
set rawAmount = GetEventDamage()
if rawAmount == 0.0 then
return
endif
set udg_PDD_source = GetEventDamageSource()
set udg_PDD_target = GetTriggerUnit()
// Determine the damage type
if rawAmount > 0.0 then
if udg_PDD_damageType != udg_PDD_CODE then
set udg_PDD_damageType = udg_PDD_PHYSICAL
endif
set udg_PDD_amount = rawAmount
else
if udg_PDD_damageType != udg_PDD_CODE then
set udg_PDD_damageType = udg_PDD_SPELL
endif
set udg_PDD_amount = -rawAmount
endif
// Register spell reduction above 100%
if udg_PDD_SPELL_RESIST_AUTO_DETECT then
set udg_PDD_amount = GetUnitSpellResistance(udg_PDD_target)*udg_PDD_amount
else
if ( IsUnitType(udg_PDD_target, UNIT_TYPE_ETHEREAL) and IsUnitEnemy(udg_PDD_target, GetOwningPlayer(udg_PDD_source)) and rawAmount < 0.0 ) then
set udg_PDD_amount = udg_PDD_ETHEREAL_DAMAGE_FACTOR*udg_PDD_amount
endif
endif
// Save health and damage variables
if udg_PDD_damageType != udg_PDD_CODE then
call UnitRemoveAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
endif
set udg_PDD_pureAmount = udg_PDD_amount
set originalHealth = GetWidgetLife(udg_PDD_target)
set oldTimerId = 0
// Call damage handlers
set udg_PDD_damageEventTrigger = 1.0
set udg_PDD_damageEventTrigger = 0.0
// If the damage was modified, apply the rescue ability
if udg_PDD_amount != udg_PDD_pureAmount then
call UnitAddAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(udg_PDD_target, GetWidgetLife(udg_PDD_target) + udg_PDD_pureAmount)
endif
// Check if a previous timer didn't yet expire
set targetId = GetHandleId(udg_PDD_target)
set oldHealth = LoadReal(udg_PDD_h, targetId, 0)
// If this is the case, update the timer information
if oldHealth != 0.0 then
set oldTimerId = LoadInteger(udg_PDD_h, targetId, 3)
set oldOriginalHealth = LoadReal(udg_PDD_h, targetId, 2)
set oldAmount = LoadReal(udg_PDD_h, targetId, 1)
set originalHealth = oldOriginalHealth - oldAmount
call SaveReal(udg_PDD_h, oldTimerId, 4, oldOriginalHealth)
endif
// Call after damage event if damage was spell, modified, code or parallel
if ( rawAmount < 0.0 or udg_PDD_pureAmount != udg_PDD_amount or oldTimerId != 0 or udg_PDD_allocatedAttacks > 0 ) then
set time = CreateTimer()
set id = GetHandleId(time)
// Save handles for after damage event
call SaveUnitHandle(udg_PDD_h, id, 0, udg_PDD_source)
call SaveUnitHandle(udg_PDD_h, id, 1, udg_PDD_target)
call SaveReal(udg_PDD_h, id, 2, udg_PDD_pureAmount)
call SaveReal(udg_PDD_h, id, 3, udg_PDD_amount)
call SaveReal(udg_PDD_h, id, 4, originalHealth)
// Save this extra to manage parallel damage instances
call SaveReal(udg_PDD_h, targetId, 0, GetWidgetLife(udg_PDD_target))
call SaveReal(udg_PDD_h, targetId, 1, udg_PDD_amount)
call SaveReal(udg_PDD_h, targetId, 2, originalHealth)
call SaveInteger(udg_PDD_h, targetId, 3, id)
// Avoid healing of negative spell damage
if rawAmount < 0.0 then
call DisableTrigger(udg_PDD_damageEvent)
call DealFixDamage(udg_PDD_source, udg_PDD_target, -rawAmount)
if ( originalHealth - udg_PDD_amount < udg_PDD_UNIT_MIN_LIFE ) then
call UnitRemoveAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call DealFixDamage(udg_PDD_source, udg_PDD_target, udg_PDD_amount)
endif
call EnableTrigger(udg_PDD_damageEvent)
endif
// Guarantee unit exploding
if originalHealth - udg_PDD_amount < udg_PDD_UNIT_MIN_LIFE then
if rawAmount > 0.0 then
call UnitRemoveAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(udg_PDD_target, udg_PDD_UNIT_MIN_LIFE)
endif
endif
// Start the after damage event
call TimerStart(time, 0.0, false, function AfterDamage)
endif
// Handle allocated attacks from UnitDamageTargetEx
if udg_PDD_totalAllocs == 0 then
set udg_PDD_totalAllocs = udg_PDD_allocatedAttacks
endif
if udg_PDD_allocatedAttacks > 0 then
set udg_PDD_allocatedAttacks = udg_PDD_allocatedAttacks - 1
set udg_PDD_allocCounter = udg_PDD_allocCounter + 1
call TriggerEvaluate(udg_PDD_runAllocatedAttacks)
endif
// Reset all required variables
set udg_PDD_damageType = -1
set udg_PDD_totalAllocs = 0
set udg_PDD_allocCounter = -1
endfunction
////////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////////
function RestoreTriggers takes nothing returns nothing
local unit enumUnit = GetEnumUnit()
// Re-register units that are alive
if GetWidgetLife(enumUnit) >= udg_PDD_UNIT_MIN_LIFE then
call TriggerRegisterUnitEvent(udg_PDD_damageEvent, enumUnit, EVENT_UNIT_DAMAGED)
endif
set enumUnit = null
endfunction
function ClearMemory_Actions takes nothing returns nothing
local group g = CreateGroup()
local code c = function DamageEngine
// Reset the damage event
call GroupEnumUnitsInRect(g, GetWorldBounds(), null)
call ResetTrigger(udg_PDD_damageEvent)
call DestroyTrigger(udg_PDD_damageEvent)
set udg_PDD_damageEvent = null
// Rebuild it then
set udg_PDD_damageEvent = CreateTrigger()
call TriggerAddCondition(udg_PDD_damageEvent, Filter(c))
call ForGroup(g, function RestoreTriggers)
// Clean things up
call DestroyGroup(g)
set g = null
set c = null
endfunction
function MapInit takes nothing returns nothing
local unit enumUnit = GetEnumUnit()
// Register units on map initialization
call UnitAddAbility(enumUnit, udg_PDD_DAMAGE_TYPE_DETECTOR)
call UnitMakeAbilityPermanent(enumUnit, true, udg_PDD_DAMAGE_TYPE_DETECTOR)
call TriggerRegisterUnitEvent(udg_PDD_damageEvent, enumUnit, EVENT_UNIT_DAMAGED)
set enumUnit = null
endfunction
function UnitEntersMap takes nothing returns nothing
local unit triggerUnit = GetTriggerUnit()
// Register units that enter the map
if ( GetUnitAbilityLevel(triggerUnit, udg_PDD_DAMAGE_TYPE_DETECTOR) < 1 ) then
call UnitAddAbility(triggerUnit, udg_PDD_DAMAGE_TYPE_DETECTOR)
call UnitMakeAbilityPermanent(triggerUnit, true, udg_PDD_DAMAGE_TYPE_DETECTOR)
call TriggerRegisterUnitEvent(udg_PDD_damageEvent, triggerUnit, EVENT_UNIT_DAMAGED)
endif
set triggerUnit = null
endfunction
function RunAllocatedAttacks takes nothing returns nothing
local integer localAllocAttacks = udg_PDD_allocatedAttacks + 1
local boolean duringModification
local unit u = LoadUnitHandle(udg_PDD_h, localAllocAttacks, 1)
local integer uId = GetHandleId(u)
local real health
local real storedHealth = LoadReal(udg_PDD_h, uId, 2)
local real storedDamage = LoadReal(udg_PDD_h, uId, 1)
// Check if the unit is being rescued from damage
set duringModification = GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0
if duringModification then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
endif
// Get the correct health value of the unit
if storedHealth != 0.0 then
set health = storedHealth - storedDamage
else
set health = GetWidgetLife(u) - storedDamage
endif
// Restore the rescue ability and return
if duringModification then
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
endif
// Calculate the correct sequence of allocated attacks
set localAllocAttacks = localAllocAttacks - udg_PDD_totalAllocs + 1 + 2*udg_PDD_allocCounter
// Deal code damage if the unit isn't exploding
set udg_PDD_damageType = udg_PDD_CODE
if health >= udg_PDD_UNIT_MIN_LIFE then
call UnitDamageTarget(LoadUnitHandle(udg_PDD_h, localAllocAttacks, 0), LoadUnitHandle(udg_PDD_h, localAllocAttacks, 1), LoadReal(udg_PDD_h, localAllocAttacks, 2), LoadBoolean(udg_PDD_h, localAllocAttacks, 3), LoadBoolean(udg_PDD_h, localAllocAttacks, 4), ConvertAttackType(LoadInteger(udg_PDD_h, localAllocAttacks, 5)), ConvertDamageType(LoadInteger(udg_PDD_h, localAllocAttacks, 6)), ConvertWeaponType(LoadInteger(udg_PDD_h, localAllocAttacks, 7)))
else
call FlushChildHashtable(udg_PDD_h, localAllocAttacks - 1)
endif
// Clean things up
call FlushChildHashtable(udg_PDD_h, localAllocAttacks)
endfunction
function InitTrig_DamageEvent takes nothing returns nothing
local group g = CreateGroup()
local region r = CreateRegion()
local trigger UnitEnters = CreateTrigger()
local trigger ClearMemory = CreateTrigger()
local code cDamageEngine = function DamageEngine
local code cUnitEnters = function UnitEntersMap
local code cClearMemory = function ClearMemory_Actions
local code cRunAllocatedAttacks = function RunAllocatedAttacks
// Initialize global variables
set udg_PDD_h = InitHashtable()
set udg_PDD_damageEvent = CreateTrigger()
set udg_PDD_damageHandler = CreateTrigger()
set udg_PDD_damageType = -1
set udg_PDD_allocatedAttacks = 0
set udg_PDD_runAllocatedAttacks = CreateTrigger()
// Initialize global configurable constants
call InitGlobalVariables()
// Initialize global fixed constants
set udg_PDD_PHYSICAL = 0
set udg_PDD_SPELL = 1
set udg_PDD_CODE = 2
set udg_PDD_UNIT_MIN_LIFE = 0.406
set udg_PDD_ATTACK_TYPE_UNIVERSAL = ConvertAttackType(7)
set udg_PDD_totalAllocs = 0
set udg_PDD_allocCounter = -1
set udg_PDD_damageEventTrigger = 0.0
// Register units on map initialization
call TriggerRegisterVariableEvent(udg_PDD_damageHandler, "udg_PDD_damageEventTrigger", EQUAL, 1.0)
call TriggerAddCondition(udg_PDD_damageEvent, Filter(cDamageEngine))
call GroupEnumUnitsInRect(g, GetWorldBounds(), null)
call ForGroup(g, function MapInit)
// Register units that enter the map
call RegionAddRect(r, GetWorldBounds())
call TriggerRegisterEnterRegion(UnitEnters, r, null)
call TriggerAddCondition(UnitEnters, Filter(cUnitEnters))
// Register trigger for allocated attacks
call TriggerAddCondition(udg_PDD_runAllocatedAttacks, Filter(cRunAllocatedAttacks))
// Clear memory leaks
call TriggerRegisterTimerEvent(ClearMemory, udg_PDD_TRIGGER_CLEANUP_PERIOD, true)
call TriggerAddCondition(ClearMemory, Filter(cClearMemory))
// Clean things up
call DestroyGroup(g)
set UnitEnters = null
set ClearMemory = null
set cDamageEngine = null
set cUnitEnters = null
set cClearMemory = null
set cRunAllocatedAttacks = null
set g = null
set r = null
endfunction
function GetUnitLife takes unit u returns real
local boolean duringModification
local integer uId = GetHandleId(u)
local real health
local real storedHealth = LoadReal(udg_PDD_h, uId, 2)
local real storedDamage = LoadReal(udg_PDD_h, uId, 1)
// Check if the unit is being rescued from damage
set duringModification = GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0
if duringModification then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
endif
// Get the correct health value of the unit
if storedHealth != 0.0 then
set health = storedHealth - storedDamage
else
set health = GetWidgetLife(u) - storedDamage
endif
// Restore the rescue ability and return
if duringModification then
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
endif
return health
endfunction
function GetUnitMaxLife takes unit u returns real
local real maxHealth
// Check if the unit is being rescued from damage
if GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0 then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
set maxHealth = GetUnitState(u, UNIT_STATE_MAX_LIFE)
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
return maxHealth
endif
// If the unit isn't being rescued, use the standard native
return GetUnitState(u, UNIT_STATE_MAX_LIFE)
endfunction
function SetUnitLife takes unit u, real newLife returns nothing
local integer targetId
local integer oldTimerId
local real oldHealth
// Check if the unit is being rescued from damage
if GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0 then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(u, newLife)
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
// Get the unit specific timer information
set targetId = GetHandleId(u)
set oldHealth = LoadReal(udg_PDD_h, targetId, 0)
// Update the unit specific timer information
if oldHealth != 0.0 then
set oldTimerId = LoadInteger(udg_PDD_h, targetId, 3)
call SaveReal(udg_PDD_h, targetId, 2, newLife)
call SaveReal(udg_PDD_h, targetId, 0, newLife)
call SaveReal(udg_PDD_h, oldTimerId, 4, newLife)
endif
return
endif
// If the unit isn't being rescued, use the standard native
call SetWidgetLife(u, newLife)
endfunction
function UnitDamageTargetEx takes unit localSource, unit localTarget, real localAmount, boolean attack, boolean ranged, attacktype localAttackType, damagetype localDamageType, weapontype localWeaponType returns boolean
// Avoid infinite loop due to recursion
if udg_PDD_damageType == udg_PDD_CODE then
return false
endif
// Avoid allocating attacks on units that are about to be killed
if ( localTarget == udg_PDD_target and GetUnitLife(localTarget) - udg_PDD_amount < udg_PDD_UNIT_MIN_LIFE ) then
return false
endif
// Store all damage parameters determined by the user
set udg_PDD_allocatedAttacks = udg_PDD_allocatedAttacks + 1
call SaveUnitHandle(udg_PDD_h, udg_PDD_allocatedAttacks, 0, localSource)
call SaveUnitHandle(udg_PDD_h, udg_PDD_allocatedAttacks, 1, localTarget)
call SaveReal(udg_PDD_h, udg_PDD_allocatedAttacks, 2, localAmount)
call SaveBoolean(udg_PDD_h, udg_PDD_allocatedAttacks, 3, attack)
call SaveBoolean(udg_PDD_h, udg_PDD_allocatedAttacks, 4, ranged)
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 5, GetHandleId(localAttackType))
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 6, GetHandleId(localDamageType))
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 7, GetHandleId(localWeaponType))
// Return true if the damage was allocated
return true
endfunction
function Set_EQ_Damage_Other_Damage_Thing takes nothing returns nothing
local timer PDD_timer = GetExpiredTimer()
local integer tid = GetHandleId(PDD_timer)
local integer i = 1
local integer cv
local item itm
local integer id
local real dur
local unit a = LoadUnitHandle(udg_SL_HASHTABLE, 14, tid)
local unit t = LoadUnitHandle(udg_SL_HASHTABLE, 15, tid)
local integer acv = GetUnitUserData(a)
local integer tcv = GetUnitUserData(t)
local player ap = GetOwningPlayer(a)
local player tp = GetOwningPlayer(t)
local player p
local integer pl = GetPlayerId(tp) + 1
local real dmg = LoadReal(udg_SL_HASHTABLE, 16, tid)
local real DmgRed = LoadReal(udg_SL_HASHTABLE, 17, tid)
local integer DDType = LoadInteger(udg_SL_HASHTABLE, 18, tid)
local real ArmorDmg = DmgRed / 5.00
local real WeaponDmg = 0.05
local real EqDmg
local real ls = udg_Global_LifeSteal[acv]
local real ms = udg_Global_ManaSteal[acv]
local real ref = udg_Global_Reflect[tcv]
local real r
call RemoveSavedHandle(udg_SL_HASHTABLE, 14, tid)
call RemoveSavedHandle(udg_SL_HASHTABLE, 15, tid)
if udg_Inv_Sens[pl] and udg_Camera_Lock[pl] > 0 then
call WindowTransition (pl, udg_Camera_Lock[pl], 0)
endif
//damageing armor and weapon
if DmgRed > 0 then
loop
exitwhen i > 9
if i != 3 then
set cv = tcv
set p = tp
set EqDmg = ArmorDmg
else
set cv = acv
set p = ap
set EqDmg = WeaponDmg
endif
if HaveSavedHandle(udg_Stat_Table, cv, i ) then
set itm = LoadItemHandle(udg_Stat_Table, cv, i )
set id = GetHandleId(itm)
set dur = LoadReal(udg_CItem_Table, id, 14) - EqDmg
call SaveReal(udg_CItem_Table, id, 14, dur)
if dur < 11 then
if not LoadBoolean(udg_Stat_Table, - cv, - i ) then
call SaveBoolean(udg_Stat_Table, - cv, - i, true )
call DisplayTextToPlayer (p, 0, 0, "|cffff0000Warning:|r |cffffff00" + GetItemName(itm) + "|r |cffff0000got low duratibility!!|r")
endif
if dur < 1 then
call ForcedUnequip (cv, i)
call DisplayTextToPlayer (p, 0, 0, "|cffff0000Broken item:|r |cffffff00" + GetItemName(itm) + "|r |cffff0000got no duratibility!!|r")
endif
endif
endif
set i = i + 1
endloop
endif
if dmg > 5 then
if ls > 0 then
set r = dmg * ls / 100.00
set ls = GetUnitLife(a) + r
call SetUnitLife(a, ls )
if r > 0.99 then
call FT_Ex (ap, tp, "+" + I2S(R2I(r)), 0.8, a, 15, 255, 30, 30, 200, 0)
endif
endif
if ms > 0 then
set r = dmg * ms / 100.00
set ms = GetUnitState(a, UNIT_STATE_MANA) + r
call SetUnitState(a, UNIT_STATE_MANA, ms )
if r > 0.99 then
call FT_Ex (ap, tp, "+" + I2S(R2I(r)), 0.8, a, 15, 30, 30, 255, 200, 180)
endif
endif
if ref > 0 then
set r = dmg * ref / 100.00
if r > 0.99 then
set udg_PDD_magicType = 100
call UnitDamageTargetEx (a, t, r, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
call FT_Ex (ap, tp, "Reflect: "+I2S(R2I(r)), 1, a, 13, 70, 255, 30, 200, 270)
endif
endif
if DDType == 0 then
if udg_Global_MDmg1[acv] > 0.00 then
call BJDebugMsg("fire dmg"+I2S(udg_Global_MDmg1[acv]))
set udg_PDD_magicType = 101
call UnitDamageTarget (a, t, udg_Global_MDmg1[acv], true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, null)
elseif udg_Global_MDmg2[acv] > 0.00 then
set udg_PDD_magicType = 102
call UnitDamageTarget (a, t, udg_Global_MDmg2[acv], true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, null)
elseif udg_Global_MDmg3[acv] > 0.00 then
set udg_PDD_magicType = 103
call UnitDamageTarget (a, t, udg_Global_MDmg3[acv], true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, null)
elseif udg_Global_MDmg4[acv] > 0.00 then
set udg_PDD_magicType = 104
call UnitDamageTarget (a, t, udg_Global_MDmg4[acv], true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, null)
elseif udg_Global_MDmg5[acv] > 0.00 then
set udg_PDD_magicType = 105
call UnitDamageTarget (a, t, udg_Global_MDmg5[acv], true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, null)
endif
endif
endif
call PauseTimer(PDD_timer)
call DestroyTimer(PDD_timer)
set PDD_timer = null
set itm = null
set a = null
set t = null
set ap = null
set tp = null
set p = null
endfunction
function Trig_Set_Damage takes nothing returns boolean
local unit a = udg_PDD_source
local unit t = udg_PDD_target
local player ap = GetOwningPlayer(a)
local player tp = GetOwningPlayer(t)
local integer acv = GetUnitUserData(a)
local integer tcv = GetUnitUserData(t)
local integer rnd //random for hit chance
local real dmg = udg_PDD_amount
local real tr
local real block
local real eva
local real alv
local real dlv
local real crit
local real critdmg
local real pdef
local real mdef
local integer hit
local integer pv
local real attackerlv
local real targetlv
local real PhysicalRed
local real MagicRed
local real DmgRed
local integer DDType = udg_PDD_damageType//0 = physical, 1 = spell, 2 = custom dmg
local integer MDType = udg_PDD_magicType//0 = physical, 1 = fire, 2 = water, 3 = lightning, 4 = poison, 5 = earth
//local boolean user = (GetPlayerSlotState(Player(0)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(0)) == MAP_CONTROL_USER)
local boolean HeroA = IsUnitType(a, UNIT_TYPE_HERO)
local boolean HeroT = IsUnitType(t, UNIT_TYPE_HERO)
local timer PDD_timer
local integer id
if dmg > 0 then
if MDType > 99 then
set MDType = MDType - 100
set DDType = 3
endif
if dmg <= 0 then
set udg_PDD_amount = 1
set dmg = udg_PDD_amount
endif
if HeroA then
set attackerlv = GetHeroLevel(a)
else
set attackerlv = GetUnitLevel(a)
endif
if HeroT then
set targetlv = GetHeroLevel(t)
else
set targetlv = GetUnitLevel(t)
endif
set block = udg_Global_Block[tcv]
set alv = udg_Global_AttLv[acv]
set dlv = udg_Global_DefLv[tcv]
if GetPlayerController(ap) != MAP_CONTROL_USER or not HeroA then
set pv = GetUnitPointValue(a)
if pv >= 50 and pv < 55 then
set MDType = pv - 49
endif
set alv = udg_Global_AttLv[acv]
endif
if ( GetPlayerController(tp) != MAP_CONTROL_USER ) and udg_Difficulty != 1 then
set dlv = udg_Global_DefLv[tcv] + udg_Difficulty * 10
else
if GetPlayerController(tp) == MAP_CONTROL_USER and GetPlayerController(ap) == MAP_CONTROL_USER then
set dmg = dmg / 4
endif
set dlv = udg_Global_DefLv[tcv]
endif
set crit = udg_Global_Crit[acv]
set critdmg = udg_Global_CritDmg[acv] + DEFAULT_CRITICAL_DAMAGE()
set eva = ( udg_Global_Eva[tcv] - 1.00 ) / ( ( 2.00 * udg_Global_Acc[acv] ) + ( udg_Global_Eva[tcv] - 1.00 ) )
set hit = HitChance(acv, tcv)//R2I((1.00 - eva) * 100.00)
set pdef = udg_Global_Pdef[tcv]
if MDType == 1 then
set mdef = udg_Global_Mdef1[tcv]
elseif MDType == 2 then
set mdef = udg_Global_Mdef2[tcv]
elseif MDType == 3 then
set mdef = udg_Global_Mdef3[tcv]
elseif MDType == 4 then
set mdef = udg_Global_Mdef4[tcv]
elseif MDType == 5 then
set mdef = udg_Global_Mdef5[tcv]
else
set mdef = 0
endif
set dmg = dmg + (udg_Global_DmgInc[acv] - udg_Global_DmgRed[tcv]) / 100.00 * dmg
if mdef < 0 then
set mdef = 0
endif
if pdef < 0 then
set pdef = 0
endif
set rnd = GetRandomInt(0, 99)
// call BJDebugMsg(GetUnitName(a)+" hit chance "+I2S(hit)+"%")
if rnd > hit and MDType == 0 and DDType == 0 then
set dmg = 0.00
call FT (ap, tp, "Miss!", 0.9 , t, 7, 51, 51, 255, 200)
set DmgRed = 0
else
set rnd = GetRandomInt(0, 99)
if rnd < block and DDType < 3 then
set dmg = 0.00
call FT (ap, tp, "Blocked!", 0.9, t, 7, 0, 0, 255, 200)
set DmgRed = 0
else
set PhysicalRed = pdef / ( 40.00 * attackerlv + pdef + 25.00 )
set MagicRed = mdef / ( 40.00 * attackerlv + mdef + 25.00 )
set rnd = GetRandomInt(0, 99)
if rnd < udg_Global_ArmorBreak[acv] then
//it was completly ignore the defence but seems that op without high hp
//so i changed so i increased the incoming dmg with divide target ressitance% by 2
//set DmgRed = 1
set PhysicalRed = PhysicalRed / 2.00
set MagicRed = MagicRed / 2
endif
if MDType > 1 then
set DmgRed = ( 1 - MagicRed )
else
set DmgRed = 1 - PhysicalRed
endif
set dmg = dmg * DmgRed
endif
if ( alv > dlv ) then
set dmg = dmg * ( 1 + ( alv - dlv ) / 100.00 )
else
set dmg = dmg / ( 1.00 + ( dlv - alv ) / 120.00)
endif
if HaveSavedHandle(udg_Stat_Table, acv, 3) then
set rnd = GetHandleId(LoadItemHandle(udg_Stat_Table, acv, 3 ))
set dmg = GetRandomReal(WeaponMinDamageModifier(LoadInteger(udg_CItem_Table, rnd, 3)) * dmg, dmg)
if udg_Global_Act_Id[acv] > 0 then
set rnd = GetRandomInt(0, 99)
if udg_Global_Act_Id[acv] == 1 then
if rnd < 5 then
set dmg = dmg * 2
call DestroyEffect(AddSpecialEffectTarget(EFFECT(1), t, EFFECT_POINT(30)))
if GetUnitMaxLife(a) * 0.05 > GetUnitLife(a) then
call SetUnitLife(a, 1)
else
call SetUnitLife(a, GetUnitLife(a) - (GetUnitMaxLife(a) * 0.05))
endif
endif
elseif udg_Global_Act_Id[acv] == 2 then
if rnd < 5 then
call AddOT (a, a, - 1, R2I(GetUnitMaxLife(a) * 0.1), 20)
endif
elseif udg_Global_Act_Id[acv] == 3 then
if rnd < 5 then
call AddOT (a, t, 0, udg_Stat_Dmg[acv] + 50, 20)
endif
elseif udg_Global_Act_Id[acv] == 4 then
if rnd < 5 then
call AddUnitBuff (a, 6, 25, 5, 0, 0)
call AddUnitBuff (a, 7, - 25, 5, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 5 then
if rnd < 5 then
call AddUnitBuff (a, 9, 13, 6, 0, 0)
call AddUnitBuff (a, 10, 13, 6, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 6 then
if rnd < 5 then
call AddUnitBuff (t, 7, - 15, 5, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 7 then
if rnd < 5 then
call AddUnitBuff (a, 11, 100, 4, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 8 then
if rnd < 5 then
call AddUnitBuff (a, 15, R2I(udg_Stat_Pdef[acv] * 0.6), 20, 0, 0)
call AddUnitBuff (a, 16, R2I(udg_Stat_Mdef1[acv] * 0.6), 20, 0, 0)
call AddUnitBuff (a, 17, R2I(udg_Stat_Mdef2[acv] * 0.6), 20, 0, 0)
call AddUnitBuff (a, 18, R2I(udg_Stat_Mdef3[acv] * 0.6), 20, 0, 0)
call AddUnitBuff (a, 19, R2I(udg_Stat_Mdef4[acv] * 0.6), 20, 0, 0)
call AddUnitBuff (a, 20, R2I(udg_Stat_Mdef5[acv] * 0.6), 20, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 9 then
if rnd < 25 then
call AddUnitBuff (a, 5, 50, 4, 0, 0)
endif
endif
endif
endif
if GetRandomReal(0.00, 100) <= crit and DDType < 3 and dmg > 0 then
set dmg = dmg * critdmg / 100.00
call FT (ap, tp, "Critical: "+I2S(R2I(dmg)), 1.5, t, 10, 255, 0, 0, 200)
else
call FT (ap, tp, I2S(R2I(dmg)), 0.8, t, 15, 179, 255, 51, 200)
endif
if dmg > 0 then
set PDD_timer = CreateTimer()
set id = GetHandleId(PDD_timer)
call SaveUnitHandle(udg_SL_HASHTABLE, 14, id, a)
call SaveUnitHandle(udg_SL_HASHTABLE, 15, id, t)
call SaveReal(udg_SL_HASHTABLE, 16, id, dmg)
call SaveReal(udg_SL_HASHTABLE, 17, id, DmgRed)
call SaveInteger(udg_SL_HASHTABLE, 18, id, DDType)
call TimerStart(PDD_timer, 0.1, false, function Set_EQ_Damage_Other_Damage_Thing)
set PDD_timer = null
endif
endif
set udg_PDD_amount = dmg
set udg_PDD_magicType = 0
if udg_CombatTimer[tcv] < 1 then
set udg_CombatTimer[tcv] = 10
set udg_CombatIndex = udg_CombatIndex + 1
set udg_CombatI2CV[udg_CombatIndex] = tcv
call StatRefresh (tcv)
if udg_Camera_Lock[GetPlayerId(tp) + 1] == 1 then
call ShowStat (GetPlayerId(tp) + 1)
endif
else
set udg_CombatTimer[tcv] = 10
endif
if udg_CombatTimer[acv] < 1 then
set udg_CombatTimer[acv] = 10
set udg_CombatIndex = udg_CombatIndex + 1
set udg_CombatI2CV[udg_CombatIndex] = acv
call StatRefresh (acv)
if udg_Camera_Lock[GetPlayerId(ap) + 1] == 1 then
call ShowStat (GetPlayerId(tp) + 1)
endif
else
set udg_CombatTimer[acv] = 10
endif
endif
set a = null
set t = null
set ap = null
set tp = null
return false
endfunction
//===========================================================================
function InitTrig_Set_Damage_1 takes nothing returns nothing
set gg_trg_Set_Damage_1 = CreateTrigger( )
call TriggerRegisterVariableEvent( gg_trg_Set_Damage_1, "udg_PDD_damageEventTrigger", EQUAL, 1.00 )
call TriggerAddCondition( gg_trg_Set_Damage_1, Condition( function Trig_Set_Damage ) )
endfunction
function GetUnitLife takes unit u returns real
local boolean duringModification
local integer uId = GetHandleId(u)
local real health
local real storedHealth = LoadReal(udg_PDD_h, uId, 2)
local real storedDamage = LoadReal(udg_PDD_h, uId, 1)
// Check if the unit is being rescued from damage
set duringModification = GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0
if duringModification then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
endif
// Get the correct health value of the unit
if storedHealth != 0.0 then
set health = storedHealth - storedDamage
else
set health = GetWidgetLife(u) - storedDamage
endif
// Restore the rescue ability and return
if duringModification then
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
endif
return health
endfunction
function GetUnitMaxLife takes unit u returns real
local real maxHealth
// Check if the unit is being rescued from damage
if GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0 then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
set maxHealth = GetUnitState(u, UNIT_STATE_MAX_LIFE)
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
return maxHealth
endif
// If the unit isn't being rescued, use the standard native
return GetUnitState(u, UNIT_STATE_MAX_LIFE)
endfunction
function SetUnitLife takes unit u, real newLife returns nothing
local integer targetId
local integer oldTimerId
local real oldHealth
// Check if the unit is being rescued from damage
if GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0 then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(u, newLife)
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
// Get the unit specific timer information
set targetId = GetHandleId(u)
set oldHealth = LoadReal(udg_PDD_h, targetId, 0)
// Update the unit specific timer information
if oldHealth != 0.0 then
set oldTimerId = LoadInteger(udg_PDD_h, targetId, 3)
call SaveReal(udg_PDD_h, targetId, 2, newLife)
call SaveReal(udg_PDD_h, targetId, 0, newLife)
call SaveReal(udg_PDD_h, oldTimerId, 4, newLife)
endif
return
endif
// If the unit isn't being rescued, use the standard native
call SetWidgetLife(u, newLife)
endfunction
function UnitDamageTargetEx takes unit localSource, unit localTarget, real localAmount, boolean attack, boolean ranged, attacktype localAttackType, damagetype localDamageType, weapontype localWeaponType returns boolean
// Avoid infinite loop due to recursion
if udg_PDD_damageType == udg_PDD_CODE then
return false
endif
// Avoid allocating attacks on units that are about to be killed
if ( localTarget == udg_PDD_target and GetUnitLife(localTarget) - udg_PDD_amount < udg_PDD_UNIT_MIN_LIFE ) then
return false
endif
// Store all damage parameters determined by the user
set udg_PDD_allocatedAttacks = udg_PDD_allocatedAttacks + 1
call SaveUnitHandle(udg_PDD_h, udg_PDD_allocatedAttacks, 0, localSource)
call SaveUnitHandle(udg_PDD_h, udg_PDD_allocatedAttacks, 1, localTarget)
call SaveReal(udg_PDD_h, udg_PDD_allocatedAttacks, 2, localAmount)
call SaveBoolean(udg_PDD_h, udg_PDD_allocatedAttacks, 3, attack)
call SaveBoolean(udg_PDD_h, udg_PDD_allocatedAttacks, 4, ranged)
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 5, GetHandleId(localAttackType))
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 6, GetHandleId(localDamageType))
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 7, GetHandleId(localWeaponType))
// Return true if the damage was allocated
return true
endfunction
function DamageDecrease takes integer cv, integer slot, real amount returns nothing
local item itm
local integer id
local real dur
local integer pl = GetPlayerId(GetOwningPlayer(udg_UDexUnits[cv])) + 1
if HaveSavedHandle(udg_Stat_Table, cv, slot ) then
set itm = LoadItemHandle(udg_Stat_Table, cv, slot )
if slot < 10 and itm != null and amount > 0 then
set id = GetHandleId(itm)
set dur = LoadReal(udg_CItem_Table, id, 14) - amount
call SaveReal(udg_CItem_Table, id, 14, dur)
if dur < 11 then
if not LoadBoolean(udg_Stat_Table, - cv, - 3 ) then
call SaveBoolean(udg_Stat_Table, - cv, - 3, true )
call DisplayTextToPlayer (Player(pl - 1), 0, 0, "|cffff0000Warning:|r |cffffff00" + GetItemName(itm) + "|r |cffff0000got low duratibility!!|r")
endif
if dur < 1 then
call ForcedUnequip (cv, slot)
call DisplayTextToPlayer (Player(pl - 1), 0, 0, "|cffff0000Broken item:|r |cffffff00" + GetItemName(itm) + "|r |cffff0000got no duratibility!!|r")
endif
endif
endif
set itm = null
endif
endfunction
function Trig_Set_Damage takes nothing returns boolean
local unit a = udg_PDD_source
local unit t = udg_PDD_target
local integer ap = GetPlayerId(GetOwningPlayer(a)) + 1
local integer tp = GetPlayerId(GetOwningPlayer(t)) + 1
local integer acv = GetUnitUserData(a)
local integer tcv = GetUnitUserData(t)
local integer rnd //random for hit chance
local real dmg = udg_PDD_amount
local real dmgaddon
local real r
local real tr
local real block
local real eva
local real alv
local real dlv
local real crit
local real critdmg
local real pdef
local real mdef
local integer hit
local integer pv
local real attackerlv
local real targetlv
local real PhysicalRed
local real MagicRed
local real ref = udg_Global_Reflect[tcv]
local real ls = udg_Global_LifeSteal[acv]
local real ms = udg_Global_ManaSteal[acv]
local real DmgRed
local integer DDType = udg_PDD_damageType//1=physical, 2=spell, 3=custom dmg
local integer MDType = udg_PDD_magicType//0=physical, 1=fire, 2=water,3=lightning,4=poison,5=earth
if dmg > 0 then
if MDType > 99 then
set MDType = MDType - 100
set DDType = 3
endif
if dmg <= 0 then
set udg_PDD_amount = 1
set dmg = udg_PDD_amount
endif
// call DisplayTextToForce( GetPlayersAll(), I2S(dmgtype)+"-"+I2S(DamageTypeDOT)+R2S(udg_Global_MDmg4[acv]) )
if DDType == 1 and MDType == 0 then
if udg_Global_MDmg1[acv] > 0.00 then
set udg_PDD_magicType = 1
call UnitDamageTargetEx (a, t, udg_Global_MDmg1[acv], true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
elseif udg_Global_MDmg2[acv] > 0.00 then
set udg_PDD_magicType = 2
call UnitDamageTargetEx (a, t, udg_Global_MDmg2[acv], true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
elseif udg_Global_MDmg3[acv] > 0.00 then
set udg_PDD_magicType = 3
call UnitDamageTargetEx (a, t, udg_Global_MDmg3[acv], true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
elseif udg_Global_MDmg4[acv] > 0.00 then
set udg_PDD_magicType = 4
call UnitDamageTargetEx (a, t, udg_Global_MDmg4[acv], true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
elseif udg_Global_MDmg5[acv] > 0.00 then
set udg_PDD_magicType = 5
call UnitDamageTargetEx (a, t, udg_Global_MDmg5[acv], true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
endif
//call DestroyEffect(AddSpecialEffectTarget(udg_Effects[1], t, EFFECT_POINT(30)))
//call FT (Player(ap-1), Player(tp-1),I2S(R2I(dmgaddon)), 0.8, t, 20, 100, 100, 255, 200)
endif
if ( IsUnitType(a, UNIT_TYPE_HERO) ) then
set attackerlv = GetHeroLevel(a)
else
set attackerlv = GetUnitLevel(a)
endif
if ( IsUnitType(t, UNIT_TYPE_HERO) ) then
set targetlv = GetHeroLevel(t)
else
set targetlv = GetUnitLevel(t)
endif
//pet power if you got summoner class, i not enabled it
//if ( udg_Pet[GetUnitUserData(udg_Hero[ap])] == a and udg_Class2[ap]==6 ) then
// set dmg = dmg + (udg_Stat_Pet_Power[ap] + GetHeroInt(udg_Hero[ap], true)/100.00) * dmg
//endif
set block = udg_Global_Block[tcv]
set alv = udg_Global_AttLv[acv]
set dlv = udg_Global_DefLv[tcv]
if ( GetPlayerController(GetOwningPlayer(a)) != MAP_CONTROL_USER ) then
set pv = GetUnitPointValue(a)
if pv >= 50 and pv < 55 then
set MDType = pv - 49
endif
set alv = udg_Global_AttLv[acv]
endif
// call DisplayTextToPlayer(Player(0),0,0,GetUnitName(a)+" TYPE"+I2S(DDType)+" mtype"+I2S(MDType)+"-->amount"+" dmg"+R2S(dmg))
if ( GetPlayerController(GetOwningPlayer(t)) != MAP_CONTROL_USER ) and udg_Difficulty != 1 then
set dlv = udg_Global_DefLv[tcv] + udg_Difficulty * 10
else
if GetPlayerController(GetOwningPlayer(t)) == MAP_CONTROL_USER and GetPlayerController(GetOwningPlayer(a)) == MAP_CONTROL_USER then
set dmg = dmg / 4
endif
set dlv = udg_Global_DefLv[tcv]
endif
set crit = udg_Global_Crit[acv]
set critdmg = udg_Global_CritDmg[acv] + DEFAULT_CRITICAL_DAMAGE()
set eva = ( udg_Global_Eva[tcv] - 1.00 ) / ( ( 2.00 * udg_Global_Acc[acv] ) + ( udg_Global_Eva[tcv] - 1.00 ) )
set hit = HitChance(acv, tcv)//R2I((1.00 - eva) * 100.00)
set pdef = udg_Global_Pdef[tcv]
if MDType == 1 then
set mdef = udg_Global_Mdef1[tcv]
elseif MDType == 2 then
set mdef = udg_Global_Mdef2[tcv]
elseif MDType == 3 then
set mdef = udg_Global_Mdef3[tcv]
elseif MDType == 4 then
set mdef = udg_Global_Mdef4[tcv]
elseif MDType == 5 then
set mdef = udg_Global_Mdef5[tcv]
else
set mdef = 0
endif
set dmg = dmg + (udg_Global_DmgInc[acv] - udg_Global_DmgRed[tcv]) / 100.00 * dmg
if mdef < 0 then
set mdef = 0
endif
if pdef < 0 then
set pdef = 0
endif
set rnd = GetRandomInt(0, 99)
if rnd < hit and MDType == 0 and DDType == 1 then
set dmg = 0.00
call FT (Player(ap - 1), Player(tp - 1), "Miss!", 0.9 , t, 7, 51, 51, 255, 200)
set DmgRed = 0
else
set rnd = GetRandomInt(0, 99)
if rnd < block and DDType < 3 then
set dmg = 0.00
call FT (Player(ap - 1), Player(tp - 1), "Blocked!", 0.9, t, 7, 0, 0, 255, 200)
set DmgRed = 0
else
set PhysicalRed = pdef / ( 40.00 * attackerlv + pdef + 25.00 )
set MagicRed = mdef / ( 40.00 * attackerlv + mdef + 25.00 )
set rnd = GetRandomInt(0, 99)
if rnd < udg_Global_ArmorBreak[acv] then
//it was completly ignore the defence but seems that op without high hp
//so i changed so i increased the incoming dmg with divide target ressitance% by 2
//set DmgRed = 1
set PhysicalRed = PhysicalRed / 2.00
set MagicRed = MagicRed / 2
endif
if MDType > 1 then
set DmgRed = ( 1 - MagicRed )
else
set DmgRed = 1 - PhysicalRed
endif
set dmg = dmg * DmgRed
if GetPlayerController(GetOwningPlayer(t)) == MAP_CONTROL_USER and DmgRed > 0 then
call DamageDecrease (tcv, 1, DmgRed / 5)
call DamageDecrease (tcv, 2, DmgRed / 5)
call DamageDecrease (tcv, 4, DmgRed / 5)
call DamageDecrease (tcv, 5, DmgRed / 5)
call DamageDecrease (tcv, 6, DmgRed / 5)
call DamageDecrease (tcv, 7, DmgRed / 5)
call DamageDecrease (tcv, 8, DmgRed / 5)
call DamageDecrease (tcv, 9, DmgRed / 5)
if udg_Inv_Sens[tp] and udg_Camera_Lock[tp] > 0 then
call WindowTransition (tp, udg_Camera_Lock[tp], 0)
endif
endif
if GetPlayerController(GetOwningPlayer(a)) == MAP_CONTROL_USER then
if HaveSavedHandle(udg_Stat_Table, acv, 3) then
call DamageDecrease (acv, 3, 0.05)
set rnd = GetHandleId(LoadItemHandle(udg_Stat_Table, acv, 3 ))
set dmg = GetRandomReal(WeaponMinDamageModifier(LoadInteger(udg_CItem_Table, rnd, 3))*dmg, dmg)
endif
endif
if ( alv > dlv ) then
set dmg = dmg * ( 1 + ( alv - dlv ) / 100.00 )
else
set dmg = dmg / ( 1.00 + ( dlv - alv ) / 120.00)
endif
if udg_Global_Act_Id[acv] > 0 then
set rnd = GetRandomInt(0, 99)
if udg_Global_Act_Id[acv] == 1 then
if rnd < 5 then
set dmg = dmg * 2
call DestroyEffect(AddSpecialEffectTarget(EFFECT(1), t, EFFECT_POINT(30)))
if GetUnitMaxLife(a)*0.05 > GetUnitLife(a) then
call SetUnitLife(a, 1)
else
call SetUnitLife(a, GetUnitLife(a)-(GetUnitMaxLife(a)*0.05))
endif
endif
elseif udg_Global_Act_Id[acv] == 2 then
if rnd < 5 then
call AddOT (a, a, -1, R2I(GetUnitMaxLife(a)*0.1), 20)
endif
elseif udg_Global_Act_Id[acv] == 3 then
if rnd < 5 then
call AddOT (a, t, 0, udg_Stat_Dmg[acv]+50, 20)
endif
elseif udg_Global_Act_Id[acv] == 4 then
if rnd < 5 then
call AddUnitBuff (a, 6, 25, 5, 0, 0)
call AddUnitBuff (a, 7, -25, 5, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 5 then
if rnd < 5 then
call AddUnitBuff (a, 9, 13, 6, 0, 0)
call AddUnitBuff (a, 10, 13, 6, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 6 then
if rnd < 5 then
call AddUnitBuff (t, 7, -15, 5, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 7 then
if rnd < 5 then
call AddUnitBuff (a, 11, 100, 4, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 8 then
if rnd < 5 then
call AddUnitBuff (a, 15, R2I(udg_Stat_Pdef[acv]*0.6), 20, 0, 0)
call AddUnitBuff (a, 16, R2I(udg_Stat_Mdef1[acv]*0.6), 20, 0, 0)
call AddUnitBuff (a, 17, R2I(udg_Stat_Mdef2[acv]*0.6), 20, 0, 0)
call AddUnitBuff (a, 18, R2I(udg_Stat_Mdef3[acv]*0.6), 20, 0, 0)
call AddUnitBuff (a, 19, R2I(udg_Stat_Mdef4[acv]*0.6), 20, 0, 0)
call AddUnitBuff (a, 20, R2I(udg_Stat_Mdef5[acv]*0.6), 20, 0, 0)
endif
elseif udg_Global_Act_Id[acv] == 9 then
if rnd < 25 then
call AddUnitBuff (a, 5, 50, 4, 0, 0)
endif
endif
endif
if GetRandomReal(0.00, 100) <= crit and DDType < 3 and dmg > 0 then
set dmg = dmg * critdmg / 100.00
call FT (Player(ap - 1), Player(tp - 1), I2S(R2I(dmg)), 1.5, t, 10, 255, 0, 0, 200)
else
call FT (Player(ap - 1), Player(tp - 1), I2S(R2I(dmg)), 0.8, t, 15, 179, 255, 51, 200)
endif
if DDType < 3 and dmg > 5 then
if ls > 0 then
set r = dmg * ls / 100.00
set ls = GetUnitLife(a) + r
call SetUnitLife(a, ls )
if r > 0.99 then
call FT_Ex (Player(ap - 1), Player(tp - 1), "+" + I2S(R2I(r)), 0.8, a, 15, 255, 30, 30, 200, 0)
endif
endif
if ms > 0 then
set r = dmg * ms / 100.00
set ms = GetUnitState(a, UNIT_STATE_MANA) + r
call SetUnitState(a, UNIT_STATE_MANA, ms )
if r > 0.99 then
call FT_Ex (Player(ap - 1), Player(tp - 1), "+" + I2S(R2I(r)), 0.8, a, 15, 30, 30, 255, 200, 180)
endif
endif
if ref > 0 then
set dmgaddon = dmg * ref / 100.00
call UnitDamageTargetEx (a, t, dmgaddon, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
if dmgaddon > 0.99 then
set udg_PDD_magicType = MDType
call FT_Ex (Player(ap - 1), Player(tp - 1), I2S(R2I(dmgaddon)), 1, t, 13, 70, 255, 30, 200, 270)
endif
endif
endif
endif
endif
set udg_PDD_amount = dmg
set udg_PDD_magicType = 0
if udg_CombatTimer[tcv] < 1 then
set udg_CombatTimer[tcv] = 10
set udg_CombatIndex = udg_CombatIndex + 1
set udg_CombatI2CV[udg_CombatIndex] = tcv
call StatRefresh (tcv)
if udg_Camera_Lock[tp] == 1 then
call ShowStat (tp)
endif
else
set udg_CombatTimer[tcv] = 10
endif
if udg_CombatTimer[acv] < 1 then
set udg_CombatTimer[acv] = 10
set udg_CombatIndex = udg_CombatIndex + 1
set udg_CombatI2CV[udg_CombatIndex] = acv
call StatRefresh (acv)
if udg_Camera_Lock[ap] == 1 then
call ShowStat (ap)
endif
else
set udg_CombatTimer[acv] = 10
endif
//call DisplayTextToPlayer(Player(0),0,0,"3-->amount"+" dmg"+R2S(dmg))
endif
set a = null
set t = null
return false
endfunction
//===========================================================================
function InitTrig_Set_Damage takes nothing returns nothing
set gg_trg_Set_Damage = CreateTrigger( )
call TriggerRegisterVariableEvent( gg_trg_Set_Damage, "udg_PDD_damageEventTrigger", EQUAL, 1.00 )
call TriggerAddCondition( gg_trg_Set_Damage, Condition( function Trig_Set_Damage ) )
endfunction