• 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 monster not damage

darkmu

Well-Known Member
Joined
Aug 26, 2007
Messages
274
Solutions
1
Reaction score
50
Location
Paraná,Brazil
I'm trying to convert a spell from player to monster, but when attacking spells, it's not damaging the player, can someone help me?
Lua:
-- Delay between animations.
local animationDelay = 200
local combat = {}

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

for i = 1, #area do
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
end

for x, _ in ipairs(area) do
    combat[x]:setArea(createCombatArea(area[x]))
end

function executeCombat(p, i) 
    p.combat[i]:execute(p.creature, p.var)
end

function onCastSpell(creature, var)

    local p = {creature = creature, var = var, combat = combat}

    local min = 300
    local max = 500

    for i = 1, #area do
        combat[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
        if i == 1 then
            combat[i]:execute(creature, var)
        else
            addEvent(executeCombat, (animationDelay * i) - animationDelay, p, i)
        end
    end

    return true
end

1600953268459.png
this attack that came out and the melee

 
Solution
You only use COMBAT_FORMULA_LEVELMAGIC for player spells (as it depends directly on the magic level).

In monster spells, COMBAT_FORMULA_DAMAGE is used, to don't execute the Magic level parameter.


In your case, I believe that if you change this, the spell will work:

Lua:
combat[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)

Lua:
combat[i]:setFormula(COMBAT_FORMULA_DAMAGE, -min, 0, -max, 0)
You only use COMBAT_FORMULA_LEVELMAGIC for player spells (as it depends directly on the magic level).

In monster spells, COMBAT_FORMULA_DAMAGE is used, to don't execute the Magic level parameter.


In your case, I believe that if you change this, the spell will work:

Lua:
combat[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)

Lua:
combat[i]:setFormula(COMBAT_FORMULA_DAMAGE, -min, 0, -max, 0)
 
Solution
You only use COMBAT_FORMULA_LEVELMAGIC for player spells (as it depends directly on the magic level).

In monster spells, COMBAT_FORMULA_DAMAGE is used, to don't execute the Magic level parameter.


In your case, I believe that if you change this, the spell will work:

Lua:
combat[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)

Lua:
combat[i]:setFormula(COMBAT_FORMULA_DAMAGE, -min, 0, -max, 0)

Thanks !! 🥰 🥰
 
Back
Top