• 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++ Skull System 0.3.7

MaR0

Banned User
Joined
Apr 16, 2018
Messages
272
Solutions
3
Reaction score
29
Hello OTland, in my tfs sources I wanted to prepare my server to war server then i had the idea of removing skulls from sources but when i removed it didn't work as desired and then decided to ask for help here :) here is my player.cpp //////////////////////////////////////////////////////////////////////// // Ope - Pastebin.com (https://pastebin.com/5SDXS3Nd) file i just wanted in the worldType = "open" if you kill someone you don't take any skulls also need to remove red skul warning and address the occurrence of losing the backpack also items, I found some threads like those Feature - Every changes you need to a Hardcore/War Server (https://otland.net/threads/every-changes-you-need-to-a-hardcore-war-server.132897/) Solved - Skullsystem Skull Dissapears (https://otland.net/threads/skullsystem-skull-dissapears.233997/)
but I was not lucky because they were not the same version.
cheers
Thanks
 
Hello OTland, in my tfs sources I wanted to prepare my server to war server then i had the idea of removing skulls from sources but when i removed it didn't work as desired and then decided to ask for help here :) here is my player.cpp //////////////////////////////////////////////////////////////////////// // Ope - Pastebin.com (https://pastebin.com/5SDXS3Nd) file i just wanted in the worldType = "open" if you kill someone you don't take any skulls also need to remove red skul warning and address the occurrence of losing the backpack also items, I found some threads like those Feature - Every changes you need to a Hardcore/War Server (https://otland.net/threads/every-changes-you-need-to-a-hardcore-war-server.132897/) Solved - Skullsystem Skull Dissapears (https://otland.net/threads/skullsystem-skull-dissapears.233997/)
but I was not lucky because they were not the same version.
cheers
Thanks
I did a search in the sources of 0.3.7 (it's actually the one I've been using for 0.4 scripts so that tells you how much the sources are the same) and it came back with 6 entries for setskull 2 being in player.

1 here
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();
}

And the 2nd one here
C++:
void Player::onTarget(Creature* target)
{
    Creature::onTarget(target);
    if(hasFlag(PlayerFlag_NotGainInFight))
        return;

    addInFightTicks(false);
    Player* targetPlayer = target->getPlayer();
    if(!targetPlayer)
        return;

    addAttacked(targetPlayer);
    if(Combat::isInPvpZone(this, targetPlayer) || isPartner(targetPlayer) || isAlly(targetPlayer)
        || (g_config.getBool(ConfigManager::ALLOW_FIGHTBACK) && targetPlayer->hasAttacked(this)
        && !targetPlayer->isEnemy(this, false)))
        return;

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

    if(getZone() != target->getZone() || skull != SKULL_NONE || targetPlayer->isEnemy(this, true)
        || g_game.getWorldType() != WORLDTYPE_OPEN)
        return;

    if(target->getSkull() != SKULL_NONE || targetPlayer->hasAttacked(this))
        targetPlayer->sendCreatureSkull(this);
    else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
    {
        setSkull(SKULL_WHITE);
        g_game.updateCreatureSkull(this);
    }
}

If I were looking to test code to remove certain functionality this is how I would start simply by commenting out the calls to specific functions such as setSkull in this method onTarget
C++:
    else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
    {
        // this applies the white skull as obvious as it is
        // setSkull(SKULL_WHITE);
        // this function seems to be more visual than functional
        // g_game.updateCreatureSkull(this);
    }

It's important when suppressing certain characteristics of the game that we comment things out instead of outright deleting them because the sources are enormous and we can easily forget what we removed. This code that is commented out or comments for that matter are ignored by the compile so including them in your code does not increase the file size of the executable and makes it easier to trouble-shoot issues down the road when things stop working as they should.
 
I did a search in the sources of 0.3.7 (it's actually the one I've been using for 0.4 scripts so that tells you how much the sources are the same) and it came back with 6 entries for setskull 2 being in player.

1 here
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();
}

And the 2nd one here
C++:
void Player::onTarget(Creature* target)
{
    Creature::onTarget(target);
    if(hasFlag(PlayerFlag_NotGainInFight))
        return;

    addInFightTicks(false);
    Player* targetPlayer = target->getPlayer();
    if(!targetPlayer)
        return;

    addAttacked(targetPlayer);
    if(Combat::isInPvpZone(this, targetPlayer) || isPartner(targetPlayer) || isAlly(targetPlayer)
        || (g_config.getBool(ConfigManager::ALLOW_FIGHTBACK) && targetPlayer->hasAttacked(this)
        && !targetPlayer->isEnemy(this, false)))
        return;

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

    if(getZone() != target->getZone() || skull != SKULL_NONE || targetPlayer->isEnemy(this, true)
        || g_game.getWorldType() != WORLDTYPE_OPEN)
        return;

    if(target->getSkull() != SKULL_NONE || targetPlayer->hasAttacked(this))
        targetPlayer->sendCreatureSkull(this);
    else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
    {
        setSkull(SKULL_WHITE);
        g_game.updateCreatureSkull(this);
    }
}

If I were looking to test code to remove certain functionality this is how I would start simply by commenting out the calls to specific functions such as setSkull in this method onTarget
C++:
    else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
    {
        // this applies the white skull as obvious as it is
        // setSkull(SKULL_WHITE);
        // this function seems to be more visual than functional
        // g_game.updateCreatureSkull(this);
    }

It's important when suppressing certain characteristics of the game that we comment things out instead of outright deleting them because the sources are enormous and we can easily forget what we removed. This code that is commented out or comments for that matter are ignored by the compile so including them in your code does not increase the file size of the executable and makes it easier to trouble-shoot issues down the road when things stop working as they should.
by the way Ok that's good as you said i got some 2 errors in compiling from 2nd code after copying your code and committing it like this
C++:
void Player::onTarget(Creature* target)
{
    Creature::onTarget(target);
    if(hasFlag(PlayerFlag_NotGainInFight))
        return;

    addInFightTicks(false);
    Player* targetPlayer = target->getPlayer();
    if(!targetPlayer)
        return;

    addAttacked(targetPlayer);
    if(Combat::isInPvpZone(this, targetPlayer) || isPartner(targetPlayer) || isAlly(targetPlayer)
        || (g_config.getBool(ConfigManager::ALLOW_FIGHTBACK) && targetPlayer->hasAttacked(this)
        && !targetPlayer->isEnemy(this, false)))
        return;

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

    if(getZone() != target->getZone() || skull != SKULL_NONE || targetPlayer->isEnemy(this, true)
        || g_game.getWorldType() != WORLDTYPE_OPEN)
        return;

    if(target->getSkull() != SKULL_NONE || targetPlayer->hasAttacked(this))
        targetPlayer->sendCreatureSkull(this);
      else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
    {
        // this applies the white skull as obvious as it is
        // setSkull(SKULL_WHITE);
        // this function seems to be more visual than functional
        // g_game.updateCreatureSkull(this);
    }
}
i got this error on compiling
Code:
1>player.cpp
1>..\player.cpp(3933): error C2039: 'ALLOW_FIGHTBACK': is not a member of 'ConfigManager'
1>c:\users\mar0\desktop\path_8_1x\sources\configmanager.h(23): note: see declaration of 'ConfigManager'
1>..\player.cpp(3933): error C2065: 'ALLOW_FIGHTBACK': undeclared identifier
1>..\player.cpp(3934): error C2660: 'Player::isEnemy': function does not take 2 arguments
1>..\player.cpp(3943): error C2660: 'Player::isEnemy': function does not take 2 arguments
1>Done building project "The Forgotten Server.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
Last edited:
by the way Ok that's good as you said i got some 2 errors in compiling from 2nd code after copying your code and committing it like this
C++:
void Player::onTarget(Creature* target)
{
    Creature::onTarget(target);
    if(hasFlag(PlayerFlag_NotGainInFight))
        return;

    addInFightTicks(false);
    Player* targetPlayer = target->getPlayer();
    if(!targetPlayer)
        return;

    addAttacked(targetPlayer);
    if(Combat::isInPvpZone(this, targetPlayer) || isPartner(targetPlayer) || isAlly(targetPlayer)
        || (g_config.getBool(ConfigManager::ALLOW_FIGHTBACK) && targetPlayer->hasAttacked(this)
        && !targetPlayer->isEnemy(this, false)))
        return;

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

    if(getZone() != target->getZone() || skull != SKULL_NONE || targetPlayer->isEnemy(this, true)
        || g_game.getWorldType() != WORLDTYPE_OPEN)
        return;

    if(target->getSkull() != SKULL_NONE || targetPlayer->hasAttacked(this))
        targetPlayer->sendCreatureSkull(this);
      else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
    {
        // this applies the white skull as obvious as it is
        // setSkull(SKULL_WHITE);
        // this function seems to be more visual than functional
        // g_game.updateCreatureSkull(this);
    }
}
i got this error on compiling
Code:
1>------ Build started: Project: TheOTXServer, Configuration: Release x64 ------
1>player.cpp
1>..\player.cpp(3933): error C2039: 'ALLOW_FIGHTBACK': is not a member of 'ConfigManager'
1>c:\users\mar0\desktop\path_8_1x\sources\configmanager.h(23): note: see declaration of 'ConfigManager'
1>..\player.cpp(3933): error C2065: 'ALLOW_FIGHTBACK': undeclared identifier
1>..\player.cpp(3934): error C2660: 'Player::isEnemy': function does not take 2 arguments
1>..\player.cpp(3943): error C2660: 'Player::isEnemy': function does not take 2 arguments
1>Done building project "TheOTXServer.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Those errors aren't from commenting out the code.
 
now this code works well when i killed someone i don't get a skulls anymore
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(targetPlayer))
            {
                addAttacked(targetPlayer);

                  if(target->getSkull() != SKULL_NONE || targetPlayer->hasAttacked(this))
        targetPlayer->sendCreatureSkull(this);
      else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
       {
        // this applies the white skull as obvious as it is
        // setSkull(SKULL_WHITE);
        // this function seems to be more visual than functional
        // g_game.updateCreatureSkull(this);
    }
}
        }
    }

    addInFightTicks(false);
}
i've some little problem when i lose the condition fight after killing someone the frag goes gone, also the same idea if i logged out and logged in again i lose it how to stop it from losing?
edit:- using this script
XML:
<event type="kill" name="kill_skulls" event="script" value="kill_skulls.lua"/>
Lua:
local storage = 4321
function onKill(cid, target)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(target)) then
        setPlayerStorageValue(cid, storage, frags+1)
        if(frags < 10) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags < 20) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags < 30) then
            doCreatureSetSkullType(cid, SKULL_RED)
        elseif(frags > 39) then
            doCreatureSetSkullType(cid, SKULL_BLACK)
        end
    end
    return true
end
in my login
Lua:
setPlayerStorageValue(cid, 4321, 0)
 
Back
Top