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

TFS 1.X+ getLostPercent

CastorFlynn

Member
Joined
Aug 29, 2021
Messages
88
Reaction score
8
Would it be possible to include a check in the source so that, if the player has a storage 12345 = 1 he receives a reduction in the loss percentage, as it already happens if he has promotion and bless?

C++:
double Player::getLostPercent() const
{
    int32_t blessingCount = std::bitset<5>(blessings).count();
    double lossPercent;
    if (level >= 25) {
        double tmpLevel = level + (levelPercent / 100.);
        lossPercent = static_cast<double>((tmpLevel + 50) * 50 * ((tmpLevel * tmpLevel) - (5 * tmpLevel) + 8)) / experience;
    } else {
        lossPercent = 10;
    }


    double percentReduction = g_config.getNumber(ConfigManager::DEATH_LOSE_PERCENT_REDUCTION);
    if (isPromoted()) {
        percentReduction += 30;
    }
    percentReduction += blessingCount * 8;


    return lossPercent * (1 - (percentReduction / 100.)) / 100.;
}
 
Would it be possible to include a check in the source so that, if the player has a storage 12345 = 1 he receives a reduction in the loss percentage, as it already happens if he has promotion and bless?

C++:
double Player::getLostPercent() const
{
    int32_t blessingCount = std::bitset<5>(blessings).count();
    double lossPercent;
    if (level >= 25) {
        double tmpLevel = level + (levelPercent / 100.);
        lossPercent = static_cast<double>((tmpLevel + 50) * 50 * ((tmpLevel * tmpLevel) - (5 * tmpLevel) + 8)) / experience;
    } else {
        lossPercent = 10;
    }


    double percentReduction = g_config.getNumber(ConfigManager::DEATH_LOSE_PERCENT_REDUCTION);
    if (isPromoted()) {
        percentReduction += 30;
    }
    percentReduction += blessingCount * 8;


    return lossPercent * (1 - (percentReduction / 100.)) / 100.;
}
C++:
double Player::getLostPercent() const
{
    int32_t blessingCount = std::bitset<5>(blessings).count();
    double lossPercent;
    if (level >= 25) {
        double tmpLevel = level + (levelPercent / 100.);
        lossPercent = static_cast<double>((tmpLevel + 50) * 50 * ((tmpLevel * tmpLevel) - (5 * tmpLevel) + 8)) / experience;
    } else {
        lossPercent = 10;
    }


    double percentReduction = g_config.getNumber(ConfigManager::DEATH_LOSE_PERCENT_REDUCTION);
    if (isPromoted()) {
        percentReduction += 30;
    }
    percentReduction += blessingCount * 8;

    // extra reduction
    int32_t storageValue;
    if (getStorageValue(12345, storageValue)) {
      if (storageValue == 1) {
        percentReduction += 30; // 30%
      }
    }

    percentReduction = std::min<double>(percentReduction,100); // max reduction = 100%
    return lossPercent * (1 - (percentReduction / 100.)) / 100.;
}
 
C++:
double Player::getLostPercent() const
{
    int32_t blessingCount = std::bitset<5>(blessings).count();
    double lossPercent;
    if (level >= 25) {
        double tmpLevel = level + (levelPercent / 100.);
        lossPercent = static_cast<double>((tmpLevel + 50) * 50 * ((tmpLevel * tmpLevel) - (5 * tmpLevel) + 8)) / experience;
    } else {
        lossPercent = 10;
    }


    double percentReduction = g_config.getNumber(ConfigManager::DEATH_LOSE_PERCENT_REDUCTION);
    if (isPromoted()) {
        percentReduction += 30;
    }
    percentReduction += blessingCount * 8;

    // extra reduction
    int32_t storageValue;
    if (getStorageValue(12345, storageValue)) {
      if (storageValue == 1) {
        percentReduction += 30; // 30%
      }
    }

    percentReduction = std::min<double>(percentReduction,100); // max reduction = 100%
    return lossPercent * (1 - (percentReduction / 100.)) / 100.;
}
This would be used in an arena, so when the player is in the arena he would have the storage set and the reduction, however, when the player dies the arena resets the storage, and in that apparently the src reduction check is occurring after the script resets . Do you have any suggestions in this case?

Or would there be some function to assign direct loss reduction in LUA in a specific script?
 
Last edited:
This would be used in an arena, so when the player is in the arena he would have the storage set and the reduction, however, when the player dies the arena resets the storage, and in that apparently the src reduction check is occurring after the script resets . Do you have any suggestions in this case?

Or would there be some function to assign direct loss reduction in LUA in a specific script?
reset the storage onLogin and not onDeath
 
Back
Top