From 7c0201f834af7171e004d25b56c232de2030d42e Mon Sep 17 00:00:00 2001 From: Trazom Date: Thu, 23 Apr 2009 04:51:49 +0400 Subject: [PATCH] [7701] Move explicit healing repeating code to DealHeal functions. Signed-off-by: VladimirMangos --- src/game/Spell.cpp | 13 ++----------- src/game/SpellAuras.cpp | 7 ++----- src/game/SpellEffects.cpp | 17 +++-------------- src/game/Unit.cpp | 15 +++++++++++++++ src/game/Unit.h | 1 + src/shared/revision_nr.h | 2 +- 6 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 7f9b796d2..0ace79988 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1040,18 +1040,12 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) else procEx |= PROC_EX_NORMAL_HIT; - caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, crit); - // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) if (m_canTrigger && missInfo != SPELL_MISS_REFLECT) caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, addhealth, m_attackType, m_spellInfo); - int32 gain = unitTarget->ModifyHealth( int32(addhealth) ); - + int32 gain = caster->DealHeal(unitTarget, addhealth, m_spellInfo, crit); unitTarget->getHostilRefManager().threatAssist(caster, float(gain) * 0.5f, m_spellInfo); - if(caster->GetTypeId()==TYPEID_PLAYER) - if(BattleGround *bg = ((Player*)caster)->GetBattleGround()) - bg->UpdatePlayerScore(((Player*)caster), SCORE_HEALING_DONE, gain); } // Do damage and triggers else if (m_damage) @@ -2776,10 +2770,7 @@ void Spell::finish(bool ok) // Heal caster for all health leech from all targets if (m_healthLeech) - { - m_caster->ModifyHealth(m_healthLeech); - m_caster->SendHealSpellLog(m_caster, m_spellInfo->Id, uint32(m_healthLeech)); - } + m_caster->DealHeal(m_caster, uint32(m_healthLeech), m_spellInfo); if (IsMeleeAttackResetSpell()) { diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 5da2d285c..65c0a69d9 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -1431,8 +1431,7 @@ void Aura::TriggerSpell() case 23493: { int32 heal = caster->GetMaxHealth() / 10; - caster->ModifyHealth( heal ); - caster->SendHealSpellLog(caster, 23493, heal); + caster->DealHeal(caster, heal, auraSpellInfo); int32 mana = caster->GetMaxPower(POWER_MANA); if (mana) @@ -5876,10 +5875,8 @@ void Aura::PeriodicTick() uint32 heal = pCaster->SpellHealingBonus(pCaster, spellProto, uint32(new_damage * multiplier), DOT, stackAmount); - int32 gain = pCaster->ModifyHealth(heal); + int32 gain = pCaster->DealHeal(pCaster, heal, spellProto); pCaster->getHostilRefManager().threatAssist(pCaster, gain * 0.5f, spellProto); - - pCaster->SendHealSpellLog(pCaster, spellProto->Id, heal); break; } case SPELL_AURA_PERIODIC_HEAL: diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index d4bb90154..933c0ebb6 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2504,14 +2504,8 @@ void Spell::EffectHealPct( uint32 /*i*/ ) if(Player* modOwner = m_caster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DAMAGE, addhealth, this); - caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false); - - int32 gain = unitTarget->ModifyHealth( int32(addhealth) ); + int32 gain = caster->DealHeal(unitTarget, addhealth, m_spellInfo); unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo); - - if(caster->GetTypeId()==TYPEID_PLAYER) - if(BattleGround *bg = ((Player*)caster)->GetBattleGround()) - bg->UpdatePlayerScore(((Player*)caster), SCORE_HEALING_DONE, gain); } } @@ -2528,8 +2522,7 @@ void Spell::EffectHealMechanical( uint32 /*i*/ ) return; uint32 addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, uint32(damage), HEAL); - caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false); - unitTarget->ModifyHealth( int32(damage) ); + caster->DealHeal(unitTarget, addhealth, m_spellInfo); } } @@ -2559,11 +2552,7 @@ void Spell::EffectHealthLeech(uint32 i) if(m_caster->isAlive()) { new_damage = m_caster->SpellHealingBonus(m_caster, m_spellInfo, new_damage, HEAL); - - m_caster->ModifyHealth(new_damage); - - if(m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->SendHealSpellLog(m_caster, m_spellInfo->Id, uint32(new_damage)); + m_caster->DealHeal(m_caster, uint32(new_damage), m_spellInfo); } // m_healthLeech+=tmpvalue; // m_damage+=new_damage; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 74ad504d6..3f4b31e0d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -7423,6 +7423,21 @@ void Unit::UnsummonAllTotems() } } +int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical) +{ + int32 gain = pVictim->ModifyHealth(int32(addhealth)); + + if (GetTypeId()==TYPEID_PLAYER) + { + SendHealSpellLog(pVictim, spellProto->Id, addhealth, critical); + + if (BattleGround *bg = ((Player*)this)->GetBattleGround()) + bg->UpdatePlayerScore((Player*)this, SCORE_HEALING_DONE, gain); + } + + return gain; +} + Unit* Unit::SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo) { if(!victim) diff --git a/src/game/Unit.h b/src/game/Unit.h index c9648da51..8c5ccc78e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -952,6 +952,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss); + int32 DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical = false); void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const *procSpell = NULL); void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage ); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 15bc8d933..b08488d22 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7700" + #define REVISION_NR "7701" #endif // __REVISION_NR_H__