• 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 does nothing, no error or anything

xkevinz

Member
Joined
Aug 15, 2007
Messages
358
Reaction score
5
Here is a spell that I am using and completely nothing happens. I don't use mana and it does nothing and I get no error in console eithier, im using this on 0.4 8.6 which is weird, does anyone know the problem? thankyou if u can help:p

Code:
local range = 5
local bounces = 4
local anim = CONST_ANI_CAKE
local effect = CONST_ME_MAGIC_BLUE
local combat_type = COMBAT_HEALING

function getPlayerDamage(cid, mina, minb, maxa, maxb, minl, maxl, minm, maxm, minc, maxc)
    local min = (getPlayerLevel(cid) / minl + getPlayerMagLevel(cid) * minm) / 100 * mina + minb
    local max = (getPlayerLevel(cid) / maxl + getPlayerMagLevel(cid) * maxm) / 100 * maxa + maxb
    if(minc and math.abs(min) < math.abs(minc)) then
        min = minc
    end
    if(maxc and math.abs(max) < math.abs(maxc)) then
        max = maxc
    end
    return -math.ceil(math.random(max, min))
end

function attackNextTarget(cid, lastPosition, bounces, ignored, dmg)
    local targets = {}
    for i, tmpTarget in pairs(getSpectators(lastPosition, range, range)) do
        if not(isInArray(ignored, tmpTarget)) and isSightClear(lastPosition, getCreaturePosition(tmpTarget), false) and not(getTileInfo(getCreaturePosition(tmpTarget)).protection) and not(getTileInfo(getCreaturePosition(tmpTarget)).nopvp) and (isPlayer(tmpTarget)) then
            table.insert(targets, tmpTarget)
        end
    end
    if(#targets > 0) then
        local target = targets[math.random(1, #targets)]
        table.insert(ignored, target)
        doSendDistanceShoot(lastPosition, getCreaturePosition(target), anim)
        doTargetCombatHealth(cid, target, combat_type, dmg, dmg, effect)
        if(bounces > 0) then
            addEvent(attackNextTarget, 150, cid, getCreaturePosition(target), bounces - 1, ignored, dmg)
        end
    end
end

function onCastSpell(cid, var)
    local target = variantToNumber(var)
    if(isPlayer(target)) then
        local dmg = -getPlayerDamage(cid, 5, 5, 10, 14, 1, 1, 1, 1)
        doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), anim)
        doTargetCombatHealth(cid, target, combat_type, dmg, dmg, effect)
        if(bounces > 0) then
            attackNextTarget(cid, getCreaturePosition(target), bounces - 1, {target}, dmg)
        end
        return true
    end
    return false
end
 
Change
Code:
local target = variantToNumber(var)
To
Code:
local target = variantToNumber(var)
if not isPlayer(target) then
     target = getTopCreature(variantToPosition(var)).uid
end
 
this is my .lua
Code:
local range = 5
local bounces = 4
local anim = CONST_ANI_CAKE
local effect = CONST_ME_MAGIC_BLUE
local combat_type = COMBAT_HEALING

function getPlayerDamage(cid, mina, minb, maxa, maxb, minl, maxl, minm, maxm, minc, maxc)
    local min = (getPlayerLevel(cid) / minl + getPlayerMagLevel(cid) * minm) / 100 * mina + minb
    local max = (getPlayerLevel(cid) / maxl + getPlayerMagLevel(cid) * maxm) / 100 * maxa + maxb
    if(minc and math.abs(min) < math.abs(minc)) then
        min = minc
    end
    if(maxc and math.abs(max) < math.abs(maxc)) then
        max = maxc
    end
    return -math.ceil(math.random(max, min))
end

function attackNextTarget(cid, lastPosition, bounces, ignored, dmg)
    local targets = {}
    for i, tmpTarget in pairs(getSpectators(lastPosition, range, range)) do
        if not(isInArray(ignored, tmpTarget)) and isSightClear(lastPosition, getCreaturePosition(tmpTarget), false) and not(getTileInfo(getCreaturePosition(tmpTarget)).protection) and not(getTileInfo(getCreaturePosition(tmpTarget)).nopvp) and (isPlayer(tmpTarget)) then
            table.insert(targets, tmpTarget)
        end
    end
    if(#targets > 0) then
        local target = targets[math.random(1, #targets)]
        table.insert(ignored, target)
        doSendDistanceShoot(lastPosition, getCreaturePosition(target), anim)
        doTargetCombatHealth(cid, target, combat_type, dmg, dmg, effect)
        if(bounces > 0) then
            addEvent(attackNextTarget, 150, cid, getCreaturePosition(target), bounces - 1, ignored, dmg)
        end
    end
end

function onCastSpell(cid, var)
local target = variantToNumber(var)
if not isPlayer(target) then
     target = getTopCreature(variantToPosition(var)).uid
end
    if(isPlayer(target)) then
        local dmg = -getPlayerDamage(cid, 5, 5, 10, 14, 1, 1, 1, 1)
        doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), anim)
        doTargetCombatHealth(cid, target, combat_type, dmg, dmg, effect)
        if(bounces > 0) then
            attackNextTarget(cid, getCreaturePosition(target), bounces - 1, {target}, dmg)
        end
        return true
    end
    return false
end

and my spells.xml is
Code:
    <instant name="Chain Healing" words="chain healing" lvl="10" mana="30" prem="0" range="6" casterTargetOrDirection="1" blockwalls="1" exhaustion="2000" needlearn="0" event="script" value="CustomSpells/Chain Healing.lua">
        <vocation id="5"/>
    </instant>
 
You can also use
Code:
local target = getCreatureTarget(cid)
Then in spells.lua, change casterTargetOrDirection="1" to needtarget="1".
 
You can also use
Code:
local target = getCreatureTarget(cid)
Then in spells.lua, change casterTargetOrDirection="1" to needtarget="1".
Code:
local range = 5
local bounces = 4
local anim = CONST_ANI_CAKE
local effect = CONST_ME_MAGIC_BLUE
local combat_type = COMBAT_HEALING

function getPlayerDamage(cid, mina, minb, maxa, maxb, minl, maxl, minm, maxm, minc, maxc)
    local min = (getPlayerLevel(cid) / minl + getPlayerMagLevel(cid) * minm) / 100 * mina + minb
    local max = (getPlayerLevel(cid) / maxl + getPlayerMagLevel(cid) * maxm) / 100 * maxa + maxb
    if(minc and math.abs(min) < math.abs(minc)) then
        min = minc
    end
    if(maxc and math.abs(max) < math.abs(maxc)) then
        max = maxc
    end
    return -math.ceil(math.random(max, min))
end

function attackNextTarget(cid, lastPosition, bounces, ignored, dmg)
    local targets = {}
    for i, tmpTarget in pairs(getSpectators(lastPosition, range, range)) do
        if not(isInArray(ignored, tmpTarget)) and isSightClear(lastPosition, getCreaturePosition(tmpTarget), false) and not(getTileInfo(getCreaturePosition(tmpTarget)).protection) and not(getTileInfo(getCreaturePosition(tmpTarget)).nopvp) and (isPlayer(tmpTarget)) then
            table.insert(targets, tmpTarget)
        end
    end
    if(#targets > 0) then
        local target = targets[math.random(1, #targets)]
        table.insert(ignored, target)
        doSendDistanceShoot(lastPosition, getCreaturePosition(target), anim)
        doTargetCombatHealth(cid, target, combat_type, dmg, dmg, effect)
        if(bounces > 0) then
            addEvent(attackNextTarget, 150, cid, getCreaturePosition(target), bounces - 1, ignored, dmg)
        end
    end
end

function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
    if(isPlayer(target)) then
        local dmg = -getPlayerDamage(cid, 5, 5, 10, 14, 1, 1, 1, 1)
        doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), anim)
        doTargetCombatHealth(cid, target, combat_type, dmg, dmg, effect)
        if(bounces > 0) then
            attackNextTarget(cid, getCreaturePosition(target), bounces - 1, {target}, dmg)
        end
        return true
    end
    return false
end

i have changed the spells.xml and now this is the errors i get when i use it now.
vdie89.png
 
Back
Top