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:
@@ -0,0 +1,4 @@
|
|||||||
|
--
|
||||||
|
DELETE FROM `acore_string` WHERE `entry` = 5084;
|
||||||
|
INSERT INTO `acore_string` (`entry`, `content_default`) VALUES
|
||||||
|
(5084, 'Spell cast failed! SpellCastResult returned: %s (%u).');
|
||||||
@@ -1148,7 +1148,9 @@ enum AcoreStrings
|
|||||||
|
|
||||||
LANG_CMD_CHAR_CHANGE_ACC_SUCCESS = 5083,
|
LANG_CMD_CHAR_CHANGE_ACC_SUCCESS = 5083,
|
||||||
|
|
||||||
// Room for more strings 5083-9999
|
LANG_CMD_CAST_ERROR_CODE = 5084,
|
||||||
|
|
||||||
|
// Room for more strings 5084-9999
|
||||||
|
|
||||||
// Level requirement notifications
|
// Level requirement notifications
|
||||||
LANG_SAY_REQ = 6604,
|
LANG_SAY_REQ = 6604,
|
||||||
|
|||||||
@@ -56,6 +56,17 @@ public:
|
|||||||
return commandTable;
|
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)
|
static bool CheckSpellExistsAndIsValid(ChatHandler* handler, SpellInfo const* spell)
|
||||||
{
|
{
|
||||||
if (!spell)
|
if (!spell)
|
||||||
@@ -103,7 +114,11 @@ public:
|
|||||||
if (!triggerFlags)
|
if (!triggerFlags)
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -125,7 +140,11 @@ public:
|
|||||||
if (!triggerFlags)
|
if (!triggerFlags)
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -141,7 +160,12 @@ public:
|
|||||||
|
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, dist);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -163,7 +187,11 @@ public:
|
|||||||
if (!triggerFlags)
|
if (!triggerFlags)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
target->CastSpell(target, spell->Id, *triggerFlags);
|
if (!CheckSpellCastResult(handler, target->CastSpell(target, spell->Id, *triggerFlags)))
|
||||||
|
{
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -192,7 +220,11 @@ public:
|
|||||||
if (!triggerFlags)
|
if (!triggerFlags)
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -214,7 +246,11 @@ public:
|
|||||||
if (!triggerFlags)
|
if (!triggerFlags)
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user