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

Item upgrade system for TFS 1.3

Azakelis

Premium User
Premium User
Joined
Feb 17, 2014
Messages
232
Solutions
17
Reaction score
319
Installation:
1. data/lib/lib.lua add:
Lua:
-- Item upgrade system
dofile('data/lib/item_upgrade_system/init.lua')

2. data/creaturescripts/creaturescripts.xml add:
XML:
    <event type="login" name="UpgradeSystemLogin" event="script" script="item_upgrade_system/onLogin.lua" />
    <event type="kill" name="UpgradeSystemKill" event="script" script="item_upgrade_system/onKill.lua" />
    <event type="healthchange" name="UpgradeSystemHealthChange" event="script" script="item_upgrade_system/onHealthChange.lua" />
    <event type="logout" name="UpgradeSystemLogout" script="item_upgrade_system/onLogout.lua" />

3. data/actions/actions.xml add (you can change item ids, default ones are some unused runes):
XML:
    <action itemid="2284" script="item_upgrade_system/upgrade.lua"/>
    <action itemid="2276" script="item_upgrade_system/add_enchant.lua"/>
    <action itemid="2270" script="item_upgrade_system/remove_enchant.lua"/>
    <action itemid="2298" script="item_upgrade_system/remove_enchants.lua"/>
    <action itemid="2272" script="item_upgrade_system/reroll_enchant.lua"/>
    <action itemid="2296" script="item_upgrade_system/reroll_enchants.lua"/>
    <action itemid="2312" script="item_upgrade_system/reroll_tier.lua"/>

4. data/events/events.xml make sure those are enabled:
XML:
    <event class="Creature" method="onTargetCombat" enabled="1" />
    <event class="Player" method="onLook" enabled="1" />
    <event class="Monster" method="onDropLoot" enabled="1" />
    <event class="Player" method="onItemMoved" enabled="1" />
    <event class="Player" method="onGainExperience" enabled="1" />

5. data/events/scripts/player.lua:

below:
Lua:
function Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
add:
Lua:
self:onItemMovedUpgradeSystem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)

below:
Lua:
    -- Apply experience stage multiplier
    exp = exp * Game.getExperienceStage(self:getLevel())

add:
Lua:
    exp = self:onGainExperienceUpgradeSystem(source, exp, rawExp)

6. data/scripts/eventcallbacks/monster/default_onDropLoot.lua:
change:
Lua:
        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

to:
Lua:
        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if item ~= nil and item:getType():isUpgradable() then
                local randomItemLevel = getRandomItemLevel(mType:getHealth(), mType:getExperience())
                item:setItemLevel(randomItemLevel)
                item:rollItemTier(true)
            end
        end

below:
Lua:
        if player then

add:
Lua:
            local itemLevel = calculateItemLevel(mType:getHealth(), mType:getExperience())
            local additionalLoot = getAdditionalLoot(player:getLevel(), itemLevel)
            if additionalLoot ~= nil then
                corpse:addItem(additionalLoot, 1)
            end

7. data/scripts/eventcallbacks/player/deafult_onLook.lua:
below:
Lua:
local description = "You see " .. thing:getDescription(distance)

add:
Lua:
    if thing:isPlayer() then
        description = thing:onLookUpgradeSystem(description)
    end

8. data/lib/core/container.lua:
change whole function:
Lua:
function Container.createLootItem(self, item)

to:
Lua:
function Container.createLootItem(self, item)
    if self:getEmptySlots() == 0 then
        return nil
    end

    local itemCount = 0
    local randvalue = getLootRandom()
    if randvalue < item.chance then
        if ItemType(item.itemId):isStackable() then
            itemCount = randvalue % item.maxCount + 1
        else
            itemCount = 1
        end
    end

    if itemCount > 0 then
        local tmpItem = self:addItem(item.itemId, math.min(itemCount, 100))
        if not tmpItem then
            return nil
        end

        if tmpItem:isContainer() then
            for i = 1, #item.childLoot do
                if not tmpItem:createLootItem(item.childLoot[i]) then
                    tmpItem:remove()
                    return nil
                end
            end
        end

        if item.subType ~= -1 then
            tmpItem:setAttribute(ITEM_ATTRIBUTE_CHARGES, item.subType)
        end

        if item.actionId ~= -1 then
            tmpItem:setActionId(item.actionId)
        end

        if item.text and item.text ~= "" then
            tmpItem:setText(item.text)
        end
        return tmpItem
    end
    return nil
end

9. data/events/scripts/creature.lua:
below:
Lua:
function Creature:onTargetCombat(target)
add:
Lua:
    Creature:onTargetCombatUpgradeSystem(target)

10. unpack scripts from item_upgrade_system.zip to correct folders (same as in zip)

11 buy my onlyfans
 

Attachments

  • item_upgrade_system.zip
    18.7 KB · Views: 90 · VirusTotal
Last edited:
What the actual hekk?

This is @oen432 code.

If you want to copy someones work and change it but keeping 60+% of the code then MAAAAAAAAYBE you should give credit to the one who made almost all of it ? :)
 
If you would like to point out which line of code is stolen I'd be happy to remove it.
 
If you would like to point which line of code is stolen I'd be happy to remove it.
You can't steal from open source unlicensed code.
This is @oen432 code.
Not much of it is left. The thing that bothers me the most is the fact that he advertises this script as "rework of older upgrade system", which is the one I made.
 
Last edited:
@Azakelis I'll try to see how it works, btw, if I use OTX 3.8 and dont have onItemMoved/onDropLoot functions on events, is enough if I take this functions from TFS 1.3 repo and register them on the corresponding file (player.lua, and monster.lua) or I need to change sources?

Code:
function Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if hasEventCallback(EVENT_CALLBACK_ONITEMMOVED) then
        EventCallback(EVENT_CALLBACK_ONITEMMOVED, self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    end
end

Code:
function Monster:onDropLoot(corpse)
    if hasEventCallback(EVENT_CALLBACK_ONDROPLOOT) then
        EventCallback(EVENT_CALLBACK_ONDROPLOOT, self, corpse)
    end
end

Then add the changes?
Edit:
Well I can't find where EVENT_CALLBACKS are located on this distribution

Guess that the functions I posted won't work, still not able to testing right now, Ik should do the tests before, but I would like to resolve the question anyways ;p
 
Last edited:
@Azakelis I'll try to see how it works, btw, if I use OTX 3.8 and dont have onItemMoved/onDropLoot functions on events, is enough if I take this functions from TFS 1.3 repo and register them on the corresponding file (player.lua, and monster.lua) or I need to change sources?

Code:
function Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if hasEventCallback(EVENT_CALLBACK_ONITEMMOVED) then
        EventCallback(EVENT_CALLBACK_ONITEMMOVED, self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    end
end

Code:
function Monster:onDropLoot(corpse)
    if hasEventCallback(EVENT_CALLBACK_ONDROPLOOT) then
        EventCallback(EVENT_CALLBACK_ONDROPLOOT, self, corpse)
    end
end

Then add the changes?
Edit:
Well I can't find where EVENT_CALLBACKS are located on this distribution

Guess that the functions I posted won't work, still not able to testing right now, Ik should do the tests before, but I would like to resolve the question anyways ;p
Source edit is needed if you don't have these.
 
No chance to do this with a lib? Or maybe just add this without EVENT CALLBACKS
Code:
function Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
self:onItemMovedUpgradeSystem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
end

The lines you mentioned to change on step #6 and #7 are writen on players.lua and monsters.lua instead of scripts/eventscallback folder.
Example (this appears on the mentioned .lua files):
Code:
local description = "You see " .. thing:getDescription(distance)
And this can be applied to monsters.lua (I don't see functions that does not belong to sources):
Code:
        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end
Sorry for asking without testing, again. Anyways if this not worth trying, which changes should I do to sources?
Edit:
Well I think this responds all. Thx
events.png
 
Last edited:
You should include a description of what is new in the system
Because the truth is I have no idea what your code is about, it only refers to what improves the items, but what does it improve?, because if you have things other than the @oen432 system, it would be good to know :D, otherwise just bumb to the thread of oen would be enough
 
Last edited:
Back
Top