Core/Commands: Move .gps to command scripts and add .wpgps command, used for generating partial SQL queries for pathing

This commit is contained in:
Shocker
2011-06-29 16:36:54 +03:00
parent 6a6e3e3265
commit bdba5cd900
8 changed files with 147 additions and 85 deletions
+1
View File
@@ -455,6 +455,7 @@ INSERT INTO `command` VALUES
('gobject target',2,'Syntax: .gobject target [#go_id|#go_name_part]\r\n\r\nLocate and show position nearest gameobject. If #go_id or #go_name_part provide then locate and show position of nearest gameobject with gameobject template id #go_id or name included #go_name_part as part.'),
('gobject turn',2,'Syntax: .gobject turn #goguid \r\n\r\nSet for gameobject #goguid orientation same as current character orientation.'),
('gps',1,'Syntax: .gps [$name|$shift-link]\r\n\r\nDisplay the position information for a selected character or creature (also if player name $name provided then for named player, or if creature/gameobject shift-link provided then pointed creature/gameobject if it loaded). Position information includes X, Y, Z, and orientation, map Id and zone Id'),
('wpgps',3,'Syntax: .wpgps\n\nOutput current position to sql developer log as partial SQL query to be used in pathing'),
('groupsummon',1,'Syntax: .groupsummon [$charactername]\r\n\r\nTeleport the given character and his group to you. Teleported only online characters but original selected group member can be offline.'),
('guid',2,'Syntax: .guid\r\n\r\nDisplay the GUID for the selected character.'),
('guild',3,'Syntax: .guild $subcommand\nType .guild to see the list of possible subcommands or .help guild $subcommand to see info on subcommands'),
@@ -0,0 +1,3 @@
DELETE FROM `command` WHERE `name` = 'wpgps';
INSERT INTO `command` VALUES
('wpgps', '3', 'Syntax: .wpgps\n\nOutput current position to sql developer log as partial SQL query to be used in pathing');
-1
View File
@@ -360,7 +360,6 @@ ChatCommand * ChatHandler::getCommandTable()
{ "die", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDieCommand>, "", NULL },
{ "revive", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReviveCommand>, "", NULL },
{ "dismount", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleDismountCommand>, "", NULL },
{ "gps", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGPSCommand>, "", NULL },
{ "guid", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGUIDCommand>, "", NULL },
{ "help", SEC_PLAYER, true, OldHandler<&ChatHandler::HandleHelpCommand>, "", NULL },
{ "itemmove", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleItemMoveCommand>, "", NULL },
-1
View File
@@ -258,7 +258,6 @@ class ChatHandler
bool HandleRecallCommand(const char* args);
bool HandleAnnounceCommand(const char* args);
bool HandleNotifyCommand(const char* args);
bool HandleGPSCommand(const char* args);
bool HandleTaxiCheatCommand(const char* args);
bool HandleWhispersCommand(const char* args);
-82
View File
@@ -122,88 +122,6 @@ bool ChatHandler::HandleGMNotifyCommand(const char* args)
return true;
}
bool ChatHandler::HandleGPSCommand(const char* args)
{
WorldObject *obj = NULL;
if (*args)
{
uint64 guid = extractGuidFromLink((char*)args);
if (guid)
obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*m_session->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
if (!obj)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
}
else
{
obj = getSelectedUnit();
if (!obj)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
}
CellPair cell_val = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
Cell cell(cell_val);
uint32 zone_id, area_id;
obj->GetZoneAndAreaId(zone_id, area_id);
MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId());
AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id);
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id);
float zone_x = obj->GetPositionX();
float zone_y = obj->GetPositionY();
Map2ZoneCoordinates(zone_x, zone_y, zone_id);
Map const *map = obj->GetMap();
float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
GridPair p = Trinity::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY());
// 63? WHY?
int gx = 63 - p.x_coord;
int gy = 63 - p.y_coord;
uint32 have_map = Map::ExistMap(obj->GetMapId(), gx, gy) ? 1 : 0;
uint32 have_vmap = Map::ExistVMap(obj->GetMapId(), gx, gy) ? 1 : 0;
if (have_vmap)
{
if (map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()))
PSendSysMessage("You are outdoors");
else
PSendSysMessage("You are indoors");
}
else PSendSysMessage("no VMAP available for area info");
PSendSysMessage(LANG_MAP_POSITION,
obj->GetMapId(), (mapEntry ? mapEntry->name[GetSessionDbcLocale()] : "<unknown>"),
zone_id, (zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : "<unknown>"),
area_id, (areaEntry ? areaEntry->area_name[GetSessionDbcLocale()] : "<unknown>"),
obj->GetPhaseMask(),
obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
zone_x, zone_y, ground_z, floor_z, have_map, have_vmap);
LiquidData liquid_status;
ZLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status);
if (res)
{
PSendSysMessage(LANG_LIQUID_STATUS, liquid_status.level, liquid_status.depth_level, liquid_status.type, res);
}
return true;
}
//Summon Player
bool ChatHandler::HandleSummonCommand(const char* args)
{
@@ -59,6 +59,7 @@ void AddSC_reload_commandscript();
void AddSC_tele_commandscript();
void AddSC_titles_commandscript();
void AddSC_wp_commandscript();
void AddSC_gps_commandscript();
#ifdef SCRIPTS
//world
@@ -658,6 +659,7 @@ void AddCommandScripts()
AddSC_tele_commandscript();
AddSC_titles_commandscript();
AddSC_wp_commandscript();
AddSC_gps_commandscript();
}
void AddWorldScripts()
+1 -1
View File
@@ -54,7 +54,7 @@ set(scripts_STAT_SRCS
# Commands/cs_die.cpp
# Commands/cs_revive.cpp
# Commands/cs_dismount.cpp
# Commands/cs_gps.cpp
Commands/cs_gps.cpp
# Commands/cs_guid.cpp
# Commands/cs_help.cpp
# Commands/cs_itemmove.cpp
+140
View File
@@ -0,0 +1,140 @@
/*
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
Name: gps_commandscript
%Complete: 100
Comment: GPS/WPGPS commands
Category: commandscripts
EndScriptData */
#include "ScriptMgr.h"
#include "Chat.h"
class gps_commandscript : public CommandScript
{
public:
gps_commandscript() : CommandScript("gps_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand commandTable[] =
{
{ "gps", SEC_ADMINISTRATOR, false, &HandleGPSCommand, "", NULL },
{ "wpgps", SEC_ADMINISTRATOR, false, &HandleWPGPSCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
static bool HandleGPSCommand(ChatHandler* handler, const char *args)
{
WorldObject *obj = NULL;
if (*args)
{
uint64 guid = handler->extractGuidFromLink((char*)args);
if (guid)
obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
if (!obj)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
return false;
}
}
else
{
obj = handler->getSelectedUnit();
if (!obj)
{
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
}
CellPair cell_val = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
Cell cell(cell_val);
uint32 zone_id, area_id;
obj->GetZoneAndAreaId(zone_id, area_id);
MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId());
AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id);
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id);
float zone_x = obj->GetPositionX();
float zone_y = obj->GetPositionY();
Map2ZoneCoordinates(zone_x, zone_y, zone_id);
Map const *map = obj->GetMap();
float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
GridPair p = Trinity::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY());
// 63? WHY?
int gx = 63 - p.x_coord;
int gy = 63 - p.y_coord;
uint32 have_map = Map::ExistMap(obj->GetMapId(), gx, gy) ? 1 : 0;
uint32 have_vmap = Map::ExistVMap(obj->GetMapId(), gx, gy) ? 1 : 0;
if (have_vmap)
{
if (map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()))
handler->PSendSysMessage("You are outdoors");
else
handler->PSendSysMessage("You are indoors");
}
else handler->PSendSysMessage("no VMAP available for area info");
handler->PSendSysMessage(LANG_MAP_POSITION,
obj->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
zone_id, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
area_id, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
obj->GetPhaseMask(),
obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
zone_x, zone_y, ground_z, floor_z, have_map, have_vmap);
LiquidData liquid_status;
ZLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status);
if (res)
{
handler->PSendSysMessage(LANG_LIQUID_STATUS, liquid_status.level, liquid_status.depth_level, liquid_status.type, res);
}
return true;
}
static bool HandleWPGPSCommand(ChatHandler* handler, const char *args)
{
Player* player = handler->GetSession()->GetPlayer();
sLog->outSQLDev("(@PATH,XX,%.3f,%.3f,%.5f,0,0,0,100,0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
handler->PSendSysMessage("Waypoint SQL written to SQL Developer log");
return true;
}
};
void AddSC_gps_commandscript()
{
new gps_commandscript();
}