mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
[7702] Implement some damage/healing achievement statistics. Author: Trazom
* ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT
* ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED
* ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED
* ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED
* ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED
* ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED
--HG--
branch : trunk
This commit is contained in:
@@ -651,22 +651,35 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||
}
|
||||
}
|
||||
|
||||
if(pVictim->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER)
|
||||
if (GetTypeId() == TYPEID_PLAYER && this != pVictim)
|
||||
{
|
||||
if(((Player*)pVictim)->InBattleGround())
|
||||
Player *killer = ((Player*)this);
|
||||
|
||||
// in bg, count dmg if victim is also a player
|
||||
if (pVictim->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
Player *killer = ((Player*)this);
|
||||
if(killer != ((Player*)pVictim))
|
||||
if(BattleGround *bg = killer->GetBattleGround())
|
||||
bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage);
|
||||
if (BattleGround *bg = killer->GetBattleGround())
|
||||
{
|
||||
// FIXME: kept by compatibility. don't know in BG if the restriction apply.
|
||||
bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage);
|
||||
}
|
||||
}
|
||||
|
||||
killer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT, damage);
|
||||
}
|
||||
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, damage);
|
||||
|
||||
if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->isPet() && !((Creature*)pVictim)->hasLootRecipient())
|
||||
((Creature*)pVictim)->SetLootRecipient(this);
|
||||
if (health <= damage)
|
||||
{
|
||||
DEBUG_LOG("DealDamage: victim just died");
|
||||
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, health);
|
||||
|
||||
Kill(pVictim, durabilityLoss);
|
||||
|
||||
/*// find player: owner of controlled `this` or `this` itself maybe
|
||||
@@ -834,6 +847,9 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||
{
|
||||
DEBUG_LOG("DealDamageAlive");
|
||||
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, damage);
|
||||
|
||||
pVictim->ModifyHealth(- (int32)damage);
|
||||
|
||||
if(damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE)
|
||||
@@ -8151,6 +8167,21 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellPro
|
||||
|
||||
if (BattleGround *bg = ((Player*)this)->GetBattleGround())
|
||||
bg->UpdatePlayerScore((Player*)this, SCORE_HEALING_DONE, gain);
|
||||
|
||||
// healing done is count ONLY if the target is a player.
|
||||
if (pVictim->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// use the actual gain, as the overheal shall not be counted.
|
||||
((Player*)this)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, gain);
|
||||
}
|
||||
|
||||
((Player*)this)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED, addhealth);
|
||||
}
|
||||
|
||||
if (pVictim->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED, gain);
|
||||
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED, addhealth);
|
||||
}
|
||||
|
||||
return gain;
|
||||
|
||||
Reference in New Issue
Block a user