• 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.4] Summons&Pets

Tofame

Intermediate OT User
Joined
Aug 17, 2021
Messages
125
Solutions
4
Reaction score
101
Location
Poland
Yo,
Today I bring to you working summoning spell (2 versions that differ a little) and hide spell that is different from other available on forum, because you can actually exclude monsters that you don't want to be removed upon usage.
Tested working on TFS 1.4.2 and that's the version I can support. I suppose it might work on generally tfs 1.x, but I'm not knowledgeable enough to say it with certainty and help in case of errors.

preview:

spells.xml
Lua:
<!-- Summon Spells -->
    <instant group="support" spellid="9" name="Hide" words="hide" level="1" mana="10" params="1" cooldown="1000" groupcooldown="1000" needlearn="0" script="summons/hide.lua"/>
    <instant group="support" spellid="9" name="Summon Demonic Duo" words="demonic duo" level="1" mana="1000" params="1" cooldown="1000" groupcooldown="1000" needlearn="0" script="summons/summon_demonic_duo.lua" />
    <instant group="support" spellid="9" name="Summon wolf" words="summon wolf" level="1" params="1" cooldown="1000" groupcooldown="1000" needlearn="0" script="summons/summon_wolf.lua" />

Now, inside data/spells/scripts create folder summons. Inside the folder paste:
hide.lua
Lua:
function onCastSpell(creature, var)

local pets = {"Tazuna", "Katsuyu", "[Pet] Gamakichi", "Pakkun", "Kumo"} --[[ MONSTERS THAT WON'T BE HIDDEN, FOR EXAMPLE PETS ]]--

local creatureSummons = creature:getSummons(summonName)
local creaturePosition = creature:getPosition()

-- ====== COUNTING SUMMONS =================
local summonCount = creature:getSummons()
if #summonCount < 1 then
    creaturePosition:sendMagicEffect(CONST_ME_POFF)
    creature:sendCancelMessage("You don't have any summons!")-- error msg
    return false
end
-- ====== REMOVING SUMMONS =================
for _,creature in pairs(creatureSummons) do
    if (isInArray(pets, creature:getName())) then
    else
        creature:getPosition():sendMagicEffect(6) -- 3 = poff, 6 = explosion
        doRemoveCreature(creature:getId())
    end
end

return true
end
summon_wolf.lua
Lua:
local summonName = "Wolf"
local manaCost = 1000

function onCastSpell(creature, var)
 
    local creatureSummons = creature:getSummons(summonName)
    local creaturePosition = creature:getPosition()
    local MAX_WOLFS_ALLOWED = 5
    local wolfs = 0
-- CHECK IF PLAYER HAS MANA
    if creature:getMana() < manaCost and not creature:hasFlag(PlayerFlag_HasInfiniteMana) then
        creature:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
-- COUNTS HOW MANY SUMMONED WOLFS YOU HAVE SUMMONED
    for _,creature in pairs(creatureSummons) do
        if creature:getName() == "Wolf" then
            wolfs = wolfs + 1
        end
    end
-- IF YOU HAVENT SUMMONED TOO MANY WOLFS THEN SUMMON ELSE DONT SUMMON
    if wolfs < MAX_WOLFS_ALLOWED then
        local summon = Game.createMonster(summonName, creaturePosition)
        creature:addMana(-manaCost)
        creature:addManaSpent(manaCost)
        summon:setMaster(creature)
        summon:setDropLoot(false)
        summon:say("Woof! ", TALKTYPE_MONSTER_SAY)
        summon:registerEvent('SummonThink')
        creature:getPosition():sendMagicEffect(48)
    
    else
        creature:sendCancelMessage("You are already at max summons.")-- error msg
    end
 
    return true
end
summon_demonic_duo.lua
Lua:
local summonName = "Frost Troll"
local summonNamex = "Furious Troll"

function onCastSpell(creature, var)
 
    local creatureSummons = creature:getSummons(summonName)
    local creaturePosition = creature:getPosition()
    local summonscountFuriousTroll = 0
    local summonscountFrostTroll = 0
 
    for _,creature in pairs(creatureSummons) do
        if creature:getName() == "Frost Troll" then
            summonscountFrostTroll = 1
        end
        if creature:getName() == "Furious Troll" then
            summonscountFuriousTroll = 1
        end
    end
    if summonscountFrostTroll == 0 then
        local summon = Game.createMonster(summonName, creaturePosition)
        summon:setMaster(creature)
        summon:setDropLoot(false)
        summon:registerEvent('SummonThink')
        -- co player powie gdy przywola: creature:say("Go " .. summonName .. "!", TALKTYPE_MONSTER_SAY)
    else
        creature:sendCancelMessage("Frost Troll is already summoned.")-- error msg
    end
 
    if summonscountFuriousTroll == 0 then
        local summonx = Game.createMonster(summonNamex, creaturePosition)
        summonx:setMaster(creature)
        summonx:setDropLoot(false)
        summonx:registerEvent('SummonThink')
    else
        creature:sendCancelMessage("Furious Troll is already summoned.")-- error msg
    end
 
    return true
end
=============================================================
Now, as a BONUS -> pets. Pets work like that: you equip item then pet appears, you deequip it and pet disappears. Include pet's name inside hide.lua to make it unable to be removed with spell hide.
data/movements/movements.xml paste this, remember to configure your itemid that you want
XML:
<movevent event="Equip" itemid="26422" slot="ring" script="A_Pet/gamakichi.lua" />
<movevent event="DeEquip" itemid="26422" slot="ring" script="A_Pet/gamakichi.lua" />

inside movements/scripts create folder "A_Pet". Inside it paste:
gamakichi.lua
Lua:
local summonName = "[Pet] Gamakichi"

function onEquip(player, item, slot, isCheck)
    if isCheck then
        return true
    end
 
    local playerSummons = player:getSummons(summonName)
    local playerPosition = player:getPosition()
    local summonsCountGamakichi = 0

   
     if Tile(playerPosition):hasFlag(TILESTATE_PROTECTIONZONE) then
        return player:sendCancelMessage("You mustn't be in PZ!")-- error msg
    end
 
    for _,player in pairs(playerSummons) do
        if player:getName() == summonName then
            summonsCountGamakichi = 1
        end
    end
 
    if summonsCountGamakichi == 0 then
        local summon = Game.createMonster(summonName, playerPosition)
        summon:setMaster(player)
        summon:setDropLoot(false)
        summon:registerEvent('SummonThink')
        -- what will player say upon summoning: player:say("Go " .. summonName .. "!", TALKTYPE_MONSTER_SAY)
    else
        player:sendCancelMessage("Gamakichi is already summoned.")-- error msg
    end
 
    return true
end

function onDeEquip(creature, item, slot)

local creatureSummons = creature:getSummons(summonName)
local creaturePosition = creature:getPosition()
 
for _,creature in pairs(creatureSummons) do
    if creature:getName() == summonName  then
        creature:getPosition():sendMagicEffect(6) -- 3 = poff, 6 = explosion
        doRemoveCreature(creature:getId())
    else
        -- nothing happens
    end
end

return true
end

Well, as you can see there was custom pet name used: [Pet] Gamakichi. Unless you already configured it to your own pet name and you set your own paths then its all right atm. If you don't know how then just paste this below (we will add [Pet] Gamakichi monster).
data/monster/monsters.xml add:
XML:
<monster name="[Pet] Gamakichi" file="monsters/B_Pets/petGamakichi.xml" />
inside data/monster/scripts create folder: B_Pets and inside it add:
petGamakichi.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="[Pet] Gamakichi" nameDescription="a gamakichi" race="blood" experience="80" speed="750" manacost="255">
    <health now="10000" max="10000" />
    <look type="24" corpse="0" />
    <targetchange interval="4000" chance="0" />
    <flags>
        <flag summonable="1" />
        <flag attackable="0" />
        <flag hostile="0" />
        <flag illusionable="1" />
        <flag convinceable="1" />
        <flag pushable="1" />
        <flag canpushitems="0" />
        <flag canpushcreatures="0" />
        <flag targetdistance="2" />
        <flag canwalkonenergy="0" />
        <flag canwalkonfire="0" />
        <flag canwalkonpoison="0" />
    </flags>
</monster>

edit2: preview added, also I just wanted to say that this script wouldn't be possible without ShivaShadowsong that taught me how to count summons summoned.
edit3: 29.08.2022 added fix for sending errors to console if you equipped pet in pz zone.
 
Last edited:
Hello. Pet can change floor? What a command for this is? THX
This post is about summoning pets/summons. There are already scripts on this forum for pet teleport on floor change etc.
 
How can I increase for player not to attack the summon and summon not to attack the master ?
 
Back
Top