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

Solved [1.0] Alterting Player::getLostPercent()

Status
Not open for further replies.

Red

Cyntara.org
Staff member
Global Moderator
Premium User
Joined
Aug 9, 2008
Messages
4,455
Solutions
2
Reaction score
921
Location
United States
Hi guys, I'm back. :eek:

I'm looking to alter Player::getLostPercent(). Here's what I have so far ([Edit - Red] for my changes.)
Code:
double Player::getLostPercent() const
{
   std::bitset<5> bitset(blessings);

   const int32_t deathLosePercent = g_config.getNumber(ConfigManager::DEATH_LOSE_PERCENT);
   if (deathLosePercent != -1) {
     int32_t lossPercent = deathLosePercent;

     if (isPromoted()) {
       lossPercent -= 3;
     }

     lossPercent -= (int32_t)bitset.count();
     return std::max<int32_t>(0, lossPercent) / (double)100;
   } else {
     double lossPercent;

     if (level >= 25) {
       double tmpLevel = level + (levelPercent / 100.);
       lossPercent = (double)((tmpLevel + 50) * 50 * ((tmpLevel * tmpLevel) - (5 * tmpLevel) + 8)) / experience;
     } else {
       lossPercent = 10;
     }
/* [Edit - Red]

     if (isPromoted()) {
       lossPercent *= 0.7;
     }
*/

/* [Red - End] */
     return lossPercent * pow(0.92, (int32_t)bitset.count()) / 100;
   }
}

I've commented out the altering of lossPercent if the player is promoted. Instead, I'd like a piece of code that manipulates lossPercent depending on the player's level.

The plaintext formula I wrote is:
Code:
1 / (level + 159) * 112

I've written a debugging code in Lua to be able to print the newly desired death penalty. My code in Lua looks like this (multiplied then floor'd then divided to round to the thousandths place):
Code:
lossPercent = lossPercent * (math.floor(((1 / (level + 159)) * 112) * 1000) / 1000)

With this information, I'm asking if anybody would be able to help me translate that formula into the source code so players actually lose experience based on my formula, as I'm unfamiliar and do not understand C++ syntax well enough to do it myself.

I appreciate the time, even for reading this :D
Red
 
Which server / revision is that?

It's TFS 1.0 (revision 1331; I don't think anything has changed since then.)
The third code is a piece of theory Lua code I wrote (since I'm unable to express what I want in the source.)

Red
 
Replace the isPromoted() block with:
Code:
        lossPercent *= std::floor(112000 / (level + 159.)) / 1000;
 
  • Like
Reactions: Red
Status
Not open for further replies.
Back
Top Bottom