• 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 Spell Formula that uses Skill, Level and Magic Level?

Sunset

Member
Joined
Jun 3, 2009
Messages
26
Reaction score
8
Location
Uruguay
I can't find this anywhere so I'm posting a request.
My idea is to create a spell like this one:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_USECHARGES, 1)

function onGetFormulaValues(player, level, maglevel)
    min = -((level / 5) + (maglevel * 1.4))
    max = -((level / 5) + (maglevel * 2.2))
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

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

that instead of using only level and magic level like here, it uses also skill and weapon damage, like knight spells do.

Ideally the formula would be something like this:
min = level / 5 + magiclevel * 1.3 + skill * attack / 2
max = level / 5 + magiclevel * 1.4 + skill * attack / 2

So it'd be like overlapping level + mlvl like sorc spells and skill * attack like knight spells,
having a total dmg that combines all attributes.
Cheers and thanks in advance.
 
The easiest way I know would be using CALLBACK_PARAM_SKILLVALUE instead of CALLBACK_PARAM_LEVELMAGICVALUE like this:
Lua:
function onGetFormulaValues(player, skill, attack)
    local level = player:getLevel() -- so we have access to player level
    local magicLevel = player:getMagicLevel() -- so have access to player magic level
    local min = level / 5 + magicLevel * 1.3 + skill * attack / 2
    local max = level / 5 + magicLevel * 1.4 + skill * attack / 2
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

Then you can do whatever you want with the damage formula regarding level, mlevel, attack and skills.
 
Back
Top