diff options
-rw-r--r-- | src/server/scripts/Spells/spell_dk.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 38901287e0d..1fbd6bd9145 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -334,6 +334,21 @@ class spell_dk_death_pact : public SpellScriptLoader { PrepareSpellScript(spell_dk_death_pact_SpellScript); + SpellCastResult CheckCast() + { + // Check if we have valid targets, otherwise skip spell casting here + if (Player* player = GetCaster()->ToPlayer()) + for (Unit::ControlList::const_iterator itr = player->m_Controlled.begin(); itr != player->m_Controlled.end(); ++itr) + if (Creature* undeadPet = (*itr)->ToCreature()) + if (undeadPet->isAlive() && + undeadPet->GetOwnerGUID() == player->GetGUID() && + undeadPet->GetCreatureInfo()->type == CREATURE_TYPE_UNDEAD && + undeadPet->IsWithinDist(player, 100.0f, false)) + return SPELL_CAST_OK; + + return SPELL_FAILED_NO_PET; + } + void FilterTargets(std::list<Unit*>& unitList) { Unit* unit_to_add = NULL; @@ -351,17 +366,11 @@ class spell_dk_death_pact : public SpellScriptLoader unitList.clear(); if (unit_to_add) unitList.push_back(unit_to_add); - else - { - // Pet not found - remove cooldown - if (Player* modOwner = GetCaster()->GetSpellModOwner()) - modOwner->RemoveSpellCooldown(GetSpellInfo()->Id, true); - FinishCast(SPELL_FAILED_NO_PET); - } } void Register() { + OnCheckCast += SpellCheckCastFn(spell_dk_death_pact_SpellScript::CheckCast); OnUnitTargetSelect += SpellUnitTargetFn(spell_dk_death_pact_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ALLY); } }; |