Implement low character expirience level in group with high character.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
Reiner030 2008-10-23 07:19:35 +04:00 committed by VladimirMangos
parent 20951d116e
commit 0d4f770811
3 changed files with 14 additions and 6 deletions

View file

@ -24,6 +24,7 @@
#include "World.h"
#include "ObjectMgr.h"
#include "Group.h"
#include "Formulas.h"
#include "ObjectAccessor.h"
#include "BattleGround.h"
#include "MapManager.h"
@ -783,7 +784,7 @@ void Group::SetTargetIcon(uint8 id, uint64 guid)
BroadcastPacket(&data);
}
void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level)
void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level)
{
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
{
@ -798,6 +799,11 @@ void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_lev
sum_level += member->getLevel();
if(!member_with_max_level || member_with_max_level->getLevel() < member->getLevel())
member_with_max_level = member;
uint32 gray_level = MaNGOS::XP::GetGrayLevel(member->getLevel());
if( victim->getLevel() > gray_level && (!not_gray_member_with_max_level
|| not_gray_member_with_max_level->getLevel() < member->getLevel()))
not_gray_member_with_max_level = member;
}
}

View file

@ -215,7 +215,7 @@ class MANGOS_DLL_SPEC Group
MemberSlotList const& GetMemberSlots() const { return m_memberSlots; }
GroupReference* GetFirstMember() { return m_memberMgr.getFirst(); }
uint32 GetMembersCount() const { return m_memberSlots.size(); }
void GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level);
void GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level);
uint8 GetMemberGroup(uint64 guid) const
{
member_citerator mslot = _getMemberCSlot(guid);

View file

@ -17810,12 +17810,13 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
uint32 count = 0;
uint32 sum_level = 0;
Player* member_with_max_level = NULL;
Player* not_gray_member_with_max_level = NULL;
pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level);
pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level);
if(member_with_max_level)
{
xp = PvP ? 0 : MaNGOS::XP::Gain(member_with_max_level, pVictim);
xp = PvP ? 0 : MaNGOS::XP::Gain(not_gray_member_with_max_level, pVictim);
// skip in check PvP case (for speed, not used)
bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup();
@ -17845,9 +17846,10 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
pGroupGuy->RewardReputation(pVictim,is_dungeon ? 1.0f : rate);
// XP updated only for alive group member
if(pGroupGuy->isAlive())
if(pGroupGuy->isAlive() && not_gray_member_with_max_level &&
pGroupGuy->getLevel() <= not_gray_member_with_max_level->getLevel())
{
uint32 itr_xp = uint32(xp*rate);
uint32 itr_xp = (member_with_max_level == not_gray_member_with_max_level) ? uint32(xp*rate) : uint32((xp*rate/2)+1);
pGroupGuy->GiveXP(itr_xp, pVictim);
if(Pet* pet = pGroupGuy->GetPet())