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

Summoning specific!

Aeronx

Intermediate OT User
Joined
Dec 17, 2015
Messages
746
Solutions
9
Reaction score
125
Hello everybody! I've been away from OTS for so long that I dont recognize half of it!

I'd like some help with this code, its for 0.3.x im using 1.2 actually, so it isnt working.

Code:
[code=lua]local max = 3

function onCastSpell(cid, var)
local count, pos = #getCreatureSummons(cid), getThingPos(cid)
if count == max then
doPlayerSendCancel(cid, 'You cannot summon more creatures.')
doSendMagicEffect(pos, CONST_ME_POFF)
return FALSE
end


for i = 1, max - count do
local v = doSummonMonster(cid, 'Dragon')
if v ~= 1 then
doPlayerSendDefaultCancel(cid, v)
doSendMagicEffect(pos, CONST_ME_POFF)
if i == 1 then
return FALSE
else
return TRUE
end
end
doSendMagicEffect(getThingPos(getCreatureSummons(cid)[count+i]), CONST_ME_TELEPORT)
end
doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
return TRUE
end
[/CODE]

Also, i'd like to know how should i refer to this spell on spells.lua

Thank you in advance!
 
Code:
    local maxSummons = 3
    local summonName = "Dragon"

    function onCastSpell(player, var)
        local summonCount, playerPosition = #player:getSummons(), player:getPosition()
        if summonCount >= maxSummons then
            player:sendCancelMessage('You cannot summon more creatures.')
            playerPosition:sendMagicEffect(CONST_ME_POFF)
            return false
        end

        for i = 1, maxSummons - summonCount do
            local summonedCreature = Game.createMonster(summonName, playerPosition)
            if summonedCreature then
                summonedCreature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                summonedCreature:setMaster(player)
            end
        end
        return true
    end
Don't bump a thread even if its friendly the same day..
 
Okey! I've tested it and it works! but i've found a problem. The summon attack me. They are just summoned creatures. Is there anyway to set me as their master and attack my target?
Actually, its like the spell "utevo res" but instead of "utevo res skeleton" use <randomword> to summon <specific-creature>.
Im so bad at explaining myself!
 
Doh.. i feel so dumb! You are totally right!
Okey! one last request, is there anyway to make summons follow you if you lose them, or if you change floor? i've found a code, but i dont think is working in 1.2.
Code:
local config = {
        tilesLimitToTeleport = 8, -- if summon is X sqm away it will be teleported to owner
        interval = 5, -- checks summons positions every X seconds
        teleportMonsterSummonsToo = true -- not work if your monsters havent registered this creaturescript
}

function onThink(cid, interval)
    if teleportMonsterSummonsToo == true or isMonster(cid) == false then
        local summons = getCreatureSummons(cid)
        if(not summons or next(summons) == nil) then
            return false
        end

        local pos = getThingPos(cid)
        if(getTilePzInfo(pos)) == true then
            return false
        end
        for _, sid in pairs(summons) do
            local summonPos = getThingPos(sid)
            if(getDistanceBetween(pos, summonPos) > config.tilesLimitToTeleport or pos.z ~= summonPos.z) then
                doTeleportThing(sid, pos)
                doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
                doSendMagicEffect(summonPos, CONST_ME_MAGIC_RED)
            end
        end
    end
    return true
end
Im really really thankfull for all your help guys! really appreciate it
 
Doh.. i feel so dumb! You are totally right!
Okey! one last request, is there anyway to make summons follow you if you lose them, or if you change floor? i've found a code, but i dont think is working in 1.2.
Code:
local config = {
        tilesLimitToTeleport = 8, -- if summon is X sqm away it will be teleported to owner
        interval = 5, -- checks summons positions every X seconds
        teleportMonsterSummonsToo = true -- not work if your monsters havent registered this creaturescript
}

function onThink(cid, interval)
    if teleportMonsterSummonsToo == true or isMonster(cid) == false then
        local summons = getCreatureSummons(cid)
        if(not summons or next(summons) == nil) then
            return false
        end

        local pos = getThingPos(cid)
        if(getTilePzInfo(pos)) == true then
            return false
        end
        for _, sid in pairs(summons) do
            local summonPos = getThingPos(sid)
            if(getDistanceBetween(pos, summonPos) > config.tilesLimitToTeleport or pos.z ~= summonPos.z) then
                doTeleportThing(sid, pos)
                doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
                doSendMagicEffect(summonPos, CONST_ME_MAGIC_RED)
            end
        end
    end
    return true
end
Im really really thankfull for all your help guys! really appreciate it
Take the initiative and convert the script yourself
https://github.com/otland/forgottenserver

Or repost this in request.
 
Back
Top