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

Action Simple Spells Upgrading System [TFS 1.3-1.2]

S

Shadow_

Guest
Hello Community,
Thank you for watching the thread, I'am sharing this system because i couldn't found simple one to do the task only so here is it.
in data/actions/actions.xml
add this line
Code:
    <action actionid="6969" script="spellupgrade.lua" />
and in data/actions/scripts/
create new file with name spellupgrade.lua
and add this
Code:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if not player:getIsUPGSpell() then
        player:UPGSpell(5)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations, You have Upgraded your S-Rated Spell!")
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Your spell is already upgraded.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
return true
end
in data/lib/core/player.lua
add those lines
Code:
-- Upgrading Spell System
UPGSpell = {
        storage = 50005,
    }
    
    function Player.UPGSpell(self, value)
        local currUPGSpell = 5
        return self:setStorageValue(UPGSpell.storage, currUPGSpell)
    end

    function Player.getIsUPGSpell(self)
        return (self:getStorageValue(UPGSpell.storage) == 5)
    end
and just in your spell add this line
Code:
     if player:getIsUPGSpell() then
you can use it for example like this
Code:
     if player:getIsUPGSpell() then
        local level = player:getLevel()
        local a = (level * 9.8) + 12357
        local b = (level * 10.2) + 15334
        local damage = {min = -a, max = -b}
        sendEffects(player:getId(), config1.delay, config1.areaEffect, config1.distanceEffect)
        runSpell(player:getId(), 0, config1.rounds, config1.delay, config1.radius, damage, config1.damageType, config1.areaEffect, config1.distanceEffect)
     else
        local level = player:getLevel()
        local a = (level * 8.5) + 12357
        local b = (level * 8.8) + 15334
        local damage = {min = -a, max = -b}
        sendEffects(player:getId(), config.delay, config.areaEffect, config.distanceEffect)
        runSpell(player:getId(), 0, config.rounds, config.delay, config.radius, damage, config.damageType, config.areaEffect, config.distanceEffect)
     end
 
Thanks for your share, but what is actually the reason to do this:

Code:
-- Upgrading Spell System
UPGSpell = {
        storage = 50005,
    }
    
    function Player.UPGSpell(self, value)
        local currUPGSpell = 5
        return self:setStorageValue(UPGSpell.storage, currUPGSpell)
    end

    function Player.getIsUPGSpell(self)
        return (self:getStorageValue(UPGSpell.storage) == 5)
    end

Not that i do not want to disencourage you to share something to the community... but isn't this a bit overdone?

I could just check storage on the individual caster whether it improves the damage by % with a constant?
like:

Code:
if player:getStorageValue(STORAGE_SPELLUPGRADE) then
min = min * 1.1
max = max * 1.5
end

It's ofcourse a good practice on the long term to get along with creating own functions which would be easier to use globally in the datapack and makes shit cleaner... but i expected something more from this xD...


Animera
 
Thanks for your share, but what is actually the reason to do this:

Code:
-- Upgrading Spell System
UPGSpell = {
        storage = 50005,
    }

    function Player.UPGSpell(self, value)
        local currUPGSpell = 5
        return self:setStorageValue(UPGSpell.storage, currUPGSpell)
    end

    function Player.getIsUPGSpell(self)
        return (self:getStorageValue(UPGSpell.storage) == 5)
    end

Not that i do not want to disencourage you to share something to the community... but isn't this a bit overdone?

I could just check storage on the individual caster whether it improves the damage by % with a constant?
like:

Code:
if player:getStorageValue(STORAGE_SPELLUPGRADE) then
min = min * 1.1
max = max * 1.5
end

It's ofcourse a good practice on the long term to get along with creating own functions which would be easier to use globally in the datapack and makes shit cleaner... but i expected something more from this xD...


Animera
I see no good reason in your "way" to do stuff either, he did it correctly imo, its far more readable and if you would change storages for some reason, you would NEED edit every ocurrence of it in your way, in his edit one storage in the method used. More of a future mind example in his code, I actually like it, very good job. (I just noticed that the storage is defined inside the same table, so ignore that part, but even if that using a method is better, if you could change something inside it like add some additional code or anything. Have fun editing all of your player:getStorageValue)
 
I see no good reason in your "way" to do stuff either, he did it correctly imo, its far more readable and if you would change storages for some reason, you would NEED edit every ocurrence of it in your way, in his edit one storage in the method used. More of a future mind example in his code, I actually like it, very good job. (I just noticed that the storage is defined inside the same table, so ignore that part, but even if that using a method is better, if you could change something inside it like add some additional code or anything. Have fun editing all of your player:getStorageValue)

You are right about that... (changing storage wise, or he might make the functions more usefull later on)... but i do not actually see a system here, because it checks individually on 1 specific storage on a specific value(5), and the changes that you want to apply requires still to edit every script 1 by 1... (which i then still do not understand why it should be used for more then 1 spell if it is just 1 item, that checks on 1 storage.... (also please look how messy the new damage formulas are).

The only difference in my script is that it is just 4 lines(without the need of some 'lib') and a global variable/constant can still be changed easily later...

just add in global.lua or somewhere in the libs folder:
Code:
STORAGE_SPELLUPGRADE = 50005

Animera
 
Last edited:
You are right about that... (changing storage wise, or he might make the functions more usefull later on)... but i do not actually see a system here, because it checks individually on 1 specific storage on a specific value(5), and the changes that you want to apply requires still to edit every script 1 by 1... (which i then still do not understand why it should be used for more then 1 spell if it is just 1 item, that checks on 1 storage.... (also please look how messy the new damage formulas are).

The only difference in my script is that it is just 4 lines(without the need of some 'lib') and a global variable/constant can still be changed easily later...

just add in global.lua or somewhere in the libs folder:
Code:
STORAGE_SPELLUPGRADE = 50005

Animera
Its coding after all so don’t expect all the humans to write the same code with the same way, and i used functions because it is the best way to do it in my point of view maybe yours is different
 
Its coding after all so don’t expect all the humans to write the same code with the same way, and i used functions because it is the best way to do it in my point of view maybe yours is different

You are right, but to me it looked like you overdone it a bit... and the only thing i wanted was to help you (not that i am the best)...

i was bored....

Animera
 
Back
Top