• 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!

TFS 1.X+ Upgrade System wrong addition of enchantment values

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,452
Solutions
27
Reaction score
837
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I forked oen's upgrade system to create my own 8.6 version for my server.

For some reason, the addition of values is not working properly, for example, if I have legs that gives +70 hitpoints, and I also equip a shield that gives +6 shielding, I automatically loose the +70 hitpoints from legs and viceversa (if I equip hitpoints, I loose shielding). This happens on many items, and I don't know how to debug/fix it.


This fork I made has many attributes taken away, here's some additional information of how it works

Thanks in advance for any help!
Regards :)
 
Bump! Any ideas? I have updated README.md with the configuration I have on the server.
Is really easy to install and test, if someone wishes to contribute! Thanks in advance
1683474242938.png
 
I did change the slot system to classicEquipmentSlots and that almost fix the problem. Now the issue is triggered using shields and two-handed weapons, here I recorded a video for it so you guys can see what's going on.


I talked to @Roddet and he gave me many hints that could guide me on a possible fix. He told me to take a look into onItemMoved event callback. This is how is written on oen's system.

Lua:
local ItemMovedEvent = EventCallback
ItemMovedEvent.onItemMoved = function(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if not item:getType():isUpgradable() then
        return
    end
    if toPosition.y <= CONST_SLOT_AMMO and toPosition.y ~= CONST_SLOT_BACKPACK then
        return
    end
    if fromPosition.y >= 64 and toPosition.y >= 64 then
        return
    end
    if fromPosition.y >= 64 and toPosition.y == CONST_SLOT_BACKPACK then
        return
    end

    local bonuses = item:getBonusAttributes()
    if bonuses then
        local itemId = item:getId()
        for i = 1, #bonuses do
            local value = bonuses[i]
            local bonusId = value[1]
            local bonusValue = value[2]
            local attr = US_ENCHANTMENTS[bonusId]
            if attr then
                if attr.combatType == US_TYPES.CONDITION then
                    if US_CONDITIONS[bonusId] and US_CONDITIONS[bonusId][bonusValue] and US_CONDITIONS[bonusId][bonusValue][itemId] then
                        if US_CONDITIONS[bonusId][bonusValue][itemId]:getType() ~= CONDITION_MANASHIELD then
                            player:removeCondition(
                                US_CONDITIONS[bonusId][bonusValue][itemId]:getType(),
                                CONDITIONID_COMBAT,
                                US_CONDITIONS[bonusId][bonusValue][itemId]:getSubId()
                            )
                        else
                            player:removeCondition(US_CONDITIONS[bonusId][bonusValue][itemId]:getType(), CONDITIONID_COMBAT)
                        end
                    end
                end
            end
        end
    end
end
ItemMovedEvent:register()

Then sent me this link with how it is scripted in @Sarah Wesker system for upgrading, here is it Item upgrade system, with the possibility of improving the damage of wands (https://gist.github.com/MillhioreBT/869009fd87c92888b6c49cab48402d14#file-upgrading_system-lua-L719-L733)

Lua:
function ec.onItemMoved(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if fromPosition.x == CONTAINER_POSITION and bit.band(fromPosition.y, 0x40) == 0 then
        local itemType = item:getType()
        if usesSlot(itemType, fromPosition.y) then
            onDeEquip(player, fromPosition.y)
        end
    end

    if toPosition.x == CONTAINER_POSITION and bit.band(toPosition.y, 0x40) == 0 then
        local itemType = item:getType()
        if usesSlot(itemType, toPosition.y) then
            onEquip(player, item, toPosition.y)
        end
    end
end

How can I fix the oen system using sarah's system as reference? I'm really bad coding, I said it many times, so I please ask you guys to help me figure out this! This is probably the only and last bug I have on my server to get the green flag and start.

Regards, and thanks in advance!
 
@ralke any of those system has time to decay or charges?
Nope! No items with decays or changes, since they're omitted, not sure in which line but it is on core.lua

When I enchant a spike sword into a "fiery spike sword" it just become a normal item (without the "Strenght" param). Also ammunitions/spears/etc are out of the system too CreatureEvent - [TFS 1.3 / 1.4] Upgrade System (https://otland.net/threads/tfs-1-3-1-4-upgrade-system.264672/page-24#post-2716519)

I'm not considering to add items such as helmet of the ancients in they enchanted form, to don't break the system.

Regards ^^
 
Using classic slot system is a bad idea when using this system. Also code you attached from Sarah is not gonna execute when you swap items.
Anyway, like I did for my private version of this system and what I'm recommending to everyone I talk to is adding proper onEquip and onUnequip events (not the one in TFS, they are limited in usage).
This system has flaws (not bugs) that I'm aware of, its a good base to work on but its not something I would recommend to use "as is". My own version went through a lot of optimization and feature enhancement, its more stable and with less impact on the server performance.
 
Nope! No items with decays or changes, since they're omitted, not sure in which line but it is on core.lua

When I enchant a spike sword into a "fiery spike sword" it just become a normal item (without the "Strenght" param). Also ammunitions/spears/etc are out of the system too CreatureEvent - [TFS 1.3 / 1.4] Upgrade System (https://otland.net/threads/tfs-1-3-1-4-upgrade-system.264672/page-24#post-2716519)

I'm not considering to add items such as helmet of the ancients in they enchanted form, to don't break the system.

Regards ^^
unfortunately it is not, the only mention of decay or charges is to prevent items that already have this attribute from being improved

 
@oen432 thanks for the reply! I used classicSlot since I removed many of the attributes of the base, resulting in this table:

it's a bit messy but is clear enought ^^ // classicSlots also helped me avoid a bug where people stacked skills by changing item from slots (from ammo to weapon, weapon to etc.. and doing that once and once again)
adding proper onEquip and onUnequip events (not the one in TFS, they are limited in usage).
This is actually what I need! I just get aware that i'm missing this method function Player:onInventoryUpdate(item, slot, equip) forgottenserver/data/events/scripts/player.lua at f3241135c1042cc7b00aa197ef36f7fd72af00c1 · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/f3241135c1042cc7b00aa197ef36f7fd72af00c1/data/events/scripts/player.lua#L344)

as an approach, but honestly I don't even know what i'm changing. I saw the flaws and worked on the system to hide them (not in a technical way, programming; I just changed some stuff using what I know and ended up like this). And I can't use it as is because I already ran the server this way and could'nt keep it online when people started to raise them skills by using onEquip / deEquip events (this forced me to reset the server).

At this point, the only flaw I see is the shield wielding, probably there could be more flaws based on events that i'm missing too, so I please ask for a way to achieve this system, in the way i'm implementing it; taking out the leechs, mana on hits, and all thoose stuff and keeping the more basic stuff, such as skills in general, and onHit strikes (like is shown above).

In case you wish a retribution for this, I can only offer job, specially on mapping (by exchanging for map pieces, some graphic art, idk). Can't really afford a freelance for helping me with this. Regards! and thanks for replying ^^

@mano368
unfortunately it is not, the only mention of decay or charges is to prevent items that already have this attribute from being improved

I'm not quite sure, but as long the item with charges doesn't have "itemLevel" they won't get bugged (also won't be allowed to get upgraded or get attributes, and that's fine for me won't use them anyways).
It's two post below the post I attached above.
 
Good afternoon, sorry to intrude... I'm using this upgrade system in Nekiro's TFS 1.5 downgrade. The attributes I receive in the items are working, but it only works if I connect equipped, if I upgrade the item, for example: magic level +1 and equip the character, nothing happens, but if I equip and reconnect then yes it works, but if I Removing it from the slot and replacing it had no effect, can anyone help me? xD
 
Good afternoon, sorry to intrude... I'm using this upgrade system in Nekiro's TFS 1.5 downgrade. The attributes I receive in the items are working, but it only works if I connect equipped, if I upgrade the item, for example: magic level +1 and equip the character, nothing happens, but if I equip and reconnect then yes it works, but if I Removing it from the slot and replacing it had no effect, can anyone help me? xD
apply the changes from core.lua here Nokturno's fix and onAttack missiles (instead of onHit) · ralke23/TFS-Upgrade-System@f72b792 (https://github.com/ralke23/TFS-Upgrade-System/commit/f72b792b49d1787f29574fd6565b48abbfe17450#diff-b7b5c74a89486ec5552af85a4e02d18dfc623bb3d7c70d5c9a640676d3d53490R7)

and tell me how it goes! regards :)
 
Back
Top