*Make EffectHealMechanical, EffectHealPct, EffectHealMaxHealth and EffectHealthLeech to use proc system for their dmg/heal (thanks kiper for research)

*Fix some spells with EffectHealMaxHealth with effect value set to 0.
*Fix a typo.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-08-28 23:01:04 +02:00
parent 2bfaeaeabe
commit 511e8c5acf
+25 -48
View File
@@ -2356,7 +2356,6 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex)
int32 power = damage; int32 power = damage;
if (powerType == POWER_MANA) if (powerType == POWER_MANA)
power -= unitTarget->GetSpellCritDamageReduction(power); power -= unitTarget->GetSpellCritDamageReduction(power);
power = std::min(0, power);
int32 newDamage = -(unitTarget->ModifyPower(powerType, -int32(power))); int32 newDamage = -(unitTarget->ModifyPower(powerType, -int32(power)));
@@ -2416,7 +2415,6 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex)
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
if (powerType == POWER_MANA) if (powerType == POWER_MANA)
power -= unitTarget->GetSpellCritDamageReduction(power); power -= unitTarget->GetSpellCritDamageReduction(power);
power = std::min(0, power);
int32 newDamage = -(unitTarget->ModifyPower(powerType, -power)); int32 newDamage = -(unitTarget->ModifyPower(powerType, -power));
@@ -2551,43 +2549,30 @@ void Spell::SpellDamageHeal(SpellEffIndex /*effIndex*/)
void Spell::EffectHealPct(SpellEffIndex /*effIndex*/) void Spell::EffectHealPct(SpellEffIndex /*effIndex*/)
{ {
if (unitTarget && unitTarget->isAlive() && damage >= 0) if (!unitTarget || !unitTarget->isAlive() || damage < 0)
{ return;
// Try to get original caster
Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster;
// Skip if m_originalCaster not available // Skip if m_originalCaster not available
if (!caster) if (!m_originalCaster)
return; return;
// Rune Tap - Party // Rune Tap - Party
if (m_spellInfo->Id == 59754 && unitTarget == m_caster) if (m_spellInfo->Id == 59754 && unitTarget == m_caster)
return; return;
uint32 addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, unitTarget->CountPctFromMaxHealth(damage), HEAL); m_healing += m_originalCaster->SpellHealingBonus(unitTarget, m_spellInfo, unitTarget->CountPctFromMaxHealth(damage), HEAL);
//if (Player *modOwner = m_caster->GetSpellModOwner())
// modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DAMAGE, addhealth, this);
int32 gain = caster->HealBySpell(unitTarget, m_spellInfo, addhealth);
unitTarget->getHostileRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo);
}
} }
void Spell::EffectHealMechanical(SpellEffIndex /*effIndex*/) void Spell::EffectHealMechanical(SpellEffIndex /*effIndex*/)
{ {
// Mechanic creature type should be correctly checked by targetCreatureType field if (!unitTarget || !unitTarget->isAlive() || damage < 0)
if (unitTarget && unitTarget->isAlive() && damage >= 0) return;
{
// Try to get original caster
Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster;
// Skip if m_originalCaster not available // Skip if m_originalCaster not available
if (!caster) if (!m_originalCaster)
return; return;
uint32 addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, uint32(damage), HEAL); m_healing += m_originalCaster->SpellHealingBonus(unitTarget, m_spellInfo, uint32(damage), HEAL);
caster->HealBySpell(unitTarget, m_spellInfo, addhealth);
}
} }
void Spell::EffectHealthLeech(SpellEffIndex effIndex) void Spell::EffectHealthLeech(SpellEffIndex effIndex)
@@ -2600,11 +2585,7 @@ void Spell::EffectHealthLeech(SpellEffIndex effIndex)
float healMultiplier = SpellMgr::CalculateSpellEffectValueMultiplier(m_spellInfo, effIndex, m_originalCaster, this); float healMultiplier = SpellMgr::CalculateSpellEffectValueMultiplier(m_spellInfo, effIndex, m_originalCaster, this);
int32 newDamage = int32(damage * healMultiplier); int32 newDamage = int32(damage * healMultiplier);
m_damage += newDamage;
uint32 curHealth = unitTarget->GetHealth();
newDamage = m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, newDamage);
if (int32(curHealth) < newDamage)
newDamage = curHealth;
if (m_caster->isAlive()) if (m_caster->isAlive())
{ {
@@ -4433,37 +4414,33 @@ void Spell::EffectThreat(SpellEffIndex /*effIndex*/)
void Spell::EffectHealMaxHealth(SpellEffIndex /*effIndex*/) void Spell::EffectHealMaxHealth(SpellEffIndex /*effIndex*/)
{ {
if (!unitTarget) if (!unitTarget || !unitTarget->isAlive())
return;
if (!unitTarget->isAlive())
return; return;
int32 addhealth; int32 addhealth;
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN) // Lay on Hands if (m_spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN) // Lay on Hands
{ {
if (m_caster && m_caster->GetGUID() == unitTarget->GetGUID()) if (m_caster->GetGUID() == unitTarget->GetGUID())
{ {
m_caster->CastSpell(m_caster, 25771, true); // Forbearance m_caster->CastSpell(m_caster, 25771, true); // Forbearance
m_caster->CastSpell(m_caster, 61988, true); // Immune shield marker (serverside) m_caster->CastSpell(m_caster, 61988, true); // Immune shield marker (serverside)
m_caster->CastSpell(m_caster, 61987, true); // Avenging Wrath marker m_caster->CastSpell(m_caster, 61987, true); // Avenging Wrath marker
} }
addhealth = m_caster->GetMaxHealth();
} }
// damage == 0 - heal for caster max health
if (damage == 0)
addhealth = m_caster->GetMaxHealth();
else else
addhealth = unitTarget->GetMaxHealth() - unitTarget->GetHealth(); addhealth = unitTarget->GetMaxHealth() - unitTarget->GetHealth();
if (m_originalCaster) if (m_originalCaster)
{ m_healing += m_originalCaster->SpellHealingBonus(unitTarget,m_spellInfo, addhealth, HEAL);
addhealth=m_originalCaster->SpellHealingBonus(unitTarget,m_spellInfo, addhealth, HEAL);
m_originalCaster->HealBySpell(unitTarget, m_spellInfo, addhealth);
}
} }
void Spell::EffectInterruptCast(SpellEffIndex effIndex) void Spell::EffectInterruptCast(SpellEffIndex effIndex)
{ {
if (!unitTarget) if (!unitTarget || !unitTarget->isAlive())
return;
if (!unitTarget->isAlive())
return; return;
// TODO: not all spells that used this effect apply cooldown at school spells // TODO: not all spells that used this effect apply cooldown at school spells