• 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 damage formula

sick

Member
Joined
Feb 5, 2009
Messages
258
Reaction score
6
Location
Lithuania, Vilnius
Hello, I'm stuck with trying to change below aoe script. It was used for a mage and damage formula worked fine, however i wanted to adapt it to melee vocations and therefore add weapon attack to the damage formula with no success. Could someone assist in this regard?

Lua:
-- Delay between animations in milliseconds.
local animationDelay = 100
local combat = {}

-- Frames (1 = Area, 2 = Player, 3 = Player + Self Damaging)
local area = {
    {
        {0,0,0},
        {0,2,0},
        {1,0,0}
    },
    {
        {0,0,0},
        {1,2,0},
        {0,0,0}
    },
    {
        {1,0,0},
        {0,2,0},
        {0,0,0}
    }
}

-- Create a new Combat object for each frame and set its parameters
for i = 1, #area do
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, 1117)
end

-- Set the area of effect for each Combat object using the area tables
for x, _ in ipairs(area) do
    combat[x]:setArea(createCombatArea(area[x]))
end

-- Function to execute a Combat object in a given frame
function executeCombat(p, i)
    -- Make sure the target is a player
    if not p.player or not p.player:isPlayer() then
        return false
    end

    -- Execute the Combat object
    p.combat[i]:execute(p.player, p.var)
end


function onCastSpell(player, var)
    -- Create a table to store player and variable data for use in the executeCombat function
    local p = {player = player, var = var, combat = combat}

    -- Damage formula
    local level = player:getLevel()
    local skill = player:getMeleeSkill()
    local min = (level * 10) + (skill * skill)
    local max = (level * 10) + (skill * skill)

    -- Execute the Combat object for each frame, with a delay between each frame
    for i = 1, #area do
        -- Set the damage formula for the Combat object
        combat[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
        if i == 1 then
            combat[i]:execute(player, var)
        else
            addEvent(executeCombat, (animationDelay * i) - animationDelay, p, i)
        end
    end

    return true
end
 
You can use something like this to get the attack of a weapon:
Lua:
local weapon = player:getSlotItem(CONST_SLOT_LEFT)
    if weapon then
        local attack = weapon:getAttack()
    end
 
You can use something like this to get the attack of a weapon:
Lua:
local weapon = player:getSlotItem(CONST_SLOT_LEFT)
    if weapon then
        local attack = weapon:getAttack()
    end

Will be nil if the item has no attack :D
I know its for melee but still add a check :D
 
Back
Top