• 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 0.4] PARTY SHARED

Izaack

Member
Joined
Jun 18, 2012
Messages
70
Solutions
1
Reaction score
17
Location
México
Hello otland, I have a problem with the party shared I was modifying party.cpp to be able to achieve that if 2 members get 50% experience, for example if a demon gives 9000 exp then if there are two in the party they get 4500 points each and if there are 3 members they get 75%, that is, they would earn 9000*0.75= 6750 points for each member and if there are 4 or more members, they get 100% experience, that is, 9000*1.0= 9000 points per member. I have this code but it only works for 2 members, I don't know what I am doing wrong, I hope you can help me...

party.cpp
C++:
void Party::shareExperience(double experience, Creature* target, bool multiplied)
{
    double shareExperience = experience;
    if (memberList.size() == 2){
    shareExperience += (experience*0.5);}

    if (memberList.size() == 3){
    shareExperience += (experience*0.75);}

    if(memberList.size() >= 4){
    shareExperience += (experience*1.0);}
    
    shareExperience /= memberList.size() + 1;
    double tmpExperience = shareExperience; //we need this, as onGainSharedExperience increases the value
    leader->onGainSharedExperience(tmpExperience, target, multiplied);
    for(PlayerVector::iterator it = memberList.begin(); it != memberList.end(); ++it)
    {
    double shareExperience = experience;
    if (memberList.size() == 2){
     shareExperience += (experience*0.5);}

    if (memberList.size() == 3){
    shareExperience += (experience*0.75);}

    if(memberList.size() >= 4){
        shareExperience += (experience*1.0);}
            shareExperience /= memberList.size() + 1;
            double tmpExperience = shareExperience;
        (*it)->onGainSharedExperience(tmpExperience, target, multiplied);
    }
}
Post automatically merged:

any?
 
Last edited:
C++:
void Party::shareExperience(double experience, Creature* target, bool multiplied)
{
    double shareExperience = experience;
    if(experience >= (double)g_config.getNumber(ConfigManager::EXTRA_PARTY_LIMIT))
        shareExperience += (experience * ((double)g_config.getNumber(ConfigManager::EXTRA_PARTY_PERCENT) / 100));

    shareExperience /= memberList.size() + 1;
    double tmpExperience = shareExperience;

    leader->onGainSharedExperience(tmpExperience, target, multiplied);
    for(PlayerVector::iterator it = memberList.begin(); it != memberList.end(); ++it)
    {
        tmpExperience = shareExperience;
        (*it)->onGainSharedExperience(tmpExperience, target, multiplied);
    }
}


config lua. let me know if u need any more functions from that
extraPartyExperienceLimit = 200
extraPartyExperiencePercent = 25
 
C++:
void Party::shareExperience(double experience, Creature* target, bool multiplied)
{
    double shareExperience = experience;
    if(experience >= (double)g_config.getNumber(ConfigManager::EXTRA_PARTY_LIMIT))
        shareExperience += (experience * ((double)g_config.getNumber(ConfigManager::EXTRA_PARTY_PERCENT) / 100));

    shareExperience /= memberList.size() + 1;
    double tmpExperience = shareExperience;

    leader->onGainSharedExperience(tmpExperience, target, multiplied);
    for(PlayerVector::iterator it = memberList.begin(); it != memberList.end(); ++it)
    {
        tmpExperience = shareExperience;
        (*it)->onGainSharedExperience(tmpExperience, target, multiplied);
    }
}


config lua. let me know if u need any more functions from that
extraPartyExperienceLimit = 200
extraPartyExperiencePercent = 25
Bro, what I want is the exp to increase, not to reduce it the more members there are in the party
example if there are two members in the party then they will gain 50% of the experience of the monster example if a demon gives 9000 exp points if there are two members in the party they will each get 4500 experience points and if there are 3 members in the party then they will get 75% experience example if a demon gives 9000 exp points each one will get 6750 experience points for being 3 members in the party but if there are 4 or more members in the party then they will get 100% experience each 1 of the members of the party that is, they will earn 9000 exp points each.
Post automatically merged:

SOLVED!!
 
Last edited:
Back
Top