• 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.0 shared exp.

musk1

New Member
Joined
Dec 31, 2014
Messages
6
Reaction score
0
Hi! I 'm trying to change shared exp. For example : If you solo kill cyclops, you will gain 150 exp. If you kill cyclops in pt independently of members in party , also you will gain 150 exp.


In party cpp ( 399 )i have :
Code:
void Party::shareExperience(uint64_t experience)
{
    uint32_t shareExperience = (uint64_t)std::ceil((((double)experience
    for (Player* member : memberList) {
        member->onGainSharedExperience(shareExperience);
    }
    leader->onGainSharedExperience(shareExperience);
}


It doesnt work.
Please help me ! :p
 
Code:
void Party::shareExperience(uint64_t experience)
{
    uint32_t shareExperience = (uint64_t)std::ceil((((double)experience / (memberList.size() + 1)) + ((double)experience * 1.10)));
    for (Player* member : memberList) {
        member->onGainSharedExperience(shareExperience);
    }
    leader->onGainSharedExperience(shareExperience);
}

You can change de rate in : experience * 1.10 <
 
Cyc = 150 exp
experience * 1.10

5 player in party, how many exp, each player will receive?

Code:
void Party::shareExperience(uint64_t experience)
{
    uint32_t shareExperience = (uint64_t)std::ceil((((double)experience / (memberList.size() + 1)) + ((double)experience * 1.10)));
    for (Player* member : memberList) {
        member->onGainSharedExperience(shareExperience);
    }
    leader->onGainSharedExperience(shareExperience);
}
 
Hi! I 'm trying to change shared exp. For example : If you solo kill cyclops, you will gain 150 exp. If you kill cyclops in pt independently of members in party , also you will gain 150 exp.


In party cpp ( 399 )i have :
Code:
void Party::shareExperience(uint64_t experience)
{
    uint32_t shareExperience = (uint64_t)std::ceil((((double)experience
    for (Player* member : memberList) {
        member->onGainSharedExperience(shareExperience);
    }
    leader->onGainSharedExperience(shareExperience);
}


It doesnt work.
Please help me ! :p
All those ((( mean something they are used to execute code in a specific order so that it overrides the default order of operations, if you don't have a closing parentheses then of course it isn't going to compile.

Lets break the code apart and see what it does.

Code:
static_cast<uint64_t>(std::ceil(( (static_cast<double>(experience) / (memberList.size() + 1)) + (static_cast<double>(experience) * extraExpRate) )));
1. Experience is casted from integer to double example if experience was 100 now its 100.0
2. memberList.size whatever that equals add 1 to it
3. Convert experience to double, see example above then multiply it by the current experience rate
4. Using the order of operations (think back to the days of math class) division comes before addition, so divide the sum of memberList.size() + 1 into experience and then add the experience times extraexprate then take the total and round it up so if the answer is 1.5 the answer will be 2 then cast that number to a 64 bit integer which will trunicate any number after the decimal place.

Which will give you the experience per player..

If you just want to give everyone the same experience

Change this
Code:
uint32_t shareExperience = static_cast<uint64_t>(std::ceil(((static_cast<double>(experience) / (memberList.size() + 1)) + (static_cast<double>(experience) * extraExpRate))));
to this
Code:
uint32_t shareExperience = static_cast<uint64_t>( std::ceil( static_cast<double>(experience) * extraExpRate ) );
 
Last edited:
All those ((( mean something they are used to execute code in a specific order so that it overrides the default order of operations, if you don't have a closing parentheses then of course it isn't going to compile.

Lets break the code apart and see what it does.

Code:
static_cast<uint64_t>(std::ceil(( (static_cast<double>(experience) / (memberList.size() + 1)) + (static_cast<double>(experience) * extraExpRate) )));
1. Experience is casted from integer to double example if experience was 100 now its 100.0
2. memberList.size whatever that equals add 1 to it
3. Convert experience to double, see example above then multiply it by the current experience rate
4. Using the order of operations (think back to the days of math class) division comes before addition, so divide the sum of memberList.size() + 1 into experience and then add the experience times extraexprate then take the total and round it up so if the answer is 1.5 the answer will be 2 then cast that number to a 64 bit integer which will trunicate any number after the decimal place.

Which will give you the experience per player..

If you just want to give everyone the same experience

Change this
Code:
uint32_t shareExperience = static_cast<uint64_t>(std::ceil(((static_cast<double>(experience) / (memberList.size() + 1)) + (static_cast<double>(experience) * extraExpRate))));
to this
Code:
uint32_t shareExperience = static_cast<uint64_t>( std::ceil( static_cast<double>(experience) * extraExpRate ) );
Bro, don't work, when have more players in party the exp increment :/
 
Do you have an onKill or onDeath event? If you do you need to check the damage map to see if only one person did all of the damage (if that is what you mean) and award them the additional experience.
 
Back
Top