Core/Spells: attempt to fix penance doing nothing on "friendly" non faction targets. should return invalid targets

This commit is contained in:
Kandera
2012-03-28 08:29:42 -04:00
parent e95d614f52
commit 6763c23777
@@ -185,6 +185,11 @@ class spell_pri_penance : public SpellScriptLoader
{
PrepareSpellScript(spell_pri_penance_SpellScript);
bool Load()
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
bool Validate(SpellInfo const* spellEntry)
{
if (!sSpellMgr->GetSpellInfo(PRIEST_SPELL_PENANCE_R1))
@@ -219,10 +224,21 @@ class spell_pri_penance : public SpellScriptLoader
}
}
SpellCastResult CheckCast()
{
Player* caster = GetCaster()->ToPlayer();
if (GetTargetUnit())
if (Player* target = GetTargetUnit()->ToPlayer())
if (caster->GetTeam() != target->GetTeam() && !caster->IsValidAttackTarget(target))
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
void Register()
{
// add dummy effect spell handler to Penance
OnEffectHitTarget += SpellEffectFn(spell_pri_penance_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
OnCheckCast += SpellCheckCastFn(spell_pri_penance_SpellScript::CheckCast);
}
};