[7559] Implement function Player::RewardPlayerAndGroupAtEvent for reward (quest objective only) player and group at special kill-like events. Author: Ramses_II

Use it for Spell::EffectKillCredit and some dummy code.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-28 16:26:31 -06:00
parent ce8462ccf9
commit 1299521d50
3 changed files with 28 additions and 2 deletions
+25
View File
@@ -19277,6 +19277,31 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
return xp || honored_kill; return xp || honored_kill;
} }
void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource)
{
uint64 creature_guid = pRewardSource->GetTypeId()==TYPEID_UNIT ? pRewardSource->GetGUID() : uint64(0);
// prepare data for near group iteration
if(Group *pGroup = GetGroup())
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pGroupGuy = itr->getSource();
if(!pGroupGuy)
continue;
if(!pGroupGuy->IsAtGroupRewardDistance(pRewardSource))
continue; // member (alive or dead) or his corpse at req. distance
// quest objectives updated only for alive group member or dead but with not released body
if(pGroupGuy->isAlive()|| !pGroupGuy->GetCorpse())
pGroupGuy->KilledMonster(creature_id, creature_guid);
}
}
else // if (!pGroup)
KilledMonster(creature_id, creature_guid);
}
bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const
{ {
if(pRewardSource->GetDistance(this) <= sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE)) if(pRewardSource->GetDistance(this) <= sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE))
+1
View File
@@ -1675,6 +1675,7 @@ class TRINITY_DLL_SPEC Player : public Unit
bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const; bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
bool RewardPlayerAndGroupAtKill(Unit* pVictim); bool RewardPlayerAndGroupAtKill(Unit* pVictim);
void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
bool isHonorOrXPTarget(Unit* pVictim); bool isHonorOrXPTarget(Unit* pVictim);
ReputationMgr& GetReputationMgr() { return m_reputationMgr; } ReputationMgr& GetReputationMgr() { return m_reputationMgr; }
+2 -2
View File
@@ -1183,7 +1183,7 @@ void Spell::EffectDummy(uint32 i)
return; return;
pCreature->SetHealth(health); pCreature->SetHealth(health);
((Player*)m_caster)->KilledMonster(16992,pCreature->GetGUID()); ((Player*)m_caster)->RewardPlayerAndGroupAtEvent(16992,pCreature);
if (pCreature->IsAIEnabled) if (pCreature->IsAIEnabled)
pCreature->AI()->AttackStart(m_caster); pCreature->AI()->AttackStart(m_caster);
@@ -6357,7 +6357,7 @@ void Spell::EffectKillCredit(uint32 i)
if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return; return;
((Player*)unitTarget)->KilledMonster(m_spellInfo->EffectMiscValue[i], 0); ((Player*)unitTarget)->RewardPlayerAndGroupAtEvent(m_spellInfo->EffectMiscValue[i], unitTarget);
} }
void Spell::EffectQuestFail(uint32 i) void Spell::EffectQuestFail(uint32 i)