Script/Commands: New command: lookup spell id #spellid

Command to allow to know spell names based on id

Example:
 lookup spell id 686:
 686 - [Shadow Bolt rank 1 esES] [know]

Closes #8800

Signed-off-by: Nay <dnpd.dd@gmail.com>
This commit is contained in:
secharles
2012-12-28 01:05:30 +00:00
committed by Nay
parent a29ec679ae
commit 8272affe92
2 changed files with 101 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
DELETE FROM `command` WHERE `name` LIKE 'lookup spell id';
INSERT INTO `command` (`name`, `security`, `help`) VALUES
('lookup spell id', '3', 'Syntax: .lookup spell id #spellid\n\nLooks up a spell by #spellid, and returns the match with its spell name.');

View File

@@ -46,6 +46,14 @@ public:
{ "email", SEC_GAMEMASTER, true, &HandleLookupPlayerEmailCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand lookupSpellCommandTable[] =
{
{ "id", SEC_ADMINISTRATOR, true, &HandleLookupSpellIdCommand, "", NULL },
{ "", SEC_ADMINISTRATOR, true, &HandleLookupSpellCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand lookupCommandTable[] =
{
{ "area", SEC_MODERATOR, true, &HandleLookupAreaCommand, "", NULL },
@@ -58,13 +66,14 @@ public:
{ "quest", SEC_ADMINISTRATOR, true, &HandleLookupQuestCommand, "", NULL },
{ "player", SEC_GAMEMASTER, true, NULL, "", lookupPlayerCommandTable },
{ "skill", SEC_ADMINISTRATOR, true, &HandleLookupSkillCommand, "", NULL },
{ "spell", SEC_ADMINISTRATOR, true, &HandleLookupSpellCommand, "", NULL },
{ "spell", SEC_ADMINISTRATOR, true, NULL, "", lookupSpellCommandTable },
{ "taxinode", SEC_ADMINISTRATOR, true, &HandleLookupTaxiNodeCommand, "", NULL },
{ "tele", SEC_MODERATOR, true, &HandleLookupTeleCommand, "", NULL },
{ "title", SEC_GAMEMASTER, true, &HandleLookupTitleCommand, "", NULL },
{ "map", SEC_ADMINISTRATOR, true, &HandleLookupMapCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "lookup", SEC_ADMINISTRATOR, true, NULL, "", lookupCommandTable },
@@ -943,6 +952,94 @@ public:
return true;
}
static bool HandleLookupSpellIdCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
// can be NULL at console call
Player* target = handler->getSelectedPlayer();
uint32 id = atoi((char*)args);
bool found = false;
uint32 count = 0;
uint32 maxResults = 1;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
if (spellInfo)
{
int locale = handler->GetSessionDbcLocale();
std::string name = spellInfo->SpellName[locale];
if (name.empty())
{
handler->SendSysMessage(LANG_COMMAND_NOSPELLFOUND);
return true;
}
if (locale < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
bool known = target && target->HasSpell(id);
bool learn = (spellInfo->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[0].TriggerSpell);
uint32 talentCost = GetTalentSpellCost(id);
bool talent = (talentCost > 0);
bool passive = spellInfo->IsPassive();
bool active = target && target->HasAura(id);
// unit32 used to prevent interpreting uint8 as char at output
// find rank of learned spell for learning spell, or talent rank
uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
// send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
std::ostringstream ss;
if (handler->GetSession())
ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
else
ss << id << " - " << name;
// include rank in link name
if (rank)
ss << handler->GetTrinityString(LANG_SPELL_RANK) << rank;
if (handler->GetSession())
ss << ' ' << localeNames[locale] << "]|h|r";
else
ss << ' ' << localeNames[locale];
if (talent)
ss << handler->GetTrinityString(LANG_TALENT);
if (passive)
ss << handler->GetTrinityString(LANG_PASSIVE);
if (learn)
ss << handler->GetTrinityString(LANG_LEARN);
if (known)
ss << handler->GetTrinityString(LANG_KNOWN);
if (active)
ss << handler->GetTrinityString(LANG_ACTIVE);
handler->SendSysMessage(ss.str().c_str());
if (!found)
found = true;
}
}
if (!found)
handler->SendSysMessage(LANG_COMMAND_NOSPELLFOUND);
return true;
}
static bool HandleLookupTaxiNodeCommand(ChatHandler* handler, const char * args)
{
if (!*args)