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
any?
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: