mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-24 07:30:07 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user