• 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 1.X+ How can I use spells/exiva without using " tfs 1.2

abdala ragab

Veteran OT User
Joined
Aug 18, 2018
Messages
461
Solutions
11
Reaction score
340
Location
gamelaot.sytes.net
On some servers only use:
Lua:
exiva Name
exani hur up
exani hur down
and it works.

In my server i need to use "
Code:
exiva "Name
exani hur "up
exani hur "down
If i dont use ", the exiva dont works, the same like exani hur "up and exani hur "down.

how can I get rid of not having to use "??
i think its in source code
thank you In advance
 
On some servers only use:
Lua:
exiva Name
exani hur up
exani hur down
and it works.

In my server i need to use "
Code:
exiva "Name
exani hur "up
exani hur "down
If i dont use ", the exiva dont works, the same like exani hur "up and exani hur "down.

how can I get rid of not having to use "??
i think its in source code
thank you In advance
that is modified in spells.xml, or in the levitate.lua file
 
This is from the source and I think the file is spells.cpp
hmm, I thought in 1.2 they moved that to lua :/

in spells.cpp look for this:

Code:
namespace {

bool Levitate(const InstantSpell*, Creature* creature, const std::string& param)
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Position& currentPos = creature->getPosition();
    const Position& destPos = Spells::getCasterPosition(creature, creature->getDirection());

    ReturnValue ret = RETURNVALUE_NOTPOSSIBLE;

    if (strcasecmp(param.c_str(), "up") == 0) {
        if (currentPos.z != 8) {
            Tile* tmpTile = g_game.map.getTile(currentPos.x, currentPos.y, currentPos.getZ() - 1);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID))) {
                tmpTile = g_game.map.getTile(destPos.x, destPos.y, destPos.getZ() - 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID | TILESTATE_FLOORCHANGE)) {
                    ret = g_game.internalMoveCreature(*player, *tmpTile, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE);
                }
            }
        }
    } else if (strcasecmp(param.c_str(), "down") == 0) {
        if (currentPos.z != 7) {
            Tile* tmpTile = g_game.map.getTile(destPos);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID))) {
                tmpTile = g_game.map.getTile(destPos.x, destPos.y, destPos.z + 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID | TILESTATE_FLOORCHANGE)) {
                    ret = g_game.internalMoveCreature(*player, *tmpTile, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE);
                }
            }
        }
    }

    if (ret != RETURNVALUE_NOERROR) {
        player->sendCancelMessage(ret);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        return false;
    }

    g_game.addMagicEffect(player->getPosition(), CONST_ME_TELEPORT);
    return true;
}

}

replace with this

Code:
namespace {

bool Levitate(const InstantSpell*, Creature* creature, const std::string& param)
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }
    const Position& currentPos = creature->getPosition();
    const Position& destPos = Spells::getCasterPosition(creature, creature->getDirection());
    
    ReturnValue ret = RETURNVALUE_NOTPOSSIBLE;
    std::istringstream iss(param);
    std::string direction;
    iss >> direction;
    
    if (strcasecmp(direction.c_str(), "up") == 0) {
        if (currentPos.z != 8) {
            Tile* tmpTile = g_game.map.getTile(currentPos.x, currentPos.y, currentPos.getZ() - 1);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID))) {
                tmpTile = g_game.map.getTile(destPos.x, destPos.y, destPos.getZ() - 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID | TILESTATE_FLOORCHANGE)) {
                    ret = g_game.internalMoveCreature(*player, *tmpTile, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE);
                }
            }
        }
    } else if (strcasecmp(direction.c_str(), "down") == 0) {
        if (currentPos.z != 7) {
            Tile* tmpTile = g_game.map.getTile(destPos);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID))) {
                tmpTile = g_game.map.getTile(destPos.x, destPos.y, destPos.z + 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID | TILESTATE_FLOORCHANGE)) {
                    ret = g_game.internalMoveCreature(*player, *tmpTile, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE);
                }
            }
        }
    }
    if (ret != RETURNVALUE_NOERROR) {
        player->sendCancelMessage(ret);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        return false;
    }
    g_game.addMagicEffect(player->getPosition(), CONST_ME_TELEPORT);
    return true;
}

}
 
try to see

Lua:
bool InstantSpell::Levitate(const InstantSpell*, Creature* creature, const std::string& param)
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Position& currentPos = creature->getPosition();
    const Position& destPos = Spells::getCasterPosition(creature, creature->getDirection());

    ReturnValue ret = RETURNVALUE_NOTPOSSIBLE;
    
    std::istringstream iss(param);
    std::string direction;
    iss >> direction;

    if (strcasecmp(direction.c_str(), "up") == 0) {
        if (currentPos.z != 8) {
            Tile* tmpTile = g_game.map.getTile(currentPos.x, currentPos.y, currentPos.getZ() - 1);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID))) {
                tmpTile = g_game.map.getTile(destPos.x, destPos.y, destPos.getZ() - 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID | TILESTATE_FLOORCHANGE)) {
                    ret = g_game.internalMoveCreature(*player, *tmpTile, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE);
                }
            }
        }
    } else if (strcasecmp(direction.c_str(), "down") == 0) {
        if (currentPos.z != 7) {
            Tile* tmpTile = g_game.map.getTile(destPos);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID))) {
                tmpTile = g_game.map.getTile(destPos.x, destPos.y, destPos.z + 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID | TILESTATE_FLOORCHANGE)) {
                    ret = g_game.internalMoveCreature(*player, *tmpTile, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE);
                }
            }
        }
    }

    if (ret != RETURNVALUE_NOERROR) {
        player->sendCancelMessage(ret);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        return false;
    }

    g_game.addMagicEffect(player->getPosition(), CONST_ME_TELEPORT);
    return true;
}
 
try to see

Lua:
bool InstantSpell::Levitate(const InstantSpell*, Creature* creature, const std::string& param)
{
    Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Position& currentPos = creature->getPosition();
    const Position& destPos = Spells::getCasterPosition(creature, creature->getDirection());

    ReturnValue ret = RETURNVALUE_NOTPOSSIBLE;
   
    std::istringstream iss(param);
    std::string direction;
    iss >> direction;

    if (strcasecmp(direction.c_str(), "up") == 0) {
        if (currentPos.z != 8) {
            Tile* tmpTile = g_game.map.getTile(currentPos.x, currentPos.y, currentPos.getZ() - 1);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID))) {
                tmpTile = g_game.map.getTile(destPos.x, destPos.y, destPos.getZ() - 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID | TILESTATE_FLOORCHANGE)) {
                    ret = g_game.internalMoveCreature(*player, *tmpTile, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE);
                }
            }
        }
    } else if (strcasecmp(direction.c_str(), "down") == 0) {
        if (currentPos.z != 7) {
            Tile* tmpTile = g_game.map.getTile(destPos);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID))) {
                tmpTile = g_game.map.getTile(destPos.x, destPos.y, destPos.z + 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID | TILESTATE_FLOORCHANGE)) {
                    ret = g_game.internalMoveCreature(*player, *tmpTile, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE);
                }
            }
        }
    }

    if (ret != RETURNVALUE_NOERROR) {
        player->sendCancelMessage(ret);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        return false;
    }

    g_game.addMagicEffect(player->getPosition(), CONST_ME_TELEPORT);
    return true;
}
try to see
i add this code
and have same problem
 
If the issue is not resolved above, please try here.

tested on tfs 1.2 by celehore OK
levitate.lua
Lua:
local function levitate(creature, parameter)
    local fromPosition = creature:getPosition()
    parameter = parameter:trim():lower()

    if (parameter == "up" and fromPosition.z ~= 8) or (parameter == "down" and fromPosition.z ~= 7) then
        local toPosition = fromPosition:getNextPosition(creature:getDirection())

        local tile
        if parameter == "up" then
            tile = Tile(Position(fromPosition.x, fromPosition.y, fromPosition.z - 1))
        else
            tile = Tile(toPosition)
        end

        if tile and tile:isWalkable() then
            local newPos = tile:getPosition()
            creature:teleportTo(newPos, true)
            fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return RETURNVALUE_NOERROR
        end
    end

    return RETURNVALUE_NOTPOSSIBLE
end

function onCastSpell(creature, variant)
    local returnValue = levitate(creature, variant:getString())
    if returnValue ~= RETURNVALUE_NOERROR then
        creature:sendCancelMessage(returnValue)
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    return true
end


spells.xml
to change:
function="Levitate">
per:
script="support/levitate.lua">
 
Last edited:
Hey, did you test the script in LUA that I sent? I actually used the base and tested it and it works perfectly without any changes to the font!!
yeah and i got this error
Lua:
Lua Script Error: [Spell Interface]
data/spells/scripts/support/levitate.lua:onCastSpell
data/spells/scripts/support/levitate.lua:15: attempt to call method 'isWalkable' (a nil value)
stack traceback:
        [C]: in function 'isWalkable'
        data/spells/scripts/support/levitate.lua:15: in function 'levitate'
        data/spells/scripts/support/levitate.lua:27: in function <data/spells/scripts/support/levitate.lua:26>
Account Manager has logged in.
 
yeah and i got this error
Lua:
Lua Script Error: [Spell Interface]
data/spells/scripts/support/levitate.lua:onCastSpell
data/spells/scripts/support/levitate.lua:15: attempt to call method 'isWalkable' (a nil value)
stack traceback:
        [C]: in function 'isWalkable'
        data/spells/scripts/support/levitate.lua:15: in function 'levitate'
        data/spells/scripts/support/levitate.lua:27: in function <data/spells/scripts/support/levitate.lua:26>
Account Manager has logged in.
any errors post it, you are missing that
you can add it in data/lib/core/tile.lua
Lua:
function Tile.isWalkable(self)
    local ground = self:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = self:getItems()
    for i = 1, self:getItemCount() do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end
 
If I'm not mistaken, your lib are out of date. Try downloading just lib and pasting them on your server to test. It's the same thing I did with this TFS 1.2 8.0 base. The guy took the Celehore base and modified it a lot.
I tried that and it didn't work either
I hope to find a better C++ solution
 
Back
Top