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

Summon Commands

mackerel

Well-Known Member
Joined
Apr 26, 2017
Messages
398
Solutions
18
Reaction score
74
Ehm..

Yeah, I was wondering if it is possible to tell your summons to perform certain spell attack

For example:

1. Utevo Res "Dragon (DRAGON HAS BEEN SUMMONED)
2. Player executes another spell such as 'Flame Bombs' - this lets the summon know to attack as well
3. Summon will attack target with 'Flame Bombs'

TFS 1.0
 
Solution
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -3.2, 1, -5.2, 1)

local area = createCombatArea(AREA_SQUARE1X1)
combat:setArea(area)

function onCastSpell(cid, var)
    local player = Player(cid)
    local summons = player:getSummons()
    local target = player:getTarget()

    if #summons == 0 then
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end

    for i = 1, #summons do
        combat:execute(summons[i], Variant(target))
    end

    return false
end
Hmm, can someone tell me why this doesn't work?
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)
combat:setArea(createCombatArea(AREA_CIRCLE2X2))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if #creature:getSummons() == 0 then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        creature:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end
    for i=1,#creature:getSummons() do
        combat:execute(creature, Variant(creature:getSummons(i)))
    end
    return false
end
 
Hmm, can someone tell me why this doesn't work?
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)
combat:setArea(createCombatArea(AREA_CIRCLE2X2))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if #creature:getSummons() == 0 then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        creature:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end
    for i=1,#creature:getSummons() do
        combat:execute(creature, Variant(creature:getSummons(i)))
    end
    return false
end
combat:execute(creature, Variant(creature:getSummons(i)))
There is no param for getSummons. This is taken from compat.lua
LUA:
function getCreatureSummons(cid)
    local c = Creature(cid)
    if c == nil then
        return false
    end

    local result = {}
    for _, summon in ipairs(c:getSummons()) do
        result[#result + 1] = summon:getId()
    end
    return result
end
 
Hmm, can someone tell me why this doesn't work?
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)
combat:setArea(createCombatArea(AREA_CIRCLE2X2))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    if #creature:getSummons() == 0 then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        creature:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end
    for i=1,#creature:getSummons() do
        combat:execute(creature, Variant(creature:getSummons(i)))
    end
    return false
end


I tried this but it didn't work

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 6)

local area = createCombatArea(AREA_CIRCLE3X3)
setCombatArea(combat, area)
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2) + 12
    return -min, -max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
    if #Player(cid):getSummons() == 0 then
        Player(cid):sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end

    for i = 1, #Player(cid):getSummons() do
        doCombat(cid, combat, var(Player(cid):getSummons(i)))
    end

    return false -- doCombat(cid, combat, var)
end

data/spells/scripts/test.lua:23: attempt to call local 'var' (a table value)
stack traceback:
-- Line 20 on here

someone |:
 
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)

local area = createCombatArea(AREA_CIRCLE3X3)
combat:setArea(area)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    local player = Player(cid)
    local summons = player:getSummons()
    if #summons == 0 then
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end

    for i = 1, #summons do
        combat:execute(creature, Variant(summons[i]))
    end

    return false
end
 
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)

local area = createCombatArea(AREA_CIRCLE3X3)
combat:setArea(area)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    local player = Player(cid)
    local summons = player:getSummons()
    if #summons == 0 then
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end

    for i = 1, #summons do
        combat:execute(creature, Variant(summons[i]))
    end

    return false
end

It works.. partially as the summons don't deal any damage nor use spell on target but rather on itself . So I modified that a bit but that doesn't work either

LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -3.2, 1, -5.2, 1)

local area = createCombatArea(AREA_SQUARE1X1)
combat:setArea(area)

function onCastSpell(cid, var)
    local player = Player(cid)
    local summons = player:getSummons()

    if #summons == 0 then
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end

    for i = 1, #summons do
        combat:execute(creature, Variant(summons[i]))
    end

    return false
end

not even this

LUA:
function onCastSpell(cid, var)
    print("refresh")
    local player = Player(cid)
    local summons = player:getSummons()
    local creature = player:getTarget()
   
    if #summons == 0 then
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end
    for i = 1, #summons do
        combat:execute(creature, Variant(summons[i]))
    end
    return false
end
 
Last edited:
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -3.2, 1, -5.2, 1)

local area = createCombatArea(AREA_SQUARE1X1)
combat:setArea(area)

function onCastSpell(cid, var)
    local player = Player(cid)
    local summons = player:getSummons()
    local target = player:getTarget()

    if #summons == 0 then
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end

    for i = 1, #summons do
        combat:execute(summons[i], Variant(target))
    end

    return false
end
 
Solution
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -3.2, 1, -5.2, 1)

local area = createCombatArea(AREA_SQUARE1X1)
combat:setArea(area)

function onCastSpell(cid, var)
    local player = Player(cid)
    local summons = player:getSummons()
    local target = player:getTarget()

    if #summons == 0 then
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You do not have any summons.")
        return false
    end

    for i = 1, #summons do
        combat:execute(summons[i], Variant(target))
    end

    return false
end

thank you, do you know whether we need to have area specified in order to attack? this:

LUA:
local area = createCombatArea(AREA_SQUARE1X1)
combat:setArea(area)

without this, I can see the distance effect but the damage does not work :confused:
 
LUA:
        combat:execute(summons[i], Variant(target))
oh gracious, the things that can be overlooked when somebodies brain is not switched on >.>
how could I be so dumb not to realise that getSummons() might return a table
very good
 
Last edited:
thank you, do you know whether we need to have area specified in order to attack? this:

LUA:
local area = createCombatArea(AREA_SQUARE1X1)
combat:setArea(area)

without this, I can see the distance effect but the damage does not work :confused:
in regards to your question, instead of createCombatArea(AREA_SQUARE1X1) put createCombatArea({1}) and see what happens
EDIT: sorry for double posting, I thought I was editing the previous one
 
in regards to your question, instead of createCombatArea(AREA_SQUARE1X1) put createCombatArea({1}) and see what happens
EDIT: sorry for double posting, I thought I was editing the previous one

it works if you do this:

({{1}})

But I just realized the spell only works if the summon is next to target, it doesn't work for distance :confused: in both cases, AREA_SQUARE1X1 and {{1}}
 
I believe that is a matter of what is in spells.xml but I could be wrong
If not, if all you want is a single target HMM type spell then it can be handled differently
 
I believe that is a matter of what is in spells.xml but I could be wrong

I think this only applies to player, I dunno if I have to change the spell itself, and if so then all the positions will have to be set etc

XML:
    <instant name="test" words="test" lvl="15" mana="10" prem="0" needtarget="1" range="5" blockwalls="1" exhaustion="2000" needlearn="0" script="test.lua">
       <vocation id="2"/> 
       <vocation id="6"/>
       <vocation id="7"/>
       <vocation id="9"/>
       <vocation id="10"/>
       <vocation id="11"/>
       <vocation id="12"/>
       <vocation id="13"/>
   </instant>

But then again, monsters have their own unique spells:

XML:
    <instant name="pirate corsair skill reducer" words="###49"  direction="1" aggressive="1" blockwalls="1" needtarget="0" needlearn="1" script="monster/pirate corsair skill reducer.lua"/>
 
Back
Top