Core/Scripts Part 1 of moving all commands to commandscripts

closes issue 4669
(first 5 patches rolled into 1)
Patch by Paradox

--HG--
branch : trunk
This commit is contained in:
Paradox
2010-11-09 10:15:35 -05:00
parent 2da116a417
commit de1798e4ac
23 changed files with 6903 additions and 6482 deletions

View File

@@ -25,6 +25,8 @@ endif()
message(STATUS "SCRIPT PREPARATIONS")
include(Spells/CMakeLists.txt)
include(Commands/CMakeLists.txt)
include(Examples/CMakeLists.txt)
set(scripts_STAT_SRCS
@@ -72,7 +74,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/server/collision/Management
${CMAKE_SOURCE_DIR}/src/server/shared
${CMAKE_SOURCE_DIR}/src/server/shared/Database
${CMAKE_SOURCE_DIR}/src/server/game/Account
${CMAKE_SOURCE_DIR}/src/server/game/Accounts
${CMAKE_SOURCE_DIR}/src/server/game/Achievements
${CMAKE_SOURCE_DIR}/src/server/game/Addons
${CMAKE_SOURCE_DIR}/src/server/game/AI
@@ -117,6 +119,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/server/game/Miscellaneous
${CMAKE_SOURCE_DIR}/src/server/game/Maps
${CMAKE_SOURCE_DIR}/src/server/game/Movement
${CMAKE_SOURCE_DIR}/src/server/game/Movement/MovementGenerators
${CMAKE_SOURCE_DIR}/src/server/game/Movement/Waypoints
${CMAKE_SOURCE_DIR}/src/server/game/Opcodes
${CMAKE_SOURCE_DIR}/src/server/game/OutdoorPvP
@@ -131,6 +134,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/server/game/Skills
${CMAKE_SOURCE_DIR}/src/server/game/Spells
${CMAKE_SOURCE_DIR}/src/server/game/Spells/Auras
${CMAKE_SOURCE_DIR}/src/server/game/Tickets
${CMAKE_SOURCE_DIR}/src/server/game/Tools
${CMAKE_SOURCE_DIR}/src/server/game/Weather
${CMAKE_SOURCE_DIR}/src/server/game/World

View File

@@ -0,0 +1,101 @@
set(scripts_STAT_SRCS
${scripts_STAT_SRCS}
Commands/cs_account.cpp
Commands/cs_achievement.cpp
Commands/cs_gm.cpp
Commands/cs_npc.cpp
Commands/cs_go.cpp
Commands/cs_learn.cpp
Commands/cs_modify.cpp
Commands/cs_debug.cpp
# Commands/cs_tele.cpp
# Commands/cs_character.cpp
# Commands/cs_event.cpp
# Commands/cs_gobject.cpp
# Commands/cs_honor.cpp
# Commands/cs_wp.cpp
# Commands/cs_titles.cpp
# Commands/cs_quest.cpp
# Commands/cs_reload.cpp
# Commands/cs_list.cpp
# Commands/cs_lookup.cpp
# Commands/cs_pdump.cpp
# Commands/cs_guild.cpp
# Commands/cs_cast.cpp
# Commands/cs_reset.cpp
# Commands/cs_instance.cpp
# Commands/cs_server.cpp
# Commands/cs_channel.cpp
# Commands/cs_pet.cpp
# Commands/cs_loadpath.cpp
# Commands/cs_ticket.cpp
# Commands/cs_aura.cpp
# Commands/cs_unaura.cpp
# Commands/cs_nameannounce.cpp
# Commands/cs_gmnameannounce.cpp
# Commands/cs_announce.cpp
# Commands/cs_gmannounce.cpp
# Commands/cs_notify.cpp
# Commands/cs_gmnotify.cpp
# Commands/cs_appear.cpp
# Commands/cs_summon.cpp
# Commands/cs_groupsummon.cpp
# Commands/cs_commands.cpp
# Commands/cs_demorph.cpp
# Commands/cs_die.cpp
# Commands/cs_revive.cpp
# Commands/cs_dismount.cpp
# Commands/cs_gps.cpp
# Commands/cs_guid.cpp
# Commands/cs_help.cpp
# Commands/cs_itemmove.cpp
# Commands/cs_cooldown.cpp
# Commands/cs_unlearn.cpp
# Commands/cs_distance.cpp
# Commands/cs_recall.cpp
# Commands/cs_save.cpp
# Commands/cs_saveall.cpp
# Commands/cs_kick.cpp
# Commands/cs_ban.cpp
# Commands/cs_unban.cpp
# Commands/cs_baninfo.cpp
# Commands/cs_banlist.cpp
# Commands/cs_start.cpp
# Commands/cs_taxicheat.cpp
# Commands/cs_linkgrave.cpp
# Commands/cs_neargrave.cpp
# Commands/cs_explorecheat.cpp
# Commands/cs_hover.cpp
# Commands/cs_levelup.cpp
# Commands/cs_showarea.cpp
# Commands/cs_hidearea.cpp
# Commands/cs_additem.cpp
# Commands/cs_additemset.cpp
# Commands/cs_bank.cpp
# Commands/cs_wchange.cpp
# Commands/cs_maxskill.cpp
# Commands/cs_setskill.cpp
# Commands/cs_whispers.cpp
# Commands/cs_pinfo.cpp
# Commands/cs_respawn.cpp
# Commands/cs_send.cpp
# Commands/cs_mute.cpp
# Commands/cs_unmute.cpp
# Commands/cs_movegens.cpp
# Commands/cs_cometome.cpp
# Commands/cs_damage.cpp
# Commands/cs_combatstop.cpp
# Commands/cs_flusharenapoints.cpp
# Commands/cs_repairitems.cpp
# Commands/cs_waterwalk.cpp
# Commands/cs_freeze.cpp
# Commands/cs_unfreeze.cpp
# Commands/cs_listfreeze.cpp
# Commands/cs_possess.cpp
# Commands/cs_unpossess.cpp
# Commands/cs_bindsight.cpp
# Commands/cs_unbindsight.cpp
# Commands/cs_playall.cpp
)
message(" -> Prepared: Commands")

View File

@@ -0,0 +1,555 @@
/*
* Copyright (C) 2008-2010 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: account_commandscript
%Complete: 100
Comment: All account related commands
Category: commandscripts
EndScriptData */
#include "ScriptPCH.h"
#include "AccountMgr.h"
class account_commandscript : public CommandScript
{
public:
account_commandscript() : CommandScript("account_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand accountSetCommandTable[] =
{
{ "addon", SEC_ADMINISTRATOR, true, &HandleAccountSetAddonCommand, "", NULL },
{ "gmlevel", SEC_CONSOLE, true, &HandleAccountSetGmLevelCommand, "", NULL },
{ "password", SEC_CONSOLE, true, &HandleAccountSetPasswordCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand accountCommandTable[] =
{
{ "addon", SEC_MODERATOR, false, &HandleAccountAddonCommand, "", NULL },
{ "create", SEC_CONSOLE, true, &HandleAccountCreateCommand, "", NULL },
{ "delete", SEC_CONSOLE, true, &HandleAccountDeleteCommand, "", NULL },
{ "onlinelist", SEC_CONSOLE, true, &HandleAccountOnlineListCommand, "", NULL },
{ "lock", SEC_PLAYER, false, &HandleAccountLockCommand, "", NULL },
{ "set", SEC_ADMINISTRATOR, true, NULL, "", accountSetCommandTable },
{ "password", SEC_PLAYER, false, &HandleAccountPasswordCommand, "", NULL },
{ "", SEC_PLAYER, false, &HandleAccountCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "account", SEC_PLAYER, true, NULL, "", accountCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
static bool HandleAccountAddonCommand(ChatHandler* handler, const char* args)
{
if (!*args)
{
handler->SendSysMessage(LANG_CMD_SYNTAX);
handler->SetSentErrorMessage(true);
return false;
}
char *szExp = strtok((char*)args, " ");
uint32 account_id = handler->GetSession()->GetAccountId();
int expansion = atoi(szExp); //get int anyway (0 if error)
if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION))
{
handler->SendSysMessage(LANG_IMPROPER_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
// No SQL injection
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id);
handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
return true;
}
/// Create an account
static bool HandleAccountCreateCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
///- %Parse the command line arguments
char *szAcc = strtok((char*)args, " ");
char *szPassword = strtok(NULL, " ");
if (!szAcc || !szPassword)
return false;
// normalized in sAccountMgr.CreateAccount
std::string account_name = szAcc;
std::string password = szPassword;
AccountOpResult result = sAccountMgr.CreateAccount(account_name, password);
switch(result)
{
case AOR_OK:
handler->PSendSysMessage(LANG_ACCOUNT_CREATED,account_name.c_str());
break;
case AOR_NAME_TOO_LONG:
handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG);
handler->SetSentErrorMessage(true);
return false;
case AOR_NAME_ALREDY_EXIST:
handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST);
handler->SetSentErrorMessage(true);
return false;
case AOR_DB_INTERNAL_ERROR:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
}
return true;
}
/// Delete a user account and all associated characters in this realm
/// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm, delete account chars in realm then delete account
static bool HandleAccountDeleteCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
///- Get the account name from the command line
char *account_name_str=strtok ((char*)args," ");
if (!account_name_str)
return false;
std::string account_name = account_name_str;
if (!AccountMgr::normalizeString(account_name))
{
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
}
uint32 account_id = sAccountMgr.GetId(account_name);
if (!account_id)
{
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
}
/// Commands not recommended call from chat, but support anyway
/// can delete only for account with less security
/// This is also reject self apply in fact
if (handler->HasLowerSecurityAccount (NULL,account_id,true))
return false;
AccountOpResult result = sAccountMgr.DeleteAccount(account_id);
switch(result)
{
case AOR_OK:
handler->PSendSysMessage(LANG_ACCOUNT_DELETED,account_name.c_str());
break;
case AOR_NAME_NOT_EXIST:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
case AOR_DB_INTERNAL_ERROR:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
}
return true;
}
/// Display info on users currently in the realm
static bool HandleAccountOnlineListCommand(ChatHandler* handler, const char* /*args*/)
{
///- Get the list of accounts ID logged to the realm
QueryResult resultDB = CharacterDatabase.Query("SELECT name,account,map,zone FROM characters WHERE online > 0");
if (!resultDB)
{
handler->SendSysMessage(LANG_ACCOUNT_LIST_EMPTY);
return true;
}
///- Display the list of account/characters online
handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR_HEADER);
handler->SendSysMessage(LANG_ACCOUNT_LIST_HEADER);
handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
///- Circle through accounts
do
{
Field *fieldsDB = resultDB->Fetch();
std::string name = fieldsDB[0].GetString();
uint32 account = fieldsDB[1].GetUInt32();
///- Get the username, last IP and GM level of each account
// No SQL injection. account is uint32.
QueryResult resultLogin =
LoginDatabase.PQuery("SELECT a.username, a.last_ip, aa.gmlevel, a.expansion "
"FROM account a "
"LEFT JOIN account_access aa "
"ON (a.id = aa.id) "
"WHERE a.id = '%u'", account);
if (resultLogin)
{
Field *fieldsLogin = resultLogin->Fetch();
handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE,
fieldsLogin[0].GetCString(),name.c_str(),fieldsLogin[1].GetCString(),fieldsDB[2].GetInt32(),fieldsDB[3].GetInt32(),fieldsLogin[3].GetUInt32(),fieldsLogin[2].GetUInt32());
}
else
handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR,name.c_str());
}while (resultDB->NextRow());
handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
return true;
}
static bool HandleAccountLockCommand(ChatHandler* handler, const char* args)
{
if (!*args)
{
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
std::string argstr = (char*)args;
if (argstr == "on")
{
LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'",handler->GetSession()->GetAccountId());
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
return true;
}
if (argstr == "off")
{
LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'",handler->GetSession()->GetAccountId());
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
return true;
}
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
static bool HandleAccountPasswordCommand(ChatHandler* handler, const char* args)
{
if (!*args)
{
handler->SendSysMessage(LANG_CMD_SYNTAX);
handler->SetSentErrorMessage(true);
return false;
}
char *old_pass = strtok((char*)args, " ");
char *new_pass = strtok(NULL, " ");
char *new_pass_c = strtok(NULL, " ");
if (!old_pass || !new_pass || !new_pass_c)
{
handler->SendSysMessage(LANG_CMD_SYNTAX);
handler->SetSentErrorMessage(true);
return false;
}
std::string password_old = old_pass;
std::string password_new = new_pass;
std::string password_new_c = new_pass_c;
if (!sAccountMgr.CheckPassword(handler->GetSession()->GetAccountId(), password_old))
{
handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
handler->SetSentErrorMessage(true);
return false;
}
if (strcmp(new_pass, new_pass_c) != 0)
{
handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
handler->SetSentErrorMessage(true);
return false;
}
AccountOpResult result = sAccountMgr.ChangePassword(handler->GetSession()->GetAccountId(), password_new);
switch(result)
{
case AOR_OK:
handler->SendSysMessage(LANG_COMMAND_PASSWORD);
break;
case AOR_PASS_TOO_LONG:
handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
handler->SetSentErrorMessage(true);
return false;
default:
handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
handler->SetSentErrorMessage(true);
return false;
}
return true;
}
static bool HandleAccountCommand(ChatHandler* handler, const char* /*args*/)
{
AccountTypes gmlevel = handler->GetSession()->GetSecurity();
handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel));
return true;
}
/// Set/Unset the expansion level for an account
static bool HandleAccountSetAddonCommand(ChatHandler* handler, const char *args)
{
///- Get the command line arguments
char *szAcc = strtok((char*)args," ");
char *szExp = strtok(NULL," ");
if (!szAcc)
return false;
std::string account_name;
uint32 account_id;
if (!szExp)
{
Player* player = handler->getSelectedPlayer();
if (!player)
return false;
account_id = player->GetSession()->GetAccountId();
sAccountMgr.GetName(account_id,account_name);
szExp = szAcc;
}
else
{
///- Convert Account name to Upper Format
account_name = szAcc;
if (!AccountMgr::normalizeString(account_name))
{
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
}
account_id = sAccountMgr.GetId(account_name);
if (!account_id)
{
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
}
}
// Let set addon state only for lesser (strong) security level
// or to self account
if (handler->GetSession() && handler->GetSession()->GetAccountId () != account_id &&
handler->HasLowerSecurityAccount (NULL,account_id,true))
return false;
int expansion = atoi(szExp); //get int anyway (0 if error)
if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION))
return false;
// No SQL injection
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",expansion,account_id);
handler->PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,expansion);
return true;
}
static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, const char *args)
{
if (!*args)
return false;
std::string targetAccountName;
uint32 targetAccountId = 0;
uint32 targetSecurity = 0;
uint32 gm = 0;
char* arg1 = strtok((char*)args, " ");
char* arg2 = strtok(NULL, " ");
char* arg3 = strtok(NULL, " ");
bool isAccountNameGiven = true;
if (arg1 && !arg3)
{
if (!handler->getSelectedPlayer())
return false;
isAccountNameGiven = false;
}
// Check for second parameter
if (!isAccountNameGiven && !arg2)
return false;
// Check for account
if (isAccountNameGiven)
{
targetAccountName = arg1;
if (!AccountMgr::normalizeString(targetAccountName))
{
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str());
handler->SetSentErrorMessage(true);
return false;
}
}
// Check for invalid specified GM level.
gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1);
if (gm > SEC_CONSOLE)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
// handler->getSession() == NULL only for console
targetAccountId = (isAccountNameGiven) ? sAccountMgr.GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
uint32 plSecurity;
if (handler->GetSession())
plSecurity = sAccountMgr.GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
else
plSecurity = SEC_CONSOLE;
// can set security level only for target with less security and to less security that we have
// This is also reject self apply in fact
targetSecurity = sAccountMgr.GetSecurity(targetAccountId, gmRealmID);
if (targetSecurity >= plSecurity || gm >= plSecurity)
{
handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
handler->SetSentErrorMessage(true);
return false;
}
// Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1
if (gmRealmID == -1)
{
QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm);
if (result)
{
handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
handler->SetSentErrorMessage(true);
return false;
}
}
// Check if provided realmID has a negative value other than -1
if (gmRealmID < -1)
{
handler->SendSysMessage(LANG_INVALID_REALMID);
handler->SetSentErrorMessage(true);
return false;
}
// If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID
if (gmRealmID == -1)
LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId);
else
LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID);
if (gm != 0)
LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID);
handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
return true;
}
/// Set password for account
static bool HandleAccountSetPasswordCommand(ChatHandler* handler, const char *args)
{
if (!*args)
return false;
///- Get the command line arguments
char *szAccount = strtok ((char*)args," ");
char *szPassword1 = strtok (NULL," ");
char *szPassword2 = strtok (NULL," ");
if (!szAccount||!szPassword1 || !szPassword2)
return false;
std::string account_name = szAccount;
if (!AccountMgr::normalizeString(account_name))
{
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
}
uint32 targetAccountId = sAccountMgr.GetId(account_name);
if (!targetAccountId)
{
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
}
/// can set password only for target with less security
/// This is also reject self apply in fact
if (handler->HasLowerSecurityAccount (NULL,targetAccountId,true))
return false;
if (strcmp(szPassword1,szPassword2))
{
handler->SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH);
handler->SetSentErrorMessage (true);
return false;
}
AccountOpResult result = sAccountMgr.ChangePassword(targetAccountId, szPassword1);
switch (result)
{
case AOR_OK:
handler->SendSysMessage(LANG_COMMAND_PASSWORD);
break;
case AOR_NAME_NOT_EXIST:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
handler->SetSentErrorMessage(true);
return false;
case AOR_PASS_TOO_LONG:
handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
handler->SetSentErrorMessage(true);
return false;
default:
handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
handler->SetSentErrorMessage(true);
return false;
}
return true;
}
};
void AddSC_account_commandscript()
{
new account_commandscript();
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2008-2010 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: achievement_commandscript
%Complete: 100
Comment: All achievement related commands
Category: commandscripts
EndScriptData */
#include "ScriptPCH.h"
#include "Chat.h"
class achievement_commandscript : public CommandScript
{
public:
achievement_commandscript() : CommandScript("achievement_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand achievementCommandTable[] =
{
{ "add", SEC_ADMINISTRATOR, false, &HandleAchievementAddCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "achievement", SEC_ADMINISTRATOR, false, NULL, "", achievementCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
static bool HandleAchievementAddCommand(ChatHandler* handler, const char *args)
{
if (!*args)
return false;
uint32 achievementId = atoi((char*)args);
if (!achievementId)
{
if (char* cId = handler->extractKeyFromLink((char*)args, "Hachievement"))
achievementId = atoi(cId);
if (!achievementId)
return false;
}
Player* target = handler->getSelectedPlayer();
if (!target)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId))
target->CompletedAchievement(pAE, true);
return true;
}
};
void AddSC_achievement_commandscript()
{
new achievement_commandscript();
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,243 @@
/*
* Copyright (C) 2008-2010 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: gm_commandscript
%Complete: 100
Comment: All gm related commands
Category: commandscripts
EndScriptData */
#include "ScriptPCH.h"
class gm_commandscript : public CommandScript
{
public:
gm_commandscript() : CommandScript("gm_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand gmCommandTable[] =
{
{ "chat", SEC_MODERATOR, false, &HandleGMChatCommand, "", NULL },
{ "fly", SEC_ADMINISTRATOR, false, &HandleGMFlyCommand, "", NULL },
{ "ingame", SEC_PLAYER, true, &HandleGMListIngameCommand, "", NULL },
{ "list", SEC_ADMINISTRATOR, true, &HandleGMListFullCommand, "", NULL },
{ "visible", SEC_MODERATOR, false, &HandleGMVisibleCommand, "", NULL },
{ "", SEC_MODERATOR, false, &HandleGMCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "gm", SEC_MODERATOR, true, NULL, "", gmCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
// Enables or disables hiding of the staff badge
static bool HandleGMChatCommand(ChatHandler* handler, const char* args)
{
if (!*args)
{
if (handler->GetSession()->GetPlayer()->isGMChat())
handler->GetSession()->SendNotification(LANG_GM_CHAT_ON);
else
handler->GetSession()->SendNotification(LANG_GM_CHAT_OFF);
return true;
}
std::string argstr = (char*)args;
if (argstr == "on")
{
handler->GetSession()->GetPlayer()->SetGMChat(true);
handler->GetSession()->SendNotification(LANG_GM_CHAT_ON);
return true;
}
if (argstr == "off")
{
handler->GetSession()->GetPlayer()->SetGMChat(false);
handler->GetSession()->SendNotification(LANG_GM_CHAT_OFF);
return true;
}
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
static bool HandleGMFlyCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player *target = handler->getSelectedPlayer();
if (!target)
target = handler->GetSession()->GetPlayer();
WorldPacket data(12);
if (strncmp(args, "on", 3) == 0)
data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
else if (strncmp(args, "off", 4) == 0)
data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY);
else
{
handler->SendSysMessage(LANG_USE_BOL);
return false;
}
data.append(target->GetPackGUID());
data << uint32(0); // unknown
target->SendMessageToSet(&data, true);
handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target).c_str(), args);
return true;
}
static bool HandleGMListIngameCommand(ChatHandler* handler, const char* /*args*/)
{
bool first = true;
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true);
HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
AccountTypes itr_sec = itr->second->GetSession()->GetSecurity();
if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= AccountTypes(sWorld.getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
(!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer())))
{
if (first)
{
handler->SendSysMessage(LANG_GMS_ON_SRV);
first = false;
}
handler->SendSysMessage(handler->GetNameLink(itr->second).c_str());
}
}
if (first)
handler->SendSysMessage(LANG_GMS_NOT_LOGGED);
return true;
}
/// Display the list of GMs
static bool HandleGMListFullCommand(ChatHandler* handler, const char* /*args*/)
{
///- Get the accounts with GM Level >0
QueryResult result = LoginDatabase.Query("SELECT a.username,aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel > 0");
if (result)
{
handler->SendSysMessage(LANG_GMLIST);
handler->SendSysMessage(" ======================== ");
handler->SendSysMessage(LANG_GMLIST_HEADER);
handler->SendSysMessage(" ======================== ");
///- Cycle through them. Display username and GM level
do
{
Field *fields = result->Fetch();
handler->PSendSysMessage("|%15s|%6s|", fields[0].GetCString(),fields[1].GetCString());
}
while (result->NextRow());
handler->PSendSysMessage(" ======================== ");
}
else
handler->PSendSysMessage(LANG_GMLIST_EMPTY);
return true;
}
//Enable\Disable Invisible mode
static bool HandleGMVisibleCommand(ChatHandler* handler, const char* args)
{
if (!*args)
{
handler->PSendSysMessage(LANG_YOU_ARE, handler->GetSession()->GetPlayer()->isGMVisible() ? handler->GetTrinityString(LANG_VISIBLE) : handler->GetTrinityString(LANG_INVISIBLE));
return true;
}
std::string argstr = (char*)args;
if (argstr == "on")
{
handler->GetSession()->GetPlayer()->SetGMVisible(true);
handler->GetSession()->SendNotification(LANG_INVISIBLE_VISIBLE);
return true;
}
if (argstr == "off")
{
handler->GetSession()->SendNotification(LANG_INVISIBLE_INVISIBLE);
handler->GetSession()->GetPlayer()->SetGMVisible(false);
return true;
}
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
//Enable\Disable GM Mode
static bool HandleGMCommand(ChatHandler* handler, const char* args)
{
if (!*args)
{
if (handler->GetSession()->GetPlayer()->isGameMaster())
handler->GetSession()->SendNotification(LANG_GM_ON);
else
handler->GetSession()->SendNotification(LANG_GM_OFF);
return true;
}
std::string argstr = (char*)args;
if (argstr == "on")
{
handler->GetSession()->GetPlayer()->SetGameMaster(true);
handler->GetSession()->SendNotification(LANG_GM_ON);
handler->GetSession()->GetPlayer()->UpdateTriggerVisibility();
#ifdef _DEBUG_VMAPS
VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
vMapManager->processCommand("stoplog");
#endif
return true;
}
if (argstr == "off")
{
handler->GetSession()->GetPlayer()->SetGameMaster(false);
handler->GetSession()->SendNotification(LANG_GM_OFF);
handler->GetSession()->GetPlayer()->UpdateTriggerVisibility();
#ifdef _DEBUG_VMAPS
VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
vMapManager->processCommand("startlog");
#endif
return true;
}
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
};
void AddSC_gm_commandscript()
{
new gm_commandscript();
}

View File

@@ -0,0 +1,617 @@
/*
* Copyright (C) 2008-2010 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: go_commandscript
%Complete: 100
Comment: All go related commands
Category: commandscripts
EndScriptData */
#include "ScriptPCH.h"
#include "MapManager.h"
#include "TicketMgr.h"
class go_commandscript : public CommandScript
{
public:
go_commandscript() : CommandScript("go_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand goCommandTable[] =
{
{ "creature", SEC_MODERATOR, false, &HandleGoCreatureCommand, "", NULL },
{ "graveyard", SEC_MODERATOR, false, &HandleGoGraveyardCommand, "", NULL },
{ "grid", SEC_MODERATOR, false, &HandleGoGridCommand, "", NULL },
{ "object", SEC_MODERATOR, false, &HandleGoObjectCommand, "", NULL },
{ "taxinode", SEC_MODERATOR, false, &HandleGoTaxinodeCommand, "", NULL },
{ "trigger", SEC_MODERATOR, false, &HandleGoTriggerCommand, "", NULL },
{ "zonexy", SEC_MODERATOR, false, &HandleGoZoneXYCommand, "", NULL },
{ "xy", SEC_MODERATOR, false, &HandleGoXYCommand, "", NULL },
{ "xyz", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL },
{ "ticket", SEC_MODERATOR, false, &HandleGoTicketCommand, "", NULL },
{ "", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "go", SEC_MODERATOR, false, NULL, "", goCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
/** \brief Teleport the GM to the specified creature
*
* .gocreature <GUID> --> TP using creature.guid
* .gocreature azuregos --> TP player to the mob with this name
* Warning: If there is more than one mob with this name
* you will be teleported to the first one that is found.
* .gocreature id 6109 --> TP player to the mob, that has this creature_template.entry
* Warning: If there is more than one mob with this "id"
* you will be teleported to the first one that is found.
*/
//teleport to creature
static bool HandleGoCreatureCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* _player = handler->GetSession()->GetPlayer();
// "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
char* pParam1 = handler->extractKeyFromLink((char*)args,"Hcreature");
if (!pParam1)
return false;
std::ostringstream whereClause;
// User wants to teleport to the NPC's template entry
if (strcmp(pParam1, "id") == 0)
{
//sLog.outError("DEBUG: ID found");
// Get the "creature_template.entry"
// number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
char* tail = strtok(NULL,"");
if (!tail)
return false;
char* cId = handler->extractKeyFromLink(tail,"Hcreature_entry");
if (!cId)
return false;
int32 tEntry = atoi(cId);
//sLog.outError("DEBUG: ID value: %d", tEntry);
if (!tEntry)
return false;
whereClause << "WHERE id = '" << tEntry << "'";
}
else
{
//sLog.outError("DEBUG: ID *not found*");
int32 guid = atoi(pParam1);
// Number is invalid - maybe the user specified the mob's name
if (!guid)
{
std::string name = pParam1;
WorldDatabase.escape_string(name);
whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << "'";
}
else
{
whereClause << "WHERE guid = '" << guid << "'";
}
}
//sLog.outError("DEBUG: %s", whereClause.c_str());
QueryResult result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM creature %s", whereClause.str().c_str());
if (!result)
{
handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);
handler->SetSentErrorMessage(true);
return false;
}
if (result->GetRowCount() > 1)
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
Field *fields = result->Fetch();
float x = fields[0].GetFloat();
float y = fields[1].GetFloat();
float z = fields[2].GetFloat();
float ort = fields[3].GetFloat();
int mapid = fields[4].GetUInt16();
if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
_player->TeleportTo(mapid, x, y, z, ort);
return true;
}
static bool HandleGoGraveyardCommand(ChatHandler* handler, const char* args)
{
Player* _player = handler->GetSession()->GetPlayer();
if (!*args)
return false;
char *gyId = strtok((char*)args, " ");
if (!gyId)
return false;
int32 i_gyId = atoi(gyId);
if (!i_gyId)
return false;
WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId);
if (!gy)
{
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST,i_gyId);
handler->SetSentErrorMessage(true);
return false;
}
if (!MapManager::IsValidMapCoord(gy->map_id,gy->x,gy->y,gy->z))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,gy->x,gy->y,gy->map_id);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
_player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation());
return true;
}
//teleport to grid
static bool HandleGoGridCommand(ChatHandler* handler, const char* args)
{
if (!*args) return false;
Player* _player = handler->GetSession()->GetPlayer();
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* pmapid = strtok(NULL, " ");
if (!px || !py)
return false;
float grid_x = (float)atof(px);
float grid_y = (float)atof(py);
uint32 mapid;
if (pmapid)
mapid = (uint32)atoi(pmapid);
else mapid = _player->GetMapId();
// center of grid
float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
if (!MapManager::IsValidMapCoord(mapid,x,y))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
Map const *map = sMapMgr.CreateBaseMap(mapid);
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
return true;
}
//teleport to gameobject
static bool HandleGoObjectCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* _player = handler->GetSession()->GetPlayer();
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject");
if (!cId)
return false;
int32 guid = atoi(cId);
if (!guid)
return false;
float x, y, z, ort;
int mapid;
// by DB guid
if (GameObjectData const* go_data = sObjectMgr.GetGOData(guid))
{
x = go_data->posX;
y = go_data->posY;
z = go_data->posZ;
ort = go_data->orientation;
mapid = go_data->mapid;
}
else
{
handler->SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
handler->SetSentErrorMessage(true);
return false;
}
if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
_player->TeleportTo(mapid, x, y, z, ort);
return true;
}
static bool HandleGoTaxinodeCommand(ChatHandler* handler, const char* args)
{
Player* _player = handler->GetSession()->GetPlayer();
if (!*args)
return false;
char* cNodeId = handler->extractKeyFromLink((char*)args,"Htaxinode");
if (!cNodeId)
return false;
int32 i_nodeId = atoi(cNodeId);
if (!i_nodeId)
return false;
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i_nodeId);
if (!node)
{
handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND,i_nodeId);
handler->SetSentErrorMessage(true);
return false;
}
if ((node->x == 0.0f && node->y == 0.0f && node->z == 0.0f) ||
!MapManager::IsValidMapCoord(node->map_id,node->x,node->y,node->z))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,node->x,node->y,node->map_id);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
_player->TeleportTo(node->map_id, node->x, node->y, node->z, _player->GetOrientation());
return true;
}
static bool HandleGoTriggerCommand(ChatHandler* handler, const char* args)
{
Player* _player = handler->GetSession()->GetPlayer();
if (!*args)
return false;
char *atId = strtok((char*)args, " ");
if (!atId)
return false;
int32 i_atId = atoi(atId);
if (!i_atId)
return false;
AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId);
if (!at)
{
handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND,i_atId);
handler->SetSentErrorMessage(true);
return false;
}
if (!MapManager::IsValidMapCoord(at->mapid,at->x,at->y,at->z))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,at->x,at->y,at->mapid);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
_player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation());
return true;
}
//teleport at coordinates
static bool HandleGoZoneXYCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* _player = handler->GetSession()->GetPlayer();
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* tail = strtok(NULL,"");
char* cAreaId = handler->extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
if (!px || !py)
return false;
float x = (float)atof(px);
float y = (float)atof(py);
// prevent accept wrong numeric args
if ((x == 0.0f && *px != '0') || (y == 0.0f && *py != '0'))
return false;
uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId();
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid);
if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
{
handler->PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid);
handler->SetSentErrorMessage(true);
return false;
}
// update to parent zone if exist (client map show only zones without parents)
AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry;
Map const *map = sMapMgr.CreateBaseMap(zoneEntry->mapid);
if (map->Instanceable())
{
handler->PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[handler->GetSessionDbcLocale()],map->GetId(),map->GetMapName());
handler->SetSentErrorMessage(true);
return false;
}
Zone2MapCoordinates(x,y,zoneEntry->ID);
if (!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation());
return true;
}
//teleport at coordinates
static bool HandleGoXYCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* _player = handler->GetSession()->GetPlayer();
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* pmapid = strtok(NULL, " ");
if (!px || !py)
return false;
float x = (float)atof(px);
float y = (float)atof(py);
uint32 mapid;
if (pmapid)
mapid = (uint32)atoi(pmapid);
else
mapid = _player->GetMapId();
if (!MapManager::IsValidMapCoord(mapid,x,y))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
Map const *map = sMapMgr.CreateBaseMap(mapid);
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
return true;
}
//teleport at coordinates, including Z
static bool HandleGoXYZCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* _player = handler->GetSession()->GetPlayer();
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* pz = strtok(NULL, " ");
char* pmapid = strtok(NULL, " ");
if (!px || !py || !pz)
return false;
float x = (float)atof(px);
float y = (float)atof(py);
float z = (float)atof(pz);
uint32 mapid;
if (pmapid)
mapid = (uint32)atoi(pmapid);
else
mapid = _player->GetMapId();
if (!MapManager::IsValidMapCoord(mapid,x,y,z))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
_player->SaveRecallPosition();
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
return true;
}
static bool HandleGoTicketCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
char *cstrticket_id = strtok((char*)args, " ");
if (!cstrticket_id)
return false;
uint64 ticket_id = atoi(cstrticket_id);
if (!ticket_id)
return false;
GM_Ticket *ticket = sTicketMgr.GetGMTicket(ticket_id);
if (!ticket)
{
handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
return true;
}
float x, y, z;
int mapid;
x = ticket->pos_x;
y = ticket->pos_y;
z = ticket->pos_z;
mapid = ticket->map;
Player* _player = handler->GetSession()->GetPlayer();
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight();
}
else
_player->SaveRecallPosition();
_player->TeleportTo(mapid, x, y, z, 1, 0);
return true;
}
};
void AddSC_go_commandscript()
{
new go_commandscript();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff