Core/Commands: Convert cast commands in commandscript
This commit is contained in:
1 parent
f90f5b6fb7
commit
c19f13e6fc
6 files changed
+313
-276
No files matched your search
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user