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

TFS 0.X Spells: The player cannot pass the "summon"

Forkz

Well-Known Member
Joined
Jun 29, 2020
Messages
360
Solutions
1
Reaction score
76
Hi otlanders,

Below is the spells script. When the summon is generated the player cannot go through the "summon" and also the "summon" does not generate in places that have no space. can anybody help me?

Lua:
function onTargetTile(cid, position)
position.stackpos = 255
doConvinceCreature(cid, doCreateMonster("headcaptor", position, false))
doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
return true
end
local arr = {
{1, 0, 1},
{0, 2, 0},
{1, 0, 1},
}
local removeTime = 1.5 --time to remove the clones


local function removeCreatures(cid, creature)
        if isCreature(creature) == TRUE then
            doRemoveCreature(creature)
        end
end

function onTargetTile(cid, pos)
local creature = doSummonCreature("headcaptor", pos)
        doCreatureAddMana(cid, -2000)
        doConvinceCreature(cid, creature)
        doCreatureSay(creature, "Utevo Mort", TALKTYPE_ORANGE_1)
        addEvent(removeCreatures, removeTime * 1000, cid, creature)
        return TRUE
end

local area, combat = createCombatArea(arr), createCombatObject()
setCombatArea(combat, area)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end

How it works in practice

1.png

Places where there are walls or PZ area


2.png
 
Solution
Lua:
local removeTime = 1.5 --time to remove the clones

local arrs = {
    { x=-1, y=-1 },
    { x=1, y=-1 },
    { x=-1, y=1 },
    { x=1, y=1 }
}

local summonName = "Rat"
local effect = CONST_ME_POFF
local summonSay = "rat"

function onCastSpell(cid, var)
    local targetId = variantToNumber(var)
    if not targetId then
        return false
    end

    for k, v in pairs(arrs) do
        local position = getCreaturePosition(targetId)
        position.x, position.y = position.x + v.x, position.y + v.y
        local creature = doCreateMonster(summonName, position, false, true)
        if isCreature(creature) then
            doTeleportThing(creature, position)
            doSendMagicEffect(position, effect)...
The easiest way I can think (without source edits)

Lua:
local removeTime = 1.5 --time to remove the clones

local arrs = {
    { x=-1, y=-1 },
    { x=1, y=-1 },
    { x=-1, y=1 },
    { x=1, y=1 }
}

local summonName = "Rat"
local effect = CONST_ME_POFF
local summonSay = "rat"

function onCastSpell(cid, var)
    local targetId = variantToNumber(var)
    if not targetId then
        return false
    end

    for k, v in pairs(arrs) do
        local position = getCreaturePosition(targetId)
        position.x, position.y = position.x + v.x, position.y + v.y
       
        if getThingFromPos(position) and getThingFromPos(position).itemid then
            if isStairs(getThingFromPos(position).itemid) then
                return false
            end
        end
       
        local creature = doCreateMonster(summonName, position, false, true)
        if isCreature(creature) then
            doTeleportThing(creature, position)
            doSendMagicEffect(position, effect)
            doConvinceCreature(cid, creature)
            doMonsterSetTarget(creature, targetId)
            doCreatureSay(creature, summonSay, TALKTYPE_ORANGE_1)
            addEvent(function (creature)
                if isCreature(creature) then
                    doRemoveCreature(creature)
                end
            end, 1000 * removeTime, creature)
        end
    end
    return true
end

then in global.lua

Lua:
stairs = { -- Add all stairs itemids --
    1111, 1111, 1111
}

function isStairs(itemid)
    if isInArray(stairs, itemid) then
        return true
    end
return false
end
my folder doesn't have "global.lua" file is there any other place i can add?
 
Back
Top