Skip to content

Commit

Permalink
chore(Scripts/DK): Move CheckCast to spell_dk_raise_ally script (#17221)
Browse files Browse the repository at this point in the history
* chore(Scripts/Spell): Move CheckCast to spell_dk_raise_ally script

* Update spell_dk.cpp

* Update spell_dk.cpp
  • Loading branch information
Kitzunu authored Sep 17, 2023
1 parent acc1303 commit b84596f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/server/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6088,23 +6088,6 @@ SpellCastResult Spell::CheckCast(bool strict)
// for effects of spells that have only one target
switch (m_spellInfo->Effects[i].Effect)
{
case SPELL_EFFECT_DUMMY:
{
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT)
{
// Raise Ally
if( m_spellInfo->Id == 61999 )
{
Unit* target = m_targets.GetUnitTarget();
if (!target)
return SPELL_FAILED_BAD_TARGETS;

if (target->IsAlive()) // not discovered attributeEx5?
return SPELL_FAILED_TARGET_NOT_DEAD;
}
}
break;
}
case SPELL_EFFECT_LEARN_SPELL:
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
Expand Down
13 changes: 13 additions & 0 deletions src/server/scripts/Spells/spell_dk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ class spell_dk_raise_ally : public SpellScript
{
PrepareSpellScript(spell_dk_raise_ally);

SpellCastResult CheckCast()
{
Player* unitTarget = GetHitPlayer();
if (!unitTarget)
return SPELL_FAILED_BAD_TARGETS;

if (unitTarget->IsAlive()) // not discovered attributeEx5?
return SPELL_FAILED_TARGET_NOT_DEAD;

return SPELL_CAST_OK;
}

void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Player* unitTarget = GetHitPlayer())
Expand Down Expand Up @@ -237,6 +249,7 @@ class spell_dk_raise_ally : public SpellScript

void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_dk_raise_ally::CheckCast);
OnEffectHitTarget += SpellEffectFn(spell_dk_raise_ally::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
Expand Down

0 comments on commit b84596f

Please sign in to comment.