• 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 [C++] Player does not get PZ after attacking PK

potinho

Advanced OT User
Joined
Oct 11, 2009
Messages
1,403
Solutions
17
Reaction score
151
Location
Brazil
Good morning everyone, today I realized that my server is behaving (I don't know if expected) but unwanted, let's think about the following scenario:

Player 1 Attacks Player 2 (and takes White Skull)
Player 2 attacks player 1 back and manages to enter a Protection Zone (shouldn't/would't)
After leaving the PZ, player 2 attacks player 1 again and turns Yellow Skull, and now it has PZ lock

I would like Player 2 to have PZ lock on the first attack, could you help me?

C++:
void Player::onTarget(Creature* target)
{
    Creature::onTarget(target);

    if(target == this)
    {
        addInFightTicks(false);
        return;
    }

    if(hasFlag(PlayerFlag_NotGainInFight))
        return;

    Player* targetPlayer = target->getPlayer();
    if(targetPlayer && !isPartner(targetPlayer) && !isAlly(targetPlayer))
    {
        if(!pzLocked && g_game.getWorldType() == WORLDTYPE_HARDCORE)
        {
            pzLocked = true;
            sendIcons();
        }

        if(getSkull() == SKULL_NONE && getSkullType(targetPlayer) == SKULL_YELLOW)
        {
            addAttacked(targetPlayer);
            targetPlayer->sendCreatureSkull(this);
        }
        else if(!targetPlayer->hasAttacked(this))
        {
            if(!pzLocked)
            {
                pzLocked = true;
                sendIcons();
            }

            if(!Combat::isInPvpZone(this, targetPlayer) && !isEnemy(this))
            {
                addAttacked(targetPlayer);

                if(targetPlayer->getSkull() == SKULL_NONE && getSkull() == SKULL_NONE && (!guildId || !targetPlayer->getGuildId()))
                {
                    setSkull(SKULL_WHITE);
                    g_game.updateCreatureSkull(this);
                }

                if(getSkull() == SKULL_NONE)
                    targetPlayer->sendCreatureSkull(this);
            }
        }
    }

    addInFightTicks(false);
}
 
Good morning everyone, today I realized that my server is behaving (I don't know if expected) but unwanted, let's think about the following scenario:

Player 1 Attacks Player 2 (and takes White Skull)
Player 2 attacks player 1 back and manages to enter a Protection Zone (shouldn't/would't)
After leaving the PZ, player 2 attacks player 1 again and turns Yellow Skull, and now it has PZ lock

I would like Player 2 to have PZ lock on the first attack, could you help me?

C++:
void Player::onTarget(Creature* target)
{
    Creature::onTarget(target);

    if(target == this)
    {
        addInFightTicks(false);
        return;
    }

    if(hasFlag(PlayerFlag_NotGainInFight))
        return;

    Player* targetPlayer = target->getPlayer();
    if(targetPlayer && !isPartner(targetPlayer) && !isAlly(targetPlayer))
    {
        if(!pzLocked && g_game.getWorldType() == WORLDTYPE_HARDCORE)
        {
            pzLocked = true;
            sendIcons();
        }

        if(getSkull() == SKULL_NONE && getSkullType(targetPlayer) == SKULL_YELLOW)
        {
            addAttacked(targetPlayer);
            targetPlayer->sendCreatureSkull(this);
        }
        else if(!targetPlayer->hasAttacked(this))
        {
            if(!pzLocked)
            {
                pzLocked = true;
                sendIcons();
            }

            if(!Combat::isInPvpZone(this, targetPlayer) && !isEnemy(this))
            {
                addAttacked(targetPlayer);

                if(targetPlayer->getSkull() == SKULL_NONE && getSkull() == SKULL_NONE && (!guildId || !targetPlayer->getGuildId()))
                {
                    setSkull(SKULL_WHITE);
                    g_game.updateCreatureSkull(this);
                }

                if(getSkull() == SKULL_NONE)
                    targetPlayer->sendCreatureSkull(this);
            }
        }
    }

    addInFightTicks(false);
}
 
I've had already fixed Yellow skull gone problem, my problem is just when fight back, its not getting pz lock.
 
I've had already fixed Yellow skull gone problem, my problem is just when fight back, its not getting pz lock.
ok, there's 2 places in that code that u can change in order to achieve that..
first option, dont check world type, and always add pzlock if anyone attack another

C++:
// FROM
        if(!pzLocked && g_game.getWorldType() == WORLDTYPE_HARDCORE)
        {
            pzLocked = true;
            sendIcons();
        }

// TO
        if(!pzLocked)
        {
            pzLocked = true;
            sendIcons();
        }


second option, dont check if player 'hasAttacked' u first, before adding pzlock

C++:
// FROM
        else if(!targetPlayer->hasAttacked(this))
        {
            if(!pzLocked)
            {
                pzLocked = true;
                sendIcons();
            }
            
// TO
            else
        {
            if(!pzLocked)
            {
                pzLocked = true;
                sendIcons();
            }
 
ok, there's 2 places in that code that u can change in order to achieve that..
first option, dont check world type, and always add pzlock if anyone attack another

C++:
// FROM
        if(!pzLocked && g_game.getWorldType() == WORLDTYPE_HARDCORE)
        {
            pzLocked = true;
            sendIcons();
        }

// TO
        if(!pzLocked)
        {
            pzLocked = true;
            sendIcons();
        }


second option, dont check if player 'hasAttacked' u first, before adding pzlock

C++:
// FROM
        else if(!targetPlayer->hasAttacked(this))
        {
            if(!pzLocked)
            {
                pzLocked = true;
                sendIcons();
            }
           
// TO
            else
        {
            if(!pzLocked)
            {
                pzLocked = true;
                sendIcons();
            }
Used second choice, works! Thanks!!!
 
Back
Top