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

C++ Guild Wars -- check

alcapone

Member
Joined
Jan 13, 2021
Messages
247
Reaction score
19
Lua:
GuildEmblems_t Player::getGuildEmblem(const Player* player) const
{
    if (!player) {
        return GUILDEMBLEM_NONE;
    }

    const Guild* playerGuild = player->getGuild();
    if (!playerGuild) {
        return GUILDEMBLEM_NONE;
    }

    if (player->getGuildWarVector().empty()) {
        if (guild == playerGuild) {
            return GUILDEMBLEM_MEMBER;
        } else {
            return GUILDEMBLEM_OTHER;
        }
    } else if (guild == playerGuild) {
        return GUILDEMBLEM_ALLY;
    } else if (isInWar(player)) {
        return GUILDEMBLEM_ENEMY;
    }

    return GUILDEMBLEM_NEUTRAL;
}



is there any way to check if the player is with GUILDEMBLEM it is possible to attack even if it is a nopvp server





Lua:
        const Tile* playerTile = target->getTile();
        if (g_game.getWorldType() == WORLD_TYPE_NO_PVP &&  (not playerTile->hasFlag(TILESTATE_PVPZONE)) ) {
           if (attacker->getPlayer() || (attackerMaster && attackerMaster->getPlayer())) {
                if (target->getPlayer()) {
                if (!isInPvpZone(attacker, target)) {
                        return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER;
                    }
                }

                if (target->isSummon() && target->getMaster()->getPlayer()) {
                   if (!isInPvpZone(attacker, target)) {
                   return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE;
                   }
                }
          }
    }
 
Last edited:
Solution
I'm no expert on TFS source or C++, but I assume the relevant stuff is in Combat::canDoCombat inside combat.cpp

Try throwing in something like...

C++:
if (attackerPlayer->isInWar(targetPlayer))
{
    return g_events->eventCreatureOnTargetCombat(attacker, target);
}

and

C++:
if (masterAttackerPlayer->isInWar(targetPlayer))
{
    return g_events->eventCreatureOnTargetCombat(attacker, target);
}

into the relevant sections (below line 351 and 366 respectively).

That should bypass the part about "Is server NO PVP?", and should act on the same logic as the guild emblem display.
No idea tho if there isn't more combat logic checks in other places. But this might at least be a start.
Lua:
GuildEmblems_t Player::getGuildEmblem(const Player* player) const

{

    if (!player) {

        return GUILDEMBLEM_NONE;

    }



    const Guild* playerGuild = player->getGuild();

    if (!playerGuild) {

        return GUILDEMBLEM_NONE;

    }



    if (player->getGuildWarVector().empty()) {

        if (guild == playerGuild) {

            return GUILDEMBLEM_MEMBER;

        } else {

            return GUILDEMBLEM_OTHER;

        }

    } else if (guild == playerGuild) {

        return GUILDEMBLEM_ALLY;

    } else if (isInWar(player)) {

        return GUILDEMBLEM_ENEMY;

    }



    return GUILDEMBLEM_NEUTRAL;

}
 
asking to see if you've tested to make server nonpvp but put a area where it is pvp only to see if players can attack each other, like private city wars, and test there you get me?
I don't want a 'pvp zone'. this is not the subject of the topic

Lua:
const Tile* playerTile = target->getTile();
        if (g_game.getWorldType() == WORLD_TYPE_NO_PVP &&  (not playerTile->hasFlag(TILESTATE_PVPZONE)) ) {
           if (attacker->getPlayer() || (attackerMaster && attackerMaster->getPlayer())) {
                if (target->getPlayer()) {
                if (!isInPvpZone(attacker, target)) {
                        return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER;
                    }
                }

                if (target->isSummon() && target->getMaster()->getPlayer()) {
                   if (!isInPvpZone(attacker, target)) {
                   return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE;
                   }
                }
          }
    }

would have to check this part to ignore if the player was in warmode
 
Last edited:
If youre not finding any solution or no one is replying then you either pay someone, or start finding other solutions like the one i mentioned, gl
you are not obliged to help or keep answering your solution there is nothing that was said in the topic stop changing the topic's focus.
 
I'm no expert on TFS source or C++, but I assume the relevant stuff is in Combat::canDoCombat inside combat.cpp

Try throwing in something like...

C++:
if (attackerPlayer->isInWar(targetPlayer))
{
    return g_events->eventCreatureOnTargetCombat(attacker, target);
}

and

C++:
if (masterAttackerPlayer->isInWar(targetPlayer))
{
    return g_events->eventCreatureOnTargetCombat(attacker, target);
}

into the relevant sections (below line 351 and 366 respectively).

That should bypass the part about "Is server NO PVP?", and should act on the same logic as the guild emblem display.
No idea tho if there isn't more combat logic checks in other places. But this might at least be a start.
 
Solution
Back
Top