• 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 Unfair Fight 8.60 0.4

bezina

New Member
Joined
Nov 11, 2016
Messages
18
Reaction score
3
I miss it on 8.60, it's a really good thing the cipsoft implemented on tibia
Should be wounderfull if someone know how to put it in 0.4 sources for OTs 8.60
I think all servers should use it


How could work?
Code:
if killer lvl is 5x player killed lvl - deathreductionloss = 80%
elseif killer lvl is 3x player killed lvl - deathreductionloss = 70%
elseif killer lvl is 2x player killed lvl - deathreductionloss = 60%
elseif killer lvl is 1.5 player killed lvl - deathreductionloss = 50%
else -  deathreductionloss = 0%
 
Solution
I didn't know cipsoft have this feature...
It's really good to block power abuse, all servers should have it

But i don't like your config, using your config a fight 45 vs 30 have reduction, and 45 vs 30 is a fair combat...
I would change to:

PHP:
if        killerLVL is 5x killedLVL :: deathreductionloss = 80%
else if   killerLVL is 4x killedLVL :: deathreductionloss = 70%
else if   killerLVL is 3x killedLVL :: deathreductionloss = 60%
else if   killerLVL is 2x killedLVL :: deathreductionloss = 50%
else                                :: deathreductionloss = 0%

Anyways i don't know much about C++ to edit 0.4 sources, not much people know
It will be hard to find someone who know

The only one guy that know a lot about it i know is...
I didn't know cipsoft have this feature...
It's really good to block power abuse, all servers should have it

But i don't like your config, using your config a fight 45 vs 30 have reduction, and 45 vs 30 is a fair combat...
I would change to:

PHP:
if        killerLVL is 5x killedLVL :: deathreductionloss = 80%
else if   killerLVL is 4x killedLVL :: deathreductionloss = 70%
else if   killerLVL is 3x killedLVL :: deathreductionloss = 60%
else if   killerLVL is 2x killedLVL :: deathreductionloss = 50%
else                                :: deathreductionloss = 0%

Anyways i don't know much about C++ to edit 0.4 sources, not much people know
It will be hard to find someone who know

The only one guy that know a lot about it i know is @MatheusMkalo
But i don't know if he have time or if he still here on forum
 
Last edited:
I didn't know cipsoft have this feature...
It's really good to block power abuse, all servers should have it

But i don't like your config, using your config a fight 45 vs 30 have reduction, and 45 vs 30 is a fair combat...
I would change to:

PHP:
if        killerLVL is 5x killedLVL :: deathreductionloss = 80%
else if   killerLVL is 4x killedLVL :: deathreductionloss = 70%
else if   killerLVL is 3x killedLVL :: deathreductionloss = 60%
else if   killerLVL is 2x killedLVL :: deathreductionloss = 50%
else                                :: deathreductionloss = 0%

Anyways i don't know much about C++ to edit 0.4 sources, not much people know
It will be hard to find someone who know

The only one guy that know a lot about it i know is @MatheusMkalo
But i don't know if he have time or if he still here on forum
I'm still here on forum.

I miss it on 8.60, it's a really good thing the cipsoft implemented on tibia
Should be wounderfull if someone know how to put it in 0.4 sources for OTs 8.60
I think all servers should use it


How could work?
Code:
if killer lvl is 5x player killed lvl - deathreductionloss = 80%
elseif killer lvl is 3x player killed lvl - deathreductionloss = 70%
elseif killer lvl is 2x player killed lvl - deathreductionloss = 60%
elseif killer lvl is 1.5 player killed lvl - deathreductionloss = 50%
else -  deathreductionloss = 0%
In player.cpp:
Change:
Code:
    if(skillLoss)
    {
        uint64_t lossExperience = getLostExperience();
        removeExperience(lossExperience, false);

To:
Code:
    if(skillLoss)
    {
        uint64_t lossExperience = getLostExperience();
        uint8_t unfairFightReduction = 0;
        Player* lastHitPlayer = g_game.getPlayerByID(lastHitCreature);
        if (lastHitPlayer) {
            double levelPercentage = lastHitPlayer->getLevel() / getLevel();
            if (levelPercentage >= 5) {
                unfairFightReduction = 80;
            } else if (levelPercentage >= 3) {
                unfairFightReduction = 70;
            } else if (levelPercentage >= 2) {
                unfairFightReduction = 60;
            } else if (levelPercentage >= 1.5) {
                unfairFightReduction = 50;
            }
        }
        removeExperience(lossExperience * (1 - (unfairFightReduction / 100.)), false);

This will only affect experience loss, if you wanna affect loss of skills etc you have to do:
Code:
        lossExperience = lossExperience * (1 - (unfairFightReduction / 100.));
        removeExperience(lossExperience, false);

Obs: This is not how unfair fight reduction works in Tibia. Just did it like this because it was asked.
http://tibia.wikia.com/wiki/Death#Unfair_Fight
 
Last edited:
Solution
I'm still here on forum.


In player.cpp:
Change:
Code:
    if(skillLoss)
    {
        uint64_t lossExperience = getLostExperience();
        removeExperience(lossExperience, false);

To:
Code:
    if(skillLoss)
    {
        uint64_t lossExperience = getLostExperience();
        uint8_t unfairFightReduction = 0;
        Player* lastHitPlayer = g_game.getPlayerByID(lastHitCreature);
        if (lastHitPlayer) {
            double levelPercentage = lastHitPlayer->getLevel() / getLevel();
            if (levelPercentage >= 5) {
                unfairFightReduction = 80;
            } else if (levelPercentage >= 3) {
                unfairFightReduction = 70;
            } else if (levelPercentage >= 2) {
                unfairFightReduction = 60;
            } else if (levelPercentage >= 1.5) {
                unfairFightReduction = 50;
            }
        }
        removeExperience(lossExperience * (1 - (unfairFightReduction / 100.)), false);

This will only affect experience loss, if you wanna affect loss of skills etc you have to do:
Code:
        lossExperience = lossExperience * (1 - (unfairFightReduction / 100.));
        removeExperience(lossExperience, false);

Obs: This is not how unfair fight reduction works in Tibia. Just did it like this because it was asked.
http://tibia.wikia.com/wiki/Death#Unfair_Fight

Do you know how to send the message when login after unfair death?
Like: "You die in a unfair fight so your losses are reduced 50%"
 
How to set a storage on 0.4 sources? I never did it...
Didn't know it was possible, its nice =)
Code:
    std::ostringstream os;
    os << static_cast<int>(unfairFightReduction);
    setStorage(1234, os.str());

You might need to include "#include <sstream>" in player.cpp

Or you could use boost::lexical_cast:
Code:
    setStorage(1234, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)));

You have to include "#include <boost/lexical_cast.hpp>" in player.cpp
 
Last edited:
Code:
    std::ostringstream os;
    os << static_cast<int>(unfairFightReduction);
    setStorage(1234, os.str());

You might need to include "#include <sstream>" in player.cpp

Or you could use boost::lexical_cast:
Code:
    setStorage(1234, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)))

You have to include "#include <boost/lexical_cast.hpp>" in player.cpp

Srry my dumb, its to confused too me
To set storage

How to set storage 665,1?

Code:
    if getPlayerStorageValue(cid, 665) == 1 then
       doPlayerSendTextMessage(cid, 1, "You die in a unfair fight so your losses are reduced 80%")
 
Srry my dumb, its to confused too me
To set storage

How to set storage 665,1?

Code:
    if getPlayerStorageValue(cid, 665) == 1 then
       doPlayerSendTextMessage(cid, 1, "You die in a unfair fight so your losses are reduced 80%")
If you want to be able to send the amount that was reduced you need to set the storage to X value not 1.
You should add what I sent you (change 1234 to 665) and the script should look like this:
Code:
   if getPlayerStorageValue(cid, 665) > 0 then
       doPlayerSendTextMessage(cid, 1, "You died in an unfair fight so your losses were reduced by " .. getPlayerStorageValue(cid, 665)  .. "%")
       doPlayerSetStorageValue(cid, 665, -1)
 
If you want to be able to send the amount that was reduced you need to set the storage to X value not 1.
You should add what I sent you (change 1234 to 665) and the script should look like this:
Code:
   if getPlayerStorageValue(cid, 665) > 0 then
       doPlayerSendTextMessage(cid, 1, "You died in an unfair fight so your losses were reduced by " .. getPlayerStorageValue(cid, 665)  .. "%")
       doPlayerSetStorageValue(cid, 665, -1)

Not work bro
Code:
    if(skillLoss)
    {
       // unfair fight
        uint64_t lossExperience = getLostExperience();
        uint8_t unfairFightReduction = 0;
        Player* lastHitPlayer = g_game.getPlayerByID(lastHitCreature);
        if (lastHitPlayer) {
            double levelPercentage = lastHitPlayer->getLevel() / getLevel();
            if (levelPercentage >= 5)
            {
                unfairFightReduction = 80;
            }
            else if (levelPercentage >= 4)
            {
                unfairFightReduction = 70;
            }
            else if (levelPercentage >= 3)
            {
                unfairFightReduction = 60;
            }
            else if (levelPercentage >= 2)
            {
                unfairFightReduction = 50;
            }
        }
        setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)))
        removeExperience(lossExperience * (1 - (unfairFightReduction / 100.)), false);



       double percent = 1. - ((double)(experience - lossExperience) / experience);

       //Magic level loss

Error
Code:
player.cpp: In member function ‘virtual bool Player::onDeath()’:
player.cpp:2311:25: error: ‘lexical_cast’ is not a member of ‘boost’
         setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)))
                         ^
player.cpp:2311:56: error: expected primary-expression before ‘>’ token
         setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)))
                                                        ^
Makefile:547: recipe for target 'player.o' failed
 
Not work bro
Code:
    if(skillLoss)
    {
       // unfair fight
        uint64_t lossExperience = getLostExperience();
        uint8_t unfairFightReduction = 0;
        Player* lastHitPlayer = g_game.getPlayerByID(lastHitCreature);
        if (lastHitPlayer) {
            double levelPercentage = lastHitPlayer->getLevel() / getLevel();
            if (levelPercentage >= 5)
            {
                unfairFightReduction = 80;
            }
            else if (levelPercentage >= 4)
            {
                unfairFightReduction = 70;
            }
            else if (levelPercentage >= 3)
            {
                unfairFightReduction = 60;
            }
            else if (levelPercentage >= 2)
            {
                unfairFightReduction = 50;
            }
        }
        setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)))
        removeExperience(lossExperience * (1 - (unfairFightReduction / 100.)), false);



       double percent = 1. - ((double)(experience - lossExperience) / experience);

       //Magic level loss

Error
Code:
player.cpp: In member function ‘virtual bool Player::onDeath()’:
player.cpp:2311:25: error: ‘lexical_cast’ is not a member of ‘boost’
         setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)))
                         ^
player.cpp:2311:56: error: expected primary-expression before ‘>’ token
         setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)))
                                                        ^
Makefile:547: recipe for target 'player.o' failed
"You have to include "#include <boost/lexical_cast.hpp>" in player.cpp"
 
"You have to include "#include <boost/lexical_cast.hpp>" in player.cpp"

My fall, srry

But now:
Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
                                                                                                                                                              ^
player.cpp: In member function ‘virtual bool Player::onDeath()’:
player.cpp:2313:9: error: expected ‘;’ before ‘removeExperience’
         removeExperience(lossExperience * (1 - (unfairFightReduction / 100.)),
         ^
mv -f .deps/protocol.Tpo .deps/protocol.Po
 
My fall, srry

But now:
Code:
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
                                                                                                                                                              ^
player.cpp: In member function ‘virtual bool Player::onDeath()’:
player.cpp:2313:9: error: expected ‘;’ before ‘removeExperience’
         removeExperience(lossExperience * (1 - (unfairFightReduction / 100.)),
         ^
mv -f .deps/protocol.Tpo .deps/protocol.Po
Code:
        setStorage(665, boost::lexical_cast<std::string>(static_cast<int>(unfairFightReduction)));

The ; in the end.
 
Back
Top