Core/Spells: Return CheckCast result from CastSpell (#23236)

* Return CheckCast result from CastSpell

* Return cast result from UnitAI methods too.

(cherry picked from commit 49d0a5bbb6)
This commit is contained in:
brotalnia
2019-05-10 19:58:26 +03:00
committed by Shauren
parent ae52409ad9
commit ab988dc982
6 changed files with 30 additions and 24 deletions
+4 -4
View File
@@ -2584,19 +2584,19 @@ bool WorldObject::IsNeutralToAll() const
return my_faction->IsNeutralToAll();
}
void WorldObject::CastSpell(CastSpellTargetArg const& targets, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
SpellCastResult WorldObject::CastSpell(CastSpellTargetArg const& targets, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
{
SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId, args.CastDifficulty != DIFFICULTY_NONE ? args.CastDifficulty : GetMap()->GetDifficultyID());
if (!info)
{
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell %u by caster %s", spellId, GetGUID().ToString().c_str());
return;
return SPELL_FAILED_SPELL_UNAVAILABLE;
}
if (!targets.Targets)
{
TC_LOG_ERROR("entities.unit", "CastSpell: Invalid target passed to spell cast %u by %s", spellId, GetGUID().ToString().c_str());
return;
return SPELL_FAILED_BAD_TARGETS;
}
Spell* spell = new Spell(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId);
@@ -2604,7 +2604,7 @@ void WorldObject::CastSpell(CastSpellTargetArg const& targets, uint32 spellId, C
spell->SetSpellValue(pair.first, pair.second);
spell->m_CastItem = args.CastItem;
spell->prepare(*targets.Targets, args.TriggeringAura);
return spell->prepare(*targets.Targets, args.TriggeringAura);
}
// function based on function Unit::CanAttack from 13850 client