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

Lua Spell for Knights

Progenosis

Member
Joined
Sep 6, 2011
Messages
131
Reaction score
18
I want to make a spell that deals damage based on the skills of the player (sword, club, axe)

This is the attack formula that has the spell I took:


Code:
local firstStrike = createCombatObject()
setCombatParam(firstStrike, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(firstStrike, COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKER)
setCombatFormula(firstStrike, COMBAT_FORMULA_LEVELMAGIC, -13.766, -50, -12.241, -100)

But this speall deals the same damage when casted by a lvl 100 knight with sword skill 100 than a lvl 100 knight with sword kill 20 player :/

How can I fix it?
 
This is from the spell berserk
Code:
function onGetFormulaValues(cid, level, skill, attack, factor)
   local skillTotal, levelTotal = skill + attack, level / 5
   return -(skillTotal * 0.5 + levelTotal), -(skillTotal * 1.5 + levelTotal)
end

setCombatCallback(firstStrike, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
You can use that instead of the COMBAT_FORMULA_LEVELMAGIC line.
 
Doesn't works :/

Code:
28/10/2014 19:01:19] data/spells/scripts/AADendenic/superexori.lua:60: attempt to index local 'bigFlames' (a number value)
 
Code:
local repeatAmount = 1
local deathFlamesArea = {
    createCombatArea({
        {0, 1, 0},
        {1, 2, 1},
        {0, 1, 0}
    }),
    createCombatArea({
        {0, 1, 1, 1, 0},
        {1, 1, 0, 1, 1},
        {1, 0, 2, 0, 1},
        {1, 1, 0, 1, 1},
        {0, 1, 1, 1, 0}
    }),
    createCombatArea({
        {0, 0, 1, 1, 1, 0, 0},
        {0, 1, 0, 0, 0, 1, 0},
        {1, 0, 0, 0, 0, 0, 1},
        {1, 0, 0, 2, 0, 0, 1},
        {1, 0, 0, 0, 0, 0, 1},
        {0, 1, 0, 0, 0, 1, 0},
        {0, 0, 1, 1, 1, 0, 0}
    })
}
local bigFlamesArea = createCombatArea({
    {0, 0, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 0, 0, 0, 1, 1, 0},
    {1, 1, 0, 0, 0, 0, 0, 1, 1},
    {1, 0, 0, 0, 0, 0, 0, 0, 1},
    {1, 0, 0, 0, 2, 0, 0, 0, 1},
    {1, 0, 0, 0, 0, 0, 0, 0, 1},
    {1, 1, 0, 0, 0, 0, 0, 1, 1},
    {0, 1, 1, 0, 0, 0, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 0, 0}
})
local deathFlames = {}
for k, area in ipairs(deathFlamesArea) do
    deathFlames[k] = createCombatObject()
    setCombatParam(deathFlames[k], COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatParam(deathFlames[k], COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKE)
    function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 0.5 + levelTotal), -(skillTotal * 1.5 + levelTotal)
    end
    setCombatCallback(deathFlames[k], CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
end
local bigFlames = createCombatObject()
setCombatParam(bigFlames, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(bigFlames, COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKER)
function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 0.5 + levelTotal), -(skillTotal * 1.5 + levelTotal)
    end
    setCombatCallback(bigFlames[k], CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onTargetTile(cid, pos)
    doSendDistanceShoot(getCreaturePosition(cid), pos, CONST_ANI_WHIRLWINDSWORD)
end
setCombatCallback(bigFlames, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
local function castSpellDelay(p)
    if(isCreature(p[1]) == TRUE) then
        doCombat(unpack(p))
    end
end
function onCastSpell(cid, var)
    for i = 0, repeatAmount - 1 do
        for k, combat in ipairs(deathFlames) do
            addEvent(castSpellDelay, (10 * k) + #deathFlames * 150 * i + 700 * i, {cid, combat, var})
        end
        addEvent(castSpellDelay, (10 * #deathFlames) + #deathFlames * 150 * i + 700 * i, {cid, bigFlames, var})
    end
    return LUA_NO_ERROR
end
 
Doesn't showthe spell's area, only shows the effect on 1 sqm where the player stands.
noteffect-png.27365
 

Attachments

The areas aren't set to combats in the script.
Code:
setCombatArea(combat, area)
But then instead of combat the name of the combat and instead of area the name of the area.
 
Back
Top