• 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 White skull time for PVP/PVE

Amiroslo

Excellent OT User
Joined
Jul 28, 2009
Messages
6,767
Solutions
5
Reaction score
769
Hi,
The current issue is when someone has a white skull, it doesn't go away if they're attacked by a monster. I am trying to separate that, so the White skull would still go away after the assigned time even when they're in a fight with a monster. The only time it wont, is if they're in a fight with a player

Is that doable on 0.4? Thank you
 
Hi,
The current issue is when someone has a white skull, it doesn't go away if they're attacked by a monster. I am trying to separate that, so the White skull would still go away after the assigned time even when they're in a fight with a monster. The only time it wont, is if they're in a fight with a player

Is that doable on 0.4? Thank you
I guess it's something from game.cpp/player.cpp issue but you can compare both if you tried to edit those sources before by this one here GitHub - Fir3element/3777: The Forgotten Server 0.4 (rev 3777) with several improvements and bugfixes (https://github.com/Fir3element/3777).
 
Any idea if it was solved somewhere or something? I am already using a diff source
C++:
void Player::onEndCondition(ConditionType_t type)
{
    Creature::onEndCondition(type);
    if(type == CONDITION_INFIGHT)
    {
        onIdleStatus();
        clearAttacked();

        pzLocked = false;
        if(skull < SKULL_RED)
            setSkull(SKULL_NONE);

        g_game.updateCreatureSkull(this);
    }

    sendIcons();
}

thats the code you wanna update.
you need to create new condition
so you have 2
e.g
CONDITION_INFIGHTWITHPLAYER
CONDITION_INFIGHTWITHCREATURE
and also
condition fire etc. will update the infight one
 
I see,
anyone has an idea what and where to change to get it to work by any chance? Ive never worked with C codes so I couldnt get it to work
 
C++:
void Player::onEndCondition(ConditionType_t type)
{
    Creature::onEndCondition(type);
    if(type == CONDITION_INFIGHT)
    {
        onIdleStatus();
        clearAttacked();

        pzLocked = false;
        if(skull < SKULL_RED)
            setSkull(SKULL_NONE);

        g_game.updateCreatureSkull(this);
    }

    sendIcons();
}

thats the code you wanna update.
you need to create new condition
so you have 2
e.g
CONDITION_INFIGHTWITHPLAYER
CONDITION_INFIGHTWITHCREATURE
and also
condition fire etc. will update the infight one
Wouldn't that be do-able if he just made it with the following?
if (this->getTarget()->isPlayer() || this->getTarget()->getTarget()->isPlayer()) {
pzLocked = true;
} else {
pzLocked = false;
}

what i did is simply checking for the skulled player target and the target for the target if any of both are players that would be pz not locked, unless i understand pzLocked incorrectly
 
Wouldn't that be do-able if he just made it with the following?


what i did is simply checking for the skulled player target and the target for the target if any of both are players that would be pz not locked, unless i understand pzLocked incorrectly
Was thinking the same but is that only place where pzlock is true will that not remove skull when attacking monster? But this is onendcondition
 
Was thinking the same but is that only place where pzlock is true will that not remove skull when attacking monster? But this is onendcondition
Ahh i get it now, true makes it locked to lose skull, so in function onAddFightTicks add the check and if monster set pzLocked to false so changing isPlayer from old code to isMonster and doing the following


Lua:
void Player::addInFightTicks(bool pzLock, int32_t ticks/* = 0*/)
{
    if(hasFlag(PlayerFlag_NotGainInFight) || getZone() == ZONE_PROTECTION)
        return;

    if(!ticks)
        ticks = g_config.getNumber(ConfigManager::PZ_LOCKED);
    else
        ticks = std::max(-1, ticks);

    if(pzLock)
        pzLocked = true;
    // If player is attacking or being attacked by a monster (once a player joins the fight ticks will reset)
    if(this->getTarget()->isMonster() || this->getTarget()->getTarget() == this) {
    //target is a monster OR monster is targeting the player
        pzLocked = false; //pz won't be locked to start decaying if the fight between (this) player and monster
    }
   
    if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT,
        CONDITION_INFIGHT, ticks))
        addCondition(condition);
}

any idea?
Tried to abuse the functionality (Logically) probably it is safe since once a player atks the skulledPlayer or vice versa addInFightTicks will override the configuration to adapt to the in-game case
 
Ahh i get it now, true makes it locked to lose skull, so in function onAddFightTicks add the check and if monster set pzLocked to false so changing isPlayer from old code to isMonster and doing the following


Lua:
void Player::addInFightTicks(bool pzLock, int32_t ticks/* = 0*/)
{
    if(hasFlag(PlayerFlag_NotGainInFight) || getZone() == ZONE_PROTECTION)
        return;

    if(!ticks)
        ticks = g_config.getNumber(ConfigManager::PZ_LOCKED);
    else
        ticks = std::max(-1, ticks);

    if(pzLock)
        pzLocked = true;
    // If player is attacking or being attacked by a monster (once a player joins the fight ticks will reset)
    if(this->getTarget()->isMonster() || this->getTarget()->getTarget() == this) {
    //target is a monster OR monster is targeting the player
        pzLocked = false; //pz won't be locked to start decaying if the fight between (this) player and monster
    }
 
    if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT,
        CONDITION_INFIGHT, ticks))
        addCondition(condition);
}

any idea?
Tried to abuse the functionality (Logically) probably it is safe since once a player atks the skulledPlayer or vice versa addInFightTicks will override the configuration to adapt to the in-game case
Logically player can logout now anytime when fighting monsters no? Let's keep thinking haha
We need to overload skull system and and make it not use pzlocked but its own ticks unless player is attacked which is 1 min in default in config Lua I think
 
Code below has one bug: player will lose skull/pz lock, even if other players hit him. If he stops attacks, skull/pz lock will disappear after PZ_LOCK time.
It would require few changes to make it pass pzLock = true, when player gets attacked by other player or attacks other player. Now only killing other player or dealing damage to other player will extend pzLock time.

We need new condition:
CONDITION_INFIGHT_PVP
It should not be saveable in database, as its not possible to logout with PZ lock and server restart (force logout) should remove PZ lock.
C++:
void Player::addInFightTicks(bool pzLock, int32_t ticks/* = 0*/)
{
    if(hasFlag(PlayerFlag_NotGainInFight) || getZone() == ZONE_PROTECTION)
        return;

    if(!ticks)
        ticks = g_config.getNumber(ConfigManager::PZ_LOCKED);
    else
        ticks = std::max(-1, ticks);

    if(pzLock) {
        pzLocked = true;

// if given in-fight ticks are PvP related, extend pzLock time
        if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT_PVP, ticks))
            addCondition(condition);
    }

    if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT, ticks))
        addCondition(condition);
}
and:
C++:
void Player::onEndCondition(ConditionType_t type)
{
    Creature::onEndCondition(type);
    if(type == CONDITION_INFIGHT)
    {
        onIdleStatus();
        clearAttacked();

// CONDITION_INFIGHT time should be longer or equal to CONDITION_INFIGHT_PVP
// so we don't need to remove skull here, just reset attackers and idle status
    }

    if(type == CONDITION_INFIGHT_PVP)
    {
        clearAttacked(); // this resets 'skull system' (yellow for attacking someone who killed you etc.)

        pzLocked = false;
        if(skull < SKULL_RED)
            setSkull(SKULL_NONE);

        g_game.updateCreatureSkull(this);
    }

    sendIcons();
}
 
Code below has one bug: player will lose skull/pz lock, even if other players hit him. If he stops attacks, skull/pz lock will disappear after PZ_LOCK time.
It would require few changes to make it pass pzLock = true, when player gets attacked by other player or attacks other player. Now only killing other player or dealing damage to other player will extend pzLock time.

We need new condition:
CONDITION_INFIGHT_PVP
It should not be saveable in database, as its not possible to logout with PZ lock and server restart (force logout) should remove PZ lock.
C++:
void Player::addInFightTicks(bool pzLock, int32_t ticks/* = 0*/)
{
    if(hasFlag(PlayerFlag_NotGainInFight) || getZone() == ZONE_PROTECTION)
        return;

    if(!ticks)
        ticks = g_config.getNumber(ConfigManager::PZ_LOCKED);
    else
        ticks = std::max(-1, ticks);

    if(pzLock) {
        pzLocked = true;

// if given in-fight ticks are PvP related, extend pzLock time
        if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT_PVP, ticks))
            addCondition(condition);
    }

    if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT, ticks))
        addCondition(condition);
}
and:
C++:
void Player::onEndCondition(ConditionType_t type)
{
    Creature::onEndCondition(type);
    if(type == CONDITION_INFIGHT)
    {
        onIdleStatus();
        clearAttacked();

// CONDITION_INFIGHT time should be longer or equal to CONDITION_INFIGHT_PVP
// so we don't need to remove skull here, just reset attackers and idle status
    }

    if(type == CONDITION_INFIGHT_PVP)
    {
        clearAttacked(); // this resets 'skull system' (yellow for attacking someone who killed you etc.)

        pzLocked = false;
        if(skull < SKULL_RED)
            setSkull(SKULL_NONE);

        g_game.updateCreatureSkull(this);
    }

    sendIcons();
}
and make sure to check for the new condition when entering protection zone tiles.

C++:
if(hasFlag(TILESTATE_PROTECTIONZONE) && player->isPzLocked())
                return RET_PLAYERISPZLOCKED;
 
Last edited:
Anyone who could help me implement this into my sources for a small paid fee? I cant figure it out as my C knowledge is lacking. Thanks in advance
 
Back
Top