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

Summon casts Spells on spellCast

XiolenceOT

New Member
Joined
Jun 5, 2023
Messages
42
Reaction score
4
I'm trying to see if anyone can help me figure this out, I'm trying to have the Vocation cast a spell that triggers the summon to cast the spel (exori) for example, but currently it's not doing anything except triggering the monster phrase. I know I must be missing something, I'm trying to do bit of everything learning the onUse functions for quests and ect. Movements.. But I want to have it do that and then the damage be formulated from the players magic level / level. If it's possible, I would really appreciate it, and be able to use the script as reference for the rest of the spells.


Lua:
 local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)
setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(player, variant)
    local summons = player:getSummons()
    if #summons > 0 then
        for _, summon in ipairs(summons) do
            doCombat(player, combat, variant, summon)
            summon:say("Prepare to go berserk!", TALKTYPE_MONSTER_SAY)
        end
        return true
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no summons.")
        return false
    end
end
 
check this sources:



u can set a "moves" on a summon, because it its like a creature u can set a "moves" for him. like a pokemon. :)
 
I'm trying to see if anyone can help me figure this out, I'm trying to have the Vocation cast a spell that triggers the summon to cast the spel (exori) for example, but currently it's not doing anything except triggering the monster phrase. I know I must be missing something, I'm trying to do bit of everything learning the onUse functions for quests and ect. Movements.. But I want to have it do that and then the damage be formulated from the players magic level / level. If it's possible, I would really appreciate it, and be able to use the script as reference for the rest of the spells.


Lua:
 local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)
setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(player, variant)
    local summons = player:getSummons()
    if #summons > 0 then
        for _, summon in ipairs(summons) do
            doCombat(player, combat, variant, summon)
            summon:say("Prepare to go berserk!", TALKTYPE_MONSTER_SAY)
        end
        return true
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no summons.")
        return false
    end
end
What is your engine version?

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)
setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / player:getMagicLevel()) + 7
    local max = (player:getLevel() / player:getMagicLevel()) + 11
    return -min, -max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(player, variant)
    local summons = player:getSummons()
    if #summons > 0 then
        for _, summon in ipairs(summons) do
            doCombat(summon, combat, variant)
            summon:say("Prepare to go berserk!", TALKTYPE_MONSTER_SAY)
        end
        return true
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no summons.")
        return false
    end
end

If it is TFS 1x or higher, you need to adapt it correctly for TFS 1x.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / player:getMagicLevel()) + 7
    local max = (player:getLevel() / player:getMagicLevel()) + 11
    return -min, -max
end

combat:setFormula(COMBAT_FORMULA_SKILLVALUE, -0.5, 0, -1.5, 0)

function onCastSpell(player, variant)
    local summons = player:getSummons()
    if #summons > 0 then
        for _, summon in ipairs(summons) do
            combat:execute(player, variant)
            summon:say("Prepare to go berserk!", TALKTYPE_MONSTER_SAY)
        end
        return true
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no summons.")
        return false
    end
end
 
What is your engine version?

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)
setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / player:getMagicLevel()) + 7
    local max = (player:getLevel() / player:getMagicLevel()) + 11
    return -min, -max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(player, variant)
    local summons = player:getSummons()
    if #summons > 0 then
        for _, summon in ipairs(summons) do
            doCombat(summon, combat, variant)
            summon:say("Prepare to go berserk!", TALKTYPE_MONSTER_SAY)
        end
        return true
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no summons.")
        return false
    end
end

If it is TFS 1x or higher, you need to adapt it correctly for TFS 1x.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / player:getMagicLevel()) + 7
    local max = (player:getLevel() / player:getMagicLevel()) + 11
    return -min, -max
end

combat:setFormula(COMBAT_FORMULA_SKILLVALUE, -0.5, 0, -1.5, 0)

function onCastSpell(player, variant)
    local summons = player:getSummons()
    if #summons > 0 then
        for _, summon in ipairs(summons) do
            combat:execute(player, variant)
            summon:say("Prepare to go berserk!", TALKTYPE_MONSTER_SAY)
        end
        return true
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no summons.")
        return false
    end
end
My bad the 1.4.2! it's just doing the beserk on my player still
 
Last edited:
Here, but you need to create a new area only for this spell:

go in data/spells/lib/spells.lua

search for AREA_SQUARE1X1 copy the entire area and rename for AREA_SUMMON1X1, then change where is 3 inside the area for 2 looking like:
Lua:
AREA_SUMMON1X1 = {
    {1, 1, 1},
    {1, 2, 1},
    {1, 1, 1}
}

now I'll give you an revscript(data/scripts):

Lua:
---Summon Berserker---
local spell = Spell(SPELL_INSTANT)
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_BLOCKSHIELD, false)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SUMMON1X1))

function onGetFormulaValues(player, level, maglevel)
    local basemin = 40
    local basemax = 80
    local formula = (maglevel * 3) + (2 * level)

    local min = (formula * 0.4)
    local max = (formula * 0.8)
    
    if min < basemin or max < basemax then
        min = basemin
        max = basemax
    end
    
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function spell.onCastSpell(creature, variant)
    local summons = creature:getSummons()
    if #summons > 0 then
        for _, summon in ipairs(summons) do
            local newVariant = Variant(summon)
            combat:execute(creature, newVariant)
            summon:say("Prepare to go berserk!", TALKTYPE_MONSTER_SAY)
        end
        return true
    else
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no summons.")
        return false
    end
end

---Aeoi---
spell:name('Summon Berserker') -- CHANGE HERE FOR NAME SPELL
spell:words('exori res') -- CHANGE HERE FOR WORD SPELL
spell:mana(120) -- CHANGE HERE FOR MANA COST SPELL
spell:cooldown(2000)
spell:magicLevel(5) -- CHANGE HERE FOR MAGIC LEVEL SPELL
spell:isPremium(true)
spell:needTarget(false)
spell:needLearn(false)
spell:isAggressive(true)
spell:needDirection(false)
spell:vocation('Sorcerer')
spell:vocation('Master Sorcerer')
spell:vocation('Druid')
spell:vocation('Elder Druid')
spell:register()

The only problem that you will face is: when your summon use exori next to another summon, they'll do damage to each other, I only solved the self damage from the summon.

maybe you can solve this using this in events/scripts/creature.lua:

After
Lua:
function Creature:onAreaCombat(tile, isAggressive)
add:

Lua:
    local player = Player(self)
    local target = tile:getTopCreature()
    if player and target and target:isMonster() then
        if target:getMaster() == player then
            return false
        end
    end

and in events.xml add change where is 0 to 1:
XML:
    <event class="Creature" method="onAreaCombat" enabled="1" />

I don't know if this solution is ok, but with this none of the area spells will work in your own summons, only target attacks like basic attk
obs.: if you do this part, you can change back the Area of spell effect to AREA_SQUARE1X1
 
Last edited:
Here, but you need to create a new area only for this spell:

go in data/spells/lib/spells.lua

search for AREA_SQUARE1X1 copy the entire area and rename for AREA_SUMMON1X1, then change where is 3 inside the area for 2 looking like:
Lua:
AREA_SUMMON1X1 = {
    {1, 1, 1},
    {1, 2, 1},
    {1, 1, 1}
}

now I'll give you an revscript(data/scripts):

Lua:
---Summon Berserker---
local spell = Spell(SPELL_INSTANT)
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_BLOCKSHIELD, false)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SUMMON1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (2.2 * player:getLevel())
    local max = (3.85 * player:getLevel())
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function spell.onCastSpell(creature, variant)
    local summons = creature:getSummons()
    if #summons > 0 then
        for _, summon in ipairs(summons) do
            local newVariant = Variant(summon)
            combat:execute(creature, newVariant)
            summon:say("Prepare to go berserk!", TALKTYPE_MONSTER_SAY)
        end
        return true
    else
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no summons.")
        return false
    end
end

---Aeoi---
spell:name('Summon Berserker') -- CHANGE HERE FOR NAME SPELL
spell:words('exori res') -- CHANGE HERE FOR WORD SPELL
spell:mana(120) -- CHANGE HERE FOR MANA COST SPELL
spell:cooldown(2000)
spell:magicLevel(5) -- CHANGE HERE FOR MAGIC LEVEL SPELL
spell:isPremium(true)
spell:needTarget(false)
spell:needLearn(false)
spell:isAggressive(true)
spell:needDirection(false)
spell:vocation('Sorcerer')
spell:vocation('Master Sorcerer')
spell:vocation('Druid')
spell:vocation('Elder Druid')
spell:register()

The only problem that you will face is: when your summon use exori next to another summon, they'll do damage to each other, I only solved the self damage from the summon.

maybe you can solve this using this in events/scripts/creature.lua:

After
Lua:
function Creature:onAreaCombat(tile, isAggressive)
add:

Lua:
    local player = Player(self)
    local target = tile:getTopCreature()
    if player and target and target:isSummon() then
        if target:getMaster() == player then
            return false
        end
    end

and in events.xml add change where is 0 to 1:
XML:
    <event class="Creature" method="onAreaCombat" enabled="1" />

I don't know if this solution is ok, but with this none of the area spells will work in your own summons, only target attacks like basic attk
obs.: if you do this part, you can change back the Area of spell effect to AREA_SQUARE1X1

it worked and then I tried to change damage formula for player magic level, and it gave me "Lua Script Error: [Test Interface]
(Unknown scriptfile)
attempt to call a nil value
stack traceback:
[C]: at 0x7ff65d6d9730"
 
it worked and then I tried to change damage formula for player magic level, and it gave me "Lua Script Error: [Test Interface]
(Unknown scriptfile)
attempt to call a nil value
stack traceback:
[C]: at 0x7ff65d6d9730"
show script
 
I changed it back exactly how you sent it, now everytime I cast I'm getting the error regardless.

EDIT: I fixed it back to working how you had it, can we make it so it goes off players magic level? and level
if i'm not wrong, I already changed the script above to work with ml and level
 
if i'm not wrong, I already changed the script above to work with ml and level

So it fixed it, but everytime the spell is called i get this error, besides that it works perfect for not damaging summons
Lua:
 Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onAreaCombat
data/events/scripts/creature.lua:17: attempt to call method 'isSummon' (a nil value)
stack traceback:
        [C]: in function 'isSummon'
        data/events/scripts/creature.lua:17: in function <data/events/scripts/creature.lua:14>
        [C]: in function 'execute'
        data/spells/scripts/attack/servantbeserk.lua:21: in function <data/spells/scripts/attack/servantbeserk.lua:16>
 
So it fixed it, but everytime the spell is called i get this error, besides that it works perfect for not damaging summons
Lua:
 Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onAreaCombat
data/events/scripts/creature.lua:17: attempt to call method 'isSummon' (a nil value)
stack traceback:
        [C]: in function 'isSummon'
        data/events/scripts/creature.lua:17: in function <data/events/scripts/creature.lua:14>
        [C]: in function 'execute'
        data/spells/scripts/attack/servantbeserk.lua:21: in function <data/spells/scripts/attack/servantbeserk.lua:16>
Change where isSummon() to isMonster()
 
Back
Top