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

* Return CheckCast result from CastSpell

* Return cast result from UnitAI methods too.
This commit is contained in:
brotalnia authored and Ovahlord committed 2022-09-12 09:15:23 +02:00
1 parent 89d0f363cf
commit 7cc33f1bb7
6 files changed
+35 -35

No files matched your search

+8 -8
View File
@@ -2894,13 +2894,13 @@ bool WorldObject::IsNeutralToAll() const
return my_faction->IsNeutralToAll();
}
void WorldObject::CastSpell(SpellCastTargets const& targets, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
SpellCastResult WorldObject::CastSpell(SpellCastTargets const& targets, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
{
SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId);
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;
}
Spell* spell = new Spell(this, info, args.TriggerFlags, args.OriginalCaster);
@@ -2908,10 +2908,10 @@ void WorldObject::CastSpell(SpellCastTargets const& targets, uint32 spellId, Cas
spell->SetSpellValue(pair.first, pair.second);
spell->m_CastItem = args.CastItem;
spell->prepare(targets, args.TriggeringAura);
return spell->prepare(targets, args.TriggeringAura);
}
void WorldObject::CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
SpellCastResult WorldObject::CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
{
SpellCastTargets targets;
if (target)
@@ -2923,17 +2923,17 @@ void WorldObject::CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraA
else
{
TC_LOG_ERROR("entities.unit", "CastSpell: Invalid target %s passed to spell cast by %s", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str());
return;
return SPELL_FAILED_BAD_TARGETS;
}
}
CastSpell(targets, spellId, args);
return CastSpell(targets, spellId, args);
}
void WorldObject::CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
SpellCastResult WorldObject::CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
{
SpellCastTargets targets;
targets.SetDst(dest);
CastSpell(targets, spellId, args);
return CastSpell(targets, spellId, args);
}
// function based on function Unit::CanAttack from 13850 client