• 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.4] Small Upgrade System (allowed wand and rods)

New update of the system, it is no longer small, but it is still in a single file, it is possible that problems may be found, but if you want to use it and test it, it is welcome, any error, or suggestion you can leave it in the comments, this way I will find out and then I will do my best to update it one more time.

¡Warning!
The system will only work correctly if you are using the latest version of TFS master, to be sure, you must use the version that contains the latest changes of today, November 29, 2021

¡The File!
The file is a bit big so I will upload it to a repository on github and they must download it from there, Click Here to see the file.
Remember: that the file must be located in the data/scripts/ folder
Não se esqueça de acionar os seguintes eventos no arquivo events.xml
XML:
<event class="Creature" method="onTargetCombat" habilitado="1" />
...
<event class="Player" method="onItemMoved" enabled="1" />

Do que se trata este sistema?
Este é um sistema simples que atualiza os atributos do item.
por exemplo:
Ataque de uma arma
A armadura de uma perna
As habilidades de um escudo ou outra coisa
em geral, qualquer atributo pode ser atualizável

Você deve ter em mente que nem todos os atributos podem ser atualizados, mas aqui vou deixar uma lista dos atributos que podem ser atualizados
Lua:
ataque
defesa
extradefesa
armaduras
varinhaDanos
elementoDanos
luta de punho
clube de luta
luta de espadas
luta de machado
luta à distância
blindagem
pescaria
saúde máxima
Maximo mana
nível mágico
saúde regular
reg mana
Rapidez
chance de acerto crítico
dano extra crítico
chance de sanguessuga de pontos de vida
quantidade de sanguessuga de pontos de vida
chance de sanguessuga de pontos de mana
quantidade de sanguessuga de pontos de mana
I have the latest version of TFS 1.4. And I use client 10.98. The specialskills don't work... the item just boosts the other stats. Do I need anything else besides this script?
 
how remplace getAbilities()?
New update of the system, it is no longer small, but it is still in a single file, it is possible that problems may be found, but if you want to use it and test it, it is welcome, any error, or suggestion you can leave it in the comments, this way I will find out and then I will do my best to update it one more time.

¡Warning!
The system will only work correctly if you are using the latest version of TFS master, to be sure, you must use the version that contains the latest changes of today, November 29, 2021

¡The File!
The file is a bit big so I will upload it to a repository on github and they must download it from there, Click Here to see the file.
Remember: that the file must be located in the data/scripts/ folder
Don't forget to trigger the following events in the events.xml file
XML:
<event class="Creature" method="onTargetCombat" enabled="1" />
...
<event class="Player" method="onItemMoved" enabled="1" />

¿What is this system about?
This is a simple system that updates item attributes.
per example:
Attack from a weapon
The armor of an legs
The abilities of a shield or something else
in general any attribute can be upgradeable

You must bear in mind that not all attributes can be upgrade, but here I will leave a list of the attributes that can be upgrade
Lua:
attack
defense
extraDefense
armor
wandDamage
elementDamage
fist fighting
club fighting
sword fighting
axe fighting
distance fighting
shielding
fishing
max health
max mana
magic level
reg health
reg mana
speed
critical hit chance
critical extra damage
hitpoints leech chance
hitpoints leech amount
manapoints leech chance
mana points leech amount

What value does that getAbilities() function return? The truth is that I am going to simplify the system but that function stops me, how can I eliminate it?

Since I only look for 1 attack point to the weapons, 1 arm to the other items with arm, and 1 magic point to the wands for each level.
I don't need any of the other skills, just those 3 things xD

Could you help me modify it to eliminate that getAbilities() function?
 
I want to disable upgrading any weapon type, changing all validWeapons to false is enough for this?
 
I want to disable upgrading any weapon type, changing all validWeapons to false is enough for this?
that table is not for that.

however you can do what you want by modifying this function:

You can also add a check here if you don't want to modify the above function:
1680034516598.png
Lua:
if target:getType():getWeaponType() ~= WEAPON_NONE then
    player:sendCancelMessage("You can't use this.")
    return true
end
though remember that shields have a weapon type, WEAPON_SHIELD, so you better check each type, or create a table to use table.contains
Lua:
if table.contains({WEAPON_SWORD, WEAPON_WAND}, target:getType():getWeaponType()) then
    player:sendCancelMessage("You can't use this.")
    return true
end
 
I want to disable upgrading any weapon type, changing all validWeapons to false is enough for this?

that table is not for that.

however you can do what you want by modifying this function:

You can also add a check here if you don't want to modify the above function:
View attachment 74451
Lua:
if target:getType():getWeaponType() ~= WEAPON_NONE then
    player:sendCancelMessage("You can't use this.")
    return true
end
though remember that shields have a weapon type, WEAPON_SHIELD, so you better check each type, or create a table to use table.contains
Lua:
if table.contains({WEAPON_SWORD, WEAPON_WAND}, target:getType():getWeaponType()) then
    player:sendCancelMessage("You can't use this.")
    return true
end
i was going to suggest this:
think also works, at least on tfs 1.5..

search
Lua:
---@return boolean
local function isValidObj(item)
    local iType = item:getType()
change to
Lua:
---@return boolean
local function isValidObj(item)
    local iType = item:getType()
    if iType:isWeapon() then return false end
Post automatically merged:

isWeapon function:
Lua:
local notWeapons = {WEAPON_NONE, WEAPON_SHIELD, WEAPON_AMMO}
function ItemType:isWeapon()
  return not table.contains(notWeapons, self:getWeaponType())
end
 
Thank you both, is there a better way than the other or all do the same job?
I used this one and added all weapon types except shield and it worked.
Lua:
if table.contains({WEAPON_SWORD, WEAPON_WAND}, target:getType():getWeaponType()) then
    player:sendCancelMessage("You can't use this.")
    return true
end
 
Hey,
first of all nice script its very usefull.
I had some problems with the application of the wand damge but I have solved it. Now I have a new problem comming up, the script upgrades each skill perfectly but not the magic level, I am useing the latest TFS 1.4 Version and your newest script.
You can try to define magic level as a custom attribute.
Lua:
    ["magic level"] = {
        abilitie = {
            type = "stats",
            index = STAT_MAGICPOINTS
        },

        condition = {
            id = CONDITIONID_DEFAULT,
            subId = 1009,
            type = CONDITION_ATTRIBUTES,
            param = CONDITION_PARAM_STAT_MAGICPOINTS,
            ticks = -1
        }
    }
And then set line in doUpgradeItem function:
Lua:
setCustomAttribute(item, "SarahWesker_magic level" , this.upgrade["magic level"], newLevel)

Tested on TFS 1.5 downgrade to 8.6
 
Tested on TFS 1.5 nekiro's 772 downgrade works good on weapons but not on wands. I have the callbacks and everything that was mentonied here ORIGIN_WAND etc. But the wand damage is not added.

I also tried it with this: Monster - Training Dummy with DPS calculation (https://otland.net/threads/training-dummy-with-dps-calculation.263659/)

And the DPS message is corresponding to wand base damage + extra damage. But the monk only receive base damage :D

You see a wand of inferno.
It can only be wielded properly by sorcerers of level 33 or higher.
Item ID: 2187
Position: 43, 260, 7
Extra Attributes (level 5, extra damage +50)

15:41 A training dummy loses 11 hitpoints due to your attack.

Real damage was 11, but reported DPS from script was 61 so i guess it counted the extra damage. Weird 😆
1685367814936.png
 
that table is not for that.

however you can do what you want by modifying this function:

You can also add a check here if you don't want to modify the above function:
View attachment 74451
Lua:
if target:getType():getWeaponType() ~= WEAPON_NONE then
    player:sendCancelMessage("You can't use this.")
    return true
end
though remember that shields have a weapon type, WEAPON_SHIELD, so you better check each type, or create a table to use table.contains
Lua:
if table.contains({WEAPON_SWORD, WEAPON_WAND}, target:getType():getWeaponType()) then
    player:sendCancelMessage("You can't use this.")
    return true
end
Thanks
 
Small Upgrade System
The upgrade of wands and rods is allowed.

You can add several types of object to use the system, in example code I have configured two objects
per example:
View attachment 63526
Each object has its well defined properties and it is already a matter of you using your imagination
||||||||: Here we have a 100% chance so it will be very easy to improve with this object, however we will give few attributes
||||||||: Here we have a 50% chance so it will be easy to improve with this object, in this case we will give more attributes for the difficulty

per example:
View attachment 63525
||||||||: We only define the variable chance here, this is because it is level 0
||||||||: We only define downLvl and chance here, This is because we can have a degradation or an increase
||||||||: We only define downLvl here, This is because we can have a degradation but not an increase

others:
View attachment 63527
||||||||: If this variable is true, then failed attempts degrade the object
||||||||: If this variable is true, the attempts are infinite

images:
View attachment 63529


File: data/scripts/small_upgrade_system.lua


Don't forget to trigger the following events in the events.xml file
XML:
<event class="Creature" method="onTargetCombat" enabled="1" />
...
<event class="Player" method="onItemMoved" enabled="1" />

¿What is this system about?
This is a simple system that updates item attributes.
per example:
Attack from a weapon
The armor of an legs
The abilities of a shield or something else
in general any attribute can be upgradeable

You must bear in mind that not all attributes can be upgrade, but here I will leave a list of the attributes that can be upgrade
Lua:
attack
defense
extraDefense
armor
wandDamage
elementDamage
fist fighting
club fighting
sword fighting
axe fighting
distance fighting
shielding
fishing
max health
max mana
magic level
reg health
reg mana
speed
critical hit chance
critical extra damage
hitpoints leech chance
hitpoints leech amount
manapoints leech chance
mana points leech amount

Note:
I will try to add more attributes to it in the future.
If you notice any bug you can leave me a comment.
I know there are better systems and with many more details, but I just wanted to share my small version
is it possible to make it work on canary? ots?
 
i am wondering... i really want to use healthgain and managain.. but this only UPGRADES the values if they are already there, how can we use for example "mind stone" on item to GIVE a random bonus, or am i looking at this the wrong way
 
@archer32
Hi, in my case it was working, I've made upgrade only for backpacks - I could upgrade my backpack from scratch even if it didn't have a basic health/mana gain.

My item which will provide regen.
Lua:
        [10026] = { -- HP & mana regen
        chance = 100,
        minRequireLvl = 0,
        maxRequireLvl = 10,
        breakWhenFail = false,
        breakLvl = 10,
        effect = CONST_ME_MAGIC_GREEN,
        upgrade = {
            ["reg health"] = 1,
            ["reg mana"] = 1,
        }
    },
Conditions:
Lua:
    ["reg health"] = {
        abilitie = {
            type = "healthGain"
        },

        condition = {
            id = CONDITIONID_DEFAULT,
            subId = 1010,
            type = CONDITION_REGENERATION,
            param = CONDITION_PARAM_HEALTHGAIN,
            ticks = -1,
            healthTicks = 4000
        }
    },
    ["reg mana"] = {
        abilitie = {
            type = "manaGain"
        },

        condition = {
            id = CONDITIONID_DEFAULT,
            subId = 1011,
            type = CONDITION_REGENERATION,
            param = CONDITION_PARAM_MANAGAIN,
            ticks = -1,
            manaTicks = 4000
        }
    },
Check if item to upgrade is backpack

Lua:
local function isBackpack(item)
    return item:getType():isBackpack()
end

In function "doUpgradeItem"
Lua:
if isBackpack(item) then
        setCustomAttribute(item, "SarahWesker_reg health" , this.upgrade["reg health"], objLevel, newLevel, success)
        setCustomAttribute(item, "SarahWesker_reg mana" , this.upgrade["reg mana"], objLevel, newLevel, success)
 end
I've modified setCustomAttribute function, so number of parameters probably won't match yours.
 
attack defense extraDefense armor wandDamage elementDamage fist fighting club fighting sword fighting axe fighting distance fighting shielding fishing max health max mana magic level reg health reg mana speed critical hit chance critical extra damage hitpoints leech chance hitpoints leech amount manapoints leech chance mana points leech amount
Can I add my own custom conditions like stun and paralyze, including other custom conditions I created such as inc.magic? Is it possible to implement and test these functions to make sure they work properly? Additionally, is it possible to restrict certain items from being upgraded, allowing only specific items to be upgraded?
 
I'm trying to adapt it to a shorter upgrade script, but I can't get the setCustomAttribute to work for adding special skills, such as life leech, for example. Does anyone know how I can adjust it?


Lua:
local HammerCreation = Action()

function HammerCreation.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = item:getId()

    if itemId == 37171 then
        local targetItemId = target:getId()

        if targetItemId == 34084 then
        
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Works!")

            local currentAttack = target:getAttribute(ITEM_ATTRIBUTE_ATTACK)

            local newAttack = currentAttack + 1
            target:setAttribute(ITEM_ATTRIBUTE_ATTACK, newAttack)

            local currentDescription = target:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
            if not currentDescription or not currentDescription:lower():find("upgraded") then

                target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Upgraded (1)")   
                target:setCustomAttribute(SPECIAL_SKILL_LIFE_LEECH_AMOUNT, 900)
                target:setTier(10)

            else

                local currentCount = tonumber(currentDescription:match("%((%d+)%)")) or 0
                local newCount = currentCount + 1
                local newDescription = "Upgraded (" .. newCount .. ")"
                target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, newDescription)


            end
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Be careful.")
        end
    end
    return true
end

HammerCreation:id(37171)
HammerCreation:register()
 
I used TFS 1.4.2, but...

It only improves attack and def for me.
The script does not add any additional bonuses to weapons.
Why?

When I upgraded Boots of Haste their speed was not changed.
 
Does not increase strikes weapon Wand
It also does not work to increase Magic level
And it does not increase healthGain/manaGain
Works well increases paladin and knight weapon attacks and skill
 
[USUARIO=112365]@archer32[/USUARIO]
Hola, en mi caso estaba funcionando, hice mejoras solo para las mochilas; podía actualizar mi mochila desde cero incluso si no tuviera una ganancia básica de salud/maná.

Mi artículo que proporcionará regeneración.
[CÓDIGO=lua] [10026] = { -- HP y regeneración de maná
probabilidad = 100,
minRequireLvl = 0,
maxRequireLvl = 10,
romperCuandoFalla = falso,
nivel de descanso = 10,
efecto = CONST_ME_MAGIC_GREEN,
actualización = {
["salud del registro"] = 1,
["reg maná"] = 1,
}
},[/CÓDIGO]
Condiciones:
[CÓDIGO=lua] ["salud del registro"] = {
habilidad = {
tipo = "ganancia de salud"
},

condición = {
identificación = CONDITIONID_DEFAULT,
subID = 1010,
tipo = CONDICIÓN_REGENERACIÓN,
parámetro = CONDITION_PARAM_HEALTHGAIN,
garrapatas = -1,
garrapatas de salud = 4000
}
},
["reg maná"] = {
habilidad = {
tipo = "ganancia de maná"
},

condición = {
identificación = CONDITIONID_DEFAULT,
subID = 1011,
tipo = CONDICIÓN_REGENERACIÓN,
parámetro = CONDITION_PARAM_MANAGAIN,
garrapatas = -1,
manaTicks = 4000
}
},[/CÓDIGO]
Comprueba si el artículo a actualizar es una mochila.

Lua:
la función local esMochila(elemento)
    artículo devuelto:getType():isBackpack()
fin[/CÓDIGO]

En la función "doUpgradeItem"
[CODE=lua]si esMochila(artículo) entonces
        setCustomAttribute(elemento, "SarahWesker_reg salud", this.upgrade["reg salud"], objLevel, newLevel, éxito)
        setCustomAttribute(item, "SarahWesker_reg mana", this.upgrade["reg mana"], objLevel, newLevel, Success)
 fin[/CÓDIGO]
Modifiqué la función setCustomAttribute, por lo que la cantidad de parámetros probablemente no coincida con la suya.
[/QUOTE]

¿Tienes el guión con las mochilas?
 
Back
Top