Core/Commands: Convert cast commands in commandscript
This commit is contained in:
@@ -92,17 +92,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand castCommandTable[] =
|
||||
{
|
||||
{ "back", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleCastBackCommand>, "", NULL },
|
||||
{ "dist", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleCastDistCommand>, "", NULL },
|
||||
{ "self", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleCastSelfCommand>, "", NULL },
|
||||
{ "target", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleCastTargetCommand>, "", NULL },
|
||||
{ "dest", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleCastDestCommand>, "", NULL },
|
||||
{ "", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleCastCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand characterDeletedCommandTable[] =
|
||||
{
|
||||
{ "delete", SEC_CONSOLE, true, OldHandler<&ChatHandler::HandleCharacterDeletedDeleteCommand>, "", NULL },
|
||||
@@ -328,7 +317,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
||||
{ "guild", SEC_ADMINISTRATOR, true, NULL, "", guildCommandTable },
|
||||
{ "group", SEC_ADMINISTRATOR, false, NULL, "", groupCommandTable },
|
||||
{ "cast", SEC_ADMINISTRATOR, false, NULL, "", castCommandTable },
|
||||
{ "reset", SEC_ADMINISTRATOR, true, NULL, "", resetCommandTable },
|
||||
{ "server", SEC_ADMINISTRATOR, true, NULL, "", serverCommandTable },
|
||||
|
||||
|
||||
@@ -147,13 +147,6 @@ class ChatHandler
|
||||
bool HandleBanListCharacterCommand(const char* args);
|
||||
bool HandleBanListIPCommand(const char* args);
|
||||
|
||||
bool HandleCastCommand(const char *args);
|
||||
bool HandleCastBackCommand(const char *args);
|
||||
bool HandleCastDistCommand(const char *args);
|
||||
bool HandleCastSelfCommand(const char *args);
|
||||
bool HandleCastTargetCommand(const char *args);
|
||||
bool HandleCastDestCommand(const char *args);
|
||||
|
||||
bool HandleCharacterCustomizeCommand(const char* args);
|
||||
bool HandleCharacterChangeFactionCommand(const char* args);
|
||||
bool HandleCharacterChangeRaceCommand(const char * args);
|
||||
|
||||
@@ -3814,227 +3814,6 @@ bool ChatHandler::HandleServerPLimitCommand(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCastCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Unit* target = getSelectedUnit();
|
||||
|
||||
if (!target)
|
||||
{
|
||||
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spell = extractSpellIdFromLink((char*)args);
|
||||
if (!spell)
|
||||
return false;
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell);
|
||||
if (!spellInfo)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer()))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* trig_str = strtok(NULL, " ");
|
||||
if (trig_str)
|
||||
{
|
||||
int l = strlen(trig_str);
|
||||
if (strncmp(trig_str, "triggered", l) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool triggered = (trig_str != NULL);
|
||||
|
||||
m_session->GetPlayer()->CastSpell(target, spell, triggered);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCastBackCommand(const char *args)
|
||||
{
|
||||
Creature* caster = getSelectedCreature();
|
||||
|
||||
if (!caster)
|
||||
{
|
||||
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spell = extractSpellIdFromLink((char*)args);
|
||||
if (!spell || !sSpellMgr->GetSpellInfo(spell))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* trig_str = strtok(NULL, " ");
|
||||
if (trig_str)
|
||||
{
|
||||
int l = strlen(trig_str);
|
||||
if (strncmp(trig_str, "triggered", l) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool triggered = (trig_str != NULL);
|
||||
|
||||
caster->CastSpell(m_session->GetPlayer(), spell, triggered);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCastDistCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spell = extractSpellIdFromLink((char*)args);
|
||||
if (!spell)
|
||||
return false;
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell);
|
||||
if (!spellInfo)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer()))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char *distStr = strtok(NULL, " ");
|
||||
|
||||
float dist = 0;
|
||||
|
||||
if (distStr)
|
||||
sscanf(distStr, "%f", &dist);
|
||||
|
||||
char* trig_str = strtok(NULL, " ");
|
||||
if (trig_str)
|
||||
{
|
||||
int l = strlen(trig_str);
|
||||
if (strncmp(trig_str, "triggered", l) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool triggered = (trig_str != NULL);
|
||||
|
||||
float x, y, z;
|
||||
m_session->GetPlayer()->GetClosePoint(x, y, z, dist);
|
||||
|
||||
m_session->GetPlayer()->CastSpell(x, y, z, spell, triggered);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCastTargetCommand(const char *args)
|
||||
{
|
||||
Creature* caster = getSelectedCreature();
|
||||
|
||||
if (!caster)
|
||||
{
|
||||
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!caster->getVictim())
|
||||
{
|
||||
SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spell = extractSpellIdFromLink((char*)args);
|
||||
if (!spell || !sSpellMgr->GetSpellInfo(spell))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* trig_str = strtok(NULL, " ");
|
||||
if (trig_str)
|
||||
{
|
||||
int l = strlen(trig_str);
|
||||
if (strncmp(trig_str, "triggered", l) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool triggered = (trig_str != NULL);
|
||||
|
||||
caster->CastSpell(caster->getVictim(), spell, triggered);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCastDestCommand(const char *args)
|
||||
{
|
||||
Unit* caster = getSelectedUnit();
|
||||
if (!caster)
|
||||
{
|
||||
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spell = extractSpellIdFromLink((char*)args);
|
||||
if (!spell || !sSpellMgr->GetSpellInfo(spell))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* px = strtok(NULL, " ");
|
||||
char* py = strtok(NULL, " ");
|
||||
char* pz = strtok(NULL, " ");
|
||||
|
||||
if (!px || !py || !pz)
|
||||
return false;
|
||||
|
||||
float x = (float)atof(px);
|
||||
float y = (float)atof(py);
|
||||
float z = (float)atof(pz);
|
||||
|
||||
char* trig_str = strtok(NULL, " ");
|
||||
if (trig_str)
|
||||
{
|
||||
int l = strlen(trig_str);
|
||||
if (strncmp(trig_str, "triggered", l) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool triggered = (trig_str != NULL);
|
||||
|
||||
caster->CastSpell(x, y, z, spell, triggered);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator
|
||||
Without this function 3rd party scripting library will get linking errors (unresolved external)
|
||||
@@ -4061,41 +3840,6 @@ bool ChatHandler::HandleComeToMeCommand(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCastSelfCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Unit* target = getSelectedUnit();
|
||||
|
||||
if (!target)
|
||||
{
|
||||
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spell = extractSpellIdFromLink((char*)args);
|
||||
if (!spell)
|
||||
return false;
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell);
|
||||
if (!spellInfo)
|
||||
return false;
|
||||
|
||||
if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer()))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
target->CastSpell(target, spell, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Define the 'Message of the day' for the realm
|
||||
bool ChatHandler::HandleServerSetMotdCommand(const char *args)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,7 @@ void AddSC_SmartSCripts();
|
||||
//Commands
|
||||
void AddSC_account_commandscript();
|
||||
void AddSC_achievement_commandscript();
|
||||
void AddSC_cast_commandscript();
|
||||
void AddSC_debug_commandscript();
|
||||
void AddSC_event_commandscript();
|
||||
void AddSC_gm_commandscript();
|
||||
@@ -649,6 +650,7 @@ void AddCommandScripts()
|
||||
{
|
||||
AddSC_account_commandscript();
|
||||
AddSC_achievement_commandscript();
|
||||
AddSC_cast_commandscript();
|
||||
AddSC_debug_commandscript();
|
||||
AddSC_event_commandscript();
|
||||
AddSC_gm_commandscript();
|
||||
|
||||
Reference in New Issue
Block a user