Skip to content

Instantly share code, notes, and snippets.

@SignFinder
Created May 31, 2011 10:29
Show Gist options
  • Save SignFinder/1000279 to your computer and use it in GitHub Desktop.
Save SignFinder/1000279 to your computer and use it in GitHub Desktop.
# HG changeset patch
# User DrTenma <dr.tenma@yahoo.com>
# Date 1286571369 10800
# Branch trunk
# Node ID 541fae6ba1344f7c877faa8ae4f6b1eef4627b9c
# Parent 85ebc0c62ad34b9a669d59a1a43b2f6eae75b22c
Glyph of Scourge Strike fix.
diff -r 85ebc0c62ad3 -r 541fae6ba134 src/server/scripts/Spells/spell_dk.cpp
--- a/src/server/scripts/Spells/spell_dk.cpp Fri Oct 08 22:33:21 2010 +0200
+++ b/src/server/scripts/Spells/spell_dk.cpp Fri Oct 08 17:56:09 2010 -0300
@@ -23,6 +23,7 @@
#include "ScriptPCH.h"
#include "Spell.h"
+#include "SpellAuraEffects.h"
enum DeathKnightSpells
{
@@ -128,21 +129,125 @@ public:
class spell_dk_scourge_strike_SpellScript : public SpellScript
{
PrepareSpellScript(spell_dk_scourge_strike_SpellScript)
+
bool Validate(SpellEntry const * /*spellEntry*/)
{
if (!sSpellStore.LookupEntry(DK_SPELL_SCOURGE_STRIKE_TRIGGERED))
return false;
+
return true;
}
+ void GetGlyphScourgeStrikeAuraEffects(Unit const * caster, Unit const * target, Unit::AuraEffectList & auras)
+ {
+ Unit::AuraEffectList const & aurasA = target->GetAuraEffectsByType(SPELL_AURA_DUMMY);
+ for (Unit::AuraEffectList::const_iterator itr = aurasA.begin(); itr != aurasA.end(); ++itr)
+ {
+ if (((*itr)->GetCasterGUID() != caster->GetGUID()) || ((*itr)->GetEffIndex() != EFFECT_0))
+ continue;
+
+ SpellEntry const * spellProto = (*itr)->GetSpellProto();
+ if ((spellProto->SpellIconID == 23) && (SpellFamilyNames(spellProto->SpellFamilyName) == SPELLFAMILY_GENERIC))
+ auras.push_back(*itr);
+ }
+ }
+
+ AuraEffect * GetGlyphScourgeStrikeAuraEffect(uint32 diseaseId, Unit::AuraEffectList const & auras)
+ {
+ for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
+ if (diseaseId == ((*itr)->GetAmount() >> 4))
+ return (*itr);
+
+ return NULL;
+ }
+
void HandleDummy(SpellEffIndex /*effIndex*/)
{
- Unit* caster = GetCaster();
- if (Unit* unitTarget = GetHitUnit())
+ static const AuraType diseaseAuraTypes[] =
{
- int32 bp = (GetHitDamage() * GetEffectValue() * unitTarget->GetDiseasesByCaster(caster->GetGUID())) / 100;
- caster->CastCustomSpell(unitTarget, DK_SPELL_SCOURGE_STRIKE_TRIGGERED, &bp, NULL, NULL, true);
+ SPELL_AURA_PERIODIC_DAMAGE, // Frost Fever and Blood Plague
+ SPELL_AURA_LINKED, // Crypt Fever and Ebon Plague
+ SPELL_AURA_NONE
+ };
+
+ Unit * caster = GetCaster();
+ Unit * target = GetHitUnit();
+
+ if (!target)
+ return;
+
+ uint32 diseases = 0;
+ int32 extratime, maxtime;
+ AuraEffect const * aurEffA;
+
+ Unit::AuraEffectList aurasA;
+ GetGlyphScourgeStrikeAuraEffects(caster, caster, aurasA);
+
+ bool hasGlyph = bool(aurasA.size());
+
+ if (hasGlyph)
+ {
+ aurEffA = *aurasA.begin();
+ extratime = aurEffA->GetAmount();
+ maxtime = SpellMgr::CalculateSpellEffectAmount(aurEffA->GetSpellProto(), EFFECT_1);
+
+ aurasA.clear();
+ GetGlyphScourgeStrikeAuraEffects(caster, target, aurasA);
}
+
+ for (AuraType const * itrA = &diseaseAuraTypes[0]; itrA && itrA[0] != SPELL_AURA_NONE; ++itrA)
+ {
+ Unit::AuraEffectList const & aurasB = target->GetAuraEffectsByType(*itrA);
+ for (Unit::AuraEffectList::const_iterator itrB = aurasB.begin(); itrB != aurasB.end(); ++itrB)
+ if (((*itrB)->GetSpellProto()->Dispel == DISPEL_DISEASE) &&
+ ((*itrB)->GetCasterGUID() == caster->GetGUID()))
+ {
+ ++diseases;
+
+ if (!hasGlyph)
+ continue;
+
+ Aura * aura = (*itrB)->GetBase();
+
+ int32 applytime = int32(aura->GetApplyTime() & 0x7FFFFFFF);
+ int32 duration = std::min(aura->GetDuration() + (extratime * IN_MILLISECONDS), aura->GetMaxDuration());
+
+ if (AuraEffect * aurEffB = GetGlyphScourgeStrikeAuraEffect(aura->GetId(), aurasA))
+ {
+ aurEffB->GetBase()->SetDuration(duration);
+
+ if (applytime != aurEffB->GetBase()->GetMaxDuration())
+ aurEffB->SetAmount(aurEffB->GetAmount() & ~(0xF));
+
+ if (maxtime <= (aurEffB->GetAmount() & 0xF))
+ continue;
+
+ aura->SetDuration(duration);
+
+ aurEffB->GetBase()->SetMaxDuration(applytime);
+ aurEffB->SetAmount(aurEffB->GetAmount() + extratime);
+
+ continue;
+ }
+
+ int32 bp0 = (aura->GetId() << 4) + extratime;
+ caster->CastCustomSpell(target, aurEffA->GetId(), &bp0, NULL, NULL, true);
+
+ Unit::AuraEffectList tmp;
+ GetGlyphScourgeStrikeAuraEffects(caster, target, tmp);
+
+ if (AuraEffect * aurEffB = GetGlyphScourgeStrikeAuraEffect(aura->GetId(), tmp))
+ {
+ aura->SetDuration(duration);
+
+ aurEffB->GetBase()->SetMaxDuration(applytime);
+ aurEffB->GetBase()->SetDuration(duration);
+ }
+ }
+ }
+
+ int32 bp0 = (GetHitDamage() * GetEffectValue() * diseases) / 100;
+ caster->CastCustomSpell(target, DK_SPELL_SCOURGE_STRIKE_TRIGGERED, &bp0, NULL, NULL, true);
}
void Register()
@@ -151,7 +256,7 @@ public:
}
};
- SpellScript* GetSpellScript() const
+ SpellScript * GetSpellScript() const
{
return new spell_dk_scourge_strike_SpellScript();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment