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

Compiling TFS 1.1 PVP_ZONE Question

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,317
Solutions
35
Reaction score
434
Hello,

I changed a part of the source to allow players to kill players below the protection level as long as they were standing on a PVP_ZONE tile:

Original:
Code:
bool Combat::isProtected(const Player* attacker, const Player* target)
{
    uint32_t protectionLevel = g_config.getNumber(ConfigManager::PROTECTION_LEVEL);
    if (target->getLevel() < protectionLevel || attacker->getLevel() < protectionLevel) {
        return true;
    }

    if (attacker->getVocationId() == VOCATION_NONE || target->getVocationId() == VOCATION_NONE) {
        return true;
    }

    if (attacker->getSkull() == SKULL_BLACK && attacker->getSkullClient(target) == SKULL_NONE) {
        return true;
    }

    return false;
}

Changed:
Code:
bool Combat::isProtected(const Player* attacker, const Player* target)
{
    uint32_t protectionLevel = g_config.getNumber(ConfigManager::PROTECTION_LEVEL);
    if ((target->getZone() != ZONE_PVP || attacker->getZone() != ZONE_PVP) && (target->getLevel() < protectionLevel || attacker->getLevel() < protectionLevel)) {
        return true;
    }

    if (attacker->getVocationId() == VOCATION_NONE || target->getVocationId() == VOCATION_NONE) {
        return true;
    }

    if (attacker->getSkull() == SKULL_BLACK && attacker->getSkullClient(target) == SKULL_NONE) {
        return true;
    }

    return false;
}

It seems to be working fine but I'm new to making source changes. Is what I did safe? Or is their a better way to do/write it?
 
Back
Top