C++ allowFightBack

Makin

Member
Joined
Sep 17, 2018
Messages
30
Best answers
1
Reaction score
1
Hello, as you can see in the video, my problem

player.cpp
Code:
void Player::onAttackedCreature(Creature* target)
{
    Creature::onAttackedCreature(target);

    if (target->getZone() == ZONE_PVP) {
        return;
    }

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

    if (hasFlag(PlayerFlag_NotGainInFight)) {
        return;
    }

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

        if (getSkull() == SKULL_NONE && hasCondition(CONDITION_INFIGHT) && getSkullClient(targetPlayer) == SKULL_YELLOW) {
            addAttacked(targetPlayer);
            targetPlayer->sendCreatureSkull(this);
        } else if ((!targetPlayer->hasAttacked(this)) || (!g_config.getBoolean(ConfigManager::ALLOW_FIGHT_BACK))) {
            if (!pzLocked) {
                pzLocked = true;
                sendIcons();
            }

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

                if (targetPlayer->getSkull() == SKULL_NONE && getSkull() == SKULL_NONE) {
                    setSkull(SKULL_WHITE);
                }

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

    addInFightTicks();
}
 

Nekiro

Support Team
Support Team
Joined
Sep 7, 2015
Messages
1,898
Best answers
81
Reaction score
682
Incomplete problem description, rule 5 of support board.
You can supply the video as additional helper not as the main describer.
 
OP
Makin

Makin

Member
Joined
Sep 17, 2018
Messages
30
Best answers
1
Reaction score
1
I can't edit the first post, I would ask you to add what I wrote to this post

My problem is that:
is player 'a' and player 'b'

player a attacks player b and player a gets a white skull
player b attacks the a player who has nailed a white skull on players b and player b after attacking the player a gets a yellow skulla

And I don't know if it's my fault that I added it in the wrong place or I have to edit the code to make it work properly
 

ZowN

New Member
Joined
Mar 19, 2015
Messages
27
Best answers
1
Reaction score
9
I don't get it, what's the problem? That is how it's supposed to work? You way of writing is also very messy, I have no idea if player a or player b is getting the yellow skull but in the video it seems player b which is how it should work?
 

Eremes

New Member
Joined
Oct 23, 2019
Messages
7
Best answers
1
Reaction score
1
His problem:
Player A attack Player B
Player B attack Player A for self defense
now Player B has a yellow skull and player A can kill him without getting a frag.
But yes, like @ZowN mentioned, i think this is how it supposed to work with allowFightBack = false, if you don't want this, just change it to allowFightBack = true?
 

ZowN

New Member
Joined
Mar 19, 2015
Messages
27
Best answers
1
Reaction score
9
Yea, that is how tibia works? What's the problem, is that NOT how you want it? Then you have to explain how you want it.
 

Nekiro

Support Team
Support Team
Joined
Sep 7, 2015
Messages
1,898
Best answers
81
Reaction score
682
That's how tibia works, that's intended behaviour.
 
Top