• 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

Member
Joined
Jun 29, 2020
Messages
182
Solutions
1
Reaction score
24
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)...
OP
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
182
Solutions
1
Reaction score
24
change doCreateMonster("headcaptor", position, false) to doCreateMonster("headcaptor", position, true, true)
I compiled a source with "force" true and the PZ area part worked.

C++:
int32_t LuaInterface::luaDoCreateMonster(lua_State* L)
{
    //doCreateMonster(name, pos[, extend = false[, force = false]])
    bool force = true, extend = false;
    int32_t params = lua_gettop(L);
    if(params > 3)
        force = popBoolean(L);

    if(params > 2)
        extend = popBoolean(L);

    PositionEx pos;
    popPosition(L, pos);

    std::string name = popString(L);
    Monster* monster = Monster::createMonster(name.c_str());
    if(!monster)
    {
        errorEx("Monster with name '" + name + "' not found");
        lua_pushboolean(L, false);
        return 1;
    }

    if(!g_game.placeCreature(monster, pos, extend, force))
    {
        delete monster;
        errorEx("Cannot create monster: " + name);

        lua_pushboolean(L, false);
        return 1;
    }

    ScriptEnviroment* env = getEnv();
    lua_pushnumber(L, env->addThing((Thing*)monster));
    return 1;
}

however some places even with the modification "force" to true, some places does not summon.


3.png
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,072
Solutions
107
Reaction score
1,141
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
try
Lua:
local combat = createCombatObject()
local removeTime = 1.5 --time to remove the clones

function onTargetTile(cid, position)
    local creature = doCreateMonster("headcaptor", position, true)
    if isCreature(creature) then
        doCreatureAddMana(cid, -2000)
        doConvinceCreature(cid, creature)
        doCreatureSay(creature, "Utevo Mort", TALKTYPE_ORANGE_1)
        addEvent(function (creature)
            if isCreature(creature) then
                doRemoveCreature(creature)
            end
        end, 1000 * removeTime, creature)
    end
    return true
end

local arr = {
    {1, 0, 1},
    {0, 2, 0},
    {1, 0, 1}
}

setCombatArea(combat, createCombatArea(arr))
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
 
Last edited:
OP
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
182
Solutions
1
Reaction score
24
try
Lua:
local combat = createCombatObject()
local removeTime = 1.5 --time to remove the clones
local summonName = "headcaptor"
local summonSays = "Utevo Mort"

function onTargetTile(cid, position)
    local creature = doCreateMonster(summonName, position, true, false, false)
    if type(creature) == 'number' then
        doCreatureAddMana(cid, -2000)
        doConvinceCreature(cid, creature)
        doCreatureSay(creature, summonSays, TALKTYPE_ORANGE_1)
        addEvent(function (creature)
            if isCreature(creature) then
                doRemoveCreature(creature)
            end
        end, removeTime * 1000, creature)
    end
    return true
end

local arr = {
    {1, 0, 1},
    {0, 2, 0},
    {1, 0, 1}
}

setCombatArea(combat, createCombatArea(arr))
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
1.png

Up

Up

try
Lua:
local combat = createCombatObject()
local removeTime = 1.5 --time to remove the clones

function onTargetTile(cid, position)
    local creature = doCreateMonster("headcaptor", position, true)
    if isCreature(creature) then
        doCreatureAddMana(cid, -2000)
        doConvinceCreature(cid, creature)
        doCreatureSay(creature, "Utevo Mort", TALKTYPE_ORANGE_1)
        addEvent(function (creature)
            if isCreature(creature) then
                doRemoveCreature(creature)
            end
        end, 1000 * removeTime, creature)
    end
    return true
end

local arr = {
    {1, 0, 1},
    {0, 2, 0},
    {1, 0, 1}
}

setCombatArea(combat, createCombatArea(arr))
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
1.png2.png3.png
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,072
Solutions
107
Reaction score
1,141
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
Ready! tested and work!
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 }
}

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("rat", position, false, true)
        if isCreature(creature) then
            doTeleportThing(creature, position)
            doSendMagicEffect(position, CONST_ME_FIREAREA)
            doCreatureAddMana(cid, -2000)
            doConvinceCreature(targetId, creature)
            doCreatureSay(creature, "rat", TALKTYPE_ORANGE_1)
            addEvent(function (creature)
                if isCreature(creature) then
                    doRemoveCreature(creature)
                end
            end, 1000 * removeTime, creature)
        end
    end
    return true
end
 
Last edited:
OP
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
182
Solutions
1
Reaction score
24
Ready! tested and work!
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 }
}

function onCastSpell(cid, var)
    for k, v in pairs(arrs) do
        local position = getCreaturePosition(cid)
        position.x, position.y = position.x + v.x, position.y + v.y
        local creature = doCreateMonster("rat", position)
        if isCreature(creature) then
            doTeleportThing(creature, position)
            doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
            doCreatureAddMana(cid, -2000)
            doConvinceCreature(cid, creature)
            doCreatureSay(creature, "rat", TALKTYPE_ORANGE_1)
            addEvent(function (creature)
                if isCreature(creature) then
                    doRemoveCreature(creature)
                end
            end, 1000 * removeTime, creature)
        end
    end
    return true
end
It is now summoning around the player and not around the attacked creature.

1.png
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,072
Solutions
107
Reaction score
1,141
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
Ready! tested and work!
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 }
}

function onCastSpell(cid, var)
    local targetId = variantToNumber(var)
    if 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("rat", position, false, true)
        if isCreature(creature) then
            doTeleportThing(creature, position)
            doSendMagicEffect(position, CONST_ME_FIREAREA)
            doCreatureAddMana(cid, -2000)
            doConvinceCreature(cid, creature)
            doCreatureSay(creature, "rat", TALKTYPE_ORANGE_1)
            addEvent(function (creature)
                if isCreature(creature) then
                    doRemoveCreature(creature)
                end
            end, 1000 * removeTime, creature)
        end
    end
    return true
end
test again!
 
OP
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
182
Solutions
1
Reaction score
24
@Sarah Wesker @Itutorial If the target moves, the summon is not attacking, does it have something to do with the script?
Post automatically merged:

test again!
not work
Post automatically merged:

Post automatically merged:


work
Post automatically merged:

test again!
local position = getCreaturePosition(variantToNumber(var))
Post automatically merged:

@Sarah Wesker @Itutorial Is it possible to make the summon be a ghost, any player can walk over it?

2.png
 
Last edited:

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,072
Solutions
107
Reaction score
1,141
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
Ready! tested and work!
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 }
}

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("rat", position, false, true)
        if isCreature(creature) then
            doTeleportThing(creature, position)
            doSendMagicEffect(position, CONST_ME_FIREAREA)
            doCreatureAddMana(cid, -2000)
            doConvinceCreature(targetId, creature)
            doCreatureSay(creature, "rat", TALKTYPE_ORANGE_1)
            addEvent(function (creature)
                if isCreature(creature) then
                    doRemoveCreature(creature)
                end
            end, 1000 * removeTime, creature)
        end
    end
    return true
end
Now if it should work, and sorry for so many attempts, I have too much time without knowing about TFS 0.3.6 scripting
 
OP
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
182
Solutions
1
Reaction score
24
Now if it should work, and sorry for so many attempts, I have too much time without knowing about TFS 0.3.6 scripting
you're already helping me a lot, there's nothing to apologize for!


With this script the summon does not attack the target :(
 

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
1,973
Solutions
52
Reaction score
671
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)
            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
Post automatically merged:

@Sarah Wesker @Itutorial Is it possible to make the summon be a ghost, any player can walk over it?
Not without source edits.
 
Solution
OP
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
182
Solutions
1
Reaction score
24
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)
            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
Post automatically merged:


Not without source edits.
Do you have knowledge for?
 
OP
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
182
Solutions
1
Reaction score
24
If the thread is now solved please mark it and create a new one for your request.
3.png
the summon is going up near stairs, is there a way to block it?
Post automatically merged:

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)
            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
Post automatically merged:


Not without source edits.
good
 
Last edited:

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
1,973
Solutions
52
Reaction score
671
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
 
Top