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

Compiling Exp Party by Members in Party

  • Thread starter Thread starter Deleted member 141899
  • Start date Start date
D

Deleted member 141899

Guest
Hello friends,

I trying to change this function bellow, to share exp accept only number of members in the party instead of ids vocations [tfs 1.1]

In Party.cpp:
Code:
void Party::updateVocationsList()
{
    std::set<uint32_t> vocationIds;

    uint32_t vocationId = leader->getVocation()->getFromVocation();
    if (vocationId != VOCATION_NONE) {
        vocationIds.insert(vocationId);
    }

    for (const Player* member : memberList) {
        vocationId = member->getVocation()->getFromVocation();
        if (vocationId != VOCATION_NONE) {
            vocationIds.insert(vocationId);
        }
    }

    size_t size = vocationIds.size();
    if (size > 1) {
        extraExpRate = static_cast<float>(size * (10 + (size - 1) * 5)) / 100.f;
    } else {
        extraExpRate = 0.20f;
    }
}

I tried change
Code:
size_t size = vocationIds.size();
to
Code:
size_t size = memberList.size();
but not works.. Can someone help me? thanks very much.
 
Try this
Code:
void Party::updateVocationsList()
{
    std::set<uint32_t> vocationIds;

    uint32_t vocationId = leader->getVocation()->getFromVocation();
    if (vocationId != VOCATION_NONE) {
        vocationIds.insert(vocationId);
    }
    size_t size = 1; // don't exclude the leader
    for (const Player* member : memberList) {
        vocationId = member->getVocation()->getFromVocation();
        if (vocationId != VOCATION_NONE) {
            ++size; // now account for all the other members
            //vocationIds.insert(vocationId);
        }
    }

    //size_t size = vocationIds.size();
    if (size > 1) {
        extraExpRate = static_cast<float>(size * (10 + (size - 1) * 5)) / 100.f;
    } else {
        extraExpRate = 0.20f;
    }
}

If size_t is a constant then use a different datatype or create a new local variable with a different datatype.
 
Last edited:
I tried and are giving diferent exp if vocations is same..
If have 2 knights sharing exp, are giving different exp.. but this code was not meant to work only counting the members in party?

Look my code:
Code:
void Party::updateVocationsList()
{
  std::set<uint32_t> vocationIds;
  uint32_t vocationId = leader->getVocation()->getFromVocation();
  if (vocationId != VOCATION_NONE) {
  vocationIds.insert(vocationId);
  }
  size_t size = 1; // don't exclude the leader
  for (const Player* member : memberList) {
  vocationId = member->getVocation()->getFromVocation();
  if (vocationId != VOCATION_NONE) {
  ++size; // now account for all the other members
  //vocationIds.insert(vocationId);
  }
  }
  //size_t size = vocationIds.size();
  if (size == 2) {
  extraExpRate = 1.0f + 0.80;
  }
  if (size == 3) {
  extraExpRate = 1.0f + 1.60;
  }
  if (size == 4) {
  extraExpRate = 1.0f + 2.40;
  }
  if (size == 5) {
  extraExpRate = 1.0f + 3.10;
  }
  if (size == 6) {
  extraExpRate = 1.0f + 3.65;
  }
  if (size == 7) {
  extraExpRate = 1.0f + 4.00;
  }
  if (size == 8) {
  extraExpRate = 1.0f + 4.30;
  }
  if (size == 9) {
  extraExpRate = 1.0f + 4.50;
  }
  if (size > 9) {
  extraExpRate = 1.0f + 5.00;
  }
}
 
I am having a hard time understanding what you want to do exactly, do you want everyone in the group to get more experience than if they were hunting alone?

Like say a demon gives idk 8k exp but if your grouped everyone in the group gets the 8k equally plus a bonus amount of experience depending on the amount of players in group?
 
@Codex NG look, the pattern of global and original code is to give 30% bonus if you have 2 different vocations, 60% bonus if you have 3 vocations, and 100% bonus if you have 4 vocations.

I want to break the code, put give an extra bonus based on the amount of members in the party instead of diverse vocations understand?

If you look at the code I did, I was increasing the bonus in accordance with the increase of members in the party because as exp divided by the number of members, it would be nice to go increasing the bonus to the exp not reduce both.

Example:

Code:
if (size == 2) {
  extraExpRate = 1.0f + 0.80;   (monster gives 2000 exp, if share with 2 peoples, then 2000 / 2 + 80% = 1800 exp)
  }
  if (size == 3) {
  extraExpRate = 1.0f + 1.60;  (monster gives 2000 exp, if share with 3 peoples, then 2000 / 3 + 160% = 1733~ exp)
  }
  if (size == 4) {
  extraExpRate = 1.0f + 2.40;  (monster gives 2000 exp, if share with 4 peoples, then 2000 / 4 + 240% = 1700~ exp)
 
Well than we are looking in the wrong place :p
Since extraExpRate it's multiplier reduces the experience given if grouped
 
The memberList size is the amount of members minus one, since the leader does not count. You have to use +1 if you want to get the member count.

I would go for the following (notice it's another function):
Code:
void Party::shareExperience(uint64_t experience, Creature* source/* = nullptr*/)
{
    double extra = extraExpRate + (FACTOR * std::max(9, memberList.size() + 1));
    uint32_t shareExperience = static_cast<uint64_t>(std::ceil(((static_cast<double>(experience) / (memberList.size() + 1)) + (static_cast<double>(experience) * extra))));
    for (Player* member : memberList) {
        member->onGainSharedExperience(shareExperience, source);
    }
    leader->onGainSharedExperience(shareExperience, source);
}
Replace FACTOR by the amount of extra experience you want to give by player count.

(And use a formula, for god's sake, don't do that if/else hell)
 
Back
Top