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

TFS 1.X+ Spell not working HELP

Newani

New Member
Joined
Sep 11, 2024
Messages
20
Reaction score
2
LUA:
local repeatAmount = 2
 
 
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_HOLYDAMAGE)
    setCombatParam(deathFlames[k], COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
 
    setCombatArea(deathFlames[k], area)
end
 
local bigFlames = createCombatObject()
setCombatParam(bigFlames, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(bigFlames, COMBAT_PARAM_EFFECT, 176)
 
setCombatArea(bigFlames, bigFlamesArea)
 
function onTargetTile(cid, pos)
    doSendDistanceShoot(getCreaturePosition(cid), pos, CONST_ANI_ETHEREALSPEAR)
end
setCombatCallback(bigFlames, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onGetFormulaValues(player, level, maglevel, factor)
    local min = (level * 5) + (maglevel * 19)
    local max = (level * 5) + (maglevel * 20.2)
    return -min, -max
end

setCombatCallback(#deathFlames, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
 
local function castSpellDelay(p)
    if(isCreature(p[1]) == TRUE) then
        doCombat(unpack(p))
    end
end
 
function onCastSpell(cid, var)
if getPlayerStorageValue(cid,23058) >= os.time() then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You are exhausted for 120 seconds.")
        return false
    end
    setPlayerStorageValue(cid, 23058, os.time() + 120) -- last number "120"  is the cooldown in seconds
    for i = 0, repeatAmount - 1 do
        for k, combat in ipairs(deathFlames) do
            addEvent(castSpellDelay, (150 * k) + #deathFlames * 150 * i + 700 * i, {cid, combat, var})
        end
        addEvent(castSpellDelay, (150 * #deathFlames) + #deathFlames * 150 * i + 700 * i, {cid, bigFlames, var})
    end

    return LUA_NO_ERROR
end
 
The spell wont work aslong as you have CallBackParam

in the latest script Mateus wrote he still uses:
combat:setCallback(CallBackParam.LEVELMAGICVALUE, levelMagicCallback)
and
bigFlames:setCallback(CallBackParam.TARGETTILE, targetTileCallback)

if we change those lines to this instead:
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "levelMagicCallback")
and
bigFlames:setCallback(CALLBACK_PARAM_TARGETTILE, "targetTileCallback")

also changed "local function" to be only function on both TargetTile and levelMagic
if it doesnt work add "local function" back and try again (not really sure what it should be in this case)

try this:
LUA:
local repeatAmount = 2

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}
})

function levelMagicCallback(player, level, magicLevel)
    local min = (level * 5) + (magicLevel * 19)
    local max = (level * 5) + (magicLevel * 20.2)
    return -min, -max
end

function targetTileCallback(creature, position)
    creature:getPosition():sendDistanceEffect(position, CONST_ANI_ETHEREALSPEAR)
end

local deathFlames = {}
for k, area in ipairs(deathFlamesArea) do
    local combat = Combat()
    combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
    combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
    combat:setArea(area)
    combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "levelMagicCallback")
    deathFlames[k] = combat
end

local bigFlames = Combat()
bigFlames:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
bigFlames:setParameter(COMBAT_PARAM_EFFECT, 176)
bigFlames:setArea(bigFlamesArea)
bigFlames:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "levelMagicCallback")
bigFlames:setCallback(CALLBACK_PARAM_TARGETTILE, "targetTileCallback")

local function castSpellDelay(actorKey, useGuid, combat, variant)
    local creature = useGuid and Player(actorKey) or Creature(actorKey)
    if creature then
        combat:execute(creature, variant)
    end
end

function onCastSpell(creature, variant)
    local player = Player(creature)
    if player then
        local now = os.time()
        local exhausted = player:getStorageValue(23058)
        if type(exhausted) ~= "number" then
            exhausted = -1
        end
        if exhausted >= now then
            local remaining = exhausted - now
            if remaining < 0 then remaining = 0 end
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are exhausted for " .. remaining .. " seconds.")
            return false
        end
        player:setStorageValue(23058, now + 120)
    end

    local useGuid = player ~= nil
    local actorKey = useGuid and player:getGuid() or creature:getId()
    for i = 0, repeatAmount - 1 do
        for k, combat in ipairs(deathFlames) do
            addEvent(castSpellDelay, (150 * k) + (700 * i), actorKey, useGuid, combat, variant)
        end
        addEvent(castSpellDelay, 450 + (700 * i), actorKey, useGuid, bigFlames, variant)
    end
    return true
end
 
Last edited:
Back
Top