Code
# HG changeset patch
# User illusion
# Date 1325684790 -14400
# Node ID 9ce8288cd717266c016c3315f62726b59837daba
# Parent b8d7bac2b8334e93908952809c1fc5a81ed0651e
NR_Add GetTakenDamage function.
This function returned taken damage of hit unit(crit, armor, and etc).
Fix scourge strike, not fully fix.
diff -r b8d7bac2b833 -r 9ce8288cd717 src/server/game/Spells/Spell.cpp
--- a/src/server/game/Spells/Spell.cpp Wed Jan 04 17:45:11 2012 +0400
+++ b/src/server/game/Spells/Spell.cpp Wed Jan 04 17:46:30 2012 +0400
@@ -1335,10 +1335,10 @@
// Add bonuses and fill damageInfo struct
caster->CalculateSpellDamageTaken(&damageInfo, m_damage, m_spellInfo, m_attackType, target->crit);
+ m_taken_damage = damageInfo.damage;
caster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
// Send log damage message to client
-
if (missInfo == SPELL_MISS_REFLECT)
damageInfo.attacker = unit;
caster->SendSpellNonMeleeDamageLog(&damageInfo);
@@ -1356,7 +1356,7 @@
}
caster->DealSpellDamage(&damageInfo, true);
-
+
// Haunt
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags[1] & 0x40000 && m_spellAura && m_spellAura->GetEffect(1))
{
diff -r b8d7bac2b833 -r 9ce8288cd717 src/server/game/Spells/Spell.h
--- a/src/server/game/Spells/Spell.h Wed Jan 04 17:45:11 2012 +0400
+++ b/src/server/game/Spells/Spell.h Wed Jan 04 17:46:30 2012 +0400
@@ -549,8 +549,9 @@
GameObject* focusObject;
// Damage and healing in effects need just calculate
- int32 m_damage; // Damge in effects count here
+ int32 m_damage; // Damage in effects count here
int32 m_healing; // Healing in effects count here
+ int32 m_taken_damage; // Damage in effects count here (after armor and resist)
// ******************************************
// Spell trigger system
diff -r b8d7bac2b833 -r 9ce8288cd717 src/server/game/Spells/SpellScript.cpp
--- a/src/server/game/Spells/SpellScript.cpp Wed Jan 04 17:45:11 2012 +0400
+++ b/src/server/game/Spells/SpellScript.cpp Wed Jan 04 17:46:30 2012 +0400
@@ -398,6 +398,16 @@
return m_spell->m_damage;
}
+int32 SpellScript::GetTakenDamage()
+{
+ if (!IsInAfterHitPhase())
+ {
+ sLog->outError("TSCR: Script: `%s` Spell: `%u`: function SpellScript::GetTakenDamage was called while spell not in after-hit phase!", m_scriptName, m_scriptSpellId);
+ return NULL;
+ }
+ return m_spell->m_taken_damage;
+}
+
void SpellScript::SetHitDamage(int32 damage)
{
if (!IsInTargetHook())
diff -r b8d7bac2b833 -r 9ce8288cd717 src/server/game/Spells/SpellScript.h
--- a/src/server/game/Spells/SpellScript.h Wed Jan 04 17:45:11 2012 +0400
+++ b/src/server/game/Spells/SpellScript.h Wed Jan 04 17:46:30 2012 +0400
@@ -212,6 +212,7 @@
bool IsInTargetHook() const;
bool IsInHitPhase() const;
bool IsInEffectHook() const;
+ bool IsInAfterHitPhase() const { return (m_currentScriptState == SPELL_SCRIPT_HOOK_AFTER_HIT); }
private:
Spell* m_spell;
uint8 m_hitPreventEffectMask;
@@ -302,6 +303,8 @@
int32 GetHitDamage();
void SetHitDamage(int32 damage);
void PreventHitDamage() { SetHitDamage(0); }
+ // returns total damage of a spell (crit comprensive)
+ int32 GetTakenDamage();
// setter/getter for for heal done by spell to target of spell hit
// returns healing calculated before hit, and real dmg done after hit
int32 GetHitHeal();
diff -r b8d7bac2b833 -r 9ce8288cd717 src/server/scripts/Spells/spell_dk.cpp
--- a/src/server/scripts/Spells/spell_dk.cpp Wed Jan 04 17:45:11 2012 +0400
+++ b/src/server/scripts/Spells/spell_dk.cpp Wed Jan 04 17:46:30 2012 +0400
@@ -375,6 +375,11 @@
class spell_dk_scourge_strike_SpellScript : public SpellScript
{
PrepareSpellScript(spell_dk_scourge_strike_SpellScript);
+ private:
+ float m_multip;
+ public:
+ spell_dk_scourge_strike_SpellScript() : m_multip(0.0f) { }
+
bool Validate(SpellInfo const* /*spellEntry*/)
{
@@ -387,8 +392,15 @@
{
Unit* caster = GetCaster();
if (Unit* unitTarget = GetHitUnit())
+ m_multip = GetEffectValue() * unitTarget->GetDiseasesByCaster(caster->GetGUID());
+ }
+
+ void HandleAfterHit()
+ {
+ Unit* caster = GetCaster();
+ if (Unit* unitTarget = GetHitUnit())
{
- int32 bp = CalculatePctN(GetHitDamage(), GetEffectValue() * unitTarget->GetDiseasesByCaster(caster->GetGUID()));
+ int32 bp = CalculatePctN(GetTakenDamage(), m_multip);
caster->CastCustomSpell(unitTarget, DK_SPELL_SCOURGE_STRIKE_TRIGGERED, &bp, NULL, NULL, true);
}
}
@@ -396,6 +408,7 @@
void Register()
{
OnEffectHitTarget += SpellEffectFn(spell_dk_scourge_strike_SpellScript::HandleDummy, EFFECT_2, SPELL_EFFECT_DUMMY);
+ AfterHit += SpellHitFn(spell_dk_scourge_strike_SpellScript::HandleAfterHit);
}
};