Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace NPartyExpDistribute
- {
- struct FPartyTotaler
- {
- int total;
- int member_count;
- int x, y;
- FPartyTotaler(LPCHARACTER center)
- : total(0), member_count(0), x(center->GetX()), y(center->GetY())
- {};
- void operator () (LPCHARACTER ch)
- {
- if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
- {
- if (LC_IsYMIR())
- total += ch->GetLevel();
- else
- total += party_exp_distribute_table[ch->GetLevel()];
- ++member_count;
- }
- }
- };
- struct FPartyDistributor
- {
- int total;
- LPCHARACTER c;
- int x, y;
- DWORD _iExp;
- int m_iMode;
- int m_iMemberCount;
- FPartyDistributor(LPCHARACTER center, int member_count, int total, DWORD iExp, int iMode)
- : total(total), c(center), x(center->GetX()), y(center->GetY()), _iExp(iExp), m_iMode(iMode), m_iMemberCount(member_count)
- {
- if (m_iMemberCount == 0)
- m_iMemberCount = 1;
- };
- void operator () (LPCHARACTER ch)
- {
- if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
- {
- DWORD iExp2 = 0;
- switch (m_iMode)
- {
- case PARTY_EXP_DISTRIBUTION_NON_PARITY:
- if (LC_IsYMIR())
- iExp2 = (DWORD) ((_iExp * ch->GetLevel()) / total);
- else
- iExp2 = (DWORD) (_iExp * (float) party_exp_distribute_table[ch->GetLevel()] / total);
- break;
- case PARTY_EXP_DISTRIBUTION_PARITY:
- iExp2 = _iExp / m_iMemberCount;
- break;
- default:
- sys_err("Unknown party exp distribution mode %d", m_iMode);
- return;
- }
- GiveExp(c, ch, iExp2);
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement