mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
Merge pull request #6976 from Elron103/pull-requests
Scripts/Spells: Fix Deathknight ability Death Pact 48743 Closes #5950
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user