mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[9921] In case player who tap creature in group leave group it must anyway rewarded with group.
This commit is contained in:
parent
e5dc7a098c
commit
bed8794a75
5 changed files with 88 additions and 55 deletions
|
|
@ -888,26 +888,44 @@ void Group::SetTargetIcon(uint8 id, uint64 whoGuid, uint64 targetGuid)
|
|||
BroadcastPacket(&data, true);
|
||||
}
|
||||
|
||||
void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level)
|
||||
static void GetDataForXPAtKill_helper(Player* player, Unit const* victim, uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level)
|
||||
{
|
||||
sum_level += player->getLevel();
|
||||
if(!member_with_max_level || member_with_max_level->getLevel() < player->getLevel())
|
||||
member_with_max_level = player;
|
||||
|
||||
uint32 gray_level = MaNGOS::XP::GetGrayLevel(player->getLevel());
|
||||
if( victim->getLevel() > gray_level && (!not_gray_member_with_max_level
|
||||
|| not_gray_member_with_max_level->getLevel() < player->getLevel()))
|
||||
not_gray_member_with_max_level = player;
|
||||
}
|
||||
|
||||
void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level, Player* additional)
|
||||
{
|
||||
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player* member = itr->getSource();
|
||||
if(!member || !member->isAlive()) // only for alive
|
||||
if (!member || !member->isAlive()) // only for alive
|
||||
continue;
|
||||
|
||||
if(!member->IsAtGroupRewardDistance(victim)) // at req. distance
|
||||
// will proccesed later
|
||||
if (member = additional)
|
||||
continue;
|
||||
|
||||
if (!member->IsAtGroupRewardDistance(victim)) // at req. distance
|
||||
continue;
|
||||
|
||||
++count;
|
||||
sum_level += member->getLevel();
|
||||
if(!member_with_max_level || member_with_max_level->getLevel() < member->getLevel())
|
||||
member_with_max_level = member;
|
||||
GetDataForXPAtKill_helper(member,victim,sum_level,member_with_max_level,not_gray_member_with_max_level);
|
||||
}
|
||||
|
||||
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;
|
||||
if (additional)
|
||||
{
|
||||
if (additional->IsAtGroupRewardDistance(victim)) // at req. distance
|
||||
{
|
||||
++count;
|
||||
GetDataForXPAtKill_helper(additional,victim,sum_level,member_with_max_level,not_gray_member_with_max_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1692,11 +1710,51 @@ void Group::_homebindIfInstance(Player *player)
|
|||
}
|
||||
}
|
||||
|
||||
void Group::RewardGroupAtKill(Unit* pVictim)
|
||||
static void RewardGroupAtKill_helper(Player* pGroupGuy, Unit* pVictim, uint32 count, bool PvP, float group_rate, uint32 sum_level, bool is_dungeon, Player* not_gray_member_with_max_level, Player* member_with_max_level, uint32 xp )
|
||||
{
|
||||
// for creature case use tapped group (for avoid use group if not set and use if player switch group after tap
|
||||
//Group* pGroup = pVictim->GetTypeId() == TYPEID_UNIT ? ((Creature*)pVictim)->GetGroupLootRecipient() : GetGroup();
|
||||
// honor can be in PvP and !PvP (racial leader) cases (for alive)
|
||||
if (pGroupGuy->isAlive())
|
||||
pGroupGuy->RewardHonor(pVictim,count);
|
||||
|
||||
// xp and reputation only in !PvP case
|
||||
if(!PvP)
|
||||
{
|
||||
float rate = group_rate * float(pGroupGuy->getLevel()) / sum_level;
|
||||
|
||||
// if is in dungeon then all receive full reputation at kill
|
||||
// rewarded any alive/dead/near_corpse group member
|
||||
pGroupGuy->RewardReputation(pVictim,is_dungeon ? 1.0f : rate);
|
||||
|
||||
// XP updated only for alive group member
|
||||
if(pGroupGuy->isAlive() && not_gray_member_with_max_level &&
|
||||
pGroupGuy->getLevel() <= not_gray_member_with_max_level->getLevel())
|
||||
{
|
||||
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())
|
||||
pet->GivePetXP(itr_xp/2);
|
||||
}
|
||||
|
||||
// quest objectives updated only for alive group member or dead but with not released body
|
||||
if(pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
|
||||
{
|
||||
// normal creature (not pet/etc) can be only in !PvP case
|
||||
if(pVictim->GetTypeId()==TYPEID_UNIT)
|
||||
pGroupGuy->KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetObjectGuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Provide rewards to group members at unit kill
|
||||
*
|
||||
* @param pVictim Killed unit
|
||||
* @param player_tap Player who tap unit if online, it can be group member or can be not if leaved after tap but before kill target
|
||||
*
|
||||
* Rewards received by group members and player_tap
|
||||
*/
|
||||
void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap)
|
||||
{
|
||||
bool PvP = pVictim->isCharmedOwnedByPlayerOrPlayer();
|
||||
|
||||
// prepare data for near group iteration (PvP and !PvP cases)
|
||||
|
|
@ -1707,7 +1765,7 @@ void Group::RewardGroupAtKill(Unit* pVictim)
|
|||
Player* member_with_max_level = NULL;
|
||||
Player* not_gray_member_with_max_level = NULL;
|
||||
|
||||
GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level);
|
||||
GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level,player_tap);
|
||||
|
||||
if(member_with_max_level)
|
||||
{
|
||||
|
|
@ -1725,41 +1783,21 @@ void Group::RewardGroupAtKill(Unit* pVictim)
|
|||
if(!pGroupGuy)
|
||||
continue;
|
||||
|
||||
// will proccessed later
|
||||
if(pGroupGuy==player_tap)
|
||||
continue;
|
||||
|
||||
if(!pGroupGuy->IsAtGroupRewardDistance(pVictim))
|
||||
continue; // member (alive or dead) or his corpse at req. distance
|
||||
|
||||
// honor can be in PvP and !PvP (racial leader) cases (for alive)
|
||||
if (pGroupGuy->isAlive())
|
||||
pGroupGuy->RewardHonor(pVictim,count);
|
||||
RewardGroupAtKill_helper(pGroupGuy, pVictim, count, PvP, group_rate, sum_level, is_dungeon, not_gray_member_with_max_level, member_with_max_level, xp);
|
||||
}
|
||||
|
||||
// xp and reputation only in !PvP case
|
||||
if(!PvP)
|
||||
{
|
||||
float rate = group_rate * float(pGroupGuy->getLevel()) / sum_level;
|
||||
|
||||
// if is in dungeon then all receive full reputation at kill
|
||||
// rewarded any alive/dead/near_corpse group member
|
||||
pGroupGuy->RewardReputation(pVictim,is_dungeon ? 1.0f : rate);
|
||||
|
||||
// XP updated only for alive group member
|
||||
if(pGroupGuy->isAlive() && not_gray_member_with_max_level &&
|
||||
pGroupGuy->getLevel() <= not_gray_member_with_max_level->getLevel())
|
||||
{
|
||||
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())
|
||||
pet->GivePetXP(itr_xp/2);
|
||||
}
|
||||
|
||||
// quest objectives updated only for alive group member or dead but with not released body
|
||||
if(pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
|
||||
{
|
||||
// normal creature (not pet/etc) can be only in !PvP case
|
||||
if(pVictim->GetTypeId()==TYPEID_UNIT)
|
||||
pGroupGuy->KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetObjectGuid());
|
||||
}
|
||||
}
|
||||
if(player_tap)
|
||||
{
|
||||
// member (alive or dead) or his corpse at req. distance
|
||||
if(player_tap->IsAtGroupRewardDistance(pVictim))
|
||||
RewardGroupAtKill_helper(player_tap, pVictim, count, PvP, group_rate, sum_level, is_dungeon, not_gray_member_with_max_level, member_with_max_level, xp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue