• 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.4] Walkthrough other players

secondlife

Member
Joined
Aug 1, 2009
Messages
298
Reaction score
23
Hi guys!!

I was trying to make in the sources (0.4) a system that could allow players with a vocation >8 to pass through players with a vocation <=8.
However, without success.

This is my part of the sources that checks this:
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

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

    if((((g_game.getWorldType() == WORLDTYPE_OPTIONAL && !player->isEnemy(this, true) &&
        player->getVocation()->isAttackable()) || player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) || (player->getVocation()->isAttackable() &&
        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))) && player->getTile()->ground &&
        Item::items[player->getTile()->ground->getID()].walkStack) && (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
        || player->getAccess() <= getAccess()))
        return true;

    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());
}

Can someone with more experience try to help me?

Is there any way to do this through the sources? Or even with .lua, maybe.

Many thanks!
 
Test it
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

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

    if((((g_game.getWorldType() == WORLDTYPE_OPTIONAL && !player->isEnemy(this, true) &&
        player->getVocation()->isAttackable()) || player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) || (player->getVocation()->isAttackable() &&
        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))) && (getVocationId() > 8 && player->getVocationId() <= 8) && player->getTile()->ground &&
        Item::items[player->getTile()->ground->getID()].walkStack) && (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
        || player->getAccess() <= getAccess()))
        return true;

    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());

}
 
Test it
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

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

    if((((g_game.getWorldType() == WORLDTYPE_OPTIONAL && !player->isEnemy(this, true) &&
        player->getVocation()->isAttackable()) || player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) || (player->getVocation()->isAttackable() &&
        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))) && (getVocationId() > 8 && player->getVocationId() <= 8) && player->getTile()->ground &&
        Item::items[player->getTile()->ground->getID()].walkStack) && (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
        || player->getAccess() <= getAccess()))
        return true;

    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());

}
Hello @Acubens. First of all, thanks for your reply. I tested the modification you have sent. It successfully compiled, but it didn't work. Players with a vocation >8 are still unable to walkthrough players with a vocation <= 8.

Just a detail i forgot to warn, I would like players with a vocation >8 to be able to walkthrough players with a vocation <= 8 in any situation, regardless of whether it is a protection zone or not.
 
Lets test again

C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

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

    // Player current vocation and creature vocation who player want pass, if it correctly then it should work
    if(getVocationId() > 8 && player->getVocationId() <= 8)
        return true;


    if((((g_game.getWorldType() == WORLDTYPE_OPTIONAL && !player->isEnemy(this, true) &&
        player->getVocation()->isAttackable()) || player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) || (player->getVocation()->isAttackable() &&
        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))) && player->getTile()->ground &&
        Item::items[player->getTile()->ground->getID()].walkStack) && (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
        || player->getAccess() <= getAccess()))
        return true;

    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());
}
 
worked perfectly @Acubens.

Is it possible to add only the walkstack attribute check so that the system does not ignore? Because now players with a vocation >8 can enter players with a vocation <8 on the tile next to the depot chest, which have the attribute walkstack = 0.
 
Test
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

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

    if(getVocationId() > 8 && player->getVocationId() <= 8 || (player->getTile()->ground && Item::items[player->getTile()->ground->getID()].walkStack) || player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges) || player->getAccess() <= getAccess())
    {
        return true;
    }
    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());
}
 
Back
Top