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

Solved [TFS 1.0] Walkthrough Low Level Players

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,318
Solutions
35
Reaction score
435
Hello OTland Community,

I'm trying to make it so players that are within the protection level can be walked through.

I did some research and copied part of a code from somewhere else and this is what I tried:

Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if (group->access || creature->isInGhostMode()) {
        return true;
    }
   
    const Player* player = creature->getPlayer();
                    if (
                        player->getVocation()->isAttackable() &&
                        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL)
                    ) {
        return true;
    }
   
    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Tile* playerTile = player->getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        Item* playerTileGround = playerTile->ground;
        if (playerTileGround && playerTileGround->hasWalkStack()) {
            Player* thisPlayer = const_cast<Player*>(this);
            if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return false;
            }

            if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
            }

            thisPlayer->setLastWalkthroughPosition(creature->getPosition());
            return true;
        }
    }

    return false;
}


However, I got these errors:
Code:
/home/otsmanager/forgottenserver/src/player.cpp: In member function 'bool Player::canWalkthrough(const Creature*) const':
/home/otsmanager/forgottenserver/src/player.cpp:964:30: error: 'class Vocation' has no member named 'isAttackable'
/home/otsmanager/forgottenserver/src/player.cpp:970:16: error: redeclaration of 'const Player* player'
/home/otsmanager/forgottenserver/src/player.cpp:962:16: error: 'const Player* player' previously declared here
 
can i ask one question ?
what is your point of making walkThrow low level?
i think TFS 1.0 has walkThrow PROTECTION_ZONE
so why do u need low level?

Hello OTland Community,

I'm trying to make it so players that are within the protection level can be walked through.

I did some research and copied part of a code from somewhere else and this is what I tried:

Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if (group->access || creature->isInGhostMode()) {
        return true;
    }
  
    const Player* player = creature->getPlayer();
                    if (
                        player->getVocation()->isAttackable() &&
                        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL)
                    ) {
        return true;
    }
  
    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Tile* playerTile = player->getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        Item* playerTileGround = playerTile->ground;
        if (playerTileGround && playerTileGround->hasWalkStack()) {
            Player* thisPlayer = const_cast<Player*>(this);
            if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return false;
            }

            if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
            }

            thisPlayer->setLastWalkthroughPosition(creature->getPosition());
            return true;
        }
    }

    return false;
}


However, I got these errors:
Code:
/home/otsmanager/forgottenserver/src/player.cpp: In member function 'bool Player::canWalkthrough(const Creature*) const':
/home/otsmanager/forgottenserver/src/player.cpp:964:30: error: 'class Vocation' has no member named 'isAttackable'
/home/otsmanager/forgottenserver/src/player.cpp:970:16: error: redeclaration of 'const Player* player'
/home/otsmanager/forgottenserver/src/player.cpp:962:16: error: 'const Player* player' previously declared here


i think i did it :)
but idk. if i'm true

btw u got this error because u use wrong functions

change this with your canWalkThrough Functions
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if (group->access || creature->isInGhostMode()) {
        return true;
    }

    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }
   
    if ((player->isAttackable() &&
    (player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))))
    return true;

    const Tile* playerTile = player->getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        Item* playerTileGround = playerTile->ground;
        if (playerTileGround && playerTileGround->hasWalkStack()) {
            Player* thisPlayer = const_cast<Player*>(this);
            if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return false;
            }

            if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
            }

            thisPlayer->setLastWalkthroughPosition(creature->getPosition());
            return true;
        }
    }

    return false;
}

i added this to be a correct function
Code:
    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }
   
    if ((player->isAttackable() &&
    (player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))))
    return true;

it should work cuz it works for me

btw here are 3 pics
my protection level in config.lua is 80 :)

ofc. when u are in pz and u are higher than protection level
u can go throw players but after 2 time of walkThrough
first time u got not possible -> second u can go walk

but with mine edit u can walk without get this possible message :p and from the first time

both characters are level 8 in pz




if this what u need tell me :p
 
Last edited by a moderator:
Thanks i'll try it out.

I wanted it walkthrough Low Levels also because in PvP people were using level 8's to block trap and since you can't kill them there was nothing you could do. I removed the PvP protection level but i think it'd be better if i made them walkthrough-able and keep the PvP protection level.

Thanks for the fix, i'll test it and let you know.. I'm sure if you works for you guys it will work for me also!
 
oh u need it in pvp zone too?
this in protection zone
anyway i will try to fix source to include pvp zone and normal area !!

you don't explain what do you want from the first

so if u need in pvp area players can walkthrough low levels i can do it :p
 
No i mean like regular non pz zone, Like the streets of thais for example.

Anywhere on the map if the player is lower than level 80 then other players should be able to walk through him, except depot tiles ofc xD!
 
FIRST
be happy @Mark , :p i fucked your TFS up <3

now player can walkthough low levels in normal area
i'm joking?

so you can watch it in teamviewer meeting
m15-824-190


when u get approve guys i will paste the code here

here you are brother <3
just replace all function
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if (group->access || creature->isInGhostMode()) {
        return true;
    }

    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }
    if ((player->isAttackable() &&
    (player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))))
    return true;
   
    const Tile* playerTile = player->getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        Item* playerTileGround = playerTile->ground;
        if (playerTileGround && playerTileGround->hasWalkStack()) {
            Player* thisPlayer = const_cast<Player*>(this);
            if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return true;
            }

            if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
            }

            thisPlayer->setLastWalkthroughPosition(creature->getPosition());
            return true;
        }
    }

    return false;
}

bool Player::canWalkthroughEx(const Creature* creature) const
{
    if (group->access) {
        return true;
    }

    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Tile* playerTile = player->getTile();
    if ((!player->isAttackable() &&
        (player->getLevel() > (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))))
        return true;
    return playerTile && playerTile->hasFlag(TILESTATE_NONE);
}
 
Last edited by a moderator:
Hmm.. seems tricky guys, now low levels can walk over anyone in the DP.
So if you showcase something on your DP, a low level can walk right through you and steal the item.
 
here you are brother <3
just replace all function
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if (group->access || creature->isInGhostMode()) {
        return true;
    }

    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }
    if ((player->isAttackable() &&
    (player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))))
    return true;
  
    const Tile* playerTile = player->getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        Item* playerTileGround = playerTile->ground;
        if (playerTileGround && playerTileGround->hasWalkStack()) {
            Player* thisPlayer = const_cast<Player*>(this);
            if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return true;
            }

            if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
            }

            thisPlayer->setLastWalkthroughPosition(creature->getPosition());
            return true;
        }
    }

    return false;
}

bool Player::canWalkthroughEx(const Creature* creature) const
{
    if (group->access) {
        return true;
    }

    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Tile* playerTile = player->getTile();
    if ((!player->isAttackable() &&
        (player->getLevel() > (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))))
        return true;
    return playerTile && playerTile->hasFlag(TILESTATE_NONE);
}

When i try put this code in my scripts get this error:
Code:
1>------ Build started: Project: theforgottenserver, Configuration: Release x64 ------
1>  player.cpp
1>..\src\player.cpp(712): error C2248: 'Tile::ground': cannot access protected member declared in class 'Tile'
1>  c:\users\vowe\desktop\otxserver-otxserv3\otxserver-otxserv3\path_8_6\src\tile.h(295): note: see declaration of 'Tile::ground'
1>  c:\users\vowe\desktop\otxserver-otxserv3\otxserver-otxserv3\path_8_6\src\protocolgame.h(33): note: see declaration of 'Tile'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
When i try put this code in my scripts get this error:
Code:
1>------ Build started: Project: theforgottenserver, Configuration: Release x64 ------
1>  player.cpp
1>..\src\player.cpp(712): error C2248: 'Tile::ground': cannot access protected member declared in class 'Tile'
1>  c:\users\vowe\desktop\otxserver-otxserv3\otxserver-otxserv3\path_8_6\src\tile.h(295): note: see declaration of 'Tile::ground'
1>  c:\users\vowe\desktop\otxserver-otxserv3\otxserver-otxserv3\path_8_6\src\protocolgame.h(33): note: see declaration of 'Tile'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

this not for otx it's 1.0
well give me otx source i will fix it for u
 


I will test, bro i try send a private message for you, i need a fix in my sources, a bug causes crash in my ot, can send me a private message? i can pay for this.


No bro don't work, also stopped walkthough in pz area :/


Bro now its work but only with elf bot and "dashing" im liked but the players can walkthough in the sqm of depot and can thief them xD a solution? @Mark
 
Last edited by a moderator:
Back
Top