aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Spell.cpp13
-rw-r--r--src/game/SpellAuras.cpp7
-rw-r--r--src/game/SpellEffects.cpp20
-rw-r--r--src/game/Unit.cpp25
-rw-r--r--src/game/Unit.h3
5 files changed, 27 insertions, 41 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 81ab3c9dd3c..378e6f0b2bc 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -957,8 +957,6 @@ 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);
@@ -966,12 +964,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
if (m_spellAura)
m_spellAura->SetProcDamage(addhealth);
- 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 > 0)
@@ -2748,10 +2742,7 @@ void Spell::finish(bool ok)
// Heal caster for all health leech from all targets
if (m_healthLeech)
- {
- int32 gain = m_caster->ModifyHealth(m_healthLeech);
- m_caster->SendHealSpellLog(m_caster, m_spellInfo->Id, uint32(m_healthLeech), false, &gain);
- }
+ 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 a41e791c38a..d476f7dcd91 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -1612,8 +1612,7 @@ void AuraEffect::TriggerSpell()
case 23493:
{
int32 heal = caster->GetMaxHealth() / 10;
- int32 gain = caster->ModifyHealth( heal );
- caster->SendHealSpellLog(caster, 23493, heal, false, &gain);
+ caster->DealHeal(caster, heal, auraSpellInfo);
int32 mana = caster->GetMaxPower(POWER_MANA);
if (mana)
@@ -5853,10 +5852,8 @@ void AuraEffect::PeriodicTick()
// Don't apply heal mods for this aura
uint32 heal = uint32(new_damage * multiplier);//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,false, &gain);
break;
}
case SPELL_AURA_PERIODIC_HEAL:
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 74600181e6f..dc7ab3f0b93 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -2601,14 +2601,8 @@ void Spell::EffectHealPct( uint32 /*i*/ )
if(Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DAMAGE, addhealth, this);
- int32 gain = unitTarget->ModifyHealth( int32(addhealth) );
- caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false, &gain);
-
+ 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);
}
}
@@ -2625,8 +2619,7 @@ void Spell::EffectHealMechanical( uint32 /*i*/ )
return;
uint32 addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, uint32(damage), HEAL);
- int32 Gain = unitTarget->ModifyHealth( int32(damage) );
- caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false, &Gain);
+ caster->DealHeal(unitTarget, addhealth, m_spellInfo);
}
}
@@ -2656,11 +2649,7 @@ void Spell::EffectHealthLeech(uint32 i)
if(m_caster->isAlive())
{
new_damage = m_caster->SpellHealingBonus(m_caster, m_spellInfo, new_damage, HEAL);
-
- int32 Gain = m_caster->ModifyHealth(new_damage);
-
- if(m_caster->GetTypeId() == TYPEID_PLAYER)
- m_caster->SendHealSpellLog(m_caster, m_spellInfo->Id, uint32(new_damage), false, &Gain);
+ m_caster->DealHeal(m_caster, uint32(new_damage), m_spellInfo);
}
// m_healthLeech+=tmpvalue;
// m_damage+=new_damage;
@@ -4324,9 +4313,8 @@ void Spell::EffectHealMaxHealth(uint32 /*i*/)
return;
int32 addhealth = unitTarget->GetMaxHealth() - unitTarget->GetHealth();
- unitTarget->SetHealth(unitTarget->GetMaxHealth());
if(m_originalCaster)
- m_originalCaster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false, &addhealth);
+ m_originalCaster->DealHeal(unitTarget, addhealth, m_spellInfo);
}
void Spell::EffectInterruptCast(uint32 i)
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index fe89baacaf1..e1a37aec703 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -8141,6 +8141,21 @@ void Unit::SetCharm(Unit* charm, bool apply)
}
}
+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, gain);
+
+ 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)
@@ -8324,21 +8339,15 @@ void Unit::UnsummonAllTotems()
}
}
-void Unit::SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical, int32 * Gain )
+void Unit::SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical, int32 gain)
{
// we guess size
WorldPacket data(SMSG_SPELLHEALLOG, (8+8+4+4+1));
data.append(pVictim->GetPackGUID());
data.append(GetPackGUID());
data << uint32(SpellID);
- int32 gainAmount;
- if (!Gain)
- gainAmount = pVictim->GetHealthGain(Damage);
- else
- gainAmount = *Gain;
-
data << uint32(Damage);
- data << uint32(Damage-gainAmount >0 ? Damage-gainAmount : 0); // overheal
+ data << uint32((int32)Damage > gain ? (int32)Damage - gain : 0); // overheal
data << uint8(critical ? 1 : 0);
data << uint8(0); // unused in client?
SendMessageToSet(&data, true);
diff --git a/src/game/Unit.h b/src/game/Unit.h
index e89b6732a14..8fdf7133ec4 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1071,6 +1071,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void RemoveSpellbyDamageTaken(uint32 damage, uint32 spell);
uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *spellProto = NULL, bool durabilityLoss = true);
void Kill(Unit *pVictim, bool durabilityLoss = true);
+ 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 );
@@ -1170,7 +1171,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
virtual bool IsUnderWater() const;
bool isInAccessiblePlaceFor(Creature const* c) const;
- void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical, int32 * Gain = NULL);
+ void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical, int32 gain);
void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype);
uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true);
void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);