diff options
author | Elron103 <scarymovie87@gmx.de> | 2012-06-29 18:45:18 +0200 |
---|---|---|
committer | Elron103 <scarymovie87@gmx.de> | 2012-06-29 18:45:18 +0200 |
commit | 8ba234e2455e0d1fe1c624e297e5f3149e8af986 (patch) | |
tree | 4dec6f88a73b74784b22c54bc8bd7b5ff3df7b91 /src | |
parent | dfdbc91e908e5bbf780c7db5417b0dc170b8085d (diff) |
Scripts/Spells: Fix Deathknight ability Death Pact 48743
Diffstat (limited to 'src')
-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); } }; |