aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/world/2012_12_28_00_world_command.sql3
-rw-r--r--src/server/scripts/Commands/cs_lookup.cpp99
2 files changed, 101 insertions, 1 deletions
diff --git a/sql/updates/world/2012_12_28_00_world_command.sql b/sql/updates/world/2012_12_28_00_world_command.sql
new file mode 100644
index 00000000000..6de970d3b81
--- /dev/null
+++ b/sql/updates/world/2012_12_28_00_world_command.sql
@@ -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.');
diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp
index c265cd1faa5..13ee91884d0 100644
--- a/src/server/scripts/Commands/cs_lookup.cpp
+++ b/src/server/scripts/Commands/cs_lookup.cpp
@@ -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)