Scripts/Commands: Cleanup and trinity_string for .go instance. Hi sha…
…uren.
This commit is contained in:
1 parent
861f114d5d
commit
77c9d5c43e
3 files changed
+52
-52
No files matched your search
@@ -0,0 +1,12 @@
|
||||
--
|
||||
DELETE FROM `trinity_string` WHERE `entry` BETWEEN 1189 AND 1197;
|
||||
INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES
|
||||
(1189, "No instances were found matching your input"),
|
||||
(1190, "Multiple instances match your input - please be more specific:"),
|
||||
(1191, "│ %03u - %s"),
|
||||
(1192, "Specified map %u is not instanced"),
|
||||
(1193, "Could not find entrance portal for map %u (%s)"),
|
||||
(1194, "Could not find exit portal for map %u (%s)"),
|
||||
(1195, "Teleported you to the entrance of mapid %u (%s)"),
|
||||
(1196, "Teleported you to the starting location of mapid %u (%s)"),
|
||||
(1197, "Failed to teleport you to mapid %u (%s) - missing attunement/expansion for parent map %u?");
|
||||
@@ -929,7 +929,16 @@ enum TrinityStrings
|
||||
LANG_GROUP_ROLE_CHANGED = 1186,
|
||||
LANG_LEADER_CANNOT_BE_ASSISTANT = 1187,
|
||||
LANG_BAN_EXISTS = 1188,
|
||||
// Room for more level 3 1189-1199 not used
|
||||
LANG_COMMAND_NO_INSTANCES_MATCH = 1189,
|
||||
LANG_COMMAND_MULTIPLE_INSTANCES_MATCH = 1190,
|
||||
LANG_COMMAND_MULTIPLE_INSTANCES_ENTRY = 1191,
|
||||
LANG_COMMAND_MAP_NOT_INSTANCE = 1192,
|
||||
LANG_COMMAND_INSTANCE_NO_ENTRANCE = 1193,
|
||||
LANG_COMMAND_INSTANCE_NO_EXIT = 1194,
|
||||
LANG_COMMAND_WENT_TO_INSTANCE_GATE = 1195,
|
||||
LANG_COMMAND_WENT_TO_INSTANCE_START = 1196,
|
||||
LANG_COMMAND_GO_INSTANCE_FAILED = 1197,
|
||||
// Room for more level 3 1197-1199 not used
|
||||
|
||||
// Debug commands
|
||||
LANG_CINEMATIC_NOT_EXIST = 1200,
|
||||
|
||||
@@ -603,33 +603,11 @@ public:
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::vector<std::string> labels;
|
||||
|
||||
// tokenize and convert to lowercase
|
||||
char* pos = const_cast<char*>(args);
|
||||
char* last = nullptr;
|
||||
do
|
||||
{
|
||||
if (*pos == ' ')
|
||||
{
|
||||
if (last)
|
||||
{
|
||||
*pos = '\0';
|
||||
labels.emplace_back(last);
|
||||
last = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!last)
|
||||
last = pos;
|
||||
*pos = tolower(*pos);
|
||||
}
|
||||
} while (*++pos);
|
||||
if (last)
|
||||
labels.emplace_back(last);
|
||||
// tokenizing done
|
||||
do *pos = tolower(*pos);
|
||||
while (*(++pos));
|
||||
|
||||
Tokenizer labels(args, ' ');
|
||||
uint32 mapid = 0;
|
||||
if (labels.size() == 1)
|
||||
{
|
||||
@@ -644,7 +622,7 @@ public:
|
||||
{
|
||||
uint32 count = 0;
|
||||
std::string const& scriptName = sObjectMgr->GetScriptName(pair.second.ScriptId);
|
||||
for (std::string const& label : labels)
|
||||
for (char const* label : labels)
|
||||
if (scriptName.find(label) != std::string::npos)
|
||||
++count;
|
||||
|
||||
@@ -653,7 +631,7 @@ public:
|
||||
}
|
||||
if (matches.empty())
|
||||
{
|
||||
handler->SendSysMessage("No matches found for your input");
|
||||
handler->SendSysMessage(LANG_COMMAND_NO_INSTANCES_MATCH);
|
||||
return false;
|
||||
}
|
||||
auto it = matches.rbegin();
|
||||
@@ -661,10 +639,10 @@ public:
|
||||
mapid = it->second.first;
|
||||
if (++it != matches.rend() && it->first == maxCount)
|
||||
{
|
||||
handler->SendSysMessage("Multiple matches found for your input - please specify:");
|
||||
handler->SendSysMessage(LANG_COMMAND_MULTIPLE_INSTANCES_MATCH);
|
||||
--it;
|
||||
do
|
||||
handler->PSendSysMessage("* Map %03u: '%s'", it->second.first, it->second.second);
|
||||
handler->PSendSysMessage(LANG_COMMAND_MULTIPLE_INSTANCES_ENTRY, it->second.first, it->second.second);
|
||||
while (++it != matches.rend() && it->first == maxCount);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
@@ -676,42 +654,43 @@ public:
|
||||
InstanceTemplate const* temp = sObjectMgr->GetInstanceTemplate(mapid);
|
||||
if (!temp)
|
||||
{
|
||||
handler->PSendSysMessage("Map %u is not instanced", mapid);
|
||||
handler->PSendSysMessage(LANG_COMMAND_MAP_NOT_INSTANCE, mapid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
std::string const& scriptname = sObjectMgr->GetScriptName(temp->ScriptId);
|
||||
|
||||
AreaTrigger const* entrance = sObjectMgr->GetMapEntranceTrigger(mapid);
|
||||
if (!entrance)
|
||||
{
|
||||
handler->PSendSysMessage("Could not find entrance for instance %u (%s)", mapid, scriptname);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
if (player->IsInFlight())
|
||||
player->FinishTaxiFlight();
|
||||
else
|
||||
player->SaveRecallPosition();
|
||||
|
||||
if (player->TeleportTo(entrance->target_mapId, entrance->target_X, entrance->target_Y, entrance->target_Z, entrance->target_Orientation))
|
||||
handler->PSendSysMessage("Teleported you to entrance of mapid %u (%s)", mapid, scriptname);
|
||||
else
|
||||
// try going to entrance
|
||||
AreaTrigger const* exit = sObjectMgr->GetGoBackTrigger(mapid);
|
||||
if (!exit)
|
||||
handler->PSendSysMessage(LANG_COMMAND_INSTANCE_NO_EXIT, mapid, scriptname);
|
||||
|
||||
if (exit && player->TeleportTo(exit->target_mapId, exit->target_X, exit->target_Y, exit->target_Z, exit->target_Orientation + M_PI))
|
||||
{
|
||||
AreaTrigger const* exit = sObjectMgr->GetGoBackTrigger(mapid);
|
||||
if (player->TeleportTo(exit->target_mapId, exit->target_X, exit->target_Y, exit->target_Z, exit->target_Orientation + M_PI))
|
||||
handler->PSendSysMessage("Teleported you in front of entrance to mapid %u (%s)", mapid, scriptname);
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage("Failed to teleport you to entrance of mapid %u (%s) - missing attunement/expansion for parent map?", mapid, scriptname);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
handler->PSendSysMessage(LANG_COMMAND_WENT_TO_INSTANCE_GATE, mapid, scriptname);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
// try going to start
|
||||
AreaTrigger const* entrance = sObjectMgr->GetMapEntranceTrigger(mapid);
|
||||
if (!entrance)
|
||||
handler->PSendSysMessage(LANG_COMMAND_INSTANCE_NO_ENTRANCE, mapid, scriptname);
|
||||
|
||||
if (entrance && player->TeleportTo(entrance->target_mapId, entrance->target_X, entrance->target_Y, entrance->target_Z, entrance->target_Orientation))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_WENT_TO_INSTANCE_START, mapid, scriptname);
|
||||
return true;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_GO_INSTANCE_FAILED, mapid, scriptname, exit->target_mapId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user