diff options
author | kandera <kanderadev@gmail.com> | 2012-06-29 10:18:58 -0700 |
---|---|---|
committer | kandera <kanderadev@gmail.com> | 2012-06-29 10:18:58 -0700 |
commit | efa92eaecf6d58e7bba7008772b165c99600248f (patch) | |
tree | 4dec6f88a73b74784b22c54bc8bd7b5ff3df7b91 /src | |
parent | 799b2c146ba5bdb758c1d39fa8de3beb6bb00159 (diff) | |
parent | 8ba234e2455e0d1fe1c624e297e5f3149e8af986 (diff) |
Merge pull request #6976 from Elron103/pull-requests
Scripts/Spells: Fix Deathknight ability Death Pact 48743 Closes #5950
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); } }; |