• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

CreatureEvent [TFS 1.1] Ultimate item stat system (elements, skills, exp, loot and more)

oshrigames

Active Member
Joined
Nov 9, 2012
Messages
221
Best answers
0
Reaction score
38
Location
israel
how complicated will it be for me to add few more item attributes to those lists?
or if at all possible?

manadrain = 2, -- add to weapons & wands
lifedrain = 5, -- add to weapons & wands
hp = 5, - all gear but weapons & wands
mana = 5, - all gear but weapons & wands
exp = +x0.2%, - rings & boots
loot = +x0.2% - rings & boots

Lua:
    -- 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 = 2,
            shootrange = 1
    },

Lua:
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}
}
Lua:
[7] = {ITEM_ATTRIBUTE_LIFEDRAIN, function(id) return id:getLifeDrain() > 1 and id:getLifeDrain(() or 0 end, STATS_SYSTEM_CONFIG.UPGRADE_STATS_VALUES_PER_LVL.lifedrain(}
Lua:
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()
    }

i mean its the biggest script i've read in my entire life 2k+ lines and too advanced for me to understand to completion :x
 
Last edited:

jel

New Member
Joined
Mar 22, 2014
Messages
105
Best answers
0
Reaction score
2

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/stats.lua:onHealthChange
data/stats.lua:1566: bad argument #2 to 'random' (interval is empty)
stack traceback:
[C]: in ?
[C]: in function 'random'
data/stats.lua:1566: in function <data/stats.lua:1508>
(...tail calls...)
in function 'random'

 

tejdi

The legend never die.
Joined
Oct 26, 2010
Messages
326
Best answers
1
Reaction score
45
Location
Poland
I love that script but I can not manage to make upgrading gems working.
I don't have any errors in the console while using gems.
Moreover, I added everything to actions.xml and also created specific .lua files.
Using gems ends with communion "You can not use this object." :(
 

Kouki

Member
Joined
Feb 5, 2016
Messages
46
Best answers
3
Reaction score
8
hey.. i have a problem..
I use tfs 1.2.. when i try to login on my server i got this error in my console..

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/stats.lua:eek:nLogin
data/creaturescripts/scripts/stats.lua:22: attempt to call global 'stat_onLogin' (a nil value)
stack traceback:
[C]: in function 'stat_onLogin'
data/creaturescripts/scripts/stats.lua:22: in function <data/creaturescripts/scripts/stats.lua:21>

someone know why?
 
Top