Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STATS_SYSTEM_CONFIG = {
- -- BASIC CONFIG STARTS HERE
- -- enable/disable features so script will execute only what you want
- monsterLoot = false,
- addSlotAction = true,
- addLevelAction = true,
- PVEStat = true,
- xpStat = true,
- lootStat = true,
- combatStats = true,
- conditionStats = true,
- -- don't forget to register them in actions or they will not work
- GEM_BASIC_LEVEL = 8310,
- GEM_ADD_SLOT = 8300,
- GEM_RANDOM = 8305,
- GEM_RARE = 8301,
- GEM_EPIC = 8302,
- GEM_LEGENDARY = 8303,
- gems_power = {
- [8301] = {min_wl = 0, max_wl = 4, min_el = 0.3, max_el = 0.6, sl = function() return 2 end}, -- rare
- [8302] = {min_wl = 3, max_wl = 6, min_el = 0.6, max_el = 0.7, sl = function() return 3 end}, -- epic
- [8303] = {min_wl = 5, max_wl = 9, min_el = 0.8, max_el = 1, sl = function() return 4 end}, -- legendary
- [8305] = {min_wl = 0, max_wl = 9, min_el = 0.3, max_el = 1, sl = function() return math.random(2, 4) end} -- random
- },
- maxSlotCount = 4,
- slotChances = {
- [1] = 1000,
- [2] = 5000,
- [3] = 15000,
- [4] = 25000
- },
- tiers = { -- item name based on slots looted (if more than 1)
- [2] = 'rare',
- [3] = 'epic',
- [4] = 'legendary'
- },
- weapon_levels = {
- -- weapon name if no slots were assigned, chance(1000 = 1%)
- [-9] = {'useless', 300},
- [-8] = {'broken', 500},
- [-7] = {'trash', 1000},
- [-6] = {'ruined', 1500},
- [-5] = {'damaged', 2000},
- [-4] = {'worthless', 2500},
- [-3] = {'blunt', 4000},
- [-2] = {'cheap', 7000},
- [-1] = {'common', 9000},
- [1] = {'uncommon', 25000},
- [2] = {'strengthened', 20000},
- [3] = {'fine', 15000},
- [4] = {'superior', 10000},
- [5] = {'rare', 7500},
- [6] = {'unique', 3500},
- [7] = {'flawless', 2500},
- [8] = {'epic', 1000},
- [9] = {'legendary', 500}
- },
- ignoredIds = {}, -- items with these ids will be banned from upgrading
- upgradeMagicItems = true, -- items with xml-sided bonuses, examples: magma coat, fire axe, boots of haste
- upgradeItemsWithNoArmor = true, -- allow upgrading clothes without arm value
- lootUpgradedItems = true,
- rare_popup = true,
- rare_text = "*rare*",
- rare_effect = true,
- rare_effect_id = CONST_ME_MAGIC_GREEN,
- rare_loot_level = true, -- set to false if you want to disable levels on looted weapons
- rare_negative_level = true, -- set to false if you want to disable it
- rare_min_level = -9,
- useSkill = true, -- enchanting power based on player's skill, set to false if you want it random
- skillTriesStorage = 3866,
- simple = { -- upgrade by jewels
- enabled = true,
- usePerks = false, -- unused
- randomSpells = true, -- todo: modal with selecting attr if false
- downgradeOnFail = true, -- item level only
- },
- -- BASIC CONFIG ENDS HERE
- -- do not touch things below unless you are a advanced scripter
- skillFormula = function(lv) return math.ceil(((1 * lv^3) - (2 * lv^2) + (4 * lv)) / (90 + lv) + lv) end,
- maxLevel = 30,
- levelUpgradeFormula = function(lv, minl)
- if STATS_SYSTEM_CONFIG.rare_negative_level then
- return math.ceil((lv/minl) * 25) + math.min(math.ceil(lv/minl * 5) +70, 75)
- else
- return 65 - math.ceil((lv/minl) * 3)
- end
- end,
- -- spells and values for certain types of item
- UPGRADE_STATS_VALUES_PER_LVL = {
- -- value per level
- atk = 1,
- def = 1,
- extradef = 1,
- arm = 1,
- hitchance = 1,
- shootrange = 1
- },
- UPGRADE_SPELLS = {
- necklace = {
- -- {'hp', 200, 10}, -- normal, percent
- -- {'mp', 300, 10},
- -- {'ml', 3, 6},
- -- {'melee', 2, 6},
- -- {'shield', 2, 6},
- -- {'dist', 2, 6},
- -- {'physical', 10, 5},
- -- {'energy', 10, 10},
- -- {'earth', 10, 10},
- -- {'fire', 10, 10},
- -- {'undefined', 10, 10},
- -- {'lifedrain', 10, 10},
- -- {'manadrain', 10, 10},
- -- {'healing', -10, -10},
- -- {'water', 20, 100},
- -- {'ice', 10, 10},
- -- {'holy', 10, 10},
- -- {'death', 10, 10},
- -- {'regHP', 5, 2}, -- normalhp, normalmp, percenthp, percentmp
- -- {'regMP', 10, 3}, -- normalhp, normalmp, percenthp, percentmp
- -- {'PVE death', 1, 100}
- },
- helmet = {
- {'ml', 2, 6},
- {'melee', 2, 6},
- {'dist', 2, 6},
- {'physical', 10, 3},
- {'energy', 10, 10},
- {'earth', 10, 10},
- {'fire', 10, 10},
- -- {'undefined', 10, 10},
- -- {'lifedrain', 10, 10},
- -- {'manadrain', 10, 10},
- -- {'healing', -10, -10},
- -- {'water', 20, 100},
- {'ice', 10, 10},
- {'holy', 10, 10},
- {'death', 10, 10},
- {'arm', 12, 70},
- },
- weapon = {
- {'melee', 3, 8},
- {'physical', 50, 10},
- {'energy', 50, 10},
- {'earth', 50, 10},
- {'fire', 50, 10},
- -- {'undefined', 50, 10},
- {'ice', 50, 10},
- {'holy', 50, 10},
- {'death', 50, 10},
- -- {'drainHP', 50, 3},
- -- {'drainMP', 50, 3},
- -- {'water', 50, 10},
- {'animals', 50, 10},
- {'humans', 50, 3},
- {'undeads', 50, 10},
- {'insects', 50, 10},
- {'atk', 6, 20},
- {'def', 10, 30},
- {'extra def', 10, 30},
- },
- distance = {
- {'dist', 3, 8},
- {'physical', 50, 10},
- {'energy', 50, 10},
- {'earth', 50, 10},
- {'fire', 50, 10},
- -- {'undefined', 50, 10},
- {'ice', 50, 10},
- {'holy', 50, 10},
- {'death', 50, 10},
- -- {'drainHP', 50, 3},
- -- {'drainMP', 50, 3},
- -- {'water', 50, 10},
- {'animals', 50, 10},
- {'humans', 50, 3},
- {'undeads', 50, 10},
- {'insects', 50, 10},
- {'atk', 6, 20},
- {'accuracy', 12, 70},
- {'range', 3, 50},
- },
- wand = {
- {'ml', 5, 15},
- {'physical', 100, 20},
- {'energy', 100, 20},
- {'earth', 100, 20},
- {'fire', 100, 20},
- -- {'undefined', 50, 10},
- {'healing', 50, 10},
- {'ice', 100, 20},
- {'holy', 100, 20},
- {'death', 100, 20},
- -- {'drainHP', 50, 3},
- -- {'drainMP', 50, 3},
- -- {'water', 50, 10},
- {'animals', 50, 10},
- {'humans', 50, 3},
- {'undeads', 50, 10},
- {'insects', 50, 10},
- {'range', 3, 50},
- },
- armor = {
- {'hp', 500, 15},
- {'mp', 800, 20},
- {'ml', 5, 7},
- {'melee', 5, 7},
- {'shield', 5, 7},
- {'dist', 5, 7},
- {'physical', 50, 5},
- {'energy', 10, 15},
- {'earth', 10, 15},
- {'fire', 10, 15},
- -- {'undefined', 10, 15},
- -- {'lifedrain', 10, 15},
- -- {'manadrain', 10, 15},
- -- {'healing', -10, -15},
- -- {'water', 20, 100},
- {'ice', 10, 15},
- {'holy', 10, 15},
- {'death', 10, 15},
- {'regHP', 5, 2},
- {'regMP', 10, 3},
- {'arm', 7, 30},
- },
- shield = {
- {'ml', 3, 10},
- {'shield', 5, 15},
- {'physical', 30, 5},
- {'energy', 10, 10},
- {'earth', 10, 10},
- {'fire', 10, 10},
- -- {'undefined', 10, 15},
- -- {'lifedrain', 10, 15},
- -- {'manadrain', 10, 15},
- {'ice', 10, 10},
- {'holy', 10, 10},
- {'death', 10, 10},
- {'regHP', 5, 2},
- {'regMP', 10, 3},
- {'def', 12, 30},
- },
- ring = {
- -- {'hp', 200, 10},
- -- {'mp', 300, 10},
- -- {'ml', 3, 6},
- -- {'melee', 3, 6},
- -- {'shield', 3, 6},
- -- {'dist', 3, 6},
- -- {'physical', 10, 5},
- -- {'energy', 10, 10},
- -- {'earth', 10, 10},
- -- {'fire', 10, 10},
- -- {'undefined', 10, 10},
- -- {'lifedrain', 10, 10},
- -- {'manadrain', 10, 10},
- -- {'healing', -10, -10},
- -- {'water', 20, 100},
- -- {'ice', 10, 10},
- -- {'holy', 10, 10},
- -- {'death', 10, 10},
- -- {'regHP', 5, 2},
- -- {'regMP', 10, 3},
- -- {'exp', 500, 30},
- },
- legs = {
- {'ml', 3, 6},
- {'melee', 3, 5},
- {'shield', 3, 5},
- {'dist', 3, 5},
- {'physical', 10, 4},
- {'energy', 10, 6},
- {'earth', 10, 6},
- {'fire', 10, 6},
- -- {'undefined', 10, 10},
- -- {'lifedrain', 10, 10},
- -- {'manadrain', 10, 10},
- -- {'healing', -10, -10},
- {'ice', 10, 6},
- {'holy', 10, 6},
- {'death', 10, 6},
- {'arm', 6, 40},
- },
- boots = {
- -- {'physical', 10, 3},
- -- {'energy', 10, 5},
- -- {'earth', 10, 5},
- -- {'fire', 10, 5},
- -- {'undefined', 10, 10},
- -- {'lifedrain', 10, 10},
- -- {'manadrain', 10, 10},
- -- {'healing', -10, -10},
- -- {'ice', 10, 5},
- -- {'holy', 10, 5},
- -- {'death', 10, 5},
- -- {'regHP', 8, 3},
- -- {'regMP', 15, 4},
- -- {'arm', 5, 50},
- },
- charges = {
- {'charges', 500, 45},
- },
- decay = {
- {'time', 1200000, 50},
- },
- },
- STATS = {
- {
- name = 'hp',
- weaponLootName = {'',''},
- armorLootName = {'','of improved health'},
- otherLootName = {'','of improved health'},
- spellName = 'Health',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'mp',
- spellName = 'Mana',
- enabledValues = true,
- weaponLootName = {'',''},
- armorLootName = {'','of improved mana'},
- otherLootName = {'','of improved mana'},
- enabledPercent = true
- },
- {
- name = 'ml',
- weaponLootName = {'magic',''},
- armorLootName = {'enchanted',''},
- otherLootName = {'magic',''},
- spellName = 'Magic Level',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'melee',
- weaponLootName = {'','of power'},
- armorLootName = {'warrior',''},
- otherLootName = {'','of power'},
- spellName = 'Melee Skill',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'shield',
- weaponLootName = {'','of defense'},
- armorLootName = {'fortified',''},
- otherLootName = {'','of defense'},
- spellName = 'Shielding',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'dist',
- weaponLootName = {'','of hunting'},
- armorLootName = {'hunter',''},
- otherLootName = {'','of hunting'},
- spellName = 'Distance Skill',
- enabledValues = true,
- enabledPercent = true
- },
- -- element types
- -- on weapon: value = more or less element damage
- -- on armor: value = when something hits you, hit value may increase or decrease depending on value
- {
- name = 'physical',
- combatType = COMBAT_PHYSICALDAMAGE,
- weaponLootName = {'','of bleeding'},
- armorLootName = {'strong',''},
- otherLootName = {'stone',''},
- spellName = 'Physical',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_BLOCKHIT
- },
- {
- name = 'energy',
- combatType = COMBAT_ENERGYDAMAGE,
- weaponLootName = {'','of thunders'},
- armorLootName = {'','of sparks'},
- otherLootName = {'','of lightning'},
- oppositeSpell = 'earth', -- unused values
- spellName = 'Energy',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_ENERGYHIT
- },
- {
- name = 'earth',
- combatType = COMBAT_EARTHDAMAGE,
- weaponLootName = {'poison',''},
- armorLootName = {'earthproof',''},
- otherLootName = {'','of antidote'},
- oppositeSpell = 'energy',
- spellName = 'Earth',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_SMALLPLANTS
- },
- {
- name = 'fire',
- combatType = COMBAT_FIREDAMAGE,
- weaponLootName = {'burning',''},
- armorLootName = {'fireproof',''},
- otherLootName = {'','of fire protection'},
- oppositeSpell = 'ice',
- spellName = 'Fire',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_FIREATTACK
- },
- {
- -- exist in tfs, not in use by default
- name = 'undefined',
- combatType = COMBAT_UNDEFINEDDAMAGE,
- weaponLootName = {'ghost',''},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'None',
- enabledValues = false,
- enabledPercent = false,
- effect = CONST_ME_GROUNDSHAKER
- },
- {
- name = 'lifedrain',
- combatType = COMBAT_LIFEDRAIN,
- weaponLootName = {'cursed',''},
- armorLootName = {'enchanted',''},
- otherLootName = {'blessed',''},
- oppositeSpell = 'healing',
- spellName = 'Lifedrain',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_MAGIC_RED
- },
- {
- name = 'manadrain',
- combatType = COMBAT_MANADRAIN,
- weaponLootName = {'','of dark magic'},
- armorLootName = {'sealed',''},
- otherLootName = {'','of mana protection'},
- spellName = 'Manadrain',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_LOSEENERGY
- },
- {
- -- should not be used by weapons
- name = 'healing',
- combatType = COMBAT_HEALING,
- weaponLootName = {'healer',''},
- armorLootName = {'','of healing'},
- otherLootName = {'','of healing'},
- oppositeSpell = 'lifedrain',
- spellName = 'Healing',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_MAGIC_BLUE
- },
- {
- name = 'water',
- combatType = COMBAT_DROWNDAMAGE,
- weaponLootName = {'','of fear'},
- armorLootName = {'','of the deep'},
- otherLootName = {'','of the deep'},
- spellName = 'Water',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_LOSEENERGY
- },
- {
- name = 'ice',
- combatType = COMBAT_ICEDAMAGE,
- weaponLootName = {'icy',''},
- armorLootName = {'frozen',''},
- otherLootName = {'','of cold'},
- oppositeSpell = 'fire',
- spellName = 'Ice',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_ICEATTACK
- },
- {
- name = 'holy',
- combatType = COMBAT_HOLYDAMAGE,
- weaponLootName = {'divine',''},
- armorLootName = {'','of darkness'},
- otherLootName = {'dark',''},
- oppositeSpell = 'death',
- spellName = 'Holy',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_HOLYDAMAGE
- },
- {
- name = 'death',
- combatType = COMBAT_DEATHDAMAGE,
- weaponLootName = {'','of darkness'},
- armorLootName = {'','of inquisition'},
- otherLootName = {'holy',''},
- oppositeSpell = 'holy',
- spellName = 'Death',
- enabledValues = true,
- enabledPercent = true,
- effect = CONST_ME_MORTAREA
- },
- -- weapon only
- {
- name = 'drainHP',
- drain = COMBAT_LIFEDRAIN,
- weaponLootName = {'vampire',''},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Drain Health',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'drainMP',
- drain = COMBAT_MANADRAIN,
- weaponLootName = {'','of weakness'},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Drain Mana',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'animals',
- weaponLootName = {'hunting',''},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Animals',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'humans',
- weaponLootName = {'',''},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Humans',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'undeads',
- weaponLootName = {'','of inquisition'},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Undeads',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'insects',
- weaponLootName = {'','of insect hunting'},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Insects',
- enabledValues = true,
- enabledPercent = true
- },
- -- buff
- {
- name = 'regHP',
- weaponLootName = {'',''},
- armorLootName = {'','of vitality'},
- otherLootName = {'','of vitality'},
- spellName = 'HP Regeneration',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'regMP',
- weaponLootName = {'',''},
- armorLootName = {'','of magic'},
- otherLootName = {'','of magic'},
- spellName = 'MP Regeneration',
- enabledValues = true,
- enabledPercent = true
- },
- -- attr based stats
- {
- name = 'charges',
- weaponLootName = {'',''},
- armorLootName = {'',''},
- otherLootName = {'charged',''},
- spellName = 'Charges',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'time',
- weaponLootName = {'',''},
- armorLootName = {'',''},
- otherLootName = {'fine',''},
- spellName = 'Duration',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'atk',
- weaponLootName = {'sharpened',''},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Attack',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'def',
- weaponLootName = {'strong',''},
- armorLootName = {'fortified',''},
- otherLootName = {'',''},
- spellName = 'Defense',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'extra def',
- weaponLootName = {'','of balance'},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Extra Defense',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'arm',
- weaponLootName = {'',''},
- armorLootName = {'masterpiece of',''},
- otherLootName = {'',''},
- spellName = 'Armor',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'accuracy',
- weaponLootName = {'accurate',''},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Hit Chance',
- enabledValues = true, -- hit% + x%
- enabledPercent = true -- hit% + hit%*x%
- },
- {
- name = 'range',
- weaponLootName = {'sniper',''},
- armorLootName = {'',''},
- otherLootName = {'',''},
- spellName = 'Range',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'PVE death',
- weaponLootName = {'',''},
- armorLootName = {'',''},
- otherLootName = {'','of good fate'},
- spellName = 'PVE Death',
- enabledValues = true,
- enabledPercent = true
- },
- -- xp, loot
- {
- name = 'exp',
- weaponLootName = {'',''},
- armorLootName = {'',''},
- otherLootName = {'','of experience'},
- spellName = 'Extra Exp',
- enabledValues = true,
- enabledPercent = true
- },
- {
- name = 'loot',
- weaponLootName = {'',''},
- armorLootName = {'',''},
- otherLootName = {'','of luck'},
- spellName = 'Luck',
- enabledValues = true,
- enabledPercent = true
- },
- },
- }
- function getItemAttribute(uid, key, force)
- local i = ItemType(Item(uid):getId())
- local string_attributes = {
- [ITEM_ATTRIBUTE_NAME] = i:getName(),
- [ITEM_ATTRIBUTE_ARTICLE] = i:getArticle(),
- [ITEM_ATTRIBUTE_PLURALNAME] = i:getPluralName(),
- ["name"] = i:getName(),
- ["article"] = i:getArticle(),
- ["pluralname"] = i:getPluralName()
- }
- local numeric_attributes = {
- [ITEM_ATTRIBUTE_WEIGHT] = i:getWeight(),
- [ITEM_ATTRIBUTE_ATTACK] = i:getAttack(),
- [ITEM_ATTRIBUTE_DEFENSE] = i:getDefense(),
- [ITEM_ATTRIBUTE_EXTRADEFENSE] = i:getExtraDefense(),
- [ITEM_ATTRIBUTE_ARMOR] = i:getArmor(),
- [ITEM_ATTRIBUTE_HITCHANCE] = i:getHitChance(),
- [ITEM_ATTRIBUTE_SHOOTRANGE] = i:getShootRange(),
- ["weight"] = i:getWeight(),
- ["attack"] = i:getAttack(),
- ["defense"] = i:getDefense(),
- ["extradefense"] = i:getExtraDefense(),
- ["armor"] = i:getArmor(),
- ["hitchance"] = i:getHitChance(),
- ["shootrange"] = i:getShootRange()
- }
- local item = Item(uid)
- local attr = item:getAttribute(key)
- if tonumber(attr) then
- if numeric_attributes[key] then
- if force and item:getActionId() == 101 then
- return attr
- else
- return attr ~= 0 and attr or numeric_attributes[key]
- end
- end
- else
- if string_attributes[key] then
- if attr == "" then
- return string_attributes[key]
- end
- end
- end
- return attr
- end
- function doItemSetAttribute(uid, key, value)
- return Item(uid):setAttribute(key, value)
- end
- function doItemEraseAttribute(uid, key)
- return Item(uid):removeAttribute(key)
- end
- local element_stats = {}
- local drain_stats = {}
- for i = 1, #STATS_SYSTEM_CONFIG.STATS do
- local stat = STATS_SYSTEM_CONFIG.STATS[i]
- if stat.drain then
- drain_stats[stat.name] = stat.drain
- end
- if stat.combatType then
- element_stats[stat.name] = {combat = stat.combatType, effect = stat.effect}
- end
- end
- local stat_conditions = {
- [1] = {['hp'] = {}, ['mp'] = {}, ['ml'] = {}, ['melee'] = {}, ['shield'] = {}, ['dist'] = {}}, -- normal
- [2] = {['hp'] = {}, ['mp'] = {}, ['ml'] = {}, ['melee'] = {}, ['shield'] = {}, ['dist'] = {}} -- percent
- }
- for i = -95, 300 do
- -- % stats and skills
- stat_conditions[2]['hp'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[2]['hp'][i], CONDITION_PARAM_SUBID, 50)
- setConditionParam(stat_conditions[2]['hp'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[2]['hp'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[2]['hp'][i], CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 100+i)
- stat_conditions[2]['mp'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[2]['mp'][i], CONDITION_PARAM_SUBID, 51)
- setConditionParam(stat_conditions[2]['mp'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[2]['mp'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[2]['mp'][i], CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, 100+i)
- stat_conditions[2]['ml'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[2]['ml'][i], CONDITION_PARAM_SUBID, 52)
- setConditionParam(stat_conditions[2]['ml'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[2]['ml'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[2]['ml'][i], CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, 100+i)
- stat_conditions[2]['melee'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[2]['melee'][i], CONDITION_PARAM_SUBID, 53)
- setConditionParam(stat_conditions[2]['melee'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[2]['melee'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[2]['melee'][i], CONDITION_PARAM_SKILL_MELEEPERCENT, 100+i)
- stat_conditions[2]['shield'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[2]['shield'][i], CONDITION_PARAM_SUBID, 54)
- setConditionParam(stat_conditions[2]['shield'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[2]['shield'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[2]['shield'][i], CONDITION_PARAM_SKILL_SHIELDPERCENT, 100+i)
- stat_conditions[2]['dist'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[2]['dist'][i], CONDITION_PARAM_SUBID, 55)
- setConditionParam(stat_conditions[2]['dist'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[2]['dist'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[2]['dist'][i], CONDITION_PARAM_SKILL_DISTANCEPERCENT, 100+i)
- end
- for i = -1500, 1500 do
- -- hp mp normal
- stat_conditions[1]['hp'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[1]['hp'][i], CONDITION_PARAM_SUBID, 56)
- setConditionParam(stat_conditions[1]['hp'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[1]['hp'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[1]['hp'][i], CONDITION_PARAM_STAT_MAXHITPOINTS, i)
- stat_conditions[1]['mp'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[1]['mp'][i], CONDITION_PARAM_SUBID, 57)
- setConditionParam(stat_conditions[1]['mp'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[1]['mp'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[1]['mp'][i], CONDITION_PARAM_STAT_MAXMANAPOINTS, i)
- end
- for i = -100, 100 do
- -- skills
- stat_conditions[1]['ml'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[1]['ml'][i], CONDITION_PARAM_SUBID, 58)
- setConditionParam(stat_conditions[1]['ml'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[1]['ml'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[1]['ml'][i], CONDITION_PARAM_STAT_MAGICPOINTS, i)
- stat_conditions[1]['melee'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[1]['melee'][i], CONDITION_PARAM_SUBID, 59)
- setConditionParam(stat_conditions[1]['melee'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[1]['melee'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[1]['melee'][i], CONDITION_PARAM_SKILL_MELEE, i)
- stat_conditions[1]['shield'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[1]['shield'][i], CONDITION_PARAM_SUBID, 60)
- setConditionParam(stat_conditions[1]['shield'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[1]['shield'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[1]['shield'][i], CONDITION_PARAM_SKILL_SHIELD, i)
- stat_conditions[1]['dist'][i] = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(stat_conditions[1]['dist'][i], CONDITION_PARAM_SUBID, 61)
- setConditionParam(stat_conditions[1]['dist'][i], CONDITION_PARAM_BUFF_SPELL, 1)
- setConditionParam(stat_conditions[1]['dist'][i], CONDITION_PARAM_TICKS, -1)
- setConditionParam(stat_conditions[1]['dist'][i], CONDITION_PARAM_SKILL_DISTANCE, i)
- end
- local magic_words = { -- see upgradeMagicItems in config
- 'physical',
- 'fire',
- 'ice',
- 'earth',
- 'energy',
- 'poison',
- 'drown',
- 'holy',
- 'death',
- 'lifedrain',
- 'manadrain',
- 'protection',
- 'magic',
- 'fighting',
- 'shielding',
- 'speed',
- 'invisibility',
- 'drinking',
- 'regeneration',
- }
- local upgrade_types = {
- none = false,
- necklace = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.necklace,
- helmet = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.helmet,
- weapon = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.weapon,
- distance = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.distance,
- wand = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.wand,
- armor = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.armor,
- shield = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.shield,
- ring = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.ring,
- legs = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.legs,
- boots = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.boots,
- charges = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.charges,
- decay = STATS_SYSTEM_CONFIG.UPGRADE_SPELLS.decay,
- }
- function Item:getUpgradeType()
- local it_id = self:getType()
- if it_id:isStackable() or it_id:isContainer() then
- return upgrade_types.none
- end
- local wp = it_id:getWeaponType()
- if self:getAttribute(ITEM_ATTRIBUTE_CHARGES) > 0 then
- if wp > 0 then
- return upgrade_types.none
- end
- return upgrade_types.charges
- end
- if self:getAttribute(ITEM_ATTRIBUTE_DURATION) > 0 then
- if wp > 0 then
- return upgrade_types.none
- end
- return upgrade_types.decay
- else
- if self:getBaseDuration() > 0 then
- if wp > 0 then
- return upgrade_types.none
- end
- return upgrade_types.decay
- end
- end
- if wp > 0 then
- if wp == WEAPON_SHIELD then
- return upgrade_types.shield
- elseif wp == WEAPON_DISTANCE then
- return upgrade_types.distance
- elseif wp == WEAPON_WAND then
- return upgrade_types.wand
- elseif isInArray({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}, wp) then
- return upgrade_types.weapon
- end
- else
- local slot = it_id:getSlotPosition() - SLOTP_LEFT - SLOTP_RIGHT
- if it_id:getArmor() > 0 or STATS_SYSTEM_CONFIG.upgradeItemsWithNoArmor then
- if slot == SLOTP_HEAD then
- return upgrade_types.helmet
- elseif slot == SLOTP_ARMOR then
- return upgrade_types.armor
- elseif slot == SLOTP_LEGS then
- return upgrade_types.legs
- elseif slot == SLOTP_FEET then
- return upgrade_types.boots
- end
- end
- if slot == SLOTP_NECKLACE then
- return upgrade_types.necklace
- end
- if slot == SLOTP_RING then
- return upgrade_types.ring
- end
- end
- return upgrade_types.none
- end
- function Item:getStatSlotCount()
- local c = 0
- for _ in self:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION):gmatch('%[(.-)%]') do
- c = c+1
- end
- return c
- end
- function Item:getStatSlots()
- local t = {}
- for _ in self:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION):gmatch('(%[.-%])') do
- if _ then
- if _:match('%[(.+)%]') then
- local n = _:match('%[(.+)%]')
- if n ~= '?' then
- local n1 = n:split(".")
- local i = #t + 1
- t[i] = {n1[1], n1[2]}
- end
- end
- end
- end
- return t
- end
- function Item:addStatSlot(spell, val, suffix)
- if spell and val then
- if not suffix then suffix = "" end
- self:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, self:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. "[" .. spell .. "." .. (val >= 0 and "+" .. val or val) .. suffix .. "]")
- else
- return false
- end
- return true
- end
- function Item:addSlot(name, val, percent)
- val = tonumber(val)
- if name and val then
- if self:addStat(name, val, (percent and "%" or "")) then
- return true
- end
- end
- return false
- end
- function Item:getBaseDuration()
- local it_id = self:getId()
- local tid = ItemType(it_id):getTransformEquipId()
- local vx = self:getAttribute(ITEM_ATTRIBUTE_DURATION)
- if tid > 0 then
- self:transform(tid)
- vx = self:getAttribute(ITEM_ATTRIBUTE_DURATION)
- self:transform(it_id)
- self:removeAttribute(ITEM_ATTRIBUTE_DURATION)
- end
- return vx
- end
- function Item:getBaseStatsInfo()
- local it_id = self:getType()
- local t = {
- attack = it_id:getAttack(),
- defense = it_id:getDefense(),
- extraDefense = it_id:getExtraDefense(),
- armor = it_id:getArmor(),
- hitChance = it_id:getHitChance(),
- shootRange = it_id:getShootRange(),
- charges = it_id:getCharges(),
- duration = self:getBaseDuration()
- }
- return t
- end
- function getEnchantingSkill(tries)
- local xp = 0
- local level = 0
- for lv = 1, STATS_SYSTEM_CONFIG.maxLevel do
- xp = STATS_SYSTEM_CONFIG.skillFormula(lv) -- alternative: xp = xp + STATS_SYSTEM_CONFIG.skillFormula(lv)
- if tries < xp then
- level = lv
- break
- end
- level = lv
- end
- return level
- end
- local SPELL_TYPE_VALUE = 1
- local SPELL_TYPE_PERCENT = 2
- local attrkeys = {
- ['charges'] = ITEM_ATTRIBUTE_CHARGES,
- ['time'] = ITEM_ATTRIBUTE_DURATION,
- ['atk'] = ITEM_ATTRIBUTE_ATTACK,
- ['def'] = ITEM_ATTRIBUTE_DEFENSE,
- ['extra def'] = ITEM_ATTRIBUTE_EXTRADEFENSE,
- ['arm'] = ITEM_ATTRIBUTE_ARMOR,
- ['accuracy'] = ITEM_ATTRIBUTE_HITCHANCE,
- ['range'] = ITEM_ATTRIBUTE_SHOOTRANGE
- }
- function Item.addStat(item, spellname, spellvalue, suffix, cid)
- if isInArray({'charges', 'time', 'atk', 'def', 'extra def', 'arm', 'accuracy', 'range'}, spellname) then
- local basestats = item:getBaseStatsInfo()
- local basestats2 = {
- ['charges'] = basestats.charges,
- ['time'] = basestats.duration,
- ['atk'] = basestats.attack,
- ['def'] = basestats.defense,
- ['extra def'] = basestats.extraDefense,
- ['arm'] = basestats.armor,
- ['accuracy'] = basestats.hitChance,
- ['range'] = basestats.shootRange
- }
- local uid = item:getUniqueId()
- local fullstats = {
- ['charges'] = getItemAttribute(uid, ITEM_ATTRIBUTE_CHARGES),
- ['time'] = item:getBaseDuration(),
- ['atk'] = getItemAttribute(uid, ITEM_ATTRIBUTE_ATTACK),
- ['def'] = getItemAttribute(uid, ITEM_ATTRIBUTE_DEFENSE),
- ['extra def'] = getItemAttribute(uid, ITEM_ATTRIBUTE_EXTRADEFENSE),
- ['arm'] = getItemAttribute(uid, ITEM_ATTRIBUTE_ARMOR),
- ['accuracy'] = getItemAttribute(uid, ITEM_ATTRIBUTE_HITCHANCE),
- ['range'] = getItemAttribute(uid, ITEM_ATTRIBUTE_SHOOTRANGE)
- }
- if suffix == "%" then
- if basestats2[spellname] == 0 then
- if cid then
- Player(cid):sendTextMessage(MESSAGE_INFO_DESCR, "Spell " .. spellname .. "% is not available for this item.")
- end
- return false
- end
- item:setAttribute(attrkeys[spellname], fullstats[spellname] + math.abs(math.floor((basestats2[spellname] * spellvalue/100)))) -- basestat intended to prevent too high values when combined with upgrade system
- else
- item:setAttribute(attrkeys[spellname], fullstats[spellname] + math.abs(spellvalue))
- end
- end
- item:addStatSlot(spellname, spellvalue, suffix)
- return true
- end
- local upgradable_stats = {
- [1] = {ITEM_ATTRIBUTE_ATTACK, function(id) return id:getAttack() end, STATS_SYSTEM_CONFIG.UPGRADE_STATS_VALUES_PER_LVL.atk},
- [2] = {ITEM_ATTRIBUTE_DEFENSE, function(id) return id:getDefense() end, STATS_SYSTEM_CONFIG.UPGRADE_STATS_VALUES_PER_LVL.def},
- [3] = {ITEM_ATTRIBUTE_EXTRADEFENSE, function(id) return id:getExtraDefense() end, STATS_SYSTEM_CONFIG.UPGRADE_STATS_VALUES_PER_LVL.extradef},
- [4] = {ITEM_ATTRIBUTE_ARMOR, function(id) return id:getArmor() end, STATS_SYSTEM_CONFIG.UPGRADE_STATS_VALUES_PER_LVL.arm},
- [5] = {ITEM_ATTRIBUTE_HITCHANCE, function(id) return id:getHitChance() end, STATS_SYSTEM_CONFIG.UPGRADE_STATS_VALUES_PER_LVL.hitchance},
- [6] = {ITEM_ATTRIBUTE_SHOOTRANGE, function(id) return id:getShootRange() > 1 and id:getShootRange() or 0 end, STATS_SYSTEM_CONFIG.UPGRADE_STATS_VALUES_PER_LVL.shootrange}
- }
- function stat_onUse(player, item, fromPosition, itemEx, toPosition, attempt)
- if item.itemid == STATS_SYSTEM_CONFIG.GEM_BASIC_LEVEL then
- if STATS_SYSTEM_CONFIG.addLevelAction then
- local it_id = ItemType(itemEx.itemid)
- if it_id then
- if not it_id:isStackable() then
- if it_id:getTransformEquipId() < 1 then
- if it_id:getCharges() < 1 then
- local item_sp_slot = it_id:getSlotPosition() - SLOTP_LEFT - SLOTP_RIGHT
- if item_sp_slot ~= SLOTP_NECKLACE and item_sp_slot ~= SLOTP_RING and (item_sp_slot > 0 or it_id:getWeaponType() > 0) then
- local stat_min = 1
- if STATS_SYSTEM_CONFIG.rare_negative_level then
- stat_min = STATS_SYSTEM_CONFIG.rare_min_level
- end
- local stat_max = #STATS_SYSTEM_CONFIG.weapon_levels
- local stat_lvl = tonumber(getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_NAME):match("%s%+%d+") or getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_NAME):match("%s%-%d+"))
- if stat_lvl == stat_max then
- player:sendTextMessage(MESSAGE_INFO_DESCR, "This item is on max level already.")
- return true
- end
- local n_lvl = stat_lvl
- if not stat_lvl then
- stat_lvl = 0
- end
- local chance = STATS_SYSTEM_CONFIG.levelUpgradeFormula(stat_lvl, stat_min)
- local it_u = Item(itemEx.uid)
- local it_name = it_u:getName()
- if stat_lvl > 0 then
- it_name = getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_NAME):split("+")[1]
- elseif stat_lvl < 0 then
- it_name = getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_NAME):split("-")[1]
- end
- it_name = it_name:gsub("^%s*(.-)%s*$", "%1")
- if math.random(1, 100) <= chance then
- n_lvl = stat_lvl + 1
- else
- if STATS_SYSTEM_CONFIG.simple.downgradeOnFail then
- n_lvl = stat_lvl - 1
- end
- end
- for i = 1, #upgradable_stats do
- local n_item_stat = upgradable_stats[i][2](it_id)
- it_u:setAttribute(upgradable_stats[i][1], getItemAttribute(itemEx.uid, upgradable_stats[i][1], true) + (upgradable_stats[i][3] * (n_lvl - stat_lvl)))
- end
- it_u:setActionId(101)
- Item(item.uid):remove(1)
- if (n_lvl - stat_lvl) > 0 then
- player:sendTextMessage(MESSAGE_INFO_DESCR, it_name:gsub("^%l", string.upper) .. " upgraded to " .. (n_lvl > 0 and "+" or "") .. n_lvl .. ".")
- toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
- else
- player:sendTextMessage(MESSAGE_INFO_DESCR, "Attempt to upgrade failed.")
- toPosition:sendMagicEffect(CONST_ME_HITAREA)
- end
- it_u:setAttribute(ITEM_ATTRIBUTE_NAME, it_name .. (n_lvl ~= 0 and (" " .. (n_lvl > 0 and "+" or "") .. n_lvl) or ""))
- return true
- end
- end
- end
- end
- end
- end
- return false
- end
- if item.itemid == STATS_SYSTEM_CONFIG.GEM_ADD_SLOT then
- if not STATS_SYSTEM_CONFIG.addSlotAction then
- return false
- end
- if not attempt then
- attempt = 1
- end
- if attempt == 10 then
- player:sendTextMessage(MESSAGE_INFO_DESCR, "Unable to add slot.")
- return true
- end
- local it_u = Item(itemEx.uid)
- if not it_u then
- return false
- end
- if not STATS_SYSTEM_CONFIG.simple.enabled then
- return false
- end
- if not STATS_SYSTEM_CONFIG.simple.randomSpells then
- -- popup modal
- -- popUpStatModal_index(player, item.uid)
- print("todo: modal window")
- return true
- end
- if isInArray(STATS_SYSTEM_CONFIG.ignoredIds, itemEx.itemid) then
- -- player:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot upgrade this item.")
- return false
- end
- local it_id = ItemType(itemEx.itemid)
- local u = it_u:getUpgradeType()
- if not u then
- -- player:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot upgrade this item.")
- return false
- end
- if not STATS_SYSTEM_CONFIG.upgradeMagicItems then
- local atr = it_u:getDescription():match('%((.+)%)')
- if atr and magic_words then
- if #magic_words > 0 then
- for i = 1, #magic_words do
- if atr:match(magic_words[i]) then
- player:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot upgrade magic items.")
- return true
- end
- end
- end
- end
- end
- local stat = math.random(1, #u)
- local tries = player:getStorageValue(STATS_SYSTEM_CONFIG.skillTriesStorage)
- if tries < 0 then
- player:setStorageValue(STATS_SYSTEM_CONFIG.skillTriesStorage, 0)
- end
- local level = STATS_SYSTEM_CONFIG.useSkill and getEnchantingSkill(tries) or math.random(1, STATS_SYSTEM_CONFIG.maxLevel)
- local spellname = u[stat][1]
- local spelltype = 0
- local available_spell_types = {}
- for i = 1, #STATS_SYSTEM_CONFIG.STATS do
- if STATS_SYSTEM_CONFIG.STATS[i].name == spellname then
- if STATS_SYSTEM_CONFIG.STATS[i].enabledValues then
- table.insert(available_spell_types, SPELL_TYPE_VALUE)
- end
- if STATS_SYSTEM_CONFIG.STATS[i].enabledPercent then
- table.insert(available_spell_types, SPELL_TYPE_PERCENT)
- end
- if #available_spell_types > 0 then
- spelltype = available_spell_types[math.random(1, #available_spell_types)]
- end
- break
- end
- end
- if spelltype == 0 then
- player:sendTextMessage(MESSAGE_INFO_DESCR, "Error: spell is unavailable.")
- return true
- end
- local spellattr = nil
- for i = 1, #STATS_SYSTEM_CONFIG.STATS do
- if STATS_SYSTEM_CONFIG.STATS[i].name == spellname then
- spellattr = STATS_SYSTEM_CONFIG.STATS[i]
- break
- end
- end
- if not spellattr then
- player:sendTextMessage(MESSAGE_INFO_DESCR, "Error: spell is unavailable.")
- return true
- end
- local prc = (level * 100/STATS_SYSTEM_CONFIG.maxLevel)/100
- local attrval = 0
- local attrstr = ""
- if spelltype == SPELL_TYPE_VALUE then
- attrval = math.floor(prc * u[stat][2])
- elseif spelltype == SPELL_TYPE_PERCENT then
- attrval = math.floor(prc * u[stat][3])
- attrstr = "%"
- end
- if attrval == 0 then
- player:sendTextMessage(MESSAGE_INFO_DESCR, "Error: spell is unavailable.")
- return true
- end
- local slotc = it_u:getStatSlotCount()
- if slotc == STATS_SYSTEM_CONFIG.maxSlotCount then
- player:sendTextMessage(MESSAGE_INFO_DESCR, "Slot limit reached.")
- return true
- end
- local cur_slots = it_u:getStatSlots()
- for i = 1, slotc do
- if spellname == cur_slots[i][1] then
- -- player:sendTextMessage(MESSAGE_INFO_DESCR, "Duplicate stat, try again.")
- stat_onUse(player, item, fromPosition, itemEx, toPosition, attempt + 1)
- return true
- end
- end
- if it_u:addStat(spellname, attrval, attrstr, player:getId()) then
- toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
- player:sendTextMessage(MESSAGE_INFO_DESCR, "Upgrade successful.\n" .. spellattr.spellName .. " " .. (attrval >= 0 and "+" .. attrval or attrval) .. attrstr)
- doRemoveItem(item.uid, 1)
- if STATS_SYSTEM_CONFIG.useSkill then
- player:setStorageValue(STATS_SYSTEM_CONFIG.skillTriesStorage, player:getStorageValue(STATS_SYSTEM_CONFIG.skillTriesStorage) + 1)
- local nlevel = STATS_SYSTEM_CONFIG.useSkill and getEnchantingSkill(player:getStorageValue(STATS_SYSTEM_CONFIG.skillTriesStorage)) or math.random(1, STATS_SYSTEM_CONFIG.maxLevel)
- if nlevel > level then
- player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You advanced to enchanting Level " .. (nlevel < STATS_SYSTEM_CONFIG.maxLevel and nlevel or nlevel .. " [max]") .. ".")
- end
- end
- end
- return true
Add Comment
Please, Sign In to add comment