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

Spell [TFS 1.x+] Omicron

Adorius Black

Advanced OT User
Joined
Mar 31, 2020
Messages
301
Solutions
3
Reaction score
180
☠️ Omicron ☠️
🤮


🖥️ Install 🖥️
data/spells/spells.xml

XML:
    <instant group="attack" spellid="910" name="Omicron" words="omicron" lvl="1" mana="1" prem="0" needweapon="0" range="6" casterTargetOrDirection="1"  exhaustion="6000" groupcooldown="2000" needlearn="0" script="custom/omicron.lua">
        <vocation name="Qira" />
        <vocation name="Toxic Qira" />
    </instant>

data/spells/scripts/custom/omicron.lua
Lua:
-- Delay between animations.
local animationDelay = 500
local combat = {}

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

}

local condition = Condition(CONDITION_POISON)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(3, 3000, -45)
condition:addDamage(3, 3000, -35)
condition:addDamage(3, 3000, -25)
condition:addDamage(3, 3000, -15)
condition:addDamage(3, 3000, -5)

for i = 1, #area do
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_POISONAREA)
    combat[i]:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISON)
    combat[i]:addCondition(condition)

end

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

function executeCombat(p, i)
    if not p.player then
        return false
    end
    if not p.player:isPlayer() then
            return false
    end
    p.combat[i]:execute(p.player, p.var)
end

function onCastSpell(player, var)

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

    -- Damage formula
    local level = player:getLevel()
    local maglevel = player:getMagicLevel()
    local min = (level / 5) + (maglevel * 4.4) + 8
    local max = (level / 5) + (maglevel * 5.2) + 14

    for i = 1, #area do
        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
 
Last edited:
can you advise me please?
Lua:
function executeCombat(pid, variant, combatId)
    local player = Player(pid)
    if not player then
        return
    end
    combat[combatId]:execute(player, variant)
end

-- snap

addEvent(executeCombat, (animationDelay * i) - animationDelay, player:getId(), var, i)
 
can you advise me please?

Lua:
local function executeCombat(_combat, player, var) -- Since we execute it only within this script, it can be a local function
    player = Player(player) -- player was cid, then we transform it to player userdata
    if not player then
        return
    end
    _combat:execute(player, var)
end

function onCastSpell(creature, var)
    local player = creature:getPlayer()
    if not player then
        return false -- Only players can cast it
    end

    -- Damage formula
    local level = player:getLevel()
    local maglevel = player:getMagicLevel()
    local min = (level / 5) + (maglevel * 4.4) + 8
    local max = (level / 5) + (maglevel * 5.2) + 14

    for i = 1, #area do
        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, combat[i], player:getId(), var) -- You should always pass creatures cid, instead userdata (object) within addEvent
        end
    end

    return true
end

Correct:
addEvent(callback, time, creature:getId())
addEvent(callback, time, player:getId())
addEvent(callback, time, cid)

Wrong - not safe:
addEvent(callback, time, creature)
addEvent(callback, time, player)
 
Lua:
local function executeCombat(_combat, player, var) -- Since we execute it only within this script, it can be a local function
    player = Player(player) -- player was cid, then we transform it to player userdata
    if not player then
        return
    end
    _combat:execute(player, var)
end

function onCastSpell(creature, var)
    local player = creature:getPlayer()
    if not player then
        return false -- Only players can cast it
    end

    -- Damage formula
    local level = player:getLevel()
    local maglevel = player:getMagicLevel()
    local min = (level / 5) + (maglevel * 4.4) + 8
    local max = (level / 5) + (maglevel * 5.2) + 14

    for i = 1, #area do
        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, combat[i], player:getId(), var) -- You should always pass creatures cid, instead userdata (object) within addEvent
        end
    end

    return true
end

Correct:
addEvent(callback, time, creature:getId())
addEvent(callback, time, player:getId())
addEvent(callback, time, cid)

Wrong - not safe:
addEvent(callback, time, creature)
addEvent(callback, time, player)
This gonna crash anyway, but on /reload spells this time
 
combat object
If he are using these changes, there should be no problems with the Combat object

per example:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setArea(createCombatArea(AREA_CIRCLE5X5))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 8) + 50
    local max = (level / 5) + (magicLevel * 12) + 75
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local spell = Spell("instant")
function spell.onCastSpell(creature, variant)
    for i = 1, 5 do
        addEvent(function (cid)
            local creature = Creature(cid)
            if creature then
                combat:execute(creature, variant)
                Game.reload(RELOAD_TYPE_SPELLS) -- <<<<<<<<<<<<<<<<<<<
            end
        end , 500 * i, creature:getId())
    end
    return true
end

spell:name("Hell's Core")
spell:words("exevo gran mas flam 2")
spell:group("attack")
spell:vocation("sorcerer", "master sorcerer")
spell:id(24)
spell:cooldown(40 * 1000)
spell:groupCooldown(4 * 1000)
spell:level(60)
spell:mana(1100)
spell:isSelfTarget(true)
spell:isPremium(true)
spell:register()

GIF 13-12-2021 10-35-11 p. m..gif
 
If he are using these changes, there should be no problems with the Combat object

per example:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setArea(createCombatArea(AREA_CIRCLE5X5))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 8) + 50
    local max = (level / 5) + (magicLevel * 12) + 75
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local spell = Spell("instant")
function spell.onCastSpell(creature, variant)
    for i = 1, 5 do
        addEvent(function (cid)
            local creature = Creature(cid)
            if creature then
                combat:execute(creature, variant)
                Game.reload(RELOAD_TYPE_SPELLS) -- <<<<<<<<<<<<<<<<<<<
            end
        end , 500 * i, creature:getId())
    end
    return true
end

spell:name("Hell's Core")
spell:words("exevo gran mas flam 2")
spell:group("attack")
spell:vocation("sorcerer", "master sorcerer")
spell:id(24)
spell:cooldown(40 * 1000)
spell:groupCooldown(4 * 1000)
spell:level(60)
spell:mana(1100)
spell:isSelfTarget(true)
spell:isPremium(true)
spell:register()

View attachment 63977
Just because i'm curious i tried your hell's core 2 script.
But as expected, there is an error with the object spell you make.
Am I missing data? I checked the src files and they seem to be correct.

The error what i get is as followed:
Lua:
[Warning - Event::checkScript] Event onCastSpell not found. scripts/attack/hells_core2.lua

Taking away the spell. and just do onCastSpell... works
 
Last edited:
This gonna crash anyway, but on /reload spells this time
I dont know if I understand good but I have no problem when i write with my GM char /reload spells . its working without crash TFS 1.4
 
Back
Top