• Sign up for TFS Icon Competition! The prize includes Otland Premium time and a medal, as well as obviously taking part in TFS history.
  • 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!

Lua [TFS 1.3] Free Scripting Service 📝

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
842
Solutions
80
Reaction score
796
Location
London
GitHub
MillhioreBT
I am bored, and I have some days in which I will not have much to do, if you need a script you can post here what you want and if it meets the requirements below, I will do it for you

🗒 Requirements:
🔶 TFS engine 1.3+
🔶 That does not include changes in the sources (if you don't know what this is, you can still ask💬)
🔶 I'll only do one script per person so don't spam🔇too much, until a second chance ...
🔶 It depends on what you ask, I will make the decision to accept or not to do it👀
🔶 I know that several people have posted threads similar to this one, but to add more variety, also not all can be available at the same time👌

Don't be afraid to ask 🤗

👍 If I like your post it means that I have taken the task! 👍
 
Last edited:

Musaab

NoxOts
Premium User
Joined
May 13, 2010
Messages
152
Reaction score
61
Location
Sweden
OP is not taking more requests.

 

Kura121

New Member
Joined
Apr 21, 2021
Messages
1
Reaction score
1
GitHub
XD
I am bored, and I have some days in which I will not have much to do, if you need a script you can post here what you want and if it meets the requirements below, I will do it for you

🗒 Requirements:
🔶 TFS engine 1.3+
🔶 That does not include changes in the sources (if you don't know what this is, you can still ask💬)
🔶 I'll only do one script per person so don't spam🔇too much, until a second chance ...
🔶 It depends on what you ask, I will make the decision to accept or not to do it👀
🔶 I know that several people have posted threads similar to this one, but to add more variety, also not all can be available at the same time👌

Don't be afraid to ask 🤗

👍 If I like your post it means that I have taken the task! 👍
Hey I have question to u, can u add me on discord? Zakrzew#5411
 

dheikon

New Member
Joined
Jan 29, 2011
Messages
5
Reaction score
1
Hi @killer990

data/scripts/yourscriptname.lua
Lua:
local stones = {
      [21402] = {
              minLevel = 0, -- minimum level to use
              maxLevel = 15, -- maximum level to you can use
            chance = 75, -- probability of leveling up
            extraPercent = 0 -- extra attribute increase percentage
      },
      [21403] = {
              minLevel = 15,
            maxLevel = 30,
            chance = 50,
            extraPercent = 1
      },
      [6666] = {
              minLevel = 30,
            maxLevel = 50,
            chance = 25,
            extraPercent = 2
      }
}

local attributes = {
    [ITEM_ATTRIBUTE_ATTACK] = {
        getValue = ItemType.getAttack,
        percent = 5 -- attribute increase percentage in this case for attack
    },
    [ITEM_ATTRIBUTE_DEFENSE] = {
        getValue = ItemType.getDefense,
        percent = 5 -- attribute increase percentage in this case for defense
    },
    [ITEM_ATTRIBUTE_EXTRADEFENSE] = {
        getValue = ItemType.getExtraDefense,
        percent = 5 -- attribute increase percentage in this case for extraDefense
    },
    [ITEM_ATTRIBUTE_ARMOR] = {
        getValue = ItemType.getArmor,
        percent = 5 -- attribute increase percentage in this case for armor
    },
    [ITEM_ATTRIBUTE_HITCHANCE] = {
        getValue = ItemType.getHitChance,
        percent = 5 -- attribute increase percentage in this case for hitChance
    }
}

local function onUpgradeLvl(level, chance, config)
    local nextLevel = math.min(config.maxLevel, level +1)
    if math.random(1, chance) <= config.chance then
        return nextLevel
    end
    return level
end

local function isUpgradeable(item)
    local it = item:getType()
    return it:getAttack() > 0 or it:getDefense() > 0 or it:getArmor() > 0 or it:getExtraDefense() > 0
end

local function getItemLevel(item)
    return item:getCustomAttribute("upgradeLevel") or 0
end

local function setItemLevel(item, level)
    return item:setCustomAttribute("upgradeLevel", level)
end

local function upgradeValue(value, level, info, stone)
    return value * ((1.0 + ((info.percent + stone.extraPercent) / 100)) * level)
end

local function doUpgrade(item, level, stone)
    local itemType = item:getType()
    if level <= 0 then
        setItemLevel(item, level)
        item:setAttribute(ITEM_ATTRIBUTE_NAME, itemType:getName())
        for attribute, info in pairs(attributes) do
            item:setAttribute(attribute, info.getValue(itemType))
        end
        return true
    end
    setItemLevel(item, level)
    item:setAttribute(ITEM_ATTRIBUTE_NAME, string.format("%s +%u", itemType:getName(), level))
    for attribute, info in pairs(attributes) do
        local value = info.getValue(itemType)
        if value ~= 0 then
            item:setAttribute(attribute, upgradeValue(value, level, info, stone))
        end
    end
    return true
end

local upgrade = Action()
function upgrade.onUse(player, item, fromPos, target, toPos, isHotkey)
    if not target or not target:isItem() then
        player:sendCancelMessage("You cannot use this object.")
        return true
    end
    local stone = stones[item:getId()]
    if not stone then
        return false
    end
    if not isUpgradeable(target) then
        player:sendCancelMessage("This item cannot be upgrade.")
        return true
    end
    local level = getItemLevel(target)
    if level < stone.minLevel then
        player:sendCancelMessage(string.format("The minimum level to use is %d.", stone.minLevel))
        return true
    end
    local newLevel = onUpgradeLvl(level, 100, stone)
    if level >= stone.maxLevel then
        player:getPosition():sendMagicEffect(CONST_ME_POFF, player)
        player:sendCancelMessage("This item is already at its maximum level.")
        return true
    elseif newLevel == level then
        player:say("Failed!", TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    elseif newLevel > level then
        player:say("Success!", TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
    end
    doUpgrade(target, newLevel, stone)
    item:remove(1)
    return true
end
for aid, _ in pairs(stones) do
    upgrade:id(aid)
end
upgrade:register()

View attachment 54604

Each stone can be configured so that it can only be used in a range of levels, for example: 0 > 15 | 15 > 30 | 30 > 50 ....
You can also configure a custom attribute increment for each stone.

Important note: If you have a system that modifies the names of the articles, then you will have problems using this update system, since this system will overwrite the original name of the article + the corresponding level, the level is not lost, but it will not be show in name in case another system modifies it.

If you have another system that modifies the names, like for example a slot system or something else, you can tell me and I will help you solve the problem quickly with a little trick.
Congratulations, very good and simple.
How would it look if when there was a failure, you went back one level?
 
Last edited:

Opatulek

New Member
Joined
Apr 25, 2021
Messages
8
Reaction score
0
if you keep helping, I'll be grateful if you change calculating method in this:
Lua:
local runeTest = Spell(SPELL_RUNE)
function runeTest.onCastSpell(creature, variant)
local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
if not target or not target:isPlayer() then
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local maxMana = creature:getMaxMana() / 100
target:addMana(math.random(maxMana * 10, maxMana * 15))
target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
target:say("MR Aaahh!")
return true
end
runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("sorcerer", "master sorcerer")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)


to:
Lua:
function onGetFormulaValues(player, level, magicLevel)
local min = (level / 5) + (magicLevel * 3.2) + 20
local max = (level / 5) + (magicLevel * 5.4) + 40
return min, max
end
 

dheikon

New Member
Joined
Jan 29, 2011
Messages
5
Reaction score
1
if you keep helping, I'll be grateful if you change calculating method in this:
Lua:
local runeTest = Spell(SPELL_RUNE)
function runeTest.onCastSpell(creature, variant)
local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
if not target or not target:isPlayer() then
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local maxMana = creature:getMaxMana() / 100
target:addMana(math.random(maxMana * 10, maxMana * 15))
target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
target:say("MR Aaahh!")
return true
end
runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("sorcerer", "master sorcerer")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)


to:
Lua:
function onGetFormulaValues(player, level, magicLevel)
local min = (level / 5) + (magicLevel * 3.2) + 20
local max = (level / 5) + (magicLevel * 5.4) + 40
return min, max
end
replace that:
Lua:
local maxMana = creature:getMaxMana() / 100
target:addMana(math.random(maxMana * 10, maxMana * 15))

for this:
Lua:
local minMana = (level / 5) + (magicLevel * 3.2) + 20
local maxMana = (level / 5) + (magicLevel * 5.4) + 40
target:addMana(math.random(minMana, maxMana))
 

Opatulek

New Member
Joined
Apr 25, 2021
Messages
8
Reaction score
0
replace that:
Lua:
local maxMana = creature:getMaxMana() / 100
target:addMana(math.random(maxMana * 10, maxMana * 15))

for this:
Lua:
local minMana = (level / 5) + (magicLevel * 3.2) + 20
local maxMana = (level / 5) + (magicLevel * 5.4) + 40
target:addMana(math.random(minMana, maxMana))

I get error:
Lua:
:callback
lua:8: attempt to perform arithmetic on global 'level' (a nil value)
stack traceback:
        [C]: in function '__div'
        lua:8: in function lua:2>

Code:
local runeTest = Spell(SPELL_RUNE)
function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local minMana = (level / 5) + (magicLevel * 3.2) + 20
    local maxMana = (level / 5) + (magicLevel * 5.4) + 40
    target:addMana(math.random(minMana, maxMana))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:say("MR Aaahh!")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("knight", "elite knight")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
 

Klonera

Once upon a time.
Joined
Jul 16, 2016
Messages
766
Solutions
7
Reaction score
170
Location
Sweden
Twitch
JoelPersson147
YouTube
Joriku
I request, Rebirth System for TFS 1.3.
  • Shows on the avatar, amount of rebirths.
  • Adds extra % hp/mana & skills for diffrent vocations on each rebirth. If a 10 or 20 amount then it gives an bonus of 5% hp/mana
Love your work, you're amazing Sarah! :3
 
Top