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

bonfim25

New Member
Joined
Jan 17, 2011
Messages
17
Reaction score
1
Location
Brazil
the only thing that changed was the alteration that Sir Islam said to work the action the rest was already working normal. !
 

chrillefock

Well-Known Member
Joined
Jul 4, 2009
Messages
94
Reaction score
22
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/creaturescr
ipts/scripts/stats.lua:21>

anyone know what i have done wrong?
 

Aeronx

Active Member
Joined
Dec 17, 2015
Messages
708
Reaction score
91
It works on TFS 1.2 There's many incompatibilities with other systems. Try it on a clean TFS 1.2 server, and then you'll know if its something on your server or just that you missed something :p
 

William Sezo

Rookie but passionate
Joined
May 6, 2016
Messages
43
Reaction score
6
Location
Brazil
It works on TFS 1.2 There's many incompatibilities with other systems. Try it on a clean TFS 1.2 server, and then you'll know if its something on your server or just that you missed something :p
Got on top of it yesterday and got it working!
Don't ask me what I did tho...

Thanks!
 

William Sezo

Rookie but passionate
Joined
May 6, 2016
Messages
43
Reaction score
6
Location
Brazil
It works for upgrading with the stones, but the +X items are not dropping from monsters.
Does anyone know how to fix this?
 

Aeronx

Active Member
Joined
Dec 17, 2015
Messages
708
Reaction score
91
Actually they drop, but there's a problem with that part,
That even random crap items like torches or bones get
Upgraded! I got it working fine on a tfs 1.2, just recheck
Your steps, and redo them if necessary. It works, not as
It should, but it works. The fixes needs to be done by yourself
Or ask someone to do it for you.
 

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,030
Reaction score
590
Location
Canada
Anyone got this working with TFS 1.2?
considering the differences in code for 1.1 vs 1.2 are small, I can't imagine why it wouldn't work with 1.2. I don't remember for sure which version I was using when I tried this system but it worked fine. It was probably 1.2.
 

God Mythera

Veteran OT User
Joined
Aug 11, 2012
Messages
2,043
Reaction score
211
Location
United States
considering the differences in code for 1.1 vs 1.2 are small, I can't imagine why it wouldn't work with 1.2. I don't remember for sure which version I was using when I tried this system but it worked fine. It was probably 1.2.
I did everything it said and my server wont open, if i was to test it again it would be when i get a dedi host ;d
 

Kemixe

New Member
Joined
Jul 18, 2014
Messages
7
Reaction score
1

When I try to use GEM_BASIC_LEVEL and GEM_ADD_SLOT, it works, but when I try to use the others, this error


Code:
Lua Script Error: [Action Interface]
data/actions/scripts/slot.lua:onUse
data/lib2/stats.lua:1470: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/lib2/stats.lua:1470: in function 'stat_onUse'
        data/actions/scripts/slot.lua:3: in function <data/actions/scripts/slot.lua:1>
Code:
    GEM_BASIC_LEVEL = 2280,
    GEM_ADD_SLOT = 2281,
    GEM_RANDOM = 2282,
    GEM_RARE = 2283,
    GEM_EPIC = 2284,
    GEM_LEGENDARY = 2296,
    gems_power = {
        [2297] = {min_wl = 0, max_wl = 4, min_el = 0.3, max_el = 0.6, sl = function() return 2 end}, -- rare
        [2298] = {min_wl = 3, max_wl = 6, min_el = 0.6, max_el = 0.7, sl = function() return 3 end}, -- epic
        [2299] = {min_wl = 5, max_wl = 9, min_el = 0.8, max_el = 1, sl = function() return 4 end}, -- legendary
        [2300] = {min_wl = 0, max_wl = 9, min_el = 0.3, max_el = 1, sl = function() return math.random(2, 4) end} -- random
Line 1470:
Code:
                if item2:generateStats(u, STATS_SYSTEM_CONFIG.gems_power[item.itemid].sl(), math.random(STATS_SYSTEM_CONFIG.gems_power[item.itemid].min_wl, STATS_SYSTEM_CONFIG.gems_power[item.itemid].max_wl), math.floor(STATS_SYSTEM_CONFIG.maxLevel * STATS_SYSTEM_CONFIG.gems_power[item.itemid].min_el), math.ceil(STATS_SYSTEM_CONFIG.maxLevel * STATS_SYSTEM_CONFIG.gems_power[item.itemid].max_el)) then
                    toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
                    doRemoveItem(item.uid, 1)
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Item modification successful.")
                    return true
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Erro1.")
                end
Actions:
Code:
function onUse(player, item, fromPosition, itemEx, toPosition)
if not (Item(itemEx.uid) or not Creature(itemEx.uid)) or itemEx.itemid == 2173 then return false end
stat_onUse(player, item, fromPosition, itemEx, toPosition)
return true
end


Thx!
 
Last edited:

Kemixe

New Member
Joined
Jul 18, 2014
Messages
7
Reaction score
1
When I try to use GEM_BASIC_LEVEL and GEM_ADD_SLOT, it works, but when I try to use the others, this error

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/slot.lua:onUse
data/lib2/stats.lua:1470: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/lib2/stats.lua:1470: in function 'stat_onUse'
        data/actions/scripts/slot.lua:3: in function <data/actions/scripts/slot.lua:1>
Code:
    GEM_BASIC_LEVEL = 2280,
    GEM_ADD_SLOT = 2281,
    GEM_RANDOM = 2282,
    GEM_RARE = 2283,
    GEM_EPIC = 2284,
    GEM_LEGENDARY = 2296,
    gems_power = {
        [2297] = {min_wl = 0, max_wl = 4, min_el = 0.3, max_el = 0.6, sl = function() return 2 end}, -- rare
        [2298] = {min_wl = 3, max_wl = 6, min_el = 0.6, max_el = 0.7, sl = function() return 3 end}, -- epic
        [2299] = {min_wl = 5, max_wl = 9, min_el = 0.8, max_el = 1, sl = function() return 4 end}, -- legendary
        [2300] = {min_wl = 0, max_wl = 9, min_el = 0.3, max_el = 1, sl = function() return math.random(2, 4) end} -- random
Line 1470:
Code:
                if item2:generateStats(u, STATS_SYSTEM_CONFIG.gems_power[item.itemid].sl(), math.random(STATS_SYSTEM_CONFIG.gems_power[item.itemid].min_wl, STATS_SYSTEM_CONFIG.gems_power[item.itemid].max_wl), math.floor(STATS_SYSTEM_CONFIG.maxLevel * STATS_SYSTEM_CONFIG.gems_power[item.itemid].min_el), math.ceil(STATS_SYSTEM_CONFIG.maxLevel * STATS_SYSTEM_CONFIG.gems_power[item.itemid].max_el)) then
                    toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
                    doRemoveItem(item.uid, 1)
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Item modification successful.")
                    return true
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Erro1.")
                end
Actions:
Code:
function onUse(player, item, fromPosition, itemEx, toPosition)
if not (Item(itemEx.uid) or not Creature(itemEx.uid)) or itemEx.itemid == 2173 then return false end
stat_onUse(player, item, fromPosition, itemEx, toPosition)
return true
end


Thx!
Fixed! Working now.
 

Exos

New Member
Joined
Dec 20, 2016
Messages
15
Reaction score
0
Does someone know where can I increase the loot chance to test the loot please? Thank you
 

Hokku

Well-Known Member
Joined
Jul 25, 2013
Messages
92
Reaction score
13
i discover a bug related to regeneration, if u desquip and equip a item with regen, it get stacked, providing you a infinite regen, someone know how to fix it?

related code to regen:

Code:
function stat_regen(cid, itemid, slot, checkid, sid)
        if not checkid then checkid = 1 end
        if not player_regen[cid] then return true end
        if not player_regen[cid][slot] then return true end
        local player = Player(cid)
        if not player then return true end
        local item = player:getSlotItem(slot)
        if not item then
                player_regen[cid][slot] = nil
                return true
        end
        if item:getId() ~= itemid then return true end
      
        local slotc = item:getStatSlotCount()
        if slotc == 0 then
                player_regen[cid][slot] = nil
                return true
        end
      
        player_regen[cid][slot] = player_regen[cid][slot] + 1
        if checkid == 60 then
                local cur_slots = item:getStatSlots()
                for i = 1, slotc do
                        if cur_slots[i][1] == 'regHP' or cur_slots[i][1] == 'regMP' then
                                if cur_slots[i][2]:match("%%") then
                                        local a, b = cur_slots[i][2]:match('([+-])(%d+)%%')
                                        if cur_slots[i][1] == 'regHP' then
                                                player:addHealth(math.ceil(player:getVocation():getHealthGainAmount() * (tonumber(a..b))/150))
                                        end
                                      
                                        if cur_slots[i][1] == 'regMP' then
                                                player:addMana(math.ceil(player:getVocation():getManaGainAmount() * (tonumber(a..b))/150))
                                        end
                                else
                                        if cur_slots[i][1] == 'regHP' then
                                                player:addHealth(tonumber(cur_slots[i][2]))
                                        end
                                      
                                        if cur_slots[i][1] == 'regMP' then
                                                player:addMana(tonumber(cur_slots[i][2]))
                                        end
                                end
                        end
                end
                checkid = 1
        end
        addEvent(stat_regen, 100, cid, itemid, slot, checkid + 1, sid + 1)
        return true
end
tried changing:

Code:
      player_regen[cid][slot] = player_regen[cid][slot] + 1
to:

Code:
      player_regen[cid][slot] = player_regen[cid][slot]
and other things but not working :/
 

xydius

Just an otland wanderer
Joined
Feb 25, 2016
Messages
43
Reaction score
30
Does someone know where can I increase the loot chance to test the loot please? Thank you
if i understood correctly u want to check the "extra loot" then edit this in the function improveChance()
Lua:
        if math.random(1, 100) <= extraPercent then
just set "math.random(1,2)" so it goes through then in that same function find
Lua:
 if math.random(1, 100000) <= (t_s[chosenId].chance + (t_s[chosenId].chance * extraPercent / 100)) * configManager.getNumber(configKeys.RATE_LOOT) then
and do the same math.random (1,2) lol youll get extra loot every time just remember to put it back like it was, btw it only give one item and is one of the few with the lowest % to drop and its based on the item droprate so if

item has 1% and extraloot is 28% you only have 1.28% (multiplied by server rate) to get that item xD just play with numbers ;P
 

xydius

Just an otland wanderer
Joined
Feb 25, 2016
Messages
43
Reaction score
30
Theres another bug when you use a random gem and it gives level but it doesnt give extra def so when you use a basic gem and it fails it gives negative extra def just fix that in generateLooted() function where it says

Lua:
for o = 1, #upgradable_stats do
                                                local n_item_stat = upgradable_stats[o][2](it_id)
                                                if n_item_stat ~= 0 then
                                                        self:setAttribute(upgradable_stats[o][1], getItemAttribute(uid, upgradable_stats[o][1]) + (upgradable_stats[o][3] * it_lvl))
                                                end
                                        end
just add this between the local variable and the if statement

Code:
if upgradable_stats[o][1] == ITEM_ATTRIBUTE_EXTRADEFENSE and (isWeapon(uid) or isShield(uid))then
                                                        n_item_stat = 1
                                                end
 
Top