• 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] Summon Explosion Spell

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,684
Solutions
127
Reaction score
2,129
Hello, I was bored so I looked into forums and someone needed this, so here you go.

How does it work?
It summons x monsters and if these monsters are near their target they will explode dealing damage.

Code:
local monsterName, monsterCount = "demon", 4 -- time is in seconds

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setArea(createCombatArea(AREA_CIRCLE5X5))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 2) + 20 -- completely random
    local max = (player:getLevel() / 5) + 93
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local function checkPosition(cid, variant)
    local creature = Creature(cid)
    if not creature then
        return true
    end

    local target = creature:getTarget()
    if not target or not creature:getMaster() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        creature:remove()
        return true
    end

    if creature:getPosition():getDistance(target:getPosition()) <= 1 then
        combat:execute(creature:getMaster(), variant)
        creature:remove()
        return true
    end

    addEvent(checkPosition, 2 * 1000, cid, variant)
    return true
end

function onCastSpell(creature, variant)
    for i = 1, monsterCount do
        local summon = Game.createMonster(monsterName, creature:getPosition(), true, false)
        if summon then
            creature:addSummon(summon)
            addEvent(checkPosition, 2 * 1000, summon.uid, variant)
        end
    end
    return true
end
 
Last edited by a moderator:
Will they run towards your target? Would be a beast spell if You had a necro class and this spell would summon like 5 skeletons running towards your target and explode.
 
Code:
function onCastSpell(creature, variant)
    for i = 1, monsterCount do
        local summon = Game.createMonster(monsterName, creature:getPosition(), true, false)
        if summon then
            creature:addSummon(summon)
            addEvent(checkPosition, 2 * 1000, summon.uid, variant)
How to change that for TFS 0.3.5 ? @Thexamx

This is 90% code translation from tfs 1.0 to tfs 0.3.5 i stuck at the last part :)
Code:
local monsterName, monsterCount = "demon", 4 -- time is in seconds
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
arr = {
{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},
}

local area = createCombatArea(arr)
setCombatArea(combat, area)

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 2) + 20 -- completely random
    local max = (player:getLevel() / 5) + 93
    return -min, -max
end
setCombatCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
local function checkPosition(cid, variant)
    local creature = Creature(cid)
    if not creature then
        return true
    end
    local target = creature:getTarget()
    if not target or not creature:getMaster() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        creature:remove()
        return true
    end
    if creature:getPosition():getDistance(target:getPosition()) <= 1 then
        combat:execute(creature:getMaster(), variant)
        creature:remove()
        return true
    end
    addEvent(checkPosition, 2 * 1000, cid, variant)
    return true
end
function onCastSpell(creature, variant)
    for i = 1, monsterCount do
        local summon = Game.createMonster(monsterName, creature:getPosition(), true, false)
        if summon then
            creature:addSummon(summon)
            addEvent(checkPosition, 2 * 1000, summon.uid, variant)
        end
    end
    return true
end

50% translation :p but errors only in 56 line
Code:
stack traceback:
[8Cdata/spells/scripts/attack/final wolves.lua:56: in function <data/spells/scripts/attack/final wolves.lua:54>
 
Last edited by a moderator:
Getting errors while adding it..

Code:
Lua Script Error: [Test Interface]
data/spells/scripts/Necromancer/summon_explosion.lua
LuaScriptInterface::luaCreateCombatArea(). Invalid area table.
stack traceback:
        [C]: in function 'createCombatArea'
        data/spells/scripts/Necromancer/summon_explosion.lua:6: in main chunk

Lua Script Error: [Test Interface]
data/spells/scripts/Necromancer/summon_explosion.lua
LuaScriptInterface::luaCombatSetArea(). Area not found
stack traceback:
        [C]: in function 'setArea'
        data/spells/scripts/Necromancer/summon_explosion.lua:6: in main chunk

Lua Script Error: [Spell Interface]
data/spells/scripts/Necromancer/summon_explosion.lua
LuaScriptInterface::luaCreateCombatArea(). Invalid area table.
stack traceback:
        [C]: in function 'createCombatArea'
        data/spells/scripts/Necromancer/summon_explosion.lua:6: in main chunk

Lua Script Error: [Spell Interface]
data/spells/scripts/Necromancer/summon_explosion.lua
LuaScriptInterface::luaCombatSetArea(). Area not found
stack traceback:
        [C]: in function 'setArea'
        data/spells/scripts/Necromancer/summon_explosion.lua:6: in main chunk

also when cast ingame i get this

Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/Necromancer/summon_explosion.lua:onCastSpell
data/spells/scripts/Necromancer/summon_explosion.lua:43: attempt to call method 'addSummon' (a nil value)
stack traceback:
        [C]: in function 'addSummon'
        data/spells/scripts/Necromancer/summon_explosion.lua:43: in function <data/spells/scripts/Necromancer/summon_explosion.lua:39>

It summons a monster, but instead of running any where it attacks the player that summoned it.
 
Back
Top