mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 01:59:09 +00:00
feat(Scripts/Commands): Output SpellCastResult if the spell fails to … (#14359)
feat(Scripts/Commands): Output SpellCastResult if the spell fails to cast when using the cast spell commands
This commit is contained in:
@@ -56,6 +56,17 @@ public:
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool CheckSpellCastResult(ChatHandler* handler, SpellCastResult result)
|
||||
{
|
||||
if (result != SPELL_CAST_OK)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_CMD_CAST_ERROR_CODE, EnumUtils::ToTitle(SpellCastResult(result)), result);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool CheckSpellExistsAndIsValid(ChatHandler* handler, SpellInfo const* spell)
|
||||
{
|
||||
if (!spell)
|
||||
@@ -103,7 +114,11 @@ public:
|
||||
if (!triggerFlags)
|
||||
return false;
|
||||
|
||||
handler->GetSession()->GetPlayer()->CastSpell(target, spell->Id, *triggerFlags);
|
||||
if (!CheckSpellCastResult(handler, handler->GetSession()->GetPlayer()->CastSpell(target, spell->Id, *triggerFlags)))
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -125,7 +140,11 @@ public:
|
||||
if (!triggerFlags)
|
||||
return false;
|
||||
|
||||
caster->CastSpell(handler->GetSession()->GetPlayer(), spell->Id, *triggerFlags);
|
||||
if (!CheckSpellCastResult(handler, caster->CastSpell(handler->GetSession()->GetPlayer(), spell->Id, *triggerFlags)))
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -141,7 +160,12 @@ public:
|
||||
|
||||
float x, y, z;
|
||||
handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, dist);
|
||||
handler->GetSession()->GetPlayer()->CastSpell(x, y, z, spell->Id, *triggerFlags);
|
||||
|
||||
if (!CheckSpellCastResult(handler, handler->GetSession()->GetPlayer()->CastSpell(x, y, z, spell->Id, *triggerFlags)))
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -163,7 +187,11 @@ public:
|
||||
if (!triggerFlags)
|
||||
return false;
|
||||
|
||||
target->CastSpell(target, spell->Id, *triggerFlags);
|
||||
if (!CheckSpellCastResult(handler, target->CastSpell(target, spell->Id, *triggerFlags)))
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -192,7 +220,11 @@ public:
|
||||
if (!triggerFlags)
|
||||
return false;
|
||||
|
||||
caster->CastSpell(caster->GetVictim(), spell->Id, *triggerFlags);
|
||||
if (!CheckSpellCastResult(handler, caster->CastSpell(caster->GetVictim(), spell->Id, *triggerFlags)))
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -214,7 +246,11 @@ public:
|
||||
if (!triggerFlags)
|
||||
return false;
|
||||
|
||||
caster->CastSpell(x, y, z, spell->Id, *triggerFlags);
|
||||
if (!CheckSpellCastResult(handler, caster->CastSpell(x, y, z, spell->Id, *triggerFlags)))
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user