• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

RevScripts Same formula for all spells

Paulix

Active Member
Joined
Sep 13, 2012
Messages
151
Solutions
8
Reaction score
36
How can I make so that all my spells use the same formula...

LUA:
function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 4.5) + 20
    local max = (level / 5) + (magicLevel * 7.6) + 48
    return -min, -max
end

cause if I need to rework some formula damage, i need to edit all spells, i want to have a fixed formula for all spells, does anyone know how i can place this formula somewhere where spells could use it please?
 
Solution
Hello, if you really want to use same formula for all spells then you can do it like that.

In data/lib/core create file spells.lua. This is the place where you will store ur global function.
LUA:
function getGlobalSpellFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 4.5) + 10
    local max = (level / 5) + (magicLevel * 7.6) + 10
    return -min, -max
end

In file data/lib/core add library to be loaded into the server context.
Code:
dofile('data/lib/core/spells.lua')

And final step will be calling that function in onGetFormulaValues. For example apprentice's strike definition with global call:
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)...
Hello, if you really want to use same formula for all spells then you can do it like that.

In data/lib/core create file spells.lua. This is the place where you will store ur global function.
LUA:
function getGlobalSpellFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 4.5) + 10
    local max = (level / 5) + (magicLevel * 7.6) + 10
    return -min, -max
end

In file data/lib/core add library to be loaded into the server context.
Code:
dofile('data/lib/core/spells.lua')

And final step will be calling that function in onGetFormulaValues. For example apprentice's strike definition with global call:
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)

function onGetFormulaValues(player, level, magicLevel)
    return getGlobalSpellFormulaValues(player, level, magicLevel)
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

Is it what you wanted to achieve or smth else is on your mind?
 
Solution
Back
Top