diff options
Diffstat (limited to 'src/server/scripts')
44 files changed, 4267 insertions, 3283 deletions
diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 792fdeb3e7b..f148ae2b3ee 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -80,6 +80,8 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/AI/ScriptedAI ${CMAKE_SOURCE_DIR}/src/server/game/AI/SmartScripts ${CMAKE_SOURCE_DIR}/src/server/game/AuctionHouse + ${CMAKE_SOURCE_DIR}/src/server/game/Battlefield + ${CMAKE_SOURCE_DIR}/src/server/game/Battlefield/Zones ${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds ${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds/Zones ${CMAKE_SOURCE_DIR}/src/server/game/Calendar diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index db975419a23..1024a3acf15 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -111,7 +111,7 @@ public: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); if (handler->GetSession()) { - sLog->outDebug(LOG_FILTER_PLAYER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password." + sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password." , handler->GetSession()->GetAccountId(),handler->GetSession()->GetRemoteAddress().c_str() , handler->GetSession()->GetPlayer()->GetName(), handler->GetSession()->GetPlayer()->GetGUIDLow()); } diff --git a/src/server/scripts/Commands/cs_bf.cpp b/src/server/scripts/Commands/cs_bf.cpp new file mode 100644 index 00000000000..7284e6ad6b7 --- /dev/null +++ b/src/server/scripts/Commands/cs_bf.cpp @@ -0,0 +1,180 @@ +/* + * 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: bf_commandscript +%Complete: 100 +Comment: All bf related commands +Category: commandscripts +EndScriptData */ + +#include "ScriptMgr.h" +#include "Chat.h" +#include "BattlefieldMgr.h" + +class bf_commandscript : public CommandScript +{ +public: + bf_commandscript() : CommandScript("bf_commandscript") { } + + ChatCommand* GetCommands() const + { + static ChatCommand battlefieldcommandTable[] = + { + { "start", SEC_ADMINISTRATOR, false, &HandleBattlefieldStart, "", NULL }, + { "stop", SEC_ADMINISTRATOR, false, &HandleBattlefieldEnd, "", NULL }, + { "switch", SEC_ADMINISTRATOR, false, &HandleBattlefieldSwitch, "", NULL }, + { "timer", SEC_ADMINISTRATOR, false, &HandleBattlefieldTimer, "", NULL }, + { "enable", SEC_ADMINISTRATOR, false, &HandleBattlefieldEnable, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "bf", SEC_ADMINISTRATOR, false, NULL, "", battlefieldcommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + + static bool HandleBattlefieldStart(ChatHandler* handler, const char* args) + { + uint32 battleid = 0; + char* battleid_str = strtok((char*)args, " "); + if (!battleid_str) + return false; + + battleid = atoi(battleid_str); + + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); + + if (!bf) + return false; + + bf->StartBattle(); + + if (battleid == 1) + handler->SendGlobalGMSysMessage("Wintergrasp (Command start used)"); + + return true; + } + + static bool HandleBattlefieldEnd(ChatHandler* handler, const char* args) + { + uint32 battleid = 0; + char* battleid_str = strtok((char*)args, " "); + if (!battleid_str) + return false; + + battleid = atoi(battleid_str); + + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); + + if (!bf) + return false; + + bf->EndBattle(true); + + if (battleid == 1) + handler->SendGlobalGMSysMessage("Wintergrasp (Command stop used)"); + + return true; + } + + static bool HandleBattlefieldEnable(ChatHandler* handler, const char* args) + { + uint32 battleid = 0; + char* battleid_str = strtok((char*)args, " "); + if (!battleid_str) + return false; + + battleid = atoi(battleid_str); + + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); + + if (!bf) + return false; + + if (bf->IsEnabled()) + { + bf->ToggleBattlefield(false); + if (battleid == 1) + handler->SendGlobalGMSysMessage("Wintergrasp is disabled"); + } + else + { + bf->ToggleBattlefield(true); + if (battleid == 1) + handler->SendGlobalGMSysMessage("Wintergrasp is enabled"); + } + + return true; + } + + static bool HandleBattlefieldSwitch(ChatHandler* handler, const char* args) + { + uint32 battleid = 0; + char* battleid_str = strtok((char*)args, " "); + if (!battleid_str) + return false; + + battleid = atoi(battleid_str); + + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); + + if (!bf) + return false; + + bf->EndBattle(false); + if (battleid == 1) + handler->SendGlobalGMSysMessage("Wintergrasp (Command switch used)"); + + return true; + } + + static bool HandleBattlefieldTimer(ChatHandler* handler, const char* args) + { + uint32 battleid = 0; + uint32 time = 0; + char* battleid_str = strtok((char*)args, " "); + if (!battleid_str) + return false; + char* time_str = strtok(NULL, " "); + if (!time_str) + return false; + + battleid = atoi(battleid_str); + + time = atoi(time_str); + + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); + + if (!bf) + return false; + + bf->SetTimer(time * IN_MILLISECONDS); + bf->SendInitWorldStatesToAll(); + if (battleid == 1) + handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)"); + + return true; + } +}; + +void AddSC_bf_commandscript() +{ + new bf_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 355ff195cf5..7f25a11bcdd 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -1325,7 +1325,7 @@ public: { Player* player = handler->GetSession()->GetPlayer(); - sLog->outInfo(LOG_FILTER_SQL, "(@PATH, XX, %.3f, %.3f, %.5f, 0,0, 0,100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + sLog->outInfo(LOG_FILTER_SQL_DEV, "(@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; diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index e7f33885036..0bb376b08dd 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ObjectMgr.h" #include "Chat.h" #include "DisableMgr.h" +#include "OutdoorPvP.h" class disable_commandscript : public CommandScript { @@ -34,56 +35,230 @@ public: ChatCommand* GetCommands() const { - + static ChatCommand removeDisableCommandTable[] = + { + { "spell", SEC_ADMINISTRATOR, true, &HandleRemoveDisableSpellCommand, "", NULL }, + { "quest", SEC_ADMINISTRATOR, true, &HandleRemoveDisableQuestCommand, "", NULL }, + { "map", SEC_ADMINISTRATOR, true, &HandleRemoveDisableMapCommand, "", NULL }, + { "battleground", SEC_ADMINISTRATOR, true, &HandleRemoveDisableBattlegroundCommand, "", NULL }, + { "achievement_criteria", SEC_ADMINISTRATOR, true, &HandleRemoveDisableAchievementCriteriaCommand, "", NULL }, + { "outdoorpvp", SEC_ADMINISTRATOR, true, &HandleRemoveDisableOutdoorPvPCommand, "", NULL }, + { "vmap", SEC_ADMINISTRATOR, true, &HandleRemoveDisableVmapCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand addDisableCommandTable[] = + { + { "spell", SEC_ADMINISTRATOR, true, &HandleAddDisableSpellCommand, "", NULL }, + { "quest", SEC_ADMINISTRATOR, true, &HandleAddDisableQuestCommand, "", NULL }, + { "map", SEC_ADMINISTRATOR, true, &HandleAddDisableMapCommand, "", NULL }, + { "battleground", SEC_ADMINISTRATOR, true, &HandleAddDisableBattlegroundCommand, "", NULL }, + { "achievement_criteria", SEC_ADMINISTRATOR, true, &HandleAddDisableAchievementCriteriaCommand, "", NULL }, + { "outdoorpvp", SEC_ADMINISTRATOR, true, &HandleAddDisableOutdoorPvPCommand, "", NULL }, + { "vmap", SEC_ADMINISTRATOR, true, &HandleAddDisableVmapCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; static ChatCommand disableCommandTable[] = { - { "spell", SEC_GAMEMASTER, false, &HandleDisableSpellCommand, "", NULL }, - { "map", SEC_GAMEMASTER, false, &HandleDisableMapCommand, "", NULL }, - { "battleground", SEC_GAMEMASTER, false, &HandleDisableBattlegroundCommand, "", NULL }, - { "achievement_criteria", SEC_GAMEMASTER, false, &HandleDisableAchievementCriteriaCommand, "", NULL }, - { "outdoorpvp", SEC_GAMEMASTER, false, &HandleDisableOutdoorPvPCommand, "", NULL }, - { "vmap", SEC_GAMEMASTER, false, &HandleDisableVmapCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", SEC_ADMINISTRATOR, true, NULL, "", addDisableCommandTable }, + { "remove", SEC_ADMINISTRATOR, true, NULL, "", removeDisableCommandTable }, + { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand commandTable[] = { - { "disable", SEC_GAMEMASTER, false, NULL, "", disableCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { "disable", SEC_ADMINISTRATOR, false, NULL, "", disableCommandTable }, + { NULL, 0, false, NULL, "", NULL } }; return commandTable; } - - static void HandleDisables(ChatHandler* handler, char const* args, uint8 disableType) + static bool HandleAddDisables(ChatHandler* handler, char const* args, uint8 disableType) { - char* cEntry = strtok((char*)args, " "); - if (!cEntry || !atoi(cEntry)) - { - handler->SendSysMessage("No entry specified."); - return; - } + char* entryStr = strtok((char*)args, " "); + if (!entryStr || !atoi(entryStr)) + return false; + + char* flagsStr = strtok(NULL, " "); + uint8 flags = flagsStr ? uint8(atoi(flagsStr)) : 0; + + char* commentStr = strtok(NULL, ""); + if (!commentStr) + return false; + + std::string disableComment = commentStr; + uint32 entry = uint32(atoi(entryStr)); - char* cFlags = strtok(NULL, " "); - if (!cFlags || !atoi(cFlags)) + std::string disableTypeStr = ""; + + switch (disableType) { - handler->SendSysMessage("No flags specified."); - return; + case DISABLE_TYPE_SPELL: + { + if (!sSpellMgr->GetSpellInfo(entry)) + { + handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); + handler->SetSentErrorMessage(true); + return false; + } + disableTypeStr = "spell"; + break; + } + case DISABLE_TYPE_QUEST: + { + if (!sObjectMgr->GetQuestTemplate(entry)) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); + handler->SetSentErrorMessage(true); + return false; + } + disableTypeStr = "quest"; + break; + } + case DISABLE_TYPE_MAP: + { + if (!sMapStore.LookupEntry(entry)) + { + handler->PSendSysMessage(LANG_COMMAND_NOMAPFOUND); + handler->SetSentErrorMessage(true); + return false; + } + disableTypeStr = "map"; + break; + } + case DISABLE_TYPE_BATTLEGROUND: + { + if (!sBattlemasterListStore.LookupEntry(entry)) + { + handler->PSendSysMessage(LANG_COMMAND_NO_BATTLEGROUND_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + disableTypeStr = "battleground"; + break; + } + case DISABLE_TYPE_ACHIEVEMENT_CRITERIA: + { + if (!sAchievementCriteriaStore.LookupEntry(entry)) + { + handler->PSendSysMessage(LANG_COMMAND_NO_ACHIEVEMENT_CRITERIA_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + disableTypeStr = "achievement criteria"; + break; + } + case DISABLE_TYPE_OUTDOORPVP: + { + if (entry > MAX_OUTDOORPVP_TYPES) + { + handler->PSendSysMessage(LANG_COMMAND_NO_OUTDOOR_PVP_FORUND); + handler->SetSentErrorMessage(true); + return false; + } + disableTypeStr = "outdoorpvp"; + break; + } + case DISABLE_TYPE_VMAP: + { + if (!sMapStore.LookupEntry(entry)) + { + handler->PSendSysMessage(LANG_COMMAND_NOMAPFOUND); + handler->SetSentErrorMessage(true); + return false; + } + disableTypeStr = "vmap"; + break; + } + default: + break; } - char* cComment = strtok(NULL, ""); - if (!cComment) + PreparedStatement* stmt = NULL; + stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); + stmt->setUInt32(0, entry); + stmt->setUInt8(1, disableType); + PreparedQueryResult result = WorldDatabase.Query(stmt); + if (result) { - handler->SendSysMessage("No comment specified."); - return; + handler->PSendSysMessage("This %s (Id: %u) is already disabled.", disableTypeStr.c_str(), entry); + handler->SetSentErrorMessage(true); + return false; } - std::string entryStr = cEntry; - std::string disableComment = cComment; - uint32 entry = (uint32)atoi(cEntry); - uint8 flags = atoi(cFlags); + stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_DISABLES); + stmt->setUInt32(0, entry); + stmt->setUInt8(1, disableType); + stmt->setUInt16(2, flags); + stmt->setString(3, disableComment); + WorldDatabase.Execute(stmt); + + handler->PSendSysMessage("Add Disabled %s (Id: %u) for reason %s", disableTypeStr.c_str(), entry, disableComment.c_str()); + return true; + } + + static bool HandleAddDisableSpellCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + + return HandleAddDisables(handler, args, DISABLE_TYPE_SPELL); + } + + static bool HandleAddDisableQuestCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + + return HandleAddDisables(handler, args, DISABLE_TYPE_QUEST); + } + + static bool HandleAddDisableMapCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + + return HandleAddDisables(handler, args, DISABLE_TYPE_MAP); + } + + static bool HandleAddDisableBattlegroundCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + + return HandleAddDisables(handler, args, DISABLE_TYPE_BATTLEGROUND); + } + + static bool HandleAddDisableAchievementCriteriaCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + + return HandleAddDisables(handler, args, DISABLE_TYPE_ACHIEVEMENT_CRITERIA); + } + + static bool HandleAddDisableOutdoorPvPCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + + HandleAddDisables(handler, args, DISABLE_TYPE_OUTDOORPVP); + return true; + } + + static bool HandleAddDisableVmapCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + return HandleAddDisables(handler, args, DISABLE_TYPE_VMAP); + } + + static bool HandleRemoveDisables(ChatHandler* handler, char const* args, uint8 disableType) + { + char* entryStr = strtok((char*)args, " "); + if (!entryStr || !atoi(entryStr)) + return false; + uint32 entry = uint32(atoi(entryStr)); std::string disableTypeStr = ""; @@ -92,6 +267,9 @@ public: case DISABLE_TYPE_SPELL: disableTypeStr = "spell"; break; + case DISABLE_TYPE_QUEST: + disableTypeStr = "quest"; + break; case DISABLE_TYPE_MAP: disableTypeStr = "map"; break; @@ -109,87 +287,85 @@ public: break; } - PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); + PreparedStatement* stmt = NULL; + stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); stmt->setUInt32(0, entry); stmt->setUInt8(1, disableType); PreparedQueryResult result = WorldDatabase.Query(stmt); - - - if (result) + if (!result) { - handler->PSendSysMessage("This %s (id %u) is already disabled.", disableTypeStr.c_str(), entry); - return; + handler->PSendSysMessage("This %s (Id: %u) is not disabled.", disableTypeStr.c_str(), entry); + handler->SetSentErrorMessage(true); + return false; } - PreparedStatement* stmt2 = WorldDatabase.GetPreparedStatement(WORLD_INS_DISABLES); - stmt2->setUInt32(0, entry); - stmt2->setUInt8(1, disableType); - stmt2->setUInt16(2, flags); - stmt2->setString(3, disableComment); - WorldDatabase.Execute(stmt2); - - handler->PSendSysMessage("Disabled %s %u for reason %s", disableTypeStr.c_str(), entry, disableComment.c_str()); - return; + stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_DISABLES); + stmt->setUInt32(0, entry); + stmt->setUInt8(1, disableType); + WorldDatabase.Execute(stmt); + handler->PSendSysMessage("Remove Disabled %s (Id: %u)", disableTypeStr.c_str(), entry); + return true; } - static bool HandleDisableSpellCommand(ChatHandler* handler, char const* args) + static bool HandleRemoveDisableSpellCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - HandleDisables(handler, args, DISABLE_TYPE_SPELL); - return true; + return HandleRemoveDisables(handler, args, DISABLE_TYPE_SPELL); } - static bool HandleDisableMapCommand(ChatHandler* handler, char const* args) + static bool HandleRemoveDisableQuestCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - HandleDisables(handler, args, DISABLE_TYPE_MAP); - return true; + return HandleRemoveDisables(handler, args, DISABLE_TYPE_QUEST); } - static bool HandleDisableBattlegroundCommand(ChatHandler* handler, char const* args) + static bool HandleRemoveDisableMapCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - HandleDisables(handler, args, DISABLE_TYPE_BATTLEGROUND); - return true; + return HandleAddDisables(handler, args, DISABLE_TYPE_MAP); } - static bool HandleDisableAchievementCriteriaCommand(ChatHandler* handler, char const* args) + static bool HandleRemoveDisableBattlegroundCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - HandleDisables(handler, args, DISABLE_TYPE_ACHIEVEMENT_CRITERIA); - return true; + return HandleRemoveDisables(handler, args, DISABLE_TYPE_BATTLEGROUND); } - static bool HandleDisableOutdoorPvPCommand(ChatHandler* handler, char const* args) + static bool HandleRemoveDisableAchievementCriteriaCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - HandleDisables(handler, args, DISABLE_TYPE_OUTDOORPVP); - return true; + return HandleRemoveDisables(handler, args, DISABLE_TYPE_ACHIEVEMENT_CRITERIA); } - static bool HandleDisableVmapCommand(ChatHandler* handler, char const* args) + static bool HandleRemoveDisableOutdoorPvPCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - HandleDisables(handler, args, DISABLE_TYPE_VMAP); - return true; + return HandleRemoveDisables(handler, args, DISABLE_TYPE_OUTDOORPVP); } + static bool HandleRemoveDisableVmapCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + + return HandleRemoveDisables(handler, args, DISABLE_TYPE_VMAP); + } }; void AddSC_disable_commandscript() { new disable_commandscript(); -}
\ No newline at end of file +} diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 80847d7dec4..1edaaf5bcbf 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1,2879 +1,2879 @@ -/*
- * Copyright (C) 2008-2012 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/>.
- */
-
-#include "Chat.h"
-#include "ScriptMgr.h"
-#include "AccountMgr.h"
-#include "ArenaTeamMgr.h"
-#include "CellImpl.h"
-#include "GridNotifiers.h"
-#include "Group.h"
-#include "InstanceSaveMgr.h"
-#include "MovementGenerator.h"
-#include "ObjectAccessor.h"
-#include "SpellAuras.h"
-#include "TargetedMovementGenerator.h"
-#include "WeatherMgr.h"
-#include "ace/INET_Addr.h"
-
-class misc_commandscript : public CommandScript
-{
-public:
- misc_commandscript() : CommandScript("misc_commandscript") { }
-
- ChatCommand* GetCommands() const
- {
- static ChatCommand groupCommandTable[] =
- {
- { "leader", SEC_ADMINISTRATOR, false, &HandleGroupLeaderCommand, "", NULL },
- { "disband", SEC_ADMINISTRATOR, false, &HandleGroupDisbandCommand, "", NULL },
- { "remove", SEC_ADMINISTRATOR, false, &HandleGroupRemoveCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
- static ChatCommand petCommandTable[] =
- {
- { "create", SEC_GAMEMASTER, false, &HandleCreatePetCommand, "", NULL },
- { "learn", SEC_GAMEMASTER, false, &HandlePetLearnCommand, "", NULL },
- { "unlearn", SEC_GAMEMASTER, false, &HandlePetUnlearnCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
- static ChatCommand sendCommandTable[] =
- {
- { "items", SEC_ADMINISTRATOR, true, &HandleSendItemsCommand, "", NULL },
- { "mail", SEC_MODERATOR, true, &HandleSendMailCommand, "", NULL },
- { "message", SEC_ADMINISTRATOR, true, &HandleSendMessageCommand, "", NULL },
- { "money", SEC_ADMINISTRATOR, true, &HandleSendMoneyCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
- static ChatCommand commandTable[] =
- {
- { "dev", SEC_ADMINISTRATOR, false, &HandleDevCommand, "", NULL },
- { "gps", SEC_ADMINISTRATOR, false, &HandleGPSCommand, "", NULL },
- { "aura", SEC_ADMINISTRATOR, false, &HandleAuraCommand, "", NULL },
- { "unaura", SEC_ADMINISTRATOR, false, &HandleUnAuraCommand, "", NULL },
- { "appear", SEC_MODERATOR, false, &HandleAppearCommand, "", NULL },
- { "summon", SEC_MODERATOR, false, &HandleSummonCommand, "", NULL },
- { "groupsummon", SEC_MODERATOR, false, &HandleGroupSummonCommand, "", NULL },
- { "commands", SEC_PLAYER, true, &HandleCommandsCommand, "", NULL },
- { "die", SEC_ADMINISTRATOR, false, &HandleDieCommand, "", NULL },
- { "revive", SEC_ADMINISTRATOR, true, &HandleReviveCommand, "", NULL },
- { "dismount", SEC_PLAYER, false, &HandleDismountCommand, "", NULL },
- { "guid", SEC_GAMEMASTER, false, &HandleGUIDCommand, "", NULL },
- { "help", SEC_PLAYER, true, &HandleHelpCommand, "", NULL },
- { "itemmove", SEC_GAMEMASTER, false, &HandleItemMoveCommand, "", NULL },
- { "cooldown", SEC_ADMINISTRATOR, false, &HandleCooldownCommand, "", NULL },
- { "distance", SEC_ADMINISTRATOR, false, &HandleGetDistanceCommand, "", NULL },
- { "recall", SEC_MODERATOR, false, &HandleRecallCommand, "", NULL },
- { "save", SEC_PLAYER, false, &HandleSaveCommand, "", NULL },
- { "saveall", SEC_MODERATOR, true, &HandleSaveAllCommand, "", NULL },
- { "kick", SEC_GAMEMASTER, true, &HandleKickPlayerCommand, "", NULL },
- { "start", SEC_PLAYER, false, &HandleStartCommand, "", NULL },
- { "taxicheat", SEC_MODERATOR, false, &HandleTaxiCheatCommand, "", NULL },
- { "linkgrave", SEC_ADMINISTRATOR, false, &HandleLinkGraveCommand, "", NULL },
- { "neargrave", SEC_ADMINISTRATOR, false, &HandleNearGraveCommand, "", NULL },
- { "explorecheat", SEC_ADMINISTRATOR, false, &HandleExploreCheatCommand, "", NULL },
- { "showarea", SEC_ADMINISTRATOR, false, &HandleShowAreaCommand, "", NULL },
- { "hidearea", SEC_ADMINISTRATOR, false, &HandleHideAreaCommand, "", NULL },
- { "additem", SEC_ADMINISTRATOR, false, &HandleAddItemCommand, "", NULL },
- { "additemset", SEC_ADMINISTRATOR, false, &HandleAddItemSetCommand, "", NULL },
- { "bank", SEC_ADMINISTRATOR, false, &HandleBankCommand, "", NULL },
- { "wchange", SEC_ADMINISTRATOR, false, &HandleChangeWeather, "", NULL },
- { "maxskill", SEC_ADMINISTRATOR, false, &HandleMaxSkillCommand, "", NULL },
- { "setskill", SEC_ADMINISTRATOR, false, &HandleSetSkillCommand, "", NULL },
- { "pinfo", SEC_GAMEMASTER, true, &HandlePInfoCommand, "", NULL },
- { "respawn", SEC_ADMINISTRATOR, false, &HandleRespawnCommand, "", NULL },
- { "send", SEC_MODERATOR, true, NULL, "", sendCommandTable },
- { "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable },
- { "mute", SEC_MODERATOR, true, &HandleMuteCommand, "", NULL },
- { "unmute", SEC_MODERATOR, true, &HandleUnmuteCommand, "", NULL },
- { "movegens", SEC_ADMINISTRATOR, false, &HandleMovegensCommand, "", NULL },
- { "cometome", SEC_ADMINISTRATOR, false, &HandleComeToMeCommand, "", NULL },
- { "damage", SEC_ADMINISTRATOR, false, &HandleDamageCommand, "", NULL },
- { "combatstop", SEC_GAMEMASTER, true, &HandleCombatStopCommand, "", NULL },
- { "flusharenapoints", SEC_ADMINISTRATOR, false, &HandleFlushArenaPointsCommand, "", NULL },
- { "repairitems", SEC_GAMEMASTER, true, &HandleRepairitemsCommand, "", NULL },
- { "waterwalk", SEC_GAMEMASTER, false, &HandleWaterwalkCommand, "", NULL },
- { "freeze", SEC_MODERATOR, false, &HandleFreezeCommand, "", NULL },
- { "unfreeze", SEC_MODERATOR, false, &HandleUnFreezeCommand, "", NULL },
- { "listfreeze", SEC_MODERATOR, false, &HandleListFreezeCommand, "", NULL },
- { "group", SEC_ADMINISTRATOR, false, NULL, "", groupCommandTable },
- { "possess", SEC_ADMINISTRATOR, false, HandlePossessCommand, "", NULL },
- { "unpossess", SEC_ADMINISTRATOR, false, HandleUnPossessCommand, "", NULL },
- { "bindsight", SEC_ADMINISTRATOR, false, HandleBindSightCommand, "", NULL },
- { "unbindsight", SEC_ADMINISTRATOR, false, HandleUnbindSightCommand, "", NULL },
- { "playall", SEC_GAMEMASTER, false, HandlePlayAllCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
- return commandTable;
- }
-
- static bool HandleDevCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- {
- if (handler->GetSession()->GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
- handler->GetSession()->SendNotification(LANG_DEV_ON);
- else
- handler->GetSession()->SendNotification(LANG_DEV_OFF);
- return true;
- }
-
- std::string argstr = (char*)args;
-
- if (argstr == "on")
- {
- handler->GetSession()->GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
- handler->GetSession()->SendNotification(LANG_DEV_ON);
- return true;
- }
-
- if (argstr == "off")
- {
- handler->GetSession()->GetPlayer()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
- handler->GetSession()->SendNotification(LANG_DEV_OFF);
- return true;
- }
-
- handler->SendSysMessage(LANG_USE_BOL);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- static bool HandleGPSCommand(ChatHandler* handler, char const* args)
- {
- WorldObject* object = NULL;
- if (*args)
- {
- uint64 guid = handler->extractGuidFromLink((char*)args);
- if (guid)
- object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
-
- if (!object)
- {
- handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
- else
- {
- object = handler->getSelectedUnit();
-
- if (!object)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
-
- CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY());
- Cell cell(cellCoord);
-
- uint32 zoneId, areaId;
- object->GetZoneAndAreaId(zoneId, areaId);
-
- MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
- AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
- AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
-
- float zoneX = object->GetPositionX();
- float zoneY = object->GetPositionY();
-
- Map2ZoneCoordinates(zoneX, zoneY, zoneId);
-
- Map const* map = object->GetMap();
- float groundZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
- float floorZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
-
- GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
-
- // 63? WHY?
- int gridX = 63 - gridCoord.x_coord;
- int gridY = 63 - gridCoord.y_coord;
-
- uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
- uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
-
- if (haveVMap)
- {
- if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->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,
- object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
- zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
- areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
- object->GetPhaseMask(),
- object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
- cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
- zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap);
-
- LiquidData liquidStatus;
- ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus);
-
- if (status)
- handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status);
-
- return true;
- }
-
- static bool HandleAuraCommand(ChatHandler* handler, char const* args)
- {
- Unit* target = handler->getSelectedUnit();
- if (!target)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
- uint32 spellId = handler->extractSpellIdFromLink((char*)args);
-
- if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
- Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, target, target);
-
- return true;
- }
-
- static bool HandleUnAuraCommand(ChatHandler* handler, char const* args)
- {
- Unit* target = handler->getSelectedUnit();
- if (!target)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- std::string argstr = args;
- if (argstr == "all")
- {
- target->RemoveAllAuras();
- return true;
- }
-
- // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
- uint32 spellId = handler->extractSpellIdFromLink((char*)args);
- if (!spellId)
- return false;
-
- target->RemoveAurasDueToSpell(spellId);
-
- return true;
- }
- // Teleport to Player
- static bool HandleAppearCommand(ChatHandler* handler, char const* args)
- {
- Player* target;
- uint64 targetGuid;
- std::string targetName;
- if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
- return false;
-
- Player* _player = handler->GetSession()->GetPlayer();
- if (target == _player || targetGuid == _player->GetGUID())
- {
- handler->SendSysMessage(LANG_CANT_TELEPORT_SELF);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (target)
- {
- // check online security
- if (handler->HasLowerSecurity(target, 0))
- return false;
-
- std::string chrNameLink = handler->playerLink(targetName);
-
- Map* map = target->GetMap();
- if (map->IsBattlegroundOrArena())
- {
- // only allow if gm mode is on
- if (!_player->isGameMaster())
- {
- handler->PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, chrNameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
- // if both players are in different bgs
- else if (_player->GetBattlegroundId() && _player->GetBattlegroundId() != target->GetBattlegroundId())
- _player->LeaveBattleground(false); // Note: should be changed so _player gets no Deserter debuff
-
- // all's well, set bg id
- // when porting out from the bg, it will be reset to 0
- _player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId());
- // remember current position as entry point for return at bg end teleportation
- if (!_player->GetMap()->IsBattlegroundOrArena())
- _player->SetBattlegroundEntryPoint();
- }
- else if (map->IsDungeon())
- {
- // we have to go to instance, and can go to player only if:
- // 1) we are in his group (either as leader or as member)
- // 2) we are not bound to any group and have GM mode on
- if (_player->GetGroup())
- {
- // we are in group, we can go only if we are in the player group
- if (_player->GetGroup() != target->GetGroup())
- {
- handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY, chrNameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
- else
- {
- // we are not in group, let's verify our GM mode
- if (!_player->isGameMaster())
- {
- handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM, chrNameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
-
- // if the player or the player's group is bound to another instance
- // the player will not be bound to another one
- InstancePlayerBind* bind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(map->IsRaid()));
- if (!bind)
- {
- Group* group = _player->GetGroup();
- // if no bind exists, create a solo bind
- InstanceGroupBind* gBind = group ? group->GetBoundInstance(target) : NULL; // if no bind exists, create a solo bind
- if (!gBind)
- if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId()))
- _player->BindToInstance(save, !save->CanReset());
- }
-
- if (map->IsRaid())
- _player->SetRaidDifficulty(target->GetRaidDifficulty());
- else
- _player->SetDungeonDifficulty(target->GetDungeonDifficulty());
- }
-
- handler->PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str());
-
- // stop flight if need
- if (_player->isInFlight())
- {
- _player->GetMotionMaster()->MovementExpired();
- _player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
- else
- _player->SaveRecallPosition();
-
- // to point to see at target with same orientation
- float x, y, z;
- target->GetContactPoint(_player, x, y, z);
-
- _player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE);
- _player->SetPhaseMask(target->GetPhaseMask(), true);
- }
- else
- {
- // check offline security
- if (handler->HasLowerSecurity(NULL, targetGuid))
- return false;
-
- std::string nameLink = handler->playerLink(targetName);
-
- handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
-
- // to point where player stay (if loaded)
- float x, y, z, o;
- uint32 map;
- bool in_flight;
- if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, targetGuid))
- 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(map, x, y, z, _player->GetOrientation());
- }
-
- return true;
- }
- // Summon Player
- static bool HandleSummonCommand(ChatHandler* handler, char const* args)
- {
- Player* target;
- uint64 targetGuid;
- std::string targetName;
- if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
- return false;
-
- Player* _player = handler->GetSession()->GetPlayer();
- if (target == _player || targetGuid == _player->GetGUID())
- {
- handler->PSendSysMessage(LANG_CANT_TELEPORT_SELF);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (target)
- {
- std::string nameLink = handler->playerLink(targetName);
- // check online security
- if (handler->HasLowerSecurity(target, 0))
- return false;
-
- if (target->IsBeingTeleported())
- {
- handler->PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- Map* map = handler->GetSession()->GetPlayer()->GetMap();
-
- if (map->IsBattlegroundOrArena())
- {
- // only allow if gm mode is on
- if (!_player->isGameMaster())
- {
- handler->PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
- // if both players are in different bgs
- else if (target->GetBattlegroundId() && handler->GetSession()->GetPlayer()->GetBattlegroundId() != target->GetBattlegroundId())
- target->LeaveBattleground(false); // Note: should be changed so target gets no Deserter debuff
-
- // all's well, set bg id
- // when porting out from the bg, it will be reset to 0
- target->SetBattlegroundId(handler->GetSession()->GetPlayer()->GetBattlegroundId(), handler->GetSession()->GetPlayer()->GetBattlegroundTypeId());
- // remember current position as entry point for return at bg end teleportation
- if (!target->GetMap()->IsBattlegroundOrArena())
- target->SetBattlegroundEntryPoint();
- }
- else if (map->IsDungeon())
- {
- Map* map = target->GetMap();
-
- if (map->Instanceable() && map->GetInstanceId() != map->GetInstanceId())
- target->UnbindInstance(map->GetInstanceId(), target->GetDungeonDifficulty(), true);
-
- // we are in instance, and can summon only player in our group with us as lead
- if (!handler->GetSession()->GetPlayer()->GetGroup() || !target->GetGroup() ||
- (target->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
- (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()))
- // the last check is a bit excessive, but let it be, just in case
- {
- handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
-
- handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), "");
- if (handler->needReportToTarget(target))
- ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str());
-
- // stop flight if need
- if (target->isInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
- else
- target->SaveRecallPosition();
-
- // before GM
- float x, y, z;
- handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectSize());
- target->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, target->GetOrientation());
- target->SetPhaseMask(handler->GetSession()->GetPlayer()->GetPhaseMask(), true);
- }
- else
- {
- // check offline security
- if (handler->HasLowerSecurity(NULL, targetGuid))
- return false;
-
- std::string nameLink = handler->playerLink(targetName);
-
- handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), handler->GetTrinityString(LANG_OFFLINE));
-
- // in point where GM stay
- Player::SavePositionInDB(handler->GetSession()->GetPlayer()->GetMapId(),
- handler->GetSession()->GetPlayer()->GetPositionX(),
- handler->GetSession()->GetPlayer()->GetPositionY(),
- handler->GetSession()->GetPlayer()->GetPositionZ(),
- handler->GetSession()->GetPlayer()->GetOrientation(),
- handler->GetSession()->GetPlayer()->GetZoneId(),
- targetGuid);
- }
-
- return true;
- }
- // Summon group of player
- static bool HandleGroupSummonCommand(ChatHandler* handler, char const* args)
- {
- Player* target;
- if (!handler->extractPlayerTarget((char*)args, &target))
- return false;
-
- // check online security
- if (handler->HasLowerSecurity(target, 0))
- return false;
-
- Group* group = target->GetGroup();
-
- std::string nameLink = handler->GetNameLink(target);
-
- if (!group)
- {
- handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- Map* gmMap = handler->GetSession()->GetPlayer()->GetMap();
- bool toInstance = gmMap->Instanceable();
-
- // we are in instance, and can summon only player in our group with us as lead
- if (toInstance && (
- !handler->GetSession()->GetPlayer()->GetGroup() || (group->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
- (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID())))
- // the last check is a bit excessive, but let it be, just in case
- {
- handler->SendSysMessage(LANG_CANNOT_SUMMON_TO_INST);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
- {
- Player* player = itr->getSource();
-
- if (!player || player == handler->GetSession()->GetPlayer() || !player->GetSession())
- continue;
-
- // check online security
- if (handler->HasLowerSecurity(player, 0))
- return false;
-
- std::string plNameLink = handler->GetNameLink(player);
-
- if (player->IsBeingTeleported() == true)
- {
- handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (toInstance)
- {
- Map* playerMap = player->GetMap();
-
- if (playerMap->Instanceable() && playerMap->GetInstanceId() != gmMap->GetInstanceId())
- {
- // cannot summon from instance to instance
- handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
-
- handler->PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), "");
- if (handler->needReportToTarget(player))
- ChatHandler(player).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str());
-
- // stop flight if need
- if (player->isInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
- else
- player->SaveRecallPosition();
-
- // before GM
- float x, y, z;
- handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize());
- player->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation());
- }
-
- return true;
- }
-
- static bool HandleCommandsCommand(ChatHandler* handler, char const* /*args*/)
- {
- handler->ShowHelpForCommand(handler->getCommandTable(), "");
- return true;
- }
-
- static bool HandleDieCommand(ChatHandler* handler, char const* /*args*/)
- {
- Unit* target = handler->getSelectedUnit();
-
- if (!target || !handler->GetSession()->GetPlayer()->GetSelection())
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (target->GetTypeId() == TYPEID_PLAYER)
- {
- if (handler->HasLowerSecurity((Player*)target, 0, false))
- return false;
- }
-
- if (target->isAlive())
- {
- if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE))
- handler->GetSession()->GetPlayer()->Kill(target);
- else
- handler->GetSession()->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
- }
-
- return true;
- }
-
- static bool HandleReviveCommand(ChatHandler* handler, char const* args)
- {
- Player* target;
- uint64 targetGuid;
- if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
- return false;
-
- if (target)
- {
- target->ResurrectPlayer(!AccountMgr::IsPlayerAccount(target->GetSession()->GetSecurity()) ? 1.0f : 0.5f);
- target->SpawnCorpseBones();
- target->SaveToDB();
- }
- else
- // will resurrected at login without corpse
- sObjectAccessor->ConvertCorpseForPlayer(targetGuid);
-
- return true;
- }
-
- static bool HandleDismountCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* player = handler->GetSession()->GetPlayer();
-
- // If player is not mounted, so go out :)
- if (!player->IsMounted())
- {
- handler->SendSysMessage(LANG_CHAR_NON_MOUNTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (player->isInFlight())
- {
- handler->SendSysMessage(LANG_YOU_IN_FLIGHT);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- player->Dismount();
- player->RemoveAurasByType(SPELL_AURA_MOUNTED);
- return true;
- }
-
- static bool HandleGUIDCommand(ChatHandler* handler, char const* /*args*/)
- {
- uint64 guid = handler->GetSession()->GetPlayer()->GetSelection();
-
- if (guid == 0)
- {
- handler->SendSysMessage(LANG_NO_SELECTION);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- handler->PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid));
- return true;
- }
-
- static bool HandleHelpCommand(ChatHandler* handler, char const* args)
- {
- char const* cmd = strtok((char*)args, " ");
- if (!cmd)
- {
- handler->ShowHelpForCommand(handler->getCommandTable(), "help");
- handler->ShowHelpForCommand(handler->getCommandTable(), "");
- }
- else
- {
- if (!handler->ShowHelpForCommand(handler->getCommandTable(), cmd))
- handler->SendSysMessage(LANG_NO_HELP_CMD);
- }
-
- return true;
- }
- // move item to other slot
- static bool HandleItemMoveCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- char const* param1 = strtok((char*)args, " ");
- if (!param1)
- return false;
-
- char const* param2 = strtok(NULL, " ");
- if (!param2)
- return false;
-
- uint8 srcSlot = uint8(atoi(param1));
- uint8 dstSlot = uint8(atoi(param2));
-
- if (srcSlot == dstSlot)
- return true;
-
- if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, srcSlot, true))
- return false;
-
- if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, dstSlot, false))
- return false;
-
- uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcSlot);
- uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstSlot);
-
- handler->GetSession()->GetPlayer()->SwapItem(src, dst);
-
- return true;
- }
-
- static bool HandleCooldownCommand(ChatHandler* handler, char const* args)
- {
- Player* target = handler->getSelectedPlayer();
- if (!target)
- {
- handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- std::string nameLink = handler->GetNameLink(target);
-
- if (!*args)
- {
- target->RemoveAllSpellCooldown();
- handler->PSendSysMessage(LANG_REMOVEALL_COOLDOWN, nameLink.c_str());
- }
- else
- {
- // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
- uint32 spellIid = handler->extractSpellIdFromLink((char*)args);
- if (!spellIid)
- return false;
-
- if (!sSpellMgr->GetSpellInfo(spellIid))
- {
- handler->PSendSysMessage(LANG_UNKNOWN_SPELL, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- target->RemoveSpellCooldown(spellIid, true);
- handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spellIid, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
- }
- return true;
- }
-
- static bool HandleGetDistanceCommand(ChatHandler* handler, char const* 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;
- }
- }
-
- handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(obj), handler->GetSession()->GetPlayer()->GetDistance2d(obj), handler->GetSession()->GetPlayer()->GetExactDist(obj), handler->GetSession()->GetPlayer()->GetExactDist2d(obj));
- return true;
- }
- // Teleport player to last position
- static bool HandleRecallCommand(ChatHandler* handler, char const* args)
- {
- Player* target;
- if (!handler->extractPlayerTarget((char*)args, &target))
- return false;
-
- // check online security
- if (handler->HasLowerSecurity(target, 0))
- return false;
-
- if (target->IsBeingTeleported())
- {
- handler->PSendSysMessage(LANG_IS_TELEPORTED, handler->GetNameLink(target).c_str());
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // stop flight if need
- if (target->isInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
-
- target->TeleportTo(target->m_recallMap, target->m_recallX, target->m_recallY, target->m_recallZ, target->m_recallO);
- return true;
- }
-
- static bool HandleSaveCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* player = handler->GetSession()->GetPlayer();
-
- // save GM account without delay and output message
- if (!AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity()))
- {
- if (Player* target = handler->getSelectedPlayer())
- target->SaveToDB();
- else
- player->SaveToDB();
- handler->SendSysMessage(LANG_PLAYER_SAVED);
- return true;
- }
-
- // save if the player has last been saved over 20 seconds ago
- uint32 saveInterval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
- if (saveInterval == 0 || (saveInterval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= saveInterval - 20 * IN_MILLISECONDS))
- player->SaveToDB();
-
- return true;
- }
-
- // Save all players in the world
- static bool HandleSaveAllCommand(ChatHandler* handler, char const* /*args*/)
- {
- sObjectAccessor->SaveAllPlayers();
- handler->SendSysMessage(LANG_PLAYERS_SAVED);
- return true;
- }
-
- // kick player
- static bool HandleKickPlayerCommand(ChatHandler* handler, char const* args)
- {
- Player* target = NULL;
- std::string playerName;
- if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
- return false;
-
- if (handler->GetSession() && target == handler->GetSession()->GetPlayer())
- {
- handler->SendSysMessage(LANG_COMMAND_KICKSELF);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // check online security
- if (handler->HasLowerSecurity(target, 0))
- return false;
-
- if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
- sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
- else
- handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
-
- target->GetSession()->KickPlayer();
-
- return true;
- }
-
- static bool HandleStartCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* player = handler->GetSession()->GetPlayer();
-
- if (player->isInFlight())
- {
- handler->SendSysMessage(LANG_YOU_IN_FLIGHT);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (player->isInCombat())
- {
- handler->SendSysMessage(LANG_YOU_IN_COMBAT);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (player->isDead() || player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
- {
- // if player is dead and stuck, send ghost to graveyard
- player->RepopAtGraveyard();
- return true;
- }
-
- // cast spell Stuck
- player->CastSpell(player, 7355, false);
- return true;
- }
- // Enable on\off all taxi paths
- static bool HandleTaxiCheatCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- {
- handler->SendSysMessage(LANG_USE_BOL);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- std::string argStr = (char*)args;
-
- Player* chr = handler->getSelectedPlayer();
-
- if (!chr)
- chr = handler->GetSession()->GetPlayer();
- else if (handler->HasLowerSecurity(chr, 0)) // check online security
- return false;
-
- if (argStr == "on")
- {
- chr->SetTaxiCheater(true);
- handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str());
- if (handler->needReportToTarget(chr))
- ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink().c_str());
- return true;
- }
-
- if (argStr == "off")
- {
- chr->SetTaxiCheater(false);
- handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str());
- if (handler->needReportToTarget(chr))
- ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str());
-
- return true;
- }
-
- handler->SendSysMessage(LANG_USE_BOL);
- handler->SetSentErrorMessage(true);
-
- return false;
- }
-
- static bool HandleLinkGraveCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- char* px = strtok((char*)args, " ");
- if (!px)
- return false;
-
- uint32 graveyardId = uint32(atoi(px));
-
- uint32 team;
-
- char* px2 = strtok(NULL, " ");
-
- if (!px2)
- team = 0;
- else if (strncmp(px2, "horde", 6) == 0)
- team = HORDE;
- else if (strncmp(px2, "alliance", 9) == 0)
- team = ALLIANCE;
- else
- return false;
-
- WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(graveyardId);
-
- if (!graveyard)
- {
- handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- Player* player = handler->GetSession()->GetPlayer();
-
- uint32 zoneId = player->GetZoneId();
-
- AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(zoneId);
- if (!areaEntry || areaEntry->zone !=0)
- {
- handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, graveyardId, zoneId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (sObjectMgr->AddGraveYardLink(graveyardId, zoneId, team))
- handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, graveyardId, zoneId);
- else
- handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, graveyardId, zoneId);
-
- return true;
- }
-
- static bool HandleNearGraveCommand(ChatHandler* handler, char const* args)
- {
- uint32 team;
-
- size_t argStr = strlen(args);
-
- if (!*args)
- team = 0;
- else if (strncmp((char*)args, "horde", argStr) == 0)
- team = HORDE;
- else if (strncmp((char*)args, "alliance", argStr) == 0)
- team = ALLIANCE;
- else
- return false;
-
- Player* player = handler->GetSession()->GetPlayer();
- uint32 zone_id = player->GetZoneId();
-
- WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard(
- player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team);
-
- if (graveyard)
- {
- uint32 graveyardId = graveyard->ID;
-
- GraveYardData const* data = sObjectMgr->FindGraveYardData(graveyardId, zone_id);
- if (!data)
- {
- handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR, graveyardId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- team = data->team;
-
- std::string team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_NOTEAM);
-
- if (team == 0)
- team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY);
- else if (team == HORDE)
- team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE);
- else if (team == ALLIANCE)
- team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
-
- handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, graveyardId, team_name.c_str(), zone_id);
- }
- else
- {
- std::string team_name;
-
- if (team == 0)
- team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY);
- else if (team == HORDE)
- team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE);
- else if (team == ALLIANCE)
- team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
-
- if (team == ~uint32(0))
- handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id);
- else
- handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str());
- }
-
- return true;
- }
-
- static bool HandleExploreCheatCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- int32 flag = int32(atoi((char*)args));
-
- Player* playerTarget = handler->getSelectedPlayer();
- if (!playerTarget)
- {
- handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (flag != 0)
- {
- handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(playerTarget).c_str());
- if (handler->needReportToTarget(playerTarget))
- ChatHandler(playerTarget).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, handler->GetNameLink().c_str());
- }
- else
- {
- handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(playerTarget).c_str());
- if (handler->needReportToTarget(playerTarget))
- ChatHandler(playerTarget).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, handler->GetNameLink().c_str());
- }
-
- for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
- {
- if (flag != 0)
- handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0xFFFFFFFF);
- else
- handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0);
- }
-
- return true;
- }
-
- static bool HandleShowAreaCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- Player* playerTarget = handler->getSelectedPlayer();
- if (!playerTarget)
- {
- handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- int32 area = GetAreaFlagByAreaID(atoi((char*)args));
- int32 offset = area / 32;
- uint32 val = uint32((1 << (area % 32)));
-
- if (area<0 || offset >= PLAYER_EXPLORED_ZONES_SIZE)
- {
- handler->SendSysMessage(LANG_BAD_VALUE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
- playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields | val)));
-
- handler->SendSysMessage(LANG_EXPLORE_AREA);
- return true;
- }
-
- static bool HandleHideAreaCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- Player* playerTarget = handler->getSelectedPlayer();
- if (!playerTarget)
- {
- handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- int32 area = GetAreaFlagByAreaID(atoi((char*)args));
- int32 offset = area / 32;
- uint32 val = uint32((1 << (area % 32)));
-
- if (area < 0 || offset >= PLAYER_EXPLORED_ZONES_SIZE)
- {
- handler->SendSysMessage(LANG_BAD_VALUE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
- playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields ^ val)));
-
- handler->SendSysMessage(LANG_UNEXPLORE_AREA);
- return true;
- }
-
- static bool HandleAddItemCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- uint32 itemId = 0;
-
- if (args[0] == '[') // [name] manual form
- {
- char const* itemNameStr = strtok((char*)args, "]");
-
- if (itemNameStr && itemNameStr[0])
- {
- std::string itemName = itemNameStr+1;
- WorldDatabase.EscapeString(itemName);
-
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME);
- stmt->setString(0, itemName);
- PreparedQueryResult result = WorldDatabase.Query(stmt);
-
- if (!result)
- {
- handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, itemNameStr+1);
- handler->SetSentErrorMessage(true);
- return false;
- }
- itemId = result->Fetch()->GetUInt32();
- }
- else
- return false;
- }
- else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r
- {
- char const* id = handler->extractKeyFromLink((char*)args, "Hitem");
- if (!id)
- return false;
- itemId = uint32(atol(id));
- }
-
- char const* ccount = strtok(NULL, " ");
-
- int32 count = 1;
-
- if (ccount)
- count = strtol(ccount, NULL, 10);
-
- if (count == 0)
- count = 1;
-
- Player* player = handler->GetSession()->GetPlayer();
- Player* playerTarget = handler->getSelectedPlayer();
- if (!playerTarget)
- playerTarget = player;
-
- sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEM), itemId, count);
-
- ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
- if (!itemTemplate)
- {
- handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // Subtract
- if (count < 0)
- {
- playerTarget->DestroyItemCount(itemId, -count, true, false);
- handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str());
- return true;
- }
-
- // Adding items
- uint32 noSpaceForCount = 0;
-
- // check space and find places
- ItemPosCountVec dest;
- InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
- if (msg != EQUIP_ERR_OK) // convert to possible store amount
- count -= noSpaceForCount;
-
- if (count == 0 || dest.empty()) // can't add any
- {
- handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- Item* item = playerTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
-
- // remove binding (let GM give it to another player later)
- if (player == playerTarget)
- for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr)
- if (Item* item1 = player->GetItemByPos(itr->pos))
- item1->SetBinding(false);
-
- if (count > 0 && item)
- {
- player->SendNewItem(item, count, false, true);
- if (player != playerTarget)
- playerTarget->SendNewItem(item, count, true, false);
- }
-
- if (noSpaceForCount > 0)
- handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
-
- return true;
- }
-
- static bool HandleAddItemSetCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- char const* id = handler->extractKeyFromLink((char*)args, "Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r
- if (!id)
- return false;
-
- uint32 itemSetId = atol(id);
-
- // prevent generation all items with itemset field value '0'
- if (itemSetId == 0)
- {
- handler->PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemSetId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- Player* player = handler->GetSession()->GetPlayer();
- Player* playerTarget = handler->getSelectedPlayer();
- if (!playerTarget)
- playerTarget = player;
-
- sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEMSET), itemSetId);
-
- bool found = false;
- ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
- for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
- {
- if (itr->second.ItemSet == itemSetId)
- {
- found = true;
- ItemPosCountVec dest;
- InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itr->second.ItemId, 1);
- if (msg == EQUIP_ERR_OK)
- {
- Item* item = playerTarget->StoreNewItem(dest, itr->second.ItemId, true);
-
- // remove binding (let GM give it to another player later)
- if (player == playerTarget)
- item->SetBinding(false);
-
- player->SendNewItem(item, 1, false, true);
- if (player != playerTarget)
- playerTarget->SendNewItem(item, 1, true, false);
- }
- else
- {
- player->SendEquipError(msg, NULL, NULL, itr->second.ItemId);
- handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itr->second.ItemId, 1);
- }
- }
- }
-
- if (!found)
- {
- handler->PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemSetId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- return true;
- }
-
- static bool HandleBankCommand(ChatHandler* handler, char const* /*args*/)
- {
- handler->GetSession()->SendShowBank(handler->GetSession()->GetPlayer()->GetGUID());
- return true;
- }
-
- static bool HandleChangeWeather(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- // Weather is OFF
- if (!sWorld->getBoolConfig(CONFIG_WEATHER))
- {
- handler->SendSysMessage(LANG_WEATHER_DISABLED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // *Change the weather of a cell
- char const* px = strtok((char*)args, " ");
- char const* py = strtok(NULL, " ");
-
- if (!px || !py)
- return false;
-
- uint32 type = uint32(atoi(px)); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand
- float grade = float(atof(py)); //0 to 1, sending -1 is instand good weather
-
- Player* player = handler->GetSession()->GetPlayer();
- uint32 zoneid = player->GetZoneId();
-
- Weather* weather = WeatherMgr::FindWeather(zoneid);
-
- if (!weather)
- weather = WeatherMgr::AddWeather(zoneid);
- if (!weather)
- {
- handler->SendSysMessage(LANG_NO_WEATHER);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- weather->SetWeather(WeatherType(type), grade);
-
- return true;
- }
-
-
- static bool HandleMaxSkillCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* SelectedPlayer = handler->getSelectedPlayer();
- if (!SelectedPlayer)
- {
- handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // each skills that have max skill value dependent from level seted to current level max skill value
- SelectedPlayer->UpdateSkillsToMaxSkillsForLevel();
- return true;
- }
-
- static bool HandleSetSkillCommand(ChatHandler* handler, char const* args)
- {
- // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r
- char const* skillStr = handler->extractKeyFromLink((char*)args, "Hskill");
- if (!skillStr)
- return false;
-
- char const* levelStr = strtok(NULL, " ");
- if (!levelStr)
- return false;
-
- char const* maxPureSkill = strtok(NULL, " ");
-
- int32 skill = atoi(skillStr);
- if (skill <= 0)
- {
- handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skill);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- int32 level = uint32(atol(levelStr));
-
- Player* target = handler->getSelectedPlayer();
- if (!target)
- {
- handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skill);
- if (!skillLine)
- {
- handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skill);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- std::string tNameLink = handler->GetNameLink(target);
-
- if (!target->GetSkillValue(skill))
- {
- handler->PSendSysMessage(LANG_SET_SKILL_ERROR, tNameLink.c_str(), skill, skillLine->name[handler->GetSessionDbcLocale()]);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- uint16 max = maxPureSkill ? atol (maxPureSkill) : target->GetPureMaxSkillValue(skill);
-
- if (level <= 0 || level > max || max <= 0)
- return false;
-
- target->SetSkill(skill, target->GetSkillStep(skill), level, max);
- handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->name[handler->GetSessionDbcLocale()], tNameLink.c_str(), level, max);
-
- return true;
- }
- // show info of player
- static bool HandlePInfoCommand(ChatHandler* handler, char const* args)
- {
- Player* target;
- uint64 targetGuid;
- std::string targetName;
-
- uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);
-
- if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName))
- {
- target = sObjectMgr->GetPlayerByLowGUID(parseGUID);
- targetGuid = parseGUID;
- }
- else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
- return false;
-
- uint32 accId = 0;
- uint32 money = 0;
- uint32 totalPlayerTime = 0;
- uint8 level = 0;
- uint32 latency = 0;
- uint8 race;
- uint8 Class;
- int64 muteTime = 0;
- int64 banTime = -1;
- uint32 mapId;
- uint32 areaId;
- uint32 phase = 0;
-
- // get additional information from Player object
- if (target)
- {
- // check online security
- if (handler->HasLowerSecurity(target, 0))
- return false;
-
- accId = target->GetSession()->GetAccountId();
- money = target->GetMoney();
- totalPlayerTime = target->GetTotalPlayedTime();
- level = target->getLevel();
- latency = target->GetSession()->GetLatency();
- race = target->getRace();
- Class = target->getClass();
- muteTime = target->GetSession()->m_muteTime;
- mapId = target->GetMapId();
- areaId = target->GetAreaId();
- phase = target->GetPhaseMask();
- }
- // get additional information from DB
- else
- {
- // check offline security
- if (handler->HasLowerSecurity(NULL, targetGuid))
- return false;
-
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
- stmt->setUInt32(0, GUID_LOPART(targetGuid));
- PreparedQueryResult result = CharacterDatabase.Query(stmt);
-
- if (!result)
- return false;
-
- Field* fields = result->Fetch();
- totalPlayerTime = fields[0].GetUInt32();
- level = fields[1].GetUInt8();
- money = fields[2].GetUInt32();
- accId = fields[3].GetUInt32();
- race = fields[4].GetUInt8();
- Class = fields[5].GetUInt8();
- mapId = fields[6].GetUInt16();
- areaId = fields[7].GetUInt16();
- }
-
- std::string userName = handler->GetTrinityString(LANG_ERROR);
- std::string eMail = handler->GetTrinityString(LANG_ERROR);
- std::string lastIp = handler->GetTrinityString(LANG_ERROR);
- uint32 security = 0;
- std::string lastLogin = handler->GetTrinityString(LANG_ERROR);
-
- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);
- stmt->setInt32(0, int32(realmID));
- stmt->setUInt32(1, accId);
- PreparedQueryResult result = LoginDatabase.Query(stmt);
-
- if (result)
- {
- Field* fields = result->Fetch();
- userName = fields[0].GetString();
- security = fields[1].GetUInt8();
- eMail = fields[2].GetString();
- muteTime = fields[5].GetUInt64();
-
- if (eMail.empty())
- eMail = "-";
-
- if (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security))
- {
- lastIp = fields[3].GetString();
- lastLogin = fields[4].GetString();
-
- uint32 ip = inet_addr(lastIp.c_str());
-#if TRINITY_ENDIAN == BIGENDIAN
- EndianConvertReverse(ip);
-#endif
-
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY);
-
- stmt->setUInt32(0, ip);
-
- PreparedQueryResult result2 = WorldDatabase.Query(stmt);
-
- if (result2)
- {
- Field* fields2 = result2->Fetch();
- lastIp.append(" (");
- lastIp.append(fields2[0].GetString());
- lastIp.append(")");
- }
- }
- else
- {
- lastIp = "-";
- lastLogin = "-";
- }
- }
-
- std::string nameLink = handler->playerLink(targetName);
-
- handler->PSendSysMessage(LANG_PINFO_ACCOUNT, (target ? "" : handler->GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(targetGuid), userName.c_str(), accId, eMail.c_str(), security, lastIp.c_str(), lastLogin.c_str(), latency);
-
- std::string bannedby = "unknown";
- std::string banreason = "";
-
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
- stmt->setUInt32(0, accId);
- PreparedQueryResult result2 = LoginDatabase.Query(stmt);
- if (!result2)
- {
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS);
- stmt->setUInt32(0, GUID_LOPART(targetGuid));
- result2 = CharacterDatabase.Query(stmt);
- }
-
- if (result2)
- {
- Field* fields = result2->Fetch();
- banTime = int64(fields[1].GetBool() ? 0 : fields[0].GetUInt32());
- bannedby = fields[2].GetString();
- banreason = fields[3].GetString();
- }
-
- if (muteTime > 0)
- handler->PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str());
-
- if (banTime >= 0)
- handler->PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str());
-
- std::string raceStr, ClassStr;
- switch (race)
- {
- case RACE_HUMAN:
- raceStr = "Human";
- break;
- case RACE_ORC:
- raceStr = "Orc";
- break;
- case RACE_DWARF:
- raceStr = "Dwarf";
- break;
- case RACE_NIGHTELF:
- raceStr = "Night Elf";
- break;
- case RACE_UNDEAD_PLAYER:
- raceStr = "Undead";
- break;
- case RACE_TAUREN:
- raceStr = "Tauren";
- break;
- case RACE_GNOME:
- raceStr = "Gnome";
- break;
- case RACE_TROLL:
- raceStr = "Troll";
- break;
- case RACE_BLOODELF:
- raceStr = "Blood Elf";
- break;
- case RACE_DRAENEI:
- raceStr = "Draenei";
- break;
- }
-
- switch (Class)
- {
- case CLASS_WARRIOR:
- ClassStr = "Warrior";
- break;
- case CLASS_PALADIN:
- ClassStr = "Paladin";
- break;
- case CLASS_HUNTER:
- ClassStr = "Hunter";
- break;
- case CLASS_ROGUE:
- ClassStr = "Rogue";
- break;
- case CLASS_PRIEST:
- ClassStr = "Priest";
- break;
- case CLASS_DEATH_KNIGHT:
- ClassStr = "Death Knight";
- break;
- case CLASS_SHAMAN:
- ClassStr = "Shaman";
- break;
- case CLASS_MAGE:
- ClassStr = "Mage";
- break;
- case CLASS_WARLOCK:
- ClassStr = "Warlock";
- break;
- case CLASS_DRUID:
- ClassStr = "Druid";
- break;
- }
-
- std::string timeStr = secsToTimeString(totalPlayerTime, true, true);
- uint32 gold = money /GOLD;
- uint32 silv = (money % GOLD) / SILVER;
- uint32 copp = (money % GOLD) % SILVER;
- handler->PSendSysMessage(LANG_PINFO_LEVEL, raceStr.c_str(), ClassStr.c_str(), timeStr.c_str(), level, gold, silv, copp);
-
- // Add map, zone, subzone and phase to output
- int locale = handler->GetSessionDbcLocale();
- std::string areaName = "<unknown>";
- std::string zoneName = "";
-
- MapEntry const* map = sMapStore.LookupEntry(mapId);
-
- AreaTableEntry const* area = GetAreaEntryByAreaID(areaId);
- if (area)
- {
- areaName = area->area_name[locale];
-
- AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone);
- if (zone)
- zoneName = zone->area_name[locale];
- }
-
- if (target)
- {
- if (!zoneName.empty())
- handler->PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zoneName.c_str(), areaName.c_str(), phase);
- else
- handler->PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], areaName.c_str(), "<unknown>", phase);
- }
- else
- handler->PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str());
-
- return true;
- }
-
- static bool HandleRespawnCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* player = handler->GetSession()->GetPlayer();
-
- // accept only explicitly selected target (not implicitly self targeting case)
- Unit* target = handler->getSelectedUnit();
- if (player->GetSelection() && target)
- {
- if (target->GetTypeId() != TYPEID_UNIT || target->isPet())
- {
- handler->SendSysMessage(LANG_SELECT_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (target->isDead())
- target->ToCreature()->Respawn();
- return true;
- }
-
- CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
- Trinity::RespawnDo u_do;
- Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do);
-
- TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
- cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange());
-
- return true;
- }
- // mute player for some times
- static bool HandleMuteCommand(ChatHandler* handler, char const* args)
- {
- char* nameStr;
- char* delayStr;
- handler->extractOptFirstArg((char*)args, &nameStr, &delayStr);
- if (!delayStr)
- return false;
-
- char const* muteReason = strtok(NULL, "\r");
- std::string muteReasonStr = "No reason";
- if (muteReason != NULL)
- muteReasonStr = muteReason;
-
- Player* target;
- uint64 targetGuid;
- std::string targetName;
- if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
- return false;
-
- uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
-
- // find only player from same account if any
- if (!target)
- if (WorldSession* session = sWorld->FindSession(accountId))
- target = session->GetPlayer();
-
- uint32 notSpeakTime = uint32(atoi(delayStr));
-
- // must have strong lesser security level
- if (handler->HasLowerSecurity (target, targetGuid, true))
- return false;
-
- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
-
- if (target)
- {
- // Target is online, mute will be in effect right away.
- int64 muteTime = time(NULL) + notSpeakTime * MINUTE;
- target->GetSession()->m_muteTime = muteTime;
- stmt->setInt64(0, muteTime);
- ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteReasonStr.c_str());
- }
- else
- {
- // Target is offline, mute will be in effect starting from the next login.
- int32 muteTime = -int32(notSpeakTime * MINUTE);
- stmt->setInt64(0, muteTime);
- }
-
- stmt->setUInt32(1, accountId);
- LoginDatabase.Execute(stmt);
- std::string nameLink = handler->playerLink(targetName);
-
- handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
-
- return true;
- }
-
- // unmute player
- static bool HandleUnmuteCommand(ChatHandler* handler, char const* args)
- {
- Player* target;
- uint64 targetGuid;
- std::string targetName;
- if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
- return false;
-
- uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
-
- // find only player from same account if any
- if (!target)
- if (WorldSession* session = sWorld->FindSession(accountId))
- target = session->GetPlayer();
-
- // must have strong lesser security level
- if (handler->HasLowerSecurity (target, targetGuid, true))
- return false;
-
- if (target)
- {
- if (target->CanSpeak())
- {
- handler->SendSysMessage(LANG_CHAT_ALREADY_ENABLED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- target->GetSession()->m_muteTime = 0;
- }
-
- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
- stmt->setInt64(0, 0);
- stmt->setUInt32(1, accountId);
- LoginDatabase.Execute(stmt);
-
- if (target)
- ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
-
- std::string nameLink = handler->playerLink(targetName);
-
- handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str());
-
- return true;
- }
-
-
- static bool HandleMovegensCommand(ChatHandler* handler, char const* /*args*/)
- {
- Unit* unit = handler->getSelectedUnit();
- if (!unit)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow());
-
- MotionMaster* motionMaster = unit->GetMotionMaster();
- float x, y, z;
- motionMaster->GetDestination(x, y, z);
-
- for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
- {
- MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(i);
- if (!movementGenerator)
- {
- handler->SendSysMessage("Empty");
- continue;
- }
-
- switch (movementGenerator->GetMovementGeneratorType())
- {
- case IDLE_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_IDLE);
- break;
- case RANDOM_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_RANDOM);
- break;
- case WAYPOINT_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_WAYPOINT);
- break;
- case ANIMAL_RANDOM_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM);
- break;
- case CONFUSED_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_CONFUSED);
- break;
- case CHASE_MOTION_TYPE:
- {
- Unit* target = NULL;
- if (unit->GetTypeId() == TYPEID_PLAYER)
- target = static_cast<ChaseMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
- else
- target = static_cast<ChaseMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
-
- if (!target)
- handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL);
- else if (target->GetTypeId() == TYPEID_PLAYER)
- handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow());
- else
- handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow());
- break;
- }
- case FOLLOW_MOTION_TYPE:
- {
- Unit* target = NULL;
- if (unit->GetTypeId() == TYPEID_PLAYER)
- target = static_cast<FollowMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
- else
- target = static_cast<FollowMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
-
- if (!target)
- handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL);
- else if (target->GetTypeId() == TYPEID_PLAYER)
- handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow());
- else
- handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow());
- break;
- }
- case HOME_MOTION_TYPE:
- {
- if (unit->GetTypeId() == TYPEID_UNIT)
- handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z);
- else
- handler->SendSysMessage(LANG_MOVEGENS_HOME_PLAYER);
- break;
- }
- case FLIGHT_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_FLIGHT);
- break;
- case POINT_MOTION_TYPE:
- {
- handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z);
- break;
- }
- case FLEEING_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_FEAR);
- break;
- case DISTRACT_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_DISTRACT);
- break;
- case EFFECT_MOTION_TYPE:
- handler->SendSysMessage(LANG_MOVEGENS_EFFECT);
- break;
- default:
- handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType());
- break;
- }
- }
- return true;
- }
- /*
- ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator
- Without this function 3rd party scripting library will get linking errors (unresolved external)
- when attempting to use the PointMovementGenerator
- */
- static bool HandleComeToMeCommand(ChatHandler* handler, char const* args)
- {
- char const* newFlagStr = strtok((char*)args, " ");
- if (!newFlagStr)
- return false;
-
- Creature* caster = handler->getSelectedCreature();
- if (!caster)
- {
- handler->SendSysMessage(LANG_SELECT_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- Player* player = handler->GetSession()->GetPlayer();
-
- caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
-
- return true;
- }
-
- static bool HandleDamageCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- Unit* target = handler->getSelectedUnit();
- if (!target || !handler->GetSession()->GetPlayer()->GetSelection())
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (target->GetTypeId() == TYPEID_PLAYER)
- {
- if (handler->HasLowerSecurity((Player*)target, 0, false))
- return false;
- }
-
- if (!target->isAlive())
- return true;
-
- char* damageStr = strtok((char*)args, " ");
- if (!damageStr)
- return false;
-
- int32 damage_int = atoi((char*)damageStr);
- if (damage_int <= 0)
- return true;
-
- uint32 damage = damage_int;
-
- char* schoolStr = strtok((char*)NULL, " ");
-
- // flat melee damage without resistence/etc reduction
- if (!schoolStr)
- {
- handler->GetSession()->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
- if (target != handler->GetSession()->GetPlayer())
- handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0);
- return true;
- }
-
- uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL;
- if (school >= MAX_SPELL_SCHOOL)
- return false;
-
- SpellSchoolMask schoolmask = SpellSchoolMask(1 << school);
-
- if (Unit::IsDamageReducedByArmor(schoolmask))
- damage = handler->GetSession()->GetPlayer()->CalcArmorReducedDamage(target, damage, NULL, BASE_ATTACK);
-
- char* spellStr = strtok((char*)NULL, " ");
-
- // melee damage by specific school
- if (!spellStr)
- {
- uint32 absorb = 0;
- uint32 resist = 0;
-
- handler->GetSession()->GetPlayer()->CalcAbsorbResist(target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
-
- if (damage <= absorb + resist)
- return true;
-
- damage -= absorb + resist;
-
- handler->GetSession()->GetPlayer()->DealDamageMods(target, damage, &absorb);
- handler->GetSession()->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false);
- handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
- return true;
- }
-
- // non-melee damage
-
- // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
- uint32 spellid = handler->extractSpellIdFromLink((char*)args);
- if (!spellid || !sSpellMgr->GetSpellInfo(spellid))
- return false;
-
- handler->GetSession()->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage);
- return true;
- }
-
- static bool HandleCombatStopCommand(ChatHandler* handler, char const* args)
- {
- Player* target = NULL;
-
- if (args && strlen(args) > 0)
- {
- target = sObjectAccessor->FindPlayerByName(args);
- if (!target)
- {
- handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
-
- if (!target)
- {
- if (!handler->extractPlayerTarget((char*)args, &target))
- return false;
- }
-
- // check online security
- if (handler->HasLowerSecurity(target, 0))
- return false;
-
- target->CombatStop();
- target->getHostileRefManager().deleteReferences();
- return true;
- }
-
- static bool HandleFlushArenaPointsCommand(ChatHandler* /*handler*/, char const* /*args*/)
- {
- sArenaTeamMgr->DistributeArenaPoints();
- return true;
- }
-
- static bool HandleRepairitemsCommand(ChatHandler* handler, char const* args)
- {
- Player* target;
- if (!handler->extractPlayerTarget((char*)args, &target))
- return false;
-
- // check online security
- if (handler->HasLowerSecurity(target, 0))
- return false;
-
- // Repair items
- target->DurabilityRepairAll(false, 0, false);
-
- handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, handler->GetNameLink(target).c_str());
- if (handler->needReportToTarget(target))
- ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, handler->GetNameLink().c_str());
-
- return true;
- }
-
- static bool HandleWaterwalkCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- Player* player = handler->getSelectedPlayer();
- if (!player)
- {
- handler->PSendSysMessage(LANG_NO_CHAR_SELECTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // check online security
- if (handler->HasLowerSecurity(player, 0))
- return false;
-
- if (strncmp(args, "on", 3) == 0)
- player->SetMovement(MOVE_WATER_WALK); // ON
- else if (strncmp(args, "off", 4) == 0)
- player->SetMovement(MOVE_LAND_WALK); // OFF
- else
- {
- handler->SendSysMessage(LANG_USE_BOL);
- return false;
- }
-
- handler->PSendSysMessage(LANG_YOU_SET_WATERWALK, args, handler->GetNameLink(player).c_str());
- if (handler->needReportToTarget(player))
- ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, handler->GetNameLink().c_str());
- return true;
- }
-
- // Send mail by command
- static bool HandleSendMailCommand(ChatHandler* handler, char const* args)
- {
- // format: name "subject text" "mail text"
- Player* target;
- uint64 targetGuid;
- std::string targetName;
- if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
- return false;
-
- char* tail1 = strtok(NULL, "");
- if (!tail1)
- return false;
-
- char const* msgSubject = handler->extractQuotedArg(tail1);
- if (!msgSubject)
- return false;
-
- char* tail2 = strtok(NULL, "");
- if (!tail2)
- return false;
-
- char const* msgText = handler->extractQuotedArg(tail2);
- if (!msgText)
- return false;
-
- // msgSubject, msgText isn't NUL after prev. check
- std::string subject = msgSubject;
- std::string text = msgText;
-
- // from console show not existed sender
- MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
-
- //- TODO: Fix poor design
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
- MailDraft(subject, text)
- .SendMailTo(trans, MailReceiver(target, GUID_LOPART(targetGuid)), sender);
-
- CharacterDatabase.CommitTransaction(trans);
-
- std::string nameLink = handler->playerLink(targetName);
- handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
- return true;
- }
- // Send items by mail
- static bool HandleSendItemsCommand(ChatHandler* handler, char const* args)
- {
- // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
- Player* receiver;
- uint64 receiverGuid;
- std::string receiverName;
- if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName))
- return false;
-
- char* tail1 = strtok(NULL, "");
- if (!tail1)
- return false;
-
- char const* msgSubject = handler->extractQuotedArg(tail1);
- if (!msgSubject)
- return false;
-
- char* tail2 = strtok(NULL, "");
- if (!tail2)
- return false;
-
- char const* msgText = handler->extractQuotedArg(tail2);
- if (!msgText)
- return false;
-
- // msgSubject, msgText isn't NUL after prev. check
- std::string subject = msgSubject;
- std::string text = msgText;
-
- // extract items
- typedef std::pair<uint32, uint32> ItemPair;
- typedef std::list< ItemPair > ItemPairs;
- ItemPairs items;
-
- // get all tail string
- char* tail = strtok(NULL, "");
-
- // get from tail next item str
- while (char* itemStr = strtok(tail, " "))
- {
- // and get new tail
- tail = strtok(NULL, "");
-
- // parse item str
- char const* itemIdStr = strtok(itemStr, ":");
- char const* itemCountStr = strtok(NULL, " ");
-
- uint32 itemId = atoi(itemIdStr);
- if (!itemId)
- return false;
-
- ItemTemplate const* item_proto = sObjectMgr->GetItemTemplate(itemId);
- if (!item_proto)
- {
- handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- uint32 itemCount = itemCountStr ? atoi(itemCountStr) : 1;
- if (itemCount < 1 || (item_proto->MaxCount > 0 && itemCount > uint32(item_proto->MaxCount)))
- {
- handler->PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, itemCount, itemId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- while (itemCount > item_proto->GetMaxStackSize())
- {
- items.push_back(ItemPair(itemId, item_proto->GetMaxStackSize()));
- itemCount -= item_proto->GetMaxStackSize();
- }
-
- items.push_back(ItemPair(itemId, itemCount));
-
- if (items.size() > MAX_MAIL_ITEMS)
- {
- handler->PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
-
- // from console show not existed sender
- MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
-
- // fill mail
- MailDraft draft(subject, text);
-
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
-
- for (ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr)
- {
- if (Item* item = Item::CreateItem(itr->first, itr->second, handler->GetSession() ? handler->GetSession()->GetPlayer() : 0))
- {
- item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
- draft.AddItem(item);
- }
- }
-
- draft.SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender);
- CharacterDatabase.CommitTransaction(trans);
-
- std::string nameLink = handler->playerLink(receiverName);
- handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
- return true;
- }
- /// Send money by mail
- static bool HandleSendMoneyCommand(ChatHandler* handler, char const* args)
- {
- /// format: name "subject text" "mail text" money
-
- Player* receiver;
- uint64 receiverGuid;
- std::string receiverName;
- if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName))
- return false;
-
- char* tail1 = strtok(NULL, "");
- if (!tail1)
- return false;
-
- char* msgSubject = handler->extractQuotedArg(tail1);
- if (!msgSubject)
- return false;
-
- char* tail2 = strtok(NULL, "");
- if (!tail2)
- return false;
-
- char* msgText = handler->extractQuotedArg(tail2);
- if (!msgText)
- return false;
-
- char* moneyStr = strtok(NULL, "");
- int32 money = moneyStr ? atoi(moneyStr) : 0;
- if (money <= 0)
- return false;
-
- // msgSubject, msgText isn't NUL after prev. check
- std::string subject = msgSubject;
- std::string text = msgText;
-
- // from console show not existed sender
- MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
-
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
-
- MailDraft(subject, text)
- .AddMoney(money)
- .SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender);
-
- CharacterDatabase.CommitTransaction(trans);
-
- std::string nameLink = handler->playerLink(receiverName);
- handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
- return true;
- }
- /// Send a message to a player in game
- static bool HandleSendMessageCommand(ChatHandler* handler, char const* args)
- {
- /// - Find the player
- Player* player;
- if (!handler->extractPlayerTarget((char*)args, &player))
- return false;
-
- char* msgStr = strtok(NULL, "");
- if (!msgStr)
- return false;
-
- ///- Check that he is not logging out.
- if (player->GetSession()->isLogingOut())
- {
- handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- /// - Send the message
- // Use SendAreaTriggerMessage for fastest delivery.
- player->GetSession()->SendAreaTriggerMessage("%s", msgStr);
- player->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
-
- // Confirmation message
- std::string nameLink = handler->GetNameLink(player);
- handler->PSendSysMessage(LANG_SENDMESSAGE, nameLink.c_str(), msgStr);
-
- return true;
- }
-
- static bool HandleCreatePetCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* player = handler->GetSession()->GetPlayer();
- Creature* creatureTarget = handler->getSelectedCreature();
-
- if (!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
- {
- handler->PSendSysMessage(LANG_SELECT_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- CreatureTemplate const* creatrueTemplate = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry());
- // Creatures with family 0 crashes the server
- if (!creatrueTemplate->family)
- {
- handler->PSendSysMessage("This creature cannot be tamed. (family id: 0).");
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (player->GetPetGUID())
- {
- handler->PSendSysMessage("You already have a pet");
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // Everything looks OK, create new pet
- Pet* pet = new Pet(player, HUNTER_PET);
- if (!pet->CreateBaseAtCreature(creatureTarget))
- {
- delete pet;
- handler->PSendSysMessage("Error 1");
- return false;
- }
-
- creatureTarget->setDeathState(JUST_DIED);
- creatureTarget->RemoveCorpse();
- creatureTarget->SetHealth(0); // just for nice GM-mode view
-
- pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
- pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
-
- if (!pet->InitStatsForLevel(creatureTarget->getLevel()))
- {
- sLog->outError(LOG_FILTER_GENERAL, "InitStatsForLevel() in EffectTameCreature failed! Pet deleted.");
- handler->PSendSysMessage("Error 2");
- delete pet;
- return false;
- }
-
- // prepare visual effect for levelup
- pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()-1);
-
- pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
- // this enables pet details window (Shift+P)
- pet->InitPetCreateSpells();
- pet->SetFullHealth();
-
- pet->GetMap()->AddToMap(pet->ToCreature());
-
- // visual effect for levelup
- pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel());
-
- player->SetMinion(pet, true);
- pet->SavePetToDB(PET_SAVE_AS_CURRENT);
- player->PetSpellInitialize();
-
- return true;
- }
-
- static bool HandlePetLearnCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- Player* player = handler->GetSession()->GetPlayer();
- Pet* pet = player->GetPet();
-
- if (!pet)
- {
- handler->PSendSysMessage("You have no pet");
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- uint32 spellId = handler->extractSpellIdFromLink((char*)args);
-
- if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
- return false;
-
- // Check if pet already has it
- if (pet->HasSpell(spellId))
- {
- handler->PSendSysMessage("Pet already has spell: %u", spellId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // Check if spell is valid
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
- if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
- {
- handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- pet->learnSpell(spellId);
-
- handler->PSendSysMessage("Pet has learned spell %u", spellId);
- return true;
- }
-
- static bool HandlePetUnlearnCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- Player* player = handler->GetSession()->GetPlayer();
- Pet* pet = player->GetPet();
- if (!pet)
- {
- handler->PSendSysMessage("You have no pet");
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- uint32 spellId = handler->extractSpellIdFromLink((char*)args);
-
- if (pet->HasSpell(spellId))
- pet->removeSpell(spellId, false);
- else
- handler->PSendSysMessage("Pet doesn't have that spell");
-
- return true;
- }
-
- static bool HandleFreezeCommand(ChatHandler* handler, char const* args)
- {
- std::string name;
- Player* player;
- char const* TargetName = strtok((char*)args, " "); // get entered name
- if (!TargetName) // if no name entered use target
- {
- player = handler->getSelectedPlayer();
- if (player) //prevent crash with creature as target
- {
- name = player->GetName();
- normalizePlayerName(name);
- }
- }
- else // if name entered
- {
- name = TargetName;
- normalizePlayerName(name);
- player = sObjectAccessor->FindPlayerByName(name.c_str());
- }
-
- if (!player)
- {
- handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
- return true;
- }
-
- if (player == handler->GetSession()->GetPlayer())
- {
- handler->SendSysMessage(LANG_COMMAND_FREEZE_ERROR);
- return true;
- }
-
- // effect
- if (player && (player != handler->GetSession()->GetPlayer()))
- {
- handler->PSendSysMessage(LANG_COMMAND_FREEZE, name.c_str());
-
- // stop combat + make player unattackable + duel stop + stop some spells
- player->setFaction(35);
- player->CombatStop();
- if (player->IsNonMeleeSpellCasted(true))
- player->InterruptNonMeleeSpells(true);
- player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
-
- // if player class = hunter || warlock remove pet if alive
- if ((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK))
- {
- if (Pet* pet = player->GetPet())
- {
- pet->SavePetToDB(PET_SAVE_AS_CURRENT);
- // not let dismiss dead pet
- if (pet && pet->isAlive())
- player->RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
- }
- }
-
- if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(9454))
- Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, player, player);
-
- // save player
- player->SaveToDB();
- }
-
- return true;
- }
-
- static bool HandleUnFreezeCommand(ChatHandler* handler, char const*args)
- {
- std::string name;
- Player* player;
- char* targetName = strtok((char*)args, " "); // Get entered name
-
- if (targetName)
- {
- name = targetName;
- normalizePlayerName(name);
- player = sObjectAccessor->FindPlayerByName(name.c_str());
- }
- else // If no name was entered - use target
- {
- player = handler->getSelectedPlayer();
- if (player)
- name = player->GetName();
- }
-
- if (player)
- {
- handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str());
-
- // Reset player faction + allow combat + allow duels
- player->setFactionForRace(player->getRace());
- player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
-
- // Remove Freeze spell (allowing movement and spells)
- player->RemoveAurasDueToSpell(9454);
-
- // Save player
- player->SaveToDB();
- }
- else
- {
- if (targetName)
- {
- // Check for offline players
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_BY_NAME);
- stmt->setString(0, name);
- PreparedQueryResult result = CharacterDatabase.Query(stmt);
-
- if (!result)
- {
- handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
- return true;
- }
-
- // If player found: delete his freeze aura
- Field* fields = result->Fetch();
- uint32 lowGuid = fields[0].GetUInt32();
-
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN);
- stmt->setUInt32(0, lowGuid);
- CharacterDatabase.Execute(stmt);
-
- handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str());
- return true;
- }
- else
- {
- handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
- return true;
- }
- }
-
- return true;
- }
-
- static bool HandleListFreezeCommand(ChatHandler* handler, char const* /*args*/)
- {
- // Get names from DB
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AURA_FROZEN);
- PreparedQueryResult result = CharacterDatabase.Query(stmt);
- if (!result)
- {
- handler->SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS);
- return true;
- }
-
- // Header of the names
- handler->PSendSysMessage(LANG_COMMAND_LIST_FREEZE);
-
- // Output of the results
- do
- {
- Field* fields = result->Fetch();
- std::string player = fields[0].GetString();
- handler->PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player.c_str());
- }
- while (result->NextRow());
-
- return true;
- }
-
- static bool HandleGroupLeaderCommand(ChatHandler* handler, char const* args)
- {
- Player* player = NULL;
- Group* group = NULL;
- uint64 guid = 0;
- char* nameStr = strtok((char*)args, " ");
-
- if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid))
- if (group && group->GetLeaderGUID() != guid)
- {
- group->ChangeLeader(guid);
- group->SendUpdate();
- }
-
- return true;
- }
-
- static bool HandleGroupDisbandCommand(ChatHandler* handler, char const* args)
- {
- Player* player = NULL;
- Group* group = NULL;
- uint64 guid = 0;
- char* nameStr = strtok((char*)args, " ");
-
- if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid))
- if (group)
- group->Disband();
-
- return true;
- }
-
- static bool HandleGroupRemoveCommand(ChatHandler* handler, char const* args)
- {
- Player* player = NULL;
- Group* group = NULL;
- uint64 guid = 0;
- char* nameStr = strtok((char*)args, " ");
-
- if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid, true))
- if (group)
- group->RemoveMember(guid);
-
- return true;
- }
-
- static bool HandlePlayAllCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- uint32 soundId = atoi((char*)args);
-
- if (!sSoundEntriesStore.LookupEntry(soundId))
- {
- handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- WorldPacket data(SMSG_PLAY_SOUND, 4);
- data << uint32(soundId) << handler->GetSession()->GetPlayer()->GetGUID();
- sWorld->SendGlobalMessage(&data);
-
- handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
- return true;
- }
-
- static bool HandlePossessCommand(ChatHandler* handler, char const* /*args*/)
- {
- Unit* unit = handler->getSelectedUnit();
- if (!unit)
- return false;
-
- handler->GetSession()->GetPlayer()->CastSpell(unit, 530, true);
- return true;
- }
-
- static bool HandleUnPossessCommand(ChatHandler* handler, char const* /*args*/)
- {
- Unit* unit = handler->getSelectedUnit();
- if (!unit)
- unit = handler->GetSession()->GetPlayer();
-
- unit->RemoveCharmAuras();
-
- return true;
- }
-
- static bool HandleBindSightCommand(ChatHandler* handler, char const* /*args*/)
- {
- Unit* unit = handler->getSelectedUnit();
- if (!unit)
- return false;
-
- handler->GetSession()->GetPlayer()->CastSpell(unit, 6277, true);
- return true;
- }
-
- static bool HandleUnbindSightCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* player = handler->GetSession()->GetPlayer();
-
- if (player->isPossessing())
- return false;
-
- player->StopCastingBindSight();
- return true;
- }
-};
-
-void AddSC_misc_commandscript()
-{
- new misc_commandscript();
-}
+/* + * Copyright (C) 2008-2012 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/>. + */ +
+#include "Chat.h" +#include "ScriptMgr.h" +#include "AccountMgr.h" +#include "ArenaTeamMgr.h" +#include "CellImpl.h" +#include "GridNotifiers.h" +#include "Group.h" +#include "InstanceSaveMgr.h" +#include "MovementGenerator.h" +#include "ObjectAccessor.h" +#include "SpellAuras.h" +#include "TargetedMovementGenerator.h" +#include "WeatherMgr.h" +#include "ace/INET_Addr.h" +
+class misc_commandscript : public CommandScript +{ +public: + misc_commandscript() : CommandScript("misc_commandscript") { } +
+ ChatCommand* GetCommands() const + { + static ChatCommand groupCommandTable[] = + { + { "leader", SEC_ADMINISTRATOR, false, &HandleGroupLeaderCommand, "", NULL }, + { "disband", SEC_ADMINISTRATOR, false, &HandleGroupDisbandCommand, "", NULL }, + { "remove", SEC_ADMINISTRATOR, false, &HandleGroupRemoveCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand petCommandTable[] = + { + { "create", SEC_GAMEMASTER, false, &HandleCreatePetCommand, "", NULL }, + { "learn", SEC_GAMEMASTER, false, &HandlePetLearnCommand, "", NULL }, + { "unlearn", SEC_GAMEMASTER, false, &HandlePetUnlearnCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand sendCommandTable[] = + { + { "items", SEC_ADMINISTRATOR, true, &HandleSendItemsCommand, "", NULL }, + { "mail", SEC_MODERATOR, true, &HandleSendMailCommand, "", NULL }, + { "message", SEC_ADMINISTRATOR, true, &HandleSendMessageCommand, "", NULL }, + { "money", SEC_ADMINISTRATOR, true, &HandleSendMoneyCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "dev", SEC_ADMINISTRATOR, false, &HandleDevCommand, "", NULL }, + { "gps", SEC_ADMINISTRATOR, false, &HandleGPSCommand, "", NULL }, + { "aura", SEC_ADMINISTRATOR, false, &HandleAuraCommand, "", NULL }, + { "unaura", SEC_ADMINISTRATOR, false, &HandleUnAuraCommand, "", NULL }, + { "appear", SEC_MODERATOR, false, &HandleAppearCommand, "", NULL }, + { "summon", SEC_MODERATOR, false, &HandleSummonCommand, "", NULL }, + { "groupsummon", SEC_MODERATOR, false, &HandleGroupSummonCommand, "", NULL }, + { "commands", SEC_PLAYER, true, &HandleCommandsCommand, "", NULL }, + { "die", SEC_ADMINISTRATOR, false, &HandleDieCommand, "", NULL }, + { "revive", SEC_ADMINISTRATOR, true, &HandleReviveCommand, "", NULL }, + { "dismount", SEC_PLAYER, false, &HandleDismountCommand, "", NULL }, + { "guid", SEC_GAMEMASTER, false, &HandleGUIDCommand, "", NULL }, + { "help", SEC_PLAYER, true, &HandleHelpCommand, "", NULL }, + { "itemmove", SEC_GAMEMASTER, false, &HandleItemMoveCommand, "", NULL }, + { "cooldown", SEC_ADMINISTRATOR, false, &HandleCooldownCommand, "", NULL }, + { "distance", SEC_ADMINISTRATOR, false, &HandleGetDistanceCommand, "", NULL }, + { "recall", SEC_MODERATOR, false, &HandleRecallCommand, "", NULL }, + { "save", SEC_PLAYER, false, &HandleSaveCommand, "", NULL }, + { "saveall", SEC_MODERATOR, true, &HandleSaveAllCommand, "", NULL }, + { "kick", SEC_GAMEMASTER, true, &HandleKickPlayerCommand, "", NULL }, + { "start", SEC_PLAYER, false, &HandleStartCommand, "", NULL }, + { "taxicheat", SEC_MODERATOR, false, &HandleTaxiCheatCommand, "", NULL }, + { "linkgrave", SEC_ADMINISTRATOR, false, &HandleLinkGraveCommand, "", NULL }, + { "neargrave", SEC_ADMINISTRATOR, false, &HandleNearGraveCommand, "", NULL }, + { "explorecheat", SEC_ADMINISTRATOR, false, &HandleExploreCheatCommand, "", NULL }, + { "showarea", SEC_ADMINISTRATOR, false, &HandleShowAreaCommand, "", NULL }, + { "hidearea", SEC_ADMINISTRATOR, false, &HandleHideAreaCommand, "", NULL }, + { "additem", SEC_ADMINISTRATOR, false, &HandleAddItemCommand, "", NULL }, + { "additemset", SEC_ADMINISTRATOR, false, &HandleAddItemSetCommand, "", NULL }, + { "bank", SEC_ADMINISTRATOR, false, &HandleBankCommand, "", NULL }, + { "wchange", SEC_ADMINISTRATOR, false, &HandleChangeWeather, "", NULL }, + { "maxskill", SEC_ADMINISTRATOR, false, &HandleMaxSkillCommand, "", NULL }, + { "setskill", SEC_ADMINISTRATOR, false, &HandleSetSkillCommand, "", NULL }, + { "pinfo", SEC_GAMEMASTER, true, &HandlePInfoCommand, "", NULL }, + { "respawn", SEC_ADMINISTRATOR, false, &HandleRespawnCommand, "", NULL }, + { "send", SEC_MODERATOR, true, NULL, "", sendCommandTable }, + { "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable }, + { "mute", SEC_MODERATOR, true, &HandleMuteCommand, "", NULL }, + { "unmute", SEC_MODERATOR, true, &HandleUnmuteCommand, "", NULL }, + { "movegens", SEC_ADMINISTRATOR, false, &HandleMovegensCommand, "", NULL }, + { "cometome", SEC_ADMINISTRATOR, false, &HandleComeToMeCommand, "", NULL }, + { "damage", SEC_ADMINISTRATOR, false, &HandleDamageCommand, "", NULL }, + { "combatstop", SEC_GAMEMASTER, true, &HandleCombatStopCommand, "", NULL }, + { "flusharenapoints", SEC_ADMINISTRATOR, false, &HandleFlushArenaPointsCommand, "", NULL }, + { "repairitems", SEC_GAMEMASTER, true, &HandleRepairitemsCommand, "", NULL }, + { "waterwalk", SEC_GAMEMASTER, false, &HandleWaterwalkCommand, "", NULL }, + { "freeze", SEC_MODERATOR, false, &HandleFreezeCommand, "", NULL }, + { "unfreeze", SEC_MODERATOR, false, &HandleUnFreezeCommand, "", NULL }, + { "listfreeze", SEC_MODERATOR, false, &HandleListFreezeCommand, "", NULL }, + { "group", SEC_ADMINISTRATOR, false, NULL, "", groupCommandTable }, + { "possess", SEC_ADMINISTRATOR, false, HandlePossessCommand, "", NULL }, + { "unpossess", SEC_ADMINISTRATOR, false, HandleUnPossessCommand, "", NULL }, + { "bindsight", SEC_ADMINISTRATOR, false, HandleBindSightCommand, "", NULL }, + { "unbindsight", SEC_ADMINISTRATOR, false, HandleUnbindSightCommand, "", NULL }, + { "playall", SEC_GAMEMASTER, false, HandlePlayAllCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } +
+ static bool HandleDevCommand(ChatHandler* handler, char const* args) + { + if (!*args) + { + if (handler->GetSession()->GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER)) + handler->GetSession()->SendNotification(LANG_DEV_ON); + else + handler->GetSession()->SendNotification(LANG_DEV_OFF); + return true; + } +
+ std::string argstr = (char*)args; +
+ if (argstr == "on") + { + handler->GetSession()->GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER); + handler->GetSession()->SendNotification(LANG_DEV_ON); + return true; + } +
+ if (argstr == "off") + { + handler->GetSession()->GetPlayer()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER); + handler->GetSession()->SendNotification(LANG_DEV_OFF); + return true; + } +
+ handler->SendSysMessage(LANG_USE_BOL); + handler->SetSentErrorMessage(true); + return false; + } +
+ static bool HandleGPSCommand(ChatHandler* handler, char const* args) + { + WorldObject* object = NULL; + if (*args) + { + uint64 guid = handler->extractGuidFromLink((char*)args); + if (guid) + object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); +
+ if (!object) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + } + else + { + object = handler->getSelectedUnit(); +
+ if (!object) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } + } +
+ CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY()); + Cell cell(cellCoord); +
+ uint32 zoneId, areaId; + object->GetZoneAndAreaId(zoneId, areaId); +
+ MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId()); + AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId); + AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId); +
+ float zoneX = object->GetPositionX(); + float zoneY = object->GetPositionY(); +
+ Map2ZoneCoordinates(zoneX, zoneY, zoneId); +
+ Map const* map = object->GetMap(); + float groundZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT); + float floorZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()); +
+ GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY()); +
+ // 63? WHY? + int gridX = 63 - gridCoord.x_coord; + int gridY = 63 - gridCoord.y_coord; +
+ uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0; + uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0; +
+ if (haveVMap) + { + if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->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, + object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"), + zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"), + areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"), + object->GetPhaseMask(), + object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(), + cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(), + zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap); +
+ LiquidData liquidStatus; + ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus); +
+ if (status) + handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status); +
+ return true; + } +
+ static bool HandleAuraCommand(ChatHandler* handler, char const* args) + { + Unit* target = handler->getSelectedUnit(); + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } +
+ // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spellId = handler->extractSpellIdFromLink((char*)args); +
+ if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) + Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, target, target); +
+ return true; + } +
+ static bool HandleUnAuraCommand(ChatHandler* handler, char const* args) + { + Unit* target = handler->getSelectedUnit(); + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } +
+ std::string argstr = args; + if (argstr == "all") + { + target->RemoveAllAuras(); + return true; + } +
+ // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spellId = handler->extractSpellIdFromLink((char*)args); + if (!spellId) + return false; +
+ target->RemoveAurasDueToSpell(spellId); +
+ return true; + } + // Teleport to Player + static bool HandleAppearCommand(ChatHandler* handler, char const* args) + { + Player* target; + uint64 targetGuid; + std::string targetName; + if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) + return false; +
+ Player* _player = handler->GetSession()->GetPlayer(); + if (target == _player || targetGuid == _player->GetGUID()) + { + handler->SendSysMessage(LANG_CANT_TELEPORT_SELF); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (target) + { + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; +
+ std::string chrNameLink = handler->playerLink(targetName); +
+ Map* map = target->GetMap(); + if (map->IsBattlegroundOrArena()) + { + // only allow if gm mode is on + if (!_player->isGameMaster()) + { + handler->PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, chrNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + // if both players are in different bgs + else if (_player->GetBattlegroundId() && _player->GetBattlegroundId() != target->GetBattlegroundId()) + _player->LeaveBattleground(false); // Note: should be changed so _player gets no Deserter debuff +
+ // all's well, set bg id + // when porting out from the bg, it will be reset to 0 + _player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId()); + // remember current position as entry point for return at bg end teleportation + if (!_player->GetMap()->IsBattlegroundOrArena()) + _player->SetBattlegroundEntryPoint(); + } + else if (map->IsDungeon()) + { + // we have to go to instance, and can go to player only if: + // 1) we are in his group (either as leader or as member) + // 2) we are not bound to any group and have GM mode on + if (_player->GetGroup()) + { + // we are in group, we can go only if we are in the player group + if (_player->GetGroup() != target->GetGroup()) + { + handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY, chrNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + } + else + { + // we are not in group, let's verify our GM mode + if (!_player->isGameMaster()) + { + handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM, chrNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + } +
+ // if the player or the player's group is bound to another instance + // the player will not be bound to another one + InstancePlayerBind* bind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(map->IsRaid())); + if (!bind) + { + Group* group = _player->GetGroup(); + // if no bind exists, create a solo bind + InstanceGroupBind* gBind = group ? group->GetBoundInstance(target) : NULL; // if no bind exists, create a solo bind + if (!gBind) + if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId())) + _player->BindToInstance(save, !save->CanReset()); + } +
+ if (map->IsRaid()) + _player->SetRaidDifficulty(target->GetRaidDifficulty()); + else + _player->SetDungeonDifficulty(target->GetDungeonDifficulty()); + } +
+ handler->PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str()); +
+ // stop flight if need + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); +
+ // to point to see at target with same orientation + float x, y, z; + target->GetContactPoint(_player, x, y, z); +
+ _player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE); + _player->SetPhaseMask(target->GetPhaseMask(), true); + } + else + { + // check offline security + if (handler->HasLowerSecurity(NULL, targetGuid)) + return false; +
+ std::string nameLink = handler->playerLink(targetName); +
+ handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str()); +
+ // to point where player stay (if loaded) + float x, y, z, o; + uint32 map; + bool in_flight; + if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, targetGuid)) + 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(map, x, y, z, _player->GetOrientation()); + } +
+ return true; + } + // Summon Player + static bool HandleSummonCommand(ChatHandler* handler, char const* args) + { + Player* target; + uint64 targetGuid; + std::string targetName; + if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) + return false; +
+ Player* _player = handler->GetSession()->GetPlayer(); + if (target == _player || targetGuid == _player->GetGUID()) + { + handler->PSendSysMessage(LANG_CANT_TELEPORT_SELF); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (target) + { + std::string nameLink = handler->playerLink(targetName); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; +
+ if (target->IsBeingTeleported()) + { + handler->PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } +
+ Map* map = handler->GetSession()->GetPlayer()->GetMap(); +
+ if (map->IsBattlegroundOrArena()) + { + // only allow if gm mode is on + if (!_player->isGameMaster()) + { + handler->PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + // if both players are in different bgs + else if (target->GetBattlegroundId() && handler->GetSession()->GetPlayer()->GetBattlegroundId() != target->GetBattlegroundId()) + target->LeaveBattleground(false); // Note: should be changed so target gets no Deserter debuff +
+ // all's well, set bg id + // when porting out from the bg, it will be reset to 0 + target->SetBattlegroundId(handler->GetSession()->GetPlayer()->GetBattlegroundId(), handler->GetSession()->GetPlayer()->GetBattlegroundTypeId()); + // remember current position as entry point for return at bg end teleportation + if (!target->GetMap()->IsBattlegroundOrArena()) + target->SetBattlegroundEntryPoint(); + } + else if (map->IsDungeon()) + { + Map* map = target->GetMap(); +
+ if (map->Instanceable() && map->GetInstanceId() != map->GetInstanceId()) + target->UnbindInstance(map->GetInstanceId(), target->GetDungeonDifficulty(), true); +
+ // we are in instance, and can summon only player in our group with us as lead + if (!handler->GetSession()->GetPlayer()->GetGroup() || !target->GetGroup() || + (target->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) || + (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID())) + // the last check is a bit excessive, but let it be, just in case + { + handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + } +
+ handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), ""); + if (handler->needReportToTarget(target)) + ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str()); +
+ // stop flight if need + if (target->isInFlight()) + { + target->GetMotionMaster()->MovementExpired(); + target->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + target->SaveRecallPosition(); +
+ // before GM + float x, y, z; + handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectSize()); + target->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, target->GetOrientation()); + target->SetPhaseMask(handler->GetSession()->GetPlayer()->GetPhaseMask(), true); + } + else + { + // check offline security + if (handler->HasLowerSecurity(NULL, targetGuid)) + return false; +
+ std::string nameLink = handler->playerLink(targetName); +
+ handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), handler->GetTrinityString(LANG_OFFLINE)); +
+ // in point where GM stay + Player::SavePositionInDB(handler->GetSession()->GetPlayer()->GetMapId(), + handler->GetSession()->GetPlayer()->GetPositionX(), + handler->GetSession()->GetPlayer()->GetPositionY(), + handler->GetSession()->GetPlayer()->GetPositionZ(), + handler->GetSession()->GetPlayer()->GetOrientation(), + handler->GetSession()->GetPlayer()->GetZoneId(), + targetGuid); + } +
+ return true; + } + // Summon group of player + static bool HandleGroupSummonCommand(ChatHandler* handler, char const* args) + { + Player* target; + if (!handler->extractPlayerTarget((char*)args, &target)) + return false; +
+ // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; +
+ Group* group = target->GetGroup(); +
+ std::string nameLink = handler->GetNameLink(target); +
+ if (!group) + { + handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } +
+ Map* gmMap = handler->GetSession()->GetPlayer()->GetMap(); + bool toInstance = gmMap->Instanceable(); +
+ // we are in instance, and can summon only player in our group with us as lead + if (toInstance && ( + !handler->GetSession()->GetPlayer()->GetGroup() || (group->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) || + (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()))) + // the last check is a bit excessive, but let it be, just in case + { + handler->SendSysMessage(LANG_CANNOT_SUMMON_TO_INST); + handler->SetSentErrorMessage(true); + return false; + } +
+ for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player* player = itr->getSource(); +
+ if (!player || player == handler->GetSession()->GetPlayer() || !player->GetSession()) + continue; +
+ // check online security + if (handler->HasLowerSecurity(player, 0)) + return false; +
+ std::string plNameLink = handler->GetNameLink(player); +
+ if (player->IsBeingTeleported() == true) + { + handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (toInstance) + { + Map* playerMap = player->GetMap(); +
+ if (playerMap->Instanceable() && playerMap->GetInstanceId() != gmMap->GetInstanceId()) + { + // cannot summon from instance to instance + handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + } +
+ handler->PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), ""); + if (handler->needReportToTarget(player)) + ChatHandler(player).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str()); +
+ // stop flight if need + if (player->isInFlight()) + { + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + player->SaveRecallPosition(); +
+ // before GM + float x, y, z; + handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize()); + player->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation()); + } +
+ return true; + } +
+ static bool HandleCommandsCommand(ChatHandler* handler, char const* /*args*/) + { + handler->ShowHelpForCommand(handler->getCommandTable(), ""); + return true; + } +
+ static bool HandleDieCommand(ChatHandler* handler, char const* /*args*/) + { + Unit* target = handler->getSelectedUnit(); +
+ if (!target || !handler->GetSession()->GetPlayer()->GetSelection()) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (target->GetTypeId() == TYPEID_PLAYER) + { + if (handler->HasLowerSecurity((Player*)target, 0, false)) + return false; + } +
+ if (target->isAlive()) + { + if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE)) + handler->GetSession()->GetPlayer()->Kill(target); + else + handler->GetSession()->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } +
+ return true; + } +
+ static bool HandleReviveCommand(ChatHandler* handler, char const* args) + { + Player* target; + uint64 targetGuid; + if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid)) + return false; +
+ if (target) + { + target->ResurrectPlayer(!AccountMgr::IsPlayerAccount(target->GetSession()->GetSecurity()) ? 1.0f : 0.5f); + target->SpawnCorpseBones(); + target->SaveToDB(); + } + else + // will resurrected at login without corpse + sObjectAccessor->ConvertCorpseForPlayer(targetGuid); +
+ return true; + } +
+ static bool HandleDismountCommand(ChatHandler* handler, char const* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); +
+ // If player is not mounted, so go out :) + if (!player->IsMounted()) + { + handler->SendSysMessage(LANG_CHAR_NON_MOUNTED); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (player->isInFlight()) + { + handler->SendSysMessage(LANG_YOU_IN_FLIGHT); + handler->SetSentErrorMessage(true); + return false; + } +
+ player->Dismount(); + player->RemoveAurasByType(SPELL_AURA_MOUNTED); + return true; + } +
+ static bool HandleGUIDCommand(ChatHandler* handler, char const* /*args*/) + { + uint64 guid = handler->GetSession()->GetPlayer()->GetSelection(); +
+ if (guid == 0) + { + handler->SendSysMessage(LANG_NO_SELECTION); + handler->SetSentErrorMessage(true); + return false; + } +
+ handler->PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid)); + return true; + } +
+ static bool HandleHelpCommand(ChatHandler* handler, char const* args) + { + char const* cmd = strtok((char*)args, " "); + if (!cmd) + { + handler->ShowHelpForCommand(handler->getCommandTable(), "help"); + handler->ShowHelpForCommand(handler->getCommandTable(), ""); + } + else + { + if (!handler->ShowHelpForCommand(handler->getCommandTable(), cmd)) + handler->SendSysMessage(LANG_NO_HELP_CMD); + } +
+ return true; + } + // move item to other slot + static bool HandleItemMoveCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ char const* param1 = strtok((char*)args, " "); + if (!param1) + return false; +
+ char const* param2 = strtok(NULL, " "); + if (!param2) + return false; +
+ uint8 srcSlot = uint8(atoi(param1)); + uint8 dstSlot = uint8(atoi(param2)); +
+ if (srcSlot == dstSlot) + return true; +
+ if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, srcSlot, true)) + return false; +
+ if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, dstSlot, false)) + return false; +
+ uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcSlot); + uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstSlot); +
+ handler->GetSession()->GetPlayer()->SwapItem(src, dst); +
+ return true; + } +
+ static bool HandleCooldownCommand(ChatHandler* handler, char const* args) + { + Player* target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } +
+ std::string nameLink = handler->GetNameLink(target); +
+ if (!*args) + { + target->RemoveAllSpellCooldown(); + handler->PSendSysMessage(LANG_REMOVEALL_COOLDOWN, nameLink.c_str()); + } + else + { + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spellIid = handler->extractSpellIdFromLink((char*)args); + if (!spellIid) + return false; +
+ if (!sSpellMgr->GetSpellInfo(spellIid)) + { + handler->PSendSysMessage(LANG_UNKNOWN_SPELL, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } +
+ target->RemoveSpellCooldown(spellIid, true); + handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spellIid, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str()); + } + return true; + } +
+ static bool HandleGetDistanceCommand(ChatHandler* handler, char const* 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; + } + } +
+ handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(obj), handler->GetSession()->GetPlayer()->GetDistance2d(obj), handler->GetSession()->GetPlayer()->GetExactDist(obj), handler->GetSession()->GetPlayer()->GetExactDist2d(obj)); + return true; + } + // Teleport player to last position + static bool HandleRecallCommand(ChatHandler* handler, char const* args) + { + Player* target; + if (!handler->extractPlayerTarget((char*)args, &target)) + return false; +
+ // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; +
+ if (target->IsBeingTeleported()) + { + handler->PSendSysMessage(LANG_IS_TELEPORTED, handler->GetNameLink(target).c_str()); + handler->SetSentErrorMessage(true); + return false; + } +
+ // stop flight if need + if (target->isInFlight()) + { + target->GetMotionMaster()->MovementExpired(); + target->CleanupAfterTaxiFlight(); + } +
+ target->TeleportTo(target->m_recallMap, target->m_recallX, target->m_recallY, target->m_recallZ, target->m_recallO); + return true; + } +
+ static bool HandleSaveCommand(ChatHandler* handler, char const* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); +
+ // save GM account without delay and output message + if (!AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity())) + { + if (Player* target = handler->getSelectedPlayer()) + target->SaveToDB(); + else + player->SaveToDB(); + handler->SendSysMessage(LANG_PLAYER_SAVED); + return true; + } +
+ // save if the player has last been saved over 20 seconds ago + uint32 saveInterval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE); + if (saveInterval == 0 || (saveInterval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= saveInterval - 20 * IN_MILLISECONDS)) + player->SaveToDB(); +
+ return true; + } +
+ // Save all players in the world + static bool HandleSaveAllCommand(ChatHandler* handler, char const* /*args*/) + { + sObjectAccessor->SaveAllPlayers(); + handler->SendSysMessage(LANG_PLAYERS_SAVED); + return true; + } +
+ // kick player + static bool HandleKickPlayerCommand(ChatHandler* handler, char const* args) + { + Player* target = NULL; + std::string playerName; + if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName)) + return false; +
+ if (handler->GetSession() && target == handler->GetSession()->GetPlayer()) + { + handler->SendSysMessage(LANG_COMMAND_KICKSELF); + handler->SetSentErrorMessage(true); + return false; + } +
+ // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; +
+ if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD)) + sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); + else + handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); +
+ target->GetSession()->KickPlayer(); +
+ return true; + } +
+ static bool HandleStartCommand(ChatHandler* handler, char const* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); +
+ if (player->isInFlight()) + { + handler->SendSysMessage(LANG_YOU_IN_FLIGHT); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (player->isInCombat()) + { + handler->SendSysMessage(LANG_YOU_IN_COMBAT); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (player->isDead() || player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + { + // if player is dead and stuck, send ghost to graveyard + player->RepopAtGraveyard(); + return true; + } +
+ // cast spell Stuck + player->CastSpell(player, 7355, false); + return true; + } + // Enable on\off all taxi paths + static bool HandleTaxiCheatCommand(ChatHandler* handler, char const* args) + { + if (!*args) + { + handler->SendSysMessage(LANG_USE_BOL); + handler->SetSentErrorMessage(true); + return false; + } +
+ std::string argStr = (char*)args; +
+ Player* chr = handler->getSelectedPlayer(); +
+ if (!chr) + chr = handler->GetSession()->GetPlayer(); + else if (handler->HasLowerSecurity(chr, 0)) // check online security + return false; +
+ if (argStr == "on") + { + chr->SetTaxiCheater(true); + handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str()); + if (handler->needReportToTarget(chr)) + ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink().c_str()); + return true; + } +
+ if (argStr == "off") + { + chr->SetTaxiCheater(false); + handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str()); + if (handler->needReportToTarget(chr)) + ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str()); +
+ return true; + } +
+ handler->SendSysMessage(LANG_USE_BOL); + handler->SetSentErrorMessage(true); +
+ return false; + } +
+ static bool HandleLinkGraveCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ char* px = strtok((char*)args, " "); + if (!px) + return false; +
+ uint32 graveyardId = uint32(atoi(px)); +
+ uint32 team; +
+ char* px2 = strtok(NULL, " "); +
+ if (!px2) + team = 0; + else if (strncmp(px2, "horde", 6) == 0) + team = HORDE; + else if (strncmp(px2, "alliance", 9) == 0) + team = ALLIANCE; + else + return false; +
+ WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(graveyardId); +
+ if (!graveyard) + { + handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId); + handler->SetSentErrorMessage(true); + return false; + } +
+ Player* player = handler->GetSession()->GetPlayer(); +
+ uint32 zoneId = player->GetZoneId(); +
+ AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(zoneId); + if (!areaEntry || areaEntry->zone !=0) + { + handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, graveyardId, zoneId); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (sObjectMgr->AddGraveYardLink(graveyardId, zoneId, team)) + handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, graveyardId, zoneId); + else + handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, graveyardId, zoneId); +
+ return true; + } +
+ static bool HandleNearGraveCommand(ChatHandler* handler, char const* args) + { + uint32 team; +
+ size_t argStr = strlen(args); +
+ if (!*args) + team = 0; + else if (strncmp((char*)args, "horde", argStr) == 0) + team = HORDE; + else if (strncmp((char*)args, "alliance", argStr) == 0) + team = ALLIANCE; + else + return false; +
+ Player* player = handler->GetSession()->GetPlayer(); + uint32 zone_id = player->GetZoneId(); +
+ WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard( + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team); +
+ if (graveyard) + { + uint32 graveyardId = graveyard->ID; +
+ GraveYardData const* data = sObjectMgr->FindGraveYardData(graveyardId, zone_id); + if (!data) + { + handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR, graveyardId); + handler->SetSentErrorMessage(true); + return false; + } +
+ team = data->team; +
+ std::string team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_NOTEAM); +
+ if (team == 0) + team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); + else if (team == HORDE) + team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); + else if (team == ALLIANCE) + team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); +
+ handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, graveyardId, team_name.c_str(), zone_id); + } + else + { + std::string team_name; +
+ if (team == 0) + team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); + else if (team == HORDE) + team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); + else if (team == ALLIANCE) + team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); +
+ if (team == ~uint32(0)) + handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id); + else + handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str()); + } +
+ return true; + } +
+ static bool HandleExploreCheatCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ int32 flag = int32(atoi((char*)args)); +
+ Player* playerTarget = handler->getSelectedPlayer(); + if (!playerTarget) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (flag != 0) + { + handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(playerTarget).c_str()); + if (handler->needReportToTarget(playerTarget)) + ChatHandler(playerTarget).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, handler->GetNameLink().c_str()); + } + else + { + handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(playerTarget).c_str()); + if (handler->needReportToTarget(playerTarget)) + ChatHandler(playerTarget).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, handler->GetNameLink().c_str()); + } +
+ for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) + { + if (flag != 0) + handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0xFFFFFFFF); + else + handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0); + } +
+ return true; + } +
+ static bool HandleShowAreaCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ Player* playerTarget = handler->getSelectedPlayer(); + if (!playerTarget) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } +
+ int32 area = GetAreaFlagByAreaID(atoi((char*)args)); + int32 offset = area / 32; + uint32 val = uint32((1 << (area % 32))); +
+ if (area<0 || offset >= PLAYER_EXPLORED_ZONES_SIZE) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } +
+ uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); + playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields | val))); +
+ handler->SendSysMessage(LANG_EXPLORE_AREA); + return true; + } +
+ static bool HandleHideAreaCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ Player* playerTarget = handler->getSelectedPlayer(); + if (!playerTarget) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } +
+ int32 area = GetAreaFlagByAreaID(atoi((char*)args)); + int32 offset = area / 32; + uint32 val = uint32((1 << (area % 32))); +
+ if (area < 0 || offset >= PLAYER_EXPLORED_ZONES_SIZE) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } +
+ uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); + playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields ^ val))); +
+ handler->SendSysMessage(LANG_UNEXPLORE_AREA); + return true; + } +
+ static bool HandleAddItemCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ uint32 itemId = 0; +
+ if (args[0] == '[') // [name] manual form + { + char const* itemNameStr = strtok((char*)args, "]"); +
+ if (itemNameStr && itemNameStr[0]) + { + std::string itemName = itemNameStr+1; + WorldDatabase.EscapeString(itemName); +
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME); + stmt->setString(0, itemName); + PreparedQueryResult result = WorldDatabase.Query(stmt); +
+ if (!result) + { + handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, itemNameStr+1); + handler->SetSentErrorMessage(true); + return false; + } + itemId = result->Fetch()->GetUInt32(); + } + else + return false; + } + else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r + { + char const* id = handler->extractKeyFromLink((char*)args, "Hitem"); + if (!id) + return false; + itemId = uint32(atol(id)); + } +
+ char const* ccount = strtok(NULL, " "); +
+ int32 count = 1; +
+ if (ccount) + count = strtol(ccount, NULL, 10); +
+ if (count == 0) + count = 1; +
+ Player* player = handler->GetSession()->GetPlayer(); + Player* playerTarget = handler->getSelectedPlayer(); + if (!playerTarget) + playerTarget = player; +
+ sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEM), itemId, count); +
+ ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId); + if (!itemTemplate) + { + handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); + handler->SetSentErrorMessage(true); + return false; + } +
+ // Subtract + if (count < 0) + { + playerTarget->DestroyItemCount(itemId, -count, true, false); + handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str()); + return true; + } +
+ // Adding items + uint32 noSpaceForCount = 0; +
+ // check space and find places + ItemPosCountVec dest; + InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); + if (msg != EQUIP_ERR_OK) // convert to possible store amount + count -= noSpaceForCount; +
+ if (count == 0 || dest.empty()) // can't add any + { + handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); + handler->SetSentErrorMessage(true); + return false; + } +
+ Item* item = playerTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); +
+ // remove binding (let GM give it to another player later) + if (player == playerTarget) + for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) + if (Item* item1 = player->GetItemByPos(itr->pos)) + item1->SetBinding(false); +
+ if (count > 0 && item) + { + player->SendNewItem(item, count, false, true); + if (player != playerTarget) + playerTarget->SendNewItem(item, count, true, false); + } +
+ if (noSpaceForCount > 0) + handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); +
+ return true; + } +
+ static bool HandleAddItemSetCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ char const* id = handler->extractKeyFromLink((char*)args, "Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r + if (!id) + return false; +
+ uint32 itemSetId = atol(id); +
+ // prevent generation all items with itemset field value '0' + if (itemSetId == 0) + { + handler->PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemSetId); + handler->SetSentErrorMessage(true); + return false; + } +
+ Player* player = handler->GetSession()->GetPlayer(); + Player* playerTarget = handler->getSelectedPlayer(); + if (!playerTarget) + playerTarget = player; +
+ sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEMSET), itemSetId); +
+ bool found = false; + ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); + for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr) + { + if (itr->second.ItemSet == itemSetId) + { + found = true; + ItemPosCountVec dest; + InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itr->second.ItemId, 1); + if (msg == EQUIP_ERR_OK) + { + Item* item = playerTarget->StoreNewItem(dest, itr->second.ItemId, true); +
+ // remove binding (let GM give it to another player later) + if (player == playerTarget) + item->SetBinding(false); +
+ player->SendNewItem(item, 1, false, true); + if (player != playerTarget) + playerTarget->SendNewItem(item, 1, true, false); + } + else + { + player->SendEquipError(msg, NULL, NULL, itr->second.ItemId); + handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itr->second.ItemId, 1); + } + } + } +
+ if (!found) + { + handler->PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemSetId); + handler->SetSentErrorMessage(true); + return false; + } +
+ return true; + } +
+ static bool HandleBankCommand(ChatHandler* handler, char const* /*args*/) + { + handler->GetSession()->SendShowBank(handler->GetSession()->GetPlayer()->GetGUID()); + return true; + } +
+ static bool HandleChangeWeather(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ // Weather is OFF + if (!sWorld->getBoolConfig(CONFIG_WEATHER)) + { + handler->SendSysMessage(LANG_WEATHER_DISABLED); + handler->SetSentErrorMessage(true); + return false; + } +
+ // *Change the weather of a cell + char const* px = strtok((char*)args, " "); + char const* py = strtok(NULL, " "); +
+ if (!px || !py) + return false; +
+ uint32 type = uint32(atoi(px)); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand + float grade = float(atof(py)); //0 to 1, sending -1 is instand good weather +
+ Player* player = handler->GetSession()->GetPlayer(); + uint32 zoneid = player->GetZoneId(); +
+ Weather* weather = WeatherMgr::FindWeather(zoneid); +
+ if (!weather) + weather = WeatherMgr::AddWeather(zoneid); + if (!weather) + { + handler->SendSysMessage(LANG_NO_WEATHER); + handler->SetSentErrorMessage(true); + return false; + } +
+ weather->SetWeather(WeatherType(type), grade); +
+ return true; + } +
+ + static bool HandleMaxSkillCommand(ChatHandler* handler, char const* /*args*/) + { + Player* SelectedPlayer = handler->getSelectedPlayer(); + if (!SelectedPlayer) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } +
+ // each skills that have max skill value dependent from level seted to current level max skill value + SelectedPlayer->UpdateSkillsToMaxSkillsForLevel(); + return true; + } +
+ static bool HandleSetSkillCommand(ChatHandler* handler, char const* args) + { + // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r + char const* skillStr = handler->extractKeyFromLink((char*)args, "Hskill"); + if (!skillStr) + return false; +
+ char const* levelStr = strtok(NULL, " "); + if (!levelStr) + return false; +
+ char const* maxPureSkill = strtok(NULL, " "); +
+ int32 skill = atoi(skillStr); + if (skill <= 0) + { + handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skill); + handler->SetSentErrorMessage(true); + return false; + } +
+ int32 level = uint32(atol(levelStr)); +
+ Player* target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } +
+ SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skill); + if (!skillLine) + { + handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skill); + handler->SetSentErrorMessage(true); + return false; + } +
+ std::string tNameLink = handler->GetNameLink(target); +
+ if (!target->GetSkillValue(skill)) + { + handler->PSendSysMessage(LANG_SET_SKILL_ERROR, tNameLink.c_str(), skill, skillLine->name[handler->GetSessionDbcLocale()]); + handler->SetSentErrorMessage(true); + return false; + } +
+ uint16 max = maxPureSkill ? atol (maxPureSkill) : target->GetPureMaxSkillValue(skill); +
+ if (level <= 0 || level > max || max <= 0) + return false; +
+ target->SetSkill(skill, target->GetSkillStep(skill), level, max); + handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->name[handler->GetSessionDbcLocale()], tNameLink.c_str(), level, max); +
+ return true; + } + // show info of player + static bool HandlePInfoCommand(ChatHandler* handler, char const* args) + { + Player* target; + uint64 targetGuid; + std::string targetName; +
+ uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER); +
+ if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName)) + { + target = sObjectMgr->GetPlayerByLowGUID(parseGUID); + targetGuid = parseGUID; + } + else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) + return false; +
+ uint32 accId = 0; + uint32 money = 0; + uint32 totalPlayerTime = 0; + uint8 level = 0; + uint32 latency = 0; + uint8 race; + uint8 Class; + int64 muteTime = 0; + int64 banTime = -1; + uint32 mapId; + uint32 areaId; + uint32 phase = 0; +
+ // get additional information from Player object + if (target) + { + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; +
+ accId = target->GetSession()->GetAccountId(); + money = target->GetMoney(); + totalPlayerTime = target->GetTotalPlayedTime(); + level = target->getLevel(); + latency = target->GetSession()->GetLatency(); + race = target->getRace(); + Class = target->getClass(); + muteTime = target->GetSession()->m_muteTime; + mapId = target->GetMapId(); + areaId = target->GetAreaId(); + phase = target->GetPhaseMask(); + } + // get additional information from DB + else + { + // check offline security + if (handler->HasLowerSecurity(NULL, targetGuid)) + return false; +
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO); + stmt->setUInt32(0, GUID_LOPART(targetGuid)); + PreparedQueryResult result = CharacterDatabase.Query(stmt); +
+ if (!result) + return false; +
+ Field* fields = result->Fetch(); + totalPlayerTime = fields[0].GetUInt32(); + level = fields[1].GetUInt8(); + money = fields[2].GetUInt32(); + accId = fields[3].GetUInt32(); + race = fields[4].GetUInt8(); + Class = fields[5].GetUInt8(); + mapId = fields[6].GetUInt16(); + areaId = fields[7].GetUInt16(); + } +
+ std::string userName = handler->GetTrinityString(LANG_ERROR); + std::string eMail = handler->GetTrinityString(LANG_ERROR); + std::string lastIp = handler->GetTrinityString(LANG_ERROR); + uint32 security = 0; + std::string lastLogin = handler->GetTrinityString(LANG_ERROR); +
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO); + stmt->setInt32(0, int32(realmID)); + stmt->setUInt32(1, accId); + PreparedQueryResult result = LoginDatabase.Query(stmt); +
+ if (result) + { + Field* fields = result->Fetch(); + userName = fields[0].GetString(); + security = fields[1].GetUInt8(); + eMail = fields[2].GetString(); + muteTime = fields[5].GetUInt64(); +
+ if (eMail.empty()) + eMail = "-"; +
+ if (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security)) + { + lastIp = fields[3].GetString(); + lastLogin = fields[4].GetString(); +
+ uint32 ip = inet_addr(lastIp.c_str()); +#if TRINITY_ENDIAN == BIGENDIAN + EndianConvertReverse(ip); +#endif +
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY); +
+ stmt->setUInt32(0, ip); +
+ PreparedQueryResult result2 = WorldDatabase.Query(stmt); +
+ if (result2) + { + Field* fields2 = result2->Fetch(); + lastIp.append(" ("); + lastIp.append(fields2[0].GetString()); + lastIp.append(")"); + } + } + else + { + lastIp = "-"; + lastLogin = "-"; + } + } +
+ std::string nameLink = handler->playerLink(targetName); +
+ handler->PSendSysMessage(LANG_PINFO_ACCOUNT, (target ? "" : handler->GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(targetGuid), userName.c_str(), accId, eMail.c_str(), security, lastIp.c_str(), lastLogin.c_str(), latency); +
+ std::string bannedby = "unknown"; + std::string banreason = ""; +
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS); + stmt->setUInt32(0, accId); + PreparedQueryResult result2 = LoginDatabase.Query(stmt); + if (!result2) + { + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS); + stmt->setUInt32(0, GUID_LOPART(targetGuid)); + result2 = CharacterDatabase.Query(stmt); + } +
+ if (result2) + { + Field* fields = result2->Fetch(); + banTime = int64(fields[1].GetBool() ? 0 : fields[0].GetUInt32()); + bannedby = fields[2].GetString(); + banreason = fields[3].GetString(); + } +
+ if (muteTime > 0) + handler->PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str()); +
+ if (banTime >= 0) + handler->PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str()); +
+ std::string raceStr, ClassStr; + switch (race) + { + case RACE_HUMAN: + raceStr = "Human"; + break; + case RACE_ORC: + raceStr = "Orc"; + break; + case RACE_DWARF: + raceStr = "Dwarf"; + break; + case RACE_NIGHTELF: + raceStr = "Night Elf"; + break; + case RACE_UNDEAD_PLAYER: + raceStr = "Undead"; + break; + case RACE_TAUREN: + raceStr = "Tauren"; + break; + case RACE_GNOME: + raceStr = "Gnome"; + break; + case RACE_TROLL: + raceStr = "Troll"; + break; + case RACE_BLOODELF: + raceStr = "Blood Elf"; + break; + case RACE_DRAENEI: + raceStr = "Draenei"; + break; + } +
+ switch (Class) + { + case CLASS_WARRIOR: + ClassStr = "Warrior"; + break; + case CLASS_PALADIN: + ClassStr = "Paladin"; + break; + case CLASS_HUNTER: + ClassStr = "Hunter"; + break; + case CLASS_ROGUE: + ClassStr = "Rogue"; + break; + case CLASS_PRIEST: + ClassStr = "Priest"; + break; + case CLASS_DEATH_KNIGHT: + ClassStr = "Death Knight"; + break; + case CLASS_SHAMAN: + ClassStr = "Shaman"; + break; + case CLASS_MAGE: + ClassStr = "Mage"; + break; + case CLASS_WARLOCK: + ClassStr = "Warlock"; + break; + case CLASS_DRUID: + ClassStr = "Druid"; + break; + } +
+ std::string timeStr = secsToTimeString(totalPlayerTime, true, true); + uint32 gold = money /GOLD; + uint32 silv = (money % GOLD) / SILVER; + uint32 copp = (money % GOLD) % SILVER; + handler->PSendSysMessage(LANG_PINFO_LEVEL, raceStr.c_str(), ClassStr.c_str(), timeStr.c_str(), level, gold, silv, copp); +
+ // Add map, zone, subzone and phase to output + int locale = handler->GetSessionDbcLocale(); + std::string areaName = "<unknown>"; + std::string zoneName = ""; +
+ MapEntry const* map = sMapStore.LookupEntry(mapId); +
+ AreaTableEntry const* area = GetAreaEntryByAreaID(areaId); + if (area) + { + areaName = area->area_name[locale]; +
+ AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone); + if (zone) + zoneName = zone->area_name[locale]; + } +
+ if (target) + { + if (!zoneName.empty()) + handler->PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zoneName.c_str(), areaName.c_str(), phase); + else + handler->PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], areaName.c_str(), "<unknown>", phase); + } + else + handler->PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str()); +
+ return true; + } +
+ static bool HandleRespawnCommand(ChatHandler* handler, char const* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); +
+ // accept only explicitly selected target (not implicitly self targeting case) + Unit* target = handler->getSelectedUnit(); + if (player->GetSelection() && target) + { + if (target->GetTypeId() != TYPEID_UNIT || target->isPet()) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (target->isDead()) + target->ToCreature()->Respawn(); + return true; + } +
+ CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY())); + Cell cell(p); + cell.SetNoCreate(); +
+ Trinity::RespawnDo u_do; + Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do); +
+ TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker); + cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange()); +
+ return true; + } + // mute player for some times + static bool HandleMuteCommand(ChatHandler* handler, char const* args) + { + char* nameStr; + char* delayStr; + handler->extractOptFirstArg((char*)args, &nameStr, &delayStr); + if (!delayStr) + return false; +
+ char const* muteReason = strtok(NULL, "\r"); + std::string muteReasonStr = "No reason"; + if (muteReason != NULL) + muteReasonStr = muteReason; +
+ Player* target; + uint64 targetGuid; + std::string targetName; + if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName)) + return false; +
+ uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); +
+ // find only player from same account if any + if (!target) + if (WorldSession* session = sWorld->FindSession(accountId)) + target = session->GetPlayer(); +
+ uint32 notSpeakTime = uint32(atoi(delayStr)); +
+ // must have strong lesser security level + if (handler->HasLowerSecurity (target, targetGuid, true)) + return false; +
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); +
+ if (target) + { + // Target is online, mute will be in effect right away. + int64 muteTime = time(NULL) + notSpeakTime * MINUTE; + target->GetSession()->m_muteTime = muteTime; + stmt->setInt64(0, muteTime); + ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteReasonStr.c_str()); + } + else + { + // Target is offline, mute will be in effect starting from the next login. + int32 muteTime = -int32(notSpeakTime * MINUTE); + stmt->setInt64(0, muteTime); + } +
+ stmt->setUInt32(1, accountId); + LoginDatabase.Execute(stmt); + std::string nameLink = handler->playerLink(targetName); +
+ handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); +
+ return true; + } +
+ // unmute player + static bool HandleUnmuteCommand(ChatHandler* handler, char const* args) + { + Player* target; + uint64 targetGuid; + std::string targetName; + if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) + return false; +
+ uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); +
+ // find only player from same account if any + if (!target) + if (WorldSession* session = sWorld->FindSession(accountId)) + target = session->GetPlayer(); +
+ // must have strong lesser security level + if (handler->HasLowerSecurity (target, targetGuid, true)) + return false; +
+ if (target) + { + if (target->CanSpeak()) + { + handler->SendSysMessage(LANG_CHAT_ALREADY_ENABLED); + handler->SetSentErrorMessage(true); + return false; + } +
+ target->GetSession()->m_muteTime = 0; + } +
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); + stmt->setInt64(0, 0); + stmt->setUInt32(1, accountId); + LoginDatabase.Execute(stmt); +
+ if (target) + ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); +
+ std::string nameLink = handler->playerLink(targetName); +
+ handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str()); +
+ return true; + } +
+ + static bool HandleMovegensCommand(ChatHandler* handler, char const* /*args*/) + { + Unit* unit = handler->getSelectedUnit(); + if (!unit) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } +
+ handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow()); +
+ MotionMaster* motionMaster = unit->GetMotionMaster(); + float x, y, z; + motionMaster->GetDestination(x, y, z); +
+ for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i) + { + MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(i); + if (!movementGenerator) + { + handler->SendSysMessage("Empty"); + continue; + } +
+ switch (movementGenerator->GetMovementGeneratorType()) + { + case IDLE_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_IDLE); + break; + case RANDOM_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_RANDOM); + break; + case WAYPOINT_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_WAYPOINT); + break; + case ANIMAL_RANDOM_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM); + break; + case CONFUSED_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_CONFUSED); + break; + case CHASE_MOTION_TYPE: + { + Unit* target = NULL; + if (unit->GetTypeId() == TYPEID_PLAYER) + target = static_cast<ChaseMovementGenerator<Player> const*>(movementGenerator)->GetTarget(); + else + target = static_cast<ChaseMovementGenerator<Creature> const*>(movementGenerator)->GetTarget(); +
+ if (!target) + handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL); + else if (target->GetTypeId() == TYPEID_PLAYER) + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); + else + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow()); + break; + } + case FOLLOW_MOTION_TYPE: + { + Unit* target = NULL; + if (unit->GetTypeId() == TYPEID_PLAYER) + target = static_cast<FollowMovementGenerator<Player> const*>(movementGenerator)->GetTarget(); + else + target = static_cast<FollowMovementGenerator<Creature> const*>(movementGenerator)->GetTarget(); +
+ if (!target) + handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); + else if (target->GetTypeId() == TYPEID_PLAYER) + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); + else + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow()); + break; + } + case HOME_MOTION_TYPE: + { + if (unit->GetTypeId() == TYPEID_UNIT) + handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z); + else + handler->SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); + break; + } + case FLIGHT_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_FLIGHT); + break; + case POINT_MOTION_TYPE: + { + handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z); + break; + } + case FLEEING_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_FEAR); + break; + case DISTRACT_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_DISTRACT); + break; + case EFFECT_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_EFFECT); + break; + default: + handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType()); + break; + } + } + return true; + } + /* + ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator + Without this function 3rd party scripting library will get linking errors (unresolved external) + when attempting to use the PointMovementGenerator + */ + static bool HandleComeToMeCommand(ChatHandler* handler, char const* args) + { + char const* newFlagStr = strtok((char*)args, " "); + if (!newFlagStr) + return false; +
+ Creature* caster = handler->getSelectedCreature(); + if (!caster) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } +
+ Player* player = handler->GetSession()->GetPlayer(); +
+ caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); +
+ return true; + } +
+ static bool HandleDamageCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ Unit* target = handler->getSelectedUnit(); + if (!target || !handler->GetSession()->GetPlayer()->GetSelection()) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (target->GetTypeId() == TYPEID_PLAYER) + { + if (handler->HasLowerSecurity((Player*)target, 0, false)) + return false; + } +
+ if (!target->isAlive()) + return true; +
+ char* damageStr = strtok((char*)args, " "); + if (!damageStr) + return false; +
+ int32 damage_int = atoi((char*)damageStr); + if (damage_int <= 0) + return true; +
+ uint32 damage = damage_int; +
+ char* schoolStr = strtok((char*)NULL, " "); +
+ // flat melee damage without resistence/etc reduction + if (!schoolStr) + { + handler->GetSession()->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + if (target != handler->GetSession()->GetPlayer()) + handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0); + return true; + } +
+ uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL; + if (school >= MAX_SPELL_SCHOOL) + return false; +
+ SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); +
+ if (Unit::IsDamageReducedByArmor(schoolmask)) + damage = handler->GetSession()->GetPlayer()->CalcArmorReducedDamage(target, damage, NULL, BASE_ATTACK); +
+ char* spellStr = strtok((char*)NULL, " "); +
+ // melee damage by specific school + if (!spellStr) + { + uint32 absorb = 0; + uint32 resist = 0; +
+ handler->GetSession()->GetPlayer()->CalcAbsorbResist(target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); +
+ if (damage <= absorb + resist) + return true; +
+ damage -= absorb + resist; +
+ handler->GetSession()->GetPlayer()->DealDamageMods(target, damage, &absorb); + handler->GetSession()->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); + handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0); + return true; + } +
+ // non-melee damage +
+ // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spellid = handler->extractSpellIdFromLink((char*)args); + if (!spellid || !sSpellMgr->GetSpellInfo(spellid)) + return false; +
+ handler->GetSession()->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage); + return true; + } +
+ static bool HandleCombatStopCommand(ChatHandler* handler, char const* args) + { + Player* target = NULL; +
+ if (args && strlen(args) > 0) + { + target = sObjectAccessor->FindPlayerByName(args); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + } +
+ if (!target) + { + if (!handler->extractPlayerTarget((char*)args, &target)) + return false; + } +
+ // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; +
+ target->CombatStop(); + target->getHostileRefManager().deleteReferences(); + return true; + } +
+ static bool HandleFlushArenaPointsCommand(ChatHandler* /*handler*/, char const* /*args*/) + { + sArenaTeamMgr->DistributeArenaPoints(); + return true; + } +
+ static bool HandleRepairitemsCommand(ChatHandler* handler, char const* args) + { + Player* target; + if (!handler->extractPlayerTarget((char*)args, &target)) + return false; +
+ // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; +
+ // Repair items + target->DurabilityRepairAll(false, 0, false); +
+ handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, handler->GetNameLink(target).c_str()); + if (handler->needReportToTarget(target)) + ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, handler->GetNameLink().c_str()); +
+ return true; + } +
+ static bool HandleWaterwalkCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ Player* player = handler->getSelectedPlayer(); + if (!player) + { + handler->PSendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } +
+ // check online security + if (handler->HasLowerSecurity(player, 0)) + return false; +
+ if (strncmp(args, "on", 3) == 0) + player->SetMovement(MOVE_WATER_WALK); // ON + else if (strncmp(args, "off", 4) == 0) + player->SetMovement(MOVE_LAND_WALK); // OFF + else + { + handler->SendSysMessage(LANG_USE_BOL); + return false; + } +
+ handler->PSendSysMessage(LANG_YOU_SET_WATERWALK, args, handler->GetNameLink(player).c_str()); + if (handler->needReportToTarget(player)) + ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, handler->GetNameLink().c_str()); + return true; + } +
+ // Send mail by command + static bool HandleSendMailCommand(ChatHandler* handler, char const* args) + { + // format: name "subject text" "mail text" + Player* target; + uint64 targetGuid; + std::string targetName; + if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) + return false; +
+ char* tail1 = strtok(NULL, ""); + if (!tail1) + return false; +
+ char const* msgSubject = handler->extractQuotedArg(tail1); + if (!msgSubject) + return false; +
+ char* tail2 = strtok(NULL, ""); + if (!tail2) + return false; +
+ char const* msgText = handler->extractQuotedArg(tail2); + if (!msgText) + return false; +
+ // msgSubject, msgText isn't NUL after prev. check + std::string subject = msgSubject; + std::string text = msgText; +
+ // from console show not existed sender + MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); +
+ //- TODO: Fix poor design + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + MailDraft(subject, text) + .SendMailTo(trans, MailReceiver(target, GUID_LOPART(targetGuid)), sender); +
+ CharacterDatabase.CommitTransaction(trans); +
+ std::string nameLink = handler->playerLink(targetName); + handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); + return true; + } + // Send items by mail + static bool HandleSendItemsCommand(ChatHandler* handler, char const* args) + { + // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12] + Player* receiver; + uint64 receiverGuid; + std::string receiverName; + if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName)) + return false; +
+ char* tail1 = strtok(NULL, ""); + if (!tail1) + return false; +
+ char const* msgSubject = handler->extractQuotedArg(tail1); + if (!msgSubject) + return false; +
+ char* tail2 = strtok(NULL, ""); + if (!tail2) + return false; +
+ char const* msgText = handler->extractQuotedArg(tail2); + if (!msgText) + return false; +
+ // msgSubject, msgText isn't NUL after prev. check + std::string subject = msgSubject; + std::string text = msgText; +
+ // extract items + typedef std::pair<uint32, uint32> ItemPair; + typedef std::list< ItemPair > ItemPairs; + ItemPairs items; +
+ // get all tail string + char* tail = strtok(NULL, ""); +
+ // get from tail next item str + while (char* itemStr = strtok(tail, " ")) + { + // and get new tail + tail = strtok(NULL, ""); +
+ // parse item str + char const* itemIdStr = strtok(itemStr, ":"); + char const* itemCountStr = strtok(NULL, " "); +
+ uint32 itemId = atoi(itemIdStr); + if (!itemId) + return false; +
+ ItemTemplate const* item_proto = sObjectMgr->GetItemTemplate(itemId); + if (!item_proto) + { + handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); + handler->SetSentErrorMessage(true); + return false; + } +
+ uint32 itemCount = itemCountStr ? atoi(itemCountStr) : 1; + if (itemCount < 1 || (item_proto->MaxCount > 0 && itemCount > uint32(item_proto->MaxCount))) + { + handler->PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, itemCount, itemId); + handler->SetSentErrorMessage(true); + return false; + } +
+ while (itemCount > item_proto->GetMaxStackSize()) + { + items.push_back(ItemPair(itemId, item_proto->GetMaxStackSize())); + itemCount -= item_proto->GetMaxStackSize(); + } +
+ items.push_back(ItemPair(itemId, itemCount)); +
+ if (items.size() > MAX_MAIL_ITEMS) + { + handler->PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); + handler->SetSentErrorMessage(true); + return false; + } + } +
+ // from console show not existed sender + MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); +
+ // fill mail + MailDraft draft(subject, text); +
+ SQLTransaction trans = CharacterDatabase.BeginTransaction(); +
+ for (ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) + { + if (Item* item = Item::CreateItem(itr->first, itr->second, handler->GetSession() ? handler->GetSession()->GetPlayer() : 0)) + { + item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted + draft.AddItem(item); + } + } +
+ draft.SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender); + CharacterDatabase.CommitTransaction(trans); +
+ std::string nameLink = handler->playerLink(receiverName); + handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); + return true; + } + /// Send money by mail + static bool HandleSendMoneyCommand(ChatHandler* handler, char const* args) + { + /// format: name "subject text" "mail text" money +
+ Player* receiver; + uint64 receiverGuid; + std::string receiverName; + if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName)) + return false; +
+ char* tail1 = strtok(NULL, ""); + if (!tail1) + return false; +
+ char* msgSubject = handler->extractQuotedArg(tail1); + if (!msgSubject) + return false; +
+ char* tail2 = strtok(NULL, ""); + if (!tail2) + return false; +
+ char* msgText = handler->extractQuotedArg(tail2); + if (!msgText) + return false; +
+ char* moneyStr = strtok(NULL, ""); + int32 money = moneyStr ? atoi(moneyStr) : 0; + if (money <= 0) + return false; +
+ // msgSubject, msgText isn't NUL after prev. check + std::string subject = msgSubject; + std::string text = msgText; +
+ // from console show not existed sender + MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); +
+ SQLTransaction trans = CharacterDatabase.BeginTransaction(); +
+ MailDraft(subject, text) + .AddMoney(money) + .SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender); +
+ CharacterDatabase.CommitTransaction(trans); +
+ std::string nameLink = handler->playerLink(receiverName); + handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); + return true; + } + /// Send a message to a player in game + static bool HandleSendMessageCommand(ChatHandler* handler, char const* args) + { + /// - Find the player + Player* player; + if (!handler->extractPlayerTarget((char*)args, &player)) + return false; +
+ char* msgStr = strtok(NULL, ""); + if (!msgStr) + return false; +
+ ///- Check that he is not logging out. + if (player->GetSession()->isLogingOut()) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } +
+ /// - Send the message + // Use SendAreaTriggerMessage for fastest delivery. + player->GetSession()->SendAreaTriggerMessage("%s", msgStr); + player->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r"); +
+ // Confirmation message + std::string nameLink = handler->GetNameLink(player); + handler->PSendSysMessage(LANG_SENDMESSAGE, nameLink.c_str(), msgStr); +
+ return true; + } +
+ static bool HandleCreatePetCommand(ChatHandler* handler, char const* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); + Creature* creatureTarget = handler->getSelectedCreature(); +
+ if (!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER) + { + handler->PSendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } +
+ CreatureTemplate const* creatrueTemplate = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry()); + // Creatures with family 0 crashes the server + if (!creatrueTemplate->family) + { + handler->PSendSysMessage("This creature cannot be tamed. (family id: 0)."); + handler->SetSentErrorMessage(true); + return false; + } +
+ if (player->GetPetGUID()) + { + handler->PSendSysMessage("You already have a pet"); + handler->SetSentErrorMessage(true); + return false; + } +
+ // Everything looks OK, create new pet + Pet* pet = new Pet(player, HUNTER_PET); + if (!pet->CreateBaseAtCreature(creatureTarget)) + { + delete pet; + handler->PSendSysMessage("Error 1"); + return false; + } +
+ creatureTarget->setDeathState(JUST_DIED); + creatureTarget->RemoveCorpse(); + creatureTarget->SetHealth(0); // just for nice GM-mode view +
+ pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID()); + pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction()); +
+ if (!pet->InitStatsForLevel(creatureTarget->getLevel())) + { + sLog->outError(LOG_FILTER_GENERAL, "InitStatsForLevel() in EffectTameCreature failed! Pet deleted."); + handler->PSendSysMessage("Error 2"); + delete pet; + return false; + } +
+ // prepare visual effect for levelup + pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()-1); +
+ pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true); + // this enables pet details window (Shift+P) + pet->InitPetCreateSpells(); + pet->SetFullHealth(); +
+ pet->GetMap()->AddToMap(pet->ToCreature()); +
+ // visual effect for levelup + pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()); +
+ player->SetMinion(pet, true); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + player->PetSpellInitialize(); +
+ return true; + } +
+ static bool HandlePetLearnCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ Player* player = handler->GetSession()->GetPlayer(); + Pet* pet = player->GetPet(); +
+ if (!pet) + { + handler->PSendSysMessage("You have no pet"); + handler->SetSentErrorMessage(true); + return false; + } +
+ uint32 spellId = handler->extractSpellIdFromLink((char*)args); +
+ if (!spellId || !sSpellMgr->GetSpellInfo(spellId)) + return false; +
+ // Check if pet already has it + if (pet->HasSpell(spellId)) + { + handler->PSendSysMessage("Pet already has spell: %u", spellId); + handler->SetSentErrorMessage(true); + return false; + } +
+ // Check if spell is valid + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo)) + { + handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId); + handler->SetSentErrorMessage(true); + return false; + } +
+ pet->learnSpell(spellId); +
+ handler->PSendSysMessage("Pet has learned spell %u", spellId); + return true; + } +
+ static bool HandlePetUnlearnCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ Player* player = handler->GetSession()->GetPlayer(); + Pet* pet = player->GetPet(); + if (!pet) + { + handler->PSendSysMessage("You have no pet"); + handler->SetSentErrorMessage(true); + return false; + } +
+ uint32 spellId = handler->extractSpellIdFromLink((char*)args); +
+ if (pet->HasSpell(spellId)) + pet->removeSpell(spellId, false); + else + handler->PSendSysMessage("Pet doesn't have that spell"); +
+ return true; + } +
+ static bool HandleFreezeCommand(ChatHandler* handler, char const* args) + { + std::string name; + Player* player; + char const* TargetName = strtok((char*)args, " "); // get entered name + if (!TargetName) // if no name entered use target + { + player = handler->getSelectedPlayer(); + if (player) //prevent crash with creature as target + { + name = player->GetName(); + normalizePlayerName(name); + } + } + else // if name entered + { + name = TargetName; + normalizePlayerName(name); + player = sObjectAccessor->FindPlayerByName(name.c_str()); + } +
+ if (!player) + { + handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG); + return true; + } +
+ if (player == handler->GetSession()->GetPlayer()) + { + handler->SendSysMessage(LANG_COMMAND_FREEZE_ERROR); + return true; + } +
+ // effect + if (player && (player != handler->GetSession()->GetPlayer())) + { + handler->PSendSysMessage(LANG_COMMAND_FREEZE, name.c_str()); +
+ // stop combat + make player unattackable + duel stop + stop some spells + player->setFaction(35); + player->CombatStop(); + if (player->IsNonMeleeSpellCasted(true)) + player->InterruptNonMeleeSpells(true); + player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); +
+ // if player class = hunter || warlock remove pet if alive + if ((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK)) + { + if (Pet* pet = player->GetPet()) + { + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + // not let dismiss dead pet + if (pet && pet->isAlive()) + player->RemovePet(pet, PET_SAVE_NOT_IN_SLOT); + } + } +
+ if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(9454)) + Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, player, player); +
+ // save player + player->SaveToDB(); + } +
+ return true; + } +
+ static bool HandleUnFreezeCommand(ChatHandler* handler, char const*args) + { + std::string name; + Player* player; + char* targetName = strtok((char*)args, " "); // Get entered name +
+ if (targetName) + { + name = targetName; + normalizePlayerName(name); + player = sObjectAccessor->FindPlayerByName(name.c_str()); + } + else // If no name was entered - use target + { + player = handler->getSelectedPlayer(); + if (player) + name = player->GetName(); + } +
+ if (player) + { + handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str()); +
+ // Reset player faction + allow combat + allow duels + player->setFactionForRace(player->getRace()); + player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); +
+ // Remove Freeze spell (allowing movement and spells) + player->RemoveAurasDueToSpell(9454); +
+ // Save player + player->SaveToDB(); + } + else + { + if (targetName) + { + // Check for offline players + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_BY_NAME); + stmt->setString(0, name); + PreparedQueryResult result = CharacterDatabase.Query(stmt); +
+ if (!result) + { + handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG); + return true; + } +
+ // If player found: delete his freeze aura + Field* fields = result->Fetch(); + uint32 lowGuid = fields[0].GetUInt32(); +
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN); + stmt->setUInt32(0, lowGuid); + CharacterDatabase.Execute(stmt); +
+ handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str()); + return true; + } + else + { + handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG); + return true; + } + } +
+ return true; + } +
+ static bool HandleListFreezeCommand(ChatHandler* handler, char const* /*args*/) + { + // Get names from DB + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AURA_FROZEN); + PreparedQueryResult result = CharacterDatabase.Query(stmt); + if (!result) + { + handler->SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS); + return true; + } +
+ // Header of the names + handler->PSendSysMessage(LANG_COMMAND_LIST_FREEZE); +
+ // Output of the results + do + { + Field* fields = result->Fetch(); + std::string player = fields[0].GetString(); + handler->PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player.c_str()); + } + while (result->NextRow()); +
+ return true; + } +
+ static bool HandleGroupLeaderCommand(ChatHandler* handler, char const* args) + { + Player* player = NULL; + Group* group = NULL; + uint64 guid = 0; + char* nameStr = strtok((char*)args, " "); +
+ if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid)) + if (group && group->GetLeaderGUID() != guid) + { + group->ChangeLeader(guid); + group->SendUpdate(); + } +
+ return true; + } +
+ static bool HandleGroupDisbandCommand(ChatHandler* handler, char const* args) + { + Player* player = NULL; + Group* group = NULL; + uint64 guid = 0; + char* nameStr = strtok((char*)args, " "); +
+ if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid)) + if (group) + group->Disband(); +
+ return true; + } +
+ static bool HandleGroupRemoveCommand(ChatHandler* handler, char const* args) + { + Player* player = NULL; + Group* group = NULL; + uint64 guid = 0; + char* nameStr = strtok((char*)args, " "); +
+ if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid, true)) + if (group) + group->RemoveMember(guid); +
+ return true; + } +
+ static bool HandlePlayAllCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; +
+ uint32 soundId = atoi((char*)args); +
+ if (!sSoundEntriesStore.LookupEntry(soundId)) + { + handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId); + handler->SetSentErrorMessage(true); + return false; + } +
+ WorldPacket data(SMSG_PLAY_SOUND, 4); + data << uint32(soundId) << handler->GetSession()->GetPlayer()->GetGUID(); + sWorld->SendGlobalMessage(&data); +
+ handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId); + return true; + } +
+ static bool HandlePossessCommand(ChatHandler* handler, char const* /*args*/) + { + Unit* unit = handler->getSelectedUnit(); + if (!unit) + return false; +
+ handler->GetSession()->GetPlayer()->CastSpell(unit, 530, true); + return true; + } +
+ static bool HandleUnPossessCommand(ChatHandler* handler, char const* /*args*/) + { + Unit* unit = handler->getSelectedUnit(); + if (!unit) + unit = handler->GetSession()->GetPlayer(); +
+ unit->RemoveCharmAuras(); +
+ return true; + } +
+ static bool HandleBindSightCommand(ChatHandler* handler, char const* /*args*/) + { + Unit* unit = handler->getSelectedUnit(); + if (!unit) + return false; +
+ handler->GetSession()->GetPlayer()->CastSpell(unit, 6277, true); + return true; + } +
+ static bool HandleUnbindSightCommand(ChatHandler* handler, char const* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); +
+ if (player->isPossessing()) + return false; +
+ player->StopCastingBindSight(); + return true; + } +}; +
+void AddSC_misc_commandscript() +{ + new misc_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index 1747b80efd5..a88c765c596 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -1130,20 +1130,15 @@ public: static bool HandleModifyDrunkCommand(ChatHandler* handler, const char* args) { - if (!*args) return false; + if (!*args) + return false; - uint32 drunklevel = (uint32)atoi(args); + uint8 drunklevel = (uint8)atoi(args); if (drunklevel > 100) drunklevel = 100; - uint16 drunkMod = drunklevel * 0xFFFF / 100; - - Player* target = handler->getSelectedPlayer(); - if (!target) - target = handler->GetSession()->GetPlayer(); - - if (target) - target->SetDrunkValue(drunkMod); + if (Player* target = handler->getSelectedPlayer()) + target->SetDrunkValue(drunklevel); return true; } diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index c8568feaeb6..3bb29f8abfe 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -949,7 +949,7 @@ public: static bool HandleReloadItemSetNamesCommand(ChatHandler* handler, const char* /*args*/) { sLog->outInfo(LOG_FILTER_GENERAL, "Re-Loading Item set names..."); - LoadRandomEnchantmentsTable(); + sObjectMgr->LoadItemSetNames(); handler->SendGlobalGMSysMessage("DB table `item_set_names` reloaded."); return true; } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index bc29a6f1f3c..06c1243645c 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -75,8 +75,8 @@ public: { boss_moroesAI(Creature* creature) : ScriptedAI(creature) { - for (uint8 i = 0; i < 4; ++i) - AddId[i] = 0; + memset(AddId, 0, sizeof(AddId)); + memset(AddGUID, 0, sizeof(AddGUID)); instance = creature->GetInstanceScript(); } @@ -105,10 +105,8 @@ public: Enrage = false; InVanish = false; - if (me->GetHealth() > 0) - { + if (me->GetHealth()) SpawnAdds(); - } if (instance) instance->SetData(TYPE_MOROES, NOT_STARTED); @@ -193,10 +191,9 @@ public: bool isAddlistEmpty() { for (uint8 i = 0; i < 4; ++i) - { if (AddId[i] == 0) return true; - } + return false; } @@ -341,17 +338,10 @@ struct boss_moroes_guestAI : public ScriptedAI if (!instance) return; - uint64 MoroesGUID = instance->GetData64(DATA_MOROES); - Creature* Moroes = (Unit::GetCreature((*me), MoroesGUID)); - if (Moroes) - { + if (Creature* Moroes = Unit::GetCreature(*me, instance->GetData64(DATA_MOROES))) for (uint8 i = 0; i < 4; ++i) - { - uint64 GUID = CAST_AI(boss_moroes::boss_moroesAI, Moroes->AI())->AddGUID[i]; - if (GUID) + if (uint64 GUID = CAST_AI(boss_moroes::boss_moroesAI, Moroes->AI())->AddGUID[i]) GuestGUID[i] = GUID; - } - } } Unit* SelectGuestTarget() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index 1ed4da1f25e..d5add0f0bb7 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -187,6 +187,7 @@ public: boss_malchezaarAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); + memset(axes, 0, sizeof(axes)); } InstanceScript* instance; @@ -218,7 +219,10 @@ public: positions.clear(); for (uint8 i = 0; i < 5; ++i) + { enfeeble_targets[i] = 0; + enfeeble_health[i] = 0; + } for (uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i) positions.push_back(&InfernalPoints[i]); diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp index 68b3bdb9b7e..6324c5adf16 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp @@ -276,14 +276,9 @@ public: std::ostringstream stream; stream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3] << ' ' << m_auiEncounter[4] << ' ' << m_auiEncounter[5]; - char* out = new char[stream.str().length() + 1]; - strcpy(out, stream.str().c_str()); - if (out) - { - OUT_SAVE_INST_DATA_COMPLETE; - return out; - } - return NULL; + + OUT_SAVE_INST_DATA_COMPLETE; + return stream.str(); } void Load(const char* in) diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp index c7d6e2fb6e4..068d00f550f 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp @@ -80,7 +80,9 @@ class boss_akilzon : public CreatureScript boss_akilzonAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); + memset(BirdGUIDs, 0, sizeof(BirdGUIDs)); } + InstanceScript* instance; uint64 BirdGUIDs[8]; @@ -116,8 +118,7 @@ class boss_akilzon : public CreatureScript CloudGUID = 0; CycloneGUID = 0; DespawnSummons(); - for (uint8 i = 0; i < 8; ++i) - BirdGUIDs[i] = 0; + memset(BirdGUIDs, 0, sizeof(BirdGUIDs)); StormCount = 0; StormSequenceTimer = 0; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp index ecf173b02e5..a8afd19cd96 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp @@ -109,6 +109,7 @@ class boss_halazzi : public CreatureScript if (instance) instance->SetData(DATA_HALAZZIEVENT, NOT_STARTED); + LynxGUID = 0; TransformCount = 0; BerserkTimer = 600000; CheckTimer = 1000; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp index 305e3813ebc..235bec7cc8a 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp @@ -180,12 +180,13 @@ class instance_zulaman : public InstanceMapScript std::string GetSaveData() { + OUT_SAVE_INST_DATA; + std::ostringstream ss; ss << "S " << BossKilled << ' ' << ChestLooted << ' ' << QuestMinute; - char* data = new char[ss.str().length()+1]; - strcpy(data, ss.str().c_str()); - //sLog->outError(LOG_FILTER_TSCR, "Zul'aman saved, %s.", data); - return data; + + OUT_SAVE_INST_DATA_COMPLETE; + return ss.str(); } void Load(const char* load) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp index d4359a100b4..88b2a766671 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp @@ -36,6 +36,7 @@ enum Spells SPELL_SLEEP = 52721, //Puts an enemy to sleep for up to 10 sec. Any damage caused will awaken the target. H_SPELL_SLEEP = 58849, SPELL_VAMPIRIC_TOUCH = 52723, //Heals the caster for half the damage dealt by a melee attack. + SPELL_MAL_GANIS_KILL_CREDIT = 58124, // Quest credit SPELL_KILL_CREDIT = 58630 // Non-existing spell as encounter credit, created in spell_dbc }; @@ -238,9 +239,9 @@ public: if (instance) { instance->SetData(DATA_MAL_GANIS_EVENT, DONE); - + DoCastAOE(SPELL_MAL_GANIS_KILL_CREDIT); // give achievement credit and LFG rewards to players. criteria use spell 58630 which doesn't exist, but it was created in spell_dbc - DoCast(me, SPELL_KILL_CREDIT); + DoCastAOE(SPELL_KILL_CREDIT); } } diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp index 1fdf941d75c..c243682cc61 100644 --- a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp +++ b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp @@ -35,11 +35,14 @@ EndScriptData */ enum Yells { - SAY_AGGRO = -1249000, - SAY_KILL = -1249001, - SAY_PHASE_2_TRANS = -1249002, - SAY_PHASE_3_TRANS = -1249003, - EMOTE_BREATH = -1249004, + // Say + SAY_AGGRO = 0, + SAY_KILL = 1, + SAY_PHASE_2_TRANS = 2, + SAY_PHASE_3_TRANS = 3, + + // Emote + EMOTE_BREATH = 4, }; enum Spells @@ -184,7 +187,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); me->SetInCombatWithZone(); if (instance) @@ -227,7 +230,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_KILL, me); + Talk(SAY_KILL); } void SpellHit(Unit* /*pCaster*/, const SpellInfo* Spell) @@ -269,7 +272,7 @@ public: me->SetCanFly(true); me->GetMotionMaster()->MovePoint(11, Phase2Location.GetPositionX(), Phase2Location.GetPositionY(), Phase2Location.GetPositionZ()+25); me->SetSpeed(MOVE_FLIGHT, 1.0f); - DoScriptText(SAY_PHASE_2_TRANS, me); + Talk(SAY_PHASE_2_TRANS); if (instance) instance->SetData(DATA_ONYXIA_PHASE, Phase); WhelpTimer = 5000; @@ -416,7 +419,7 @@ public: Phase = PHASE_END; if (instance) instance->SetData(DATA_ONYXIA_PHASE, Phase); - DoScriptText(SAY_PHASE_3_TRANS, me); + Talk(SAY_PHASE_3_TRANS); SetCombatMovement(true); me->SetCanFly(false); @@ -432,7 +435,7 @@ public: if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); - DoScriptText(EMOTE_BREATH, me); + Talk(EMOTE_BREATH); DoCast(me, PointData->SpellId); DeepBreathTimer = 70000; } diff --git a/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp b/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp index 6c0d43b053e..3a6a3f6241c 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp @@ -119,6 +119,18 @@ public: void Initialize() { GahzRillaEncounter = NOT_STARTED; + ZumrahGUID = 0; + BlyGUID = 0; + WeegliGUID = 0; + OroGUID = 0; + RavenGUID = 0; + MurtaGUID = 0; + EndDoorGUID = 0; + PyramidPhase = 0; + major_wave_Timer = 0; + minor_wave_Timer = 0; + addGroupSize = 0; + waypoint = 0; } void OnCreatureCreate(Creature* creature) diff --git a/src/server/scripts/Kalimdor/moonglade.cpp b/src/server/scripts/Kalimdor/moonglade.cpp index 9df208d2578..3c8d2267903 100644 --- a/src/server/scripts/Kalimdor/moonglade.cpp +++ b/src/server/scripts/Kalimdor/moonglade.cpp @@ -296,7 +296,10 @@ public: struct npc_clintar_spiritAI : public npc_escortAI { public: - npc_clintar_spiritAI(Creature* creature) : npc_escortAI(creature) {} + npc_clintar_spiritAI(Creature* creature) : npc_escortAI(creature) + { + PlayerGUID = 0; + } uint8 Step; uint32 CurrWP; diff --git a/src/server/scripts/Northrend/CMakeLists.txt b/src/server/scripts/Northrend/CMakeLists.txt index 3502e7fb104..dd8dd17c947 100644 --- a/src/server/scripts/Northrend/CMakeLists.txt +++ b/src/server/scripts/Northrend/CMakeLists.txt @@ -10,6 +10,7 @@ set(scripts_STAT_SRCS ${scripts_STAT_SRCS} + Northrend/wintergrasp.cpp Northrend/isle_of_conquest.cpp Northrend/storm_peaks.cpp Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp index 76d5949eb44..d77c84b2978 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp @@ -219,8 +219,6 @@ public: } InstanceScript* instance; - - Creature* pMemory; uint64 MemoryGUID; bool bHealth; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index b3b9801fd00..1019deac106 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -37,15 +37,17 @@ EndScriptData */ enum Yells { - SAY_INTRO = -1649055, - SAY_AGGRO = -1649056, - SAY_KILL1 = -1649057, - SAY_KILL2 = -1649058, - SAY_DEATH = -1649059, - EMOTE_SPIKE = -1649060, - SAY_BURROWER = -1649061, - EMOTE_LEECHING_SWARM = -1649062, - SAY_LEECHING_SWARM = -1649063, + SAY_INTRO = 0, + SAY_AGGRO = 1, + EMOTE_SUBMERGE = 2, + EMOTE_BURROWER = 3, + SAY_EMERGE = 4, + SAY_LEECHING_SWARM = 5, + EMOTE_LEECHING_SWARM = 6, + SAY_KILL_PLAYER = 7, + SAY_DEATH = 8, + + EMOTE_SPIKE = 0, }; enum Summons @@ -195,7 +197,7 @@ public: { if (who->GetTypeId() == TYPEID_PLAYER) { - DoScriptText(urand(0, 1) ? SAY_KILL1 : SAY_KILL2, me); + Talk(SAY_KILL_PLAYER); if (instance) instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); } @@ -321,7 +323,7 @@ public: DoCast(me, SPELL_SUBMERGE_ANUBARAK); DoCast(me, SPELL_CLEAR_ALL_DEBUFFS); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - DoScriptText(SAY_BURROWER, me); + Talk(EMOTE_BURROWER); m_uiScarabSummoned = 0; m_uiSummonScarabTimer = 4*IN_MILLISECONDS; m_uiStage = 2; @@ -669,6 +671,7 @@ public: { m_uiTargetGUID = who->GetGUID(); DoCast(who, SPELL_MARK); + Talk(EMOTE_SPIKE, who->GetGUID()); me->SetSpeed(MOVE_RUN, 0.5f); m_uiSpeed = 0; m_uiIncreaseSpeedTimer = 1*IN_MILLISECONDS; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp index 3b0aeb958cb..c662daf3671 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp @@ -33,10 +33,9 @@ EndScriptData */ #include "SpellAuraEffects.h" #include "trial_of_the_crusader.h" -enum eYell +enum Yells { - SAY_GARROSH_KILL_ALLIANCE_PLAYER4 = -1649118, - SAY_VARIAN_KILL_HORDE_PLAYER4 = -1649123, + SAY_KILL_PLAYER = 6, }; enum eAIs @@ -359,11 +358,12 @@ struct boss_faction_championsAI : public ScriptedAI if (TeamInInstance == ALLIANCE) { if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_VARIAN))) - DoScriptText(SAY_VARIAN_KILL_HORDE_PLAYER4+urand(0, 3), temp); // + cause we are on negative + temp->AI()->Talk(SAY_KILL_PLAYER); } else - if (Creature* temp = me->FindNearestCreature(NPC_GARROSH, 300.f)) - DoScriptText(SAY_GARROSH_KILL_ALLIANCE_PLAYER4+urand(0, 3), temp); // + cause we are on negative + if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_GARROSH))) + temp->AI()->Talk(SAY_KILL_PLAYER); + instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index 4e791dfc22f..f9e2080895a 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -36,16 +36,18 @@ EndScriptData */ enum Yells { - SAY_INTRO = -1649030, - SAY_AGGRO = -1649031, - SAY_DEATH = -1649032, - EMOTE_INCINERATE = -1649033, - SAY_INCINERATE = -1649034, - EMOTE_LEGION_FLAME = -1649035, - EMOTE_NETHER_PORTAL = -1649036, - SAY_NETHER_PORTAL = -1649037, - EMOTE_INFERNAL_ERUPTION = -1649038, - SAY_INFERNAL_ERUPTION = -1649039, + SAY_INTRO = 0, + SAY_AGGRO = 1, + EMOTE_LEGION_FLAME = 2, + EMOTE_NETHER_PORTAL = 3, + SAY_MISTRESS_OF_PAIN = 4, + EMOTE_INCINERATE = 5, + SAY_INCINERATE = 6, + EMOTE_INFERNAL_ERUPTION = 7, + SAY_INFERNAL_ERUPTION = 8, + SAY_KILL_PLAYER = 9, + SAY_DEATH = 10, + SAY_BERSERK = 11, }; enum Equipment @@ -192,8 +194,8 @@ public: if (m_uiSummonNetherPortalTimer <= uiDiff) { - DoScriptText(EMOTE_NETHER_PORTAL, me); - DoScriptText(SAY_NETHER_PORTAL, me); + Talk(EMOTE_NETHER_PORTAL); + Talk(SAY_MISTRESS_OF_PAIN); DoCast(SPELL_NETHER_PORTAL); m_uiSummonNetherPortalTimer = 2*MINUTE*IN_MILLISECONDS; } else m_uiSummonNetherPortalTimer -= uiDiff; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp index 6c69ccbc72d..8dd4f7dad3e 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp @@ -35,16 +35,16 @@ EndScriptData */ enum Yells { - //Gormok - SAY_SNOBOLLED = -1649000, - //Acidmaw & Dreadscale - SAY_SUBMERGE = -1649010, - SAY_EMERGE = -1649011, - SAY_BERSERK = -1649012, - //Icehowl - SAY_TRAMPLE_STARE = -1649020, - SAY_TRAMPLE_FAIL = -1649021, - SAY_TRAMPLE_START = -1649022, + // Gormok + EMOTE_SNOBOLLED = 0, + + // Acidmaw & Dreadscale + EMOTE_ENRAGE = 0, + + // Icehowl + EMOTE_TRAMPLE_START = 0, + EMOTE_TRAMPLE_CRASH = 1, + EMOTE_TRAMPLE_FAIL = 2, }; enum Equipment @@ -239,7 +239,7 @@ public: if (m_uiSummonCount > 0) { me->SummonCreature(NPC_SNOBOLD_VASSAL, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN); - DoScriptText(SAY_SNOBOLLED, me); + Talk(EMOTE_SNOBOLLED); } m_uiSummonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); } else m_uiSummonTimer -= diff; @@ -460,12 +460,11 @@ struct boss_jormungarAI : public ScriptedAI if (instanceScript && instanceScript->GetData(TYPE_NORTHREND_BEASTS) == SNAKES_SPECIAL && !enraged) { - DoScriptText(SAY_EMERGE, me); me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); DoCast(SPELL_ENRAGE); enraged = true; - DoScriptText(SAY_BERSERK, me); + Talk(EMOTE_ENRAGE); switch (stage) { case 0: @@ -512,7 +511,6 @@ struct boss_jormungarAI : public ScriptedAI case 1: // Submerge me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); DoCast(me, SPELL_SUBMERGE_0); - DoScriptText(SAY_SUBMERGE, me); me->GetMotionMaster()->MovePoint(0, ToCCommonLoc[1].GetPositionX()+ frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionY() + frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionZ()); stage = 2; case 2: // Wait til emerge @@ -524,7 +522,6 @@ struct boss_jormungarAI : public ScriptedAI break; case 3: // Emerge me->SetDisplayId(modelStationary); - DoScriptText(SAY_EMERGE, me); me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0); DoCast(me, SPELL_EMERGE_0); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); @@ -558,7 +555,6 @@ struct boss_jormungarAI : public ScriptedAI case 5: // Submerge me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); DoCast(me, SPELL_SUBMERGE_0); - DoScriptText(SAY_SUBMERGE, me); me->GetMotionMaster()->MovePoint(0, ToCCommonLoc[1].GetPositionX() + frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionY() + frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionZ()); stage = 6; case 6: // Wait til emerge @@ -570,7 +566,6 @@ struct boss_jormungarAI : public ScriptedAI break; case 7: // Emerge me->SetDisplayId(modelMobile); - DoScriptText(SAY_EMERGE, me); me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0); DoCast(me, SPELL_EMERGE_0); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); @@ -925,7 +920,6 @@ public: { m_uiTrampleTargetGUID = target->GetGUID(); me->SetTarget(m_uiTrampleTargetGUID); - DoScriptText(SAY_TRAMPLE_STARE, me, target); m_bTrampleCasted = false; SetCombatMovement(false); me->GetMotionMaster()->MoveIdle(); @@ -953,7 +947,7 @@ public: } else m_uiTrampleTimer -= diff; break; case 4: - DoScriptText(SAY_TRAMPLE_START, me); + Talk(EMOTE_TRAMPLE_START, m_uiTrampleTargetGUID); me->GetMotionMaster()->MoveCharge(m_fTrampleTargetX, m_fTrampleTargetY, m_fTrampleTargetZ+2, 42, 1); me->SetTarget(0); m_uiStage = 5; @@ -985,7 +979,12 @@ public: if (!m_bTrampleCasted) { DoCast(me, SPELL_STAGGERED_DAZE); - DoScriptText(SAY_TRAMPLE_FAIL, me); + Talk(EMOTE_TRAMPLE_CRASH); + } + else + { + DoCast(me, SPELL_FROTHING_RAGE, true); + Talk(EMOTE_TRAMPLE_FAIL); } m_bMovementStarted = false; me->GetMotionMaster()->MovementExpired(); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp index 4cfe4f61dbb..203e49420be 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -40,17 +40,15 @@ EndScriptData */ enum Yells { - SAY_AGGRO = -1649040, - SAY_DEATH = -1649041, - SAY_BERSERK = -1649042, - EMOTE_SHIELD = -1649043, - SAY_SHIELD = -1649044, - SAY_KILL1 = -1649045, - SAY_KILL2 = -1649046, - EMOTE_LIGHT_VORTEX = -1649047, - SAY_LIGHT_VORTEX = -1649048, - EMOTE_DARK_VORTEX = -1649049, - SAY_DARK_VORTEX = -1649050, + SAY_AGGRO = 0, + SAY_NIGHT = 1, + SAY_LIGHT = 2, + EMOTE_VORTEX = 3, + EMOTE_TWINK_PACT = 4, + SAY_TWINK_PACT = 5, + SAY_KILL_PLAYER = 6, + SAY_BERSERK = 7, + SAY_DEATH = 8, }; enum Equipment @@ -167,7 +165,6 @@ struct boss_twin_baseAI : public ScriptedAI uint32 m_uiTouchTimer; uint32 m_uiBerserkTimer; - int32 m_uiVortexSay; int32 m_uiVortexEmote; uint32 m_uiSisterNpcId; uint32 m_uiMyEmphatySpellId; @@ -179,7 +176,8 @@ struct boss_twin_baseAI : public ScriptedAI uint32 m_uiSpikeSpellId; uint32 m_uiTouchSpellId; - void Reset() { + void Reset() + { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); me->SetReactState(REACT_PASSIVE); me->ModifyAuraState(m_uiAuraState, true); @@ -224,7 +222,7 @@ struct boss_twin_baseAI : public ScriptedAI { if (who->GetTypeId() == TYPEID_PLAYER) { - DoScriptText(urand(0, 1) ? SAY_KILL1 : SAY_KILL2, me); + Talk(SAY_KILL_PLAYER); if (instance) instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); } @@ -336,8 +334,7 @@ struct boss_twin_baseAI : public ScriptedAI { if (Creature* pSister = GetSister()) pSister->AI()->DoAction(ACTION_VORTEX); - DoScriptText(m_uiVortexEmote, me); - DoScriptText(m_uiVortexSay, me); + Talk(m_uiVortexEmote); DoCastAOE(m_uiVortexSpellId); m_uiStage = 0; m_uiSpecialAbilityTimer = MINUTE*IN_MILLISECONDS; @@ -348,8 +345,8 @@ struct boss_twin_baseAI : public ScriptedAI case 2: // Shield+Pact if (m_uiSpecialAbilityTimer <= uiDiff) { - DoScriptText(EMOTE_SHIELD, me); - DoScriptText(SAY_SHIELD, me); + Talk(EMOTE_TWINK_PACT); + Talk(SAY_TWINK_PACT); if (Creature* pSister = GetSister()) { pSister->AI()->DoAction(ACTION_PACT); @@ -426,8 +423,7 @@ public: m_uiStage = 0; m_uiWeapon = EQUIP_MAIN_1; m_uiAuraState = AURA_STATE_UNKNOWN22; - m_uiVortexEmote = EMOTE_LIGHT_VORTEX; - m_uiVortexSay = SAY_LIGHT_VORTEX; + m_uiVortexEmote = EMOTE_VORTEX; m_uiSisterNpcId = NPC_DARKBANE; m_uiMyEmphatySpellId = SPELL_TWIN_EMPATHY_DARK; m_uiOtherEssenceSpellId = SPELL_DARK_ESSENCE_HELPER; @@ -496,8 +492,7 @@ public: m_uiStage = 1; m_uiWeapon = EQUIP_MAIN_2; m_uiAuraState = AURA_STATE_UNKNOWN19; - m_uiVortexEmote = EMOTE_DARK_VORTEX; - m_uiVortexSay = SAY_DARK_VORTEX; + m_uiVortexEmote = EMOTE_VORTEX; m_uiSisterNpcId = NPC_LIGHTBANE; m_uiMyEmphatySpellId = SPELL_TWIN_EMPATHY_LIGHT; m_uiOtherEssenceSpellId = SPELL_LIGHT_ESSENCE_HELPER; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp index 4dfe5708025..3fb76ea52dc 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp @@ -47,6 +47,7 @@ class instance_trial_of_the_crusader : public InstanceMapScript uint64 BarrentGUID; uint64 TirionGUID; + uint64 TirionFordringGUID; uint64 FizzlebangGUID; uint64 GarroshGUID; uint64 VarianGUID; @@ -85,6 +86,8 @@ class instance_trial_of_the_crusader : public InstanceMapScript TrialCounter = 50; EventStage = 0; + TirionFordringGUID = 0; + TributeChestGUID = 0; MainGateDoorGUID = 0; @@ -147,6 +150,9 @@ class instance_trial_of_the_crusader : public InstanceMapScript case NPC_TIRION: TirionGUID = creature->GetGUID(); break; + case NPC_TIRION_FORDRING: + TirionFordringGUID = creature->GetGUID(); + break; case NPC_FIZZLEBANG: FizzlebangGUID = creature->GetGUID(); break; @@ -422,6 +428,8 @@ class instance_trial_of_the_crusader : public InstanceMapScript return BarrentGUID; case NPC_TIRION: return TirionGUID; + case NPC_TIRION_FORDRING: + return TirionFordringGUID; case NPC_FIZZLEBANG: return FizzlebangGUID; case NPC_GARROSH: diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp index 4ad93c0afe1..7064368f090 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp @@ -34,45 +34,58 @@ EndScriptData */ enum eYells { - SAY_STAGE_0_01 = -1649070, - SAY_STAGE_0_02 = -1649071, - SAY_STAGE_0_03a = -1649072, - SAY_STAGE_0_03h = -1649073, - SAY_STAGE_0_04 = -1649074, - SAY_STAGE_0_05 = -1649075, - SAY_STAGE_0_06 = -1649076, - SAY_STAGE_0_WIPE = -1649077, - SAY_STAGE_1_01 = -1649080, - SAY_STAGE_1_02 = -1649081, - SAY_STAGE_1_03 = -1649082, - SAY_STAGE_1_04 = -1649083, - SAY_STAGE_1_05 = -1649030, //INTRO Jaraxxus - SAY_STAGE_1_06 = -1649084, - SAY_STAGE_1_07 = -1649086, - SAY_STAGE_1_08 = -1649087, - SAY_STAGE_1_09 = -1649088, - SAY_STAGE_1_10 = -1649089, - SAY_STAGE_1_11 = -1649090, - SAY_STAGE_2_01 = -1649091, - SAY_STAGE_2_02a = -1649092, - SAY_STAGE_2_02h = -1649093, - SAY_STAGE_2_03 = -1649094, - SAY_STAGE_2_04a = -1649095, - SAY_STAGE_2_04h = -1649096, - SAY_STAGE_2_05a = -1649097, - SAY_STAGE_2_05h = -1649098, - SAY_STAGE_2_06 = -1649099, - SAY_STAGE_3_01 = -1649100, - SAY_STAGE_3_02 = -1649101, - SAY_STAGE_3_03a = -1649102, - SAY_STAGE_3_03h = -1649103, - SAY_STAGE_4_01 = -1649104, - SAY_STAGE_4_02 = -1649105, - SAY_STAGE_4_03 = -1649106, - SAY_STAGE_4_04 = -1649107, - SAY_STAGE_4_05 = -1649108, - SAY_STAGE_4_06 = -1649109, - SAY_STAGE_4_07 = -1649110, + // Highlord Tirion Fordring - 34996 + SAY_STAGE_0_01 = 0, + SAY_STAGE_0_02 = 1, + SAY_STAGE_0_04 = 2, + SAY_STAGE_0_05 = 3, + SAY_STAGE_0_06 = 4, + SAY_STAGE_0_WIPE = 5, + SAY_STAGE_1_01 = 6, + SAY_STAGE_1_07 = 7, + SAY_STAGE_1_08 = 8, + SAY_STAGE_1_11 = 9, + SAY_STAGE_2_01 = 10, + SAY_STAGE_2_03 = 11, + SAY_STAGE_2_06 = 12, + SAY_STAGE_3_01 = 13, + SAY_STAGE_3_02 = 14, + SAY_STAGE_4_01 = 15, + SAY_STAGE_4_03 = 16, + + // Varian Wrynn + SAY_STAGE_0_03a = 0, + SAY_STAGE_1_10 = 1, + SAY_STAGE_2_02a = 2, + SAY_STAGE_2_04a = 3, + SAY_STAGE_2_05a = 4, + SAY_STAGE_3_03a = 5, + + // Garrosh + SAY_STAGE_0_03h = 0, + SAY_STAGE_1_09 = 1, + SAY_STAGE_2_02h = 2, + SAY_STAGE_2_04h = 3, + SAY_STAGE_2_05h = 4, + SAY_STAGE_3_03h = 5, + + // Wilfred Fizzlebang + SAY_STAGE_1_02 = 0, + SAY_STAGE_1_03 = 1, + SAY_STAGE_1_04 = 2, + SAY_STAGE_1_06 = 3, + + // Lord Jaraxxus + SAY_STAGE_1_05 = 0, + + // The Lich King + SAY_STAGE_4_02 = 0, + SAY_STAGE_4_05 = 1, + SAY_STAGE_4_04 = 2, + + // Highlord Tirion Fordring - 36095 + SAY_STAGE_4_06 = 0, + SAY_STAGE_4_07 = 1, }; struct _Messages @@ -289,13 +302,13 @@ class boss_lich_king_toc : public CreatureScript switch (instance->GetData(TYPE_EVENT)) { case 5010: - DoScriptText(SAY_STAGE_4_02, me); + Talk(SAY_STAGE_4_02); m_uiUpdateTimer = 3000; me->GetMotionMaster()->MovePoint(0, LichKingLoc[0]); instance->SetData(TYPE_EVENT, 5020); break; case 5030: - DoScriptText(SAY_STAGE_4_04, me); + Talk(SAY_STAGE_4_04); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); m_uiUpdateTimer = 10000; instance->SetData(TYPE_EVENT, 5040); @@ -312,7 +325,7 @@ class boss_lich_king_toc : public CreatureScript instance->SetData(TYPE_EVENT, 5060); break; case 5060: - DoScriptText(SAY_STAGE_4_05, me); + Talk(SAY_STAGE_4_05); me->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL); m_uiUpdateTimer = 2500; instance->SetData(TYPE_EVENT, 5070); @@ -371,7 +384,7 @@ class npc_fizzlebang_toc : public CreatureScript void JustDied(Unit* killer) { - DoScriptText(SAY_STAGE_1_06, me, killer); + Talk(SAY_STAGE_1_06, killer->GetGUID()); instance->SetData(TYPE_EVENT, 1180); if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_JARAXXUS))) { @@ -430,13 +443,13 @@ class npc_fizzlebang_toc : public CreatureScript m_uiUpdateTimer = 4000; break; case 1120: - DoScriptText(SAY_STAGE_1_02, me); + Talk(SAY_STAGE_1_02); instance->SetData(TYPE_EVENT, 1130); m_uiUpdateTimer = 12000; break; case 1130: me->GetMotionMaster()->MovementExpired(); - DoScriptText(SAY_STAGE_1_03, me); + Talk(SAY_STAGE_1_03); me->HandleEmoteCommand(EMOTE_ONESHOT_SPELL_CAST_OMNI); if (Unit* pTrigger = me->SummonCreature(NPC_TRIGGER, ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 4.69494f, TEMPSUMMON_MANUAL_DESPAWN)) { @@ -470,7 +483,7 @@ class npc_fizzlebang_toc : public CreatureScript m_uiUpdateTimer = 3000; break; case 1140: - DoScriptText(SAY_STAGE_1_04, me); + Talk(SAY_STAGE_1_04); if (Creature* temp = me->SummonCreature(NPC_JARAXXUS, ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 5.0f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME)) { temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -492,7 +505,7 @@ class npc_fizzlebang_toc : public CreatureScript break; case 1144: if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_JARAXXUS))) - DoScriptText(SAY_STAGE_1_05, temp); + temp->AI()->Talk(SAY_STAGE_1_05); instance->SetData(TYPE_EVENT, 1150); m_uiUpdateTimer = 5000; break; @@ -555,13 +568,13 @@ class npc_tirion_toc : public CreatureScript { case 110: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_TALK); - DoScriptText(SAY_STAGE_0_01, me); + Talk(SAY_STAGE_0_01); m_uiUpdateTimer = 22000; instance->SetData(TYPE_EVENT, 120); break; case 140: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_TALK); - DoScriptText(SAY_STAGE_0_02, me); + Talk(SAY_STAGE_0_02); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 150); break; @@ -587,7 +600,7 @@ class npc_tirion_toc : public CreatureScript instance->SetData(TYPE_EVENT, 160); break; case 200: - DoScriptText(SAY_STAGE_0_04, me); + Talk(SAY_STAGE_0_04); m_uiUpdateTimer = 8000; instance->SetData(TYPE_EVENT, 205); break; @@ -619,7 +632,7 @@ class npc_tirion_toc : public CreatureScript instance->SetData(TYPE_EVENT, 230); break; case 300: - DoScriptText(SAY_STAGE_0_05, me); + Talk(SAY_STAGE_0_05); m_uiUpdateTimer = 8000; instance->SetData(TYPE_EVENT, 305); break; @@ -646,54 +659,54 @@ class npc_tirion_toc : public CreatureScript instance->SetData(TYPE_EVENT, 320); break; case 400: - DoScriptText(SAY_STAGE_0_06, me); + Talk(SAY_STAGE_0_06); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 0); break; case 666: - DoScriptText(SAY_STAGE_0_WIPE, me); + Talk(SAY_STAGE_0_WIPE); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 0); break; case 1010: - DoScriptText(SAY_STAGE_1_01, me); + Talk(SAY_STAGE_1_01); m_uiUpdateTimer = 7000; instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); me->SummonCreature(NPC_FIZZLEBANG, ToCSpawnLoc[0].GetPositionX(), ToCSpawnLoc[0].GetPositionY(), ToCSpawnLoc[0].GetPositionZ(), 2, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); instance->SetData(TYPE_EVENT, 0); break; case 1180: - DoScriptText(SAY_STAGE_1_07, me); + Talk(SAY_STAGE_1_07); m_uiUpdateTimer = 3000; instance->SetData(TYPE_EVENT, 0); break; case 2000: - DoScriptText(SAY_STAGE_1_08, me); + Talk(SAY_STAGE_1_08); m_uiUpdateTimer = 18000; instance->SetData(TYPE_EVENT, 2010); break; case 2030: - DoScriptText(SAY_STAGE_1_11, me); + Talk(SAY_STAGE_1_11); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 0); break; case 3000: - DoScriptText(SAY_STAGE_2_01, me); + Talk(SAY_STAGE_2_01); m_uiUpdateTimer = 12000; instance->SetData(TYPE_EVENT, 3050); break; case 3001: - DoScriptText(SAY_STAGE_2_01, me); + Talk(SAY_STAGE_2_01); m_uiUpdateTimer = 12000; instance->SetData(TYPE_EVENT, 3051); break; case 3060: - DoScriptText(SAY_STAGE_2_03, me); + Talk(SAY_STAGE_2_03); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 3070); break; case 3061: - DoScriptText(SAY_STAGE_2_03, me); + Talk(SAY_STAGE_2_03); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 3071); break; @@ -718,17 +731,17 @@ class npc_tirion_toc : public CreatureScript break; //Crusaders battle end case 3100: - DoScriptText(SAY_STAGE_2_06, me); + Talk(SAY_STAGE_2_06); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 0); break; case 4000: - DoScriptText(SAY_STAGE_3_01, me); + Talk(SAY_STAGE_3_01); m_uiUpdateTimer = 13000; instance->SetData(TYPE_EVENT, 4010); break; case 4010: - DoScriptText(SAY_STAGE_3_02, me); + Talk(SAY_STAGE_3_02); if (Creature* temp = me->SummonCreature(NPC_LIGHTBANE, ToCSpawnLoc[1].GetPositionX(), ToCSpawnLoc[1].GetPositionY(), ToCSpawnLoc[1].GetPositionZ(), 5, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME)) { temp->SetVisible(false); @@ -769,7 +782,7 @@ class npc_tirion_toc : public CreatureScript instance->SetData(TYPE_EVENT, 5000); break; case 5000: - DoScriptText(SAY_STAGE_4_01, me); + Talk(SAY_STAGE_4_01); m_uiUpdateTimer = 10000; instance->SetData(TYPE_EVENT, 5005); break; @@ -779,7 +792,7 @@ class npc_tirion_toc : public CreatureScript me->SummonCreature(NPC_LICH_KING_1, ToCSpawnLoc[0].GetPositionX(), ToCSpawnLoc[0].GetPositionY(), ToCSpawnLoc[0].GetPositionZ(), 5); break; case 5020: - DoScriptText(SAY_STAGE_4_03, me); + Talk(SAY_STAGE_4_03); m_uiUpdateTimer = 1000; instance->SetData(TYPE_EVENT, 0); break; @@ -789,14 +802,16 @@ class npc_tirion_toc : public CreatureScript instance->SetData(TYPE_EVENT, 6005); break; case 6005: - DoScriptText(SAY_STAGE_4_06, me); + if (Creature* tirionFordring = Unit::GetCreature((*me), instance->GetData64(NPC_TIRION_FORDRING))) + tirionFordring->AI()->Talk(SAY_STAGE_4_06); m_uiUpdateTimer = 20000; instance->SetData(TYPE_EVENT, 6010); break; case 6010: if (IsHeroic()) { - DoScriptText(SAY_STAGE_4_07, me); + if (Creature* tirionFordring = Unit::GetCreature((*me), instance->GetData64(NPC_TIRION_FORDRING))) + tirionFordring->AI()->Talk(SAY_STAGE_4_07); m_uiUpdateTimer = 60000; instance->SetData(TYPE_ANUBARAK, SPECIAL); instance->SetData(TYPE_EVENT, 6020); @@ -854,7 +869,7 @@ class npc_garrosh_toc : public CreatureScript { case 130: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_TALK); - DoScriptText(SAY_STAGE_0_03h, me); + Talk(SAY_STAGE_0_03h); m_uiUpdateTimer = 3000; instance->SetData(TYPE_EVENT, 132); break; @@ -864,27 +879,27 @@ class npc_garrosh_toc : public CreatureScript instance->SetData(TYPE_EVENT, 140); break; case 2010: - DoScriptText(SAY_STAGE_1_09, me); + Talk(SAY_STAGE_1_09); m_uiUpdateTimer = 9000; instance->SetData(TYPE_EVENT, 2020); break; case 3050: - DoScriptText(SAY_STAGE_2_02h, me); + Talk(SAY_STAGE_2_02h); m_uiUpdateTimer = 15000; instance->SetData(TYPE_EVENT, 3060); break; case 3070: - DoScriptText(SAY_STAGE_2_04h, me); + Talk(SAY_STAGE_2_04h); m_uiUpdateTimer = 6000; instance->SetData(TYPE_EVENT, 3080); break; case 3081: - DoScriptText(SAY_STAGE_2_05h, me); + Talk(SAY_STAGE_2_05h); m_uiUpdateTimer = 3000; instance->SetData(TYPE_EVENT, 3091); break; case 4030: - DoScriptText(SAY_STAGE_3_03h, me); + Talk(SAY_STAGE_3_03h); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 4040); break; @@ -935,7 +950,7 @@ class npc_varian_toc : public CreatureScript { case 120: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_TALK); - DoScriptText(SAY_STAGE_0_03a, me); + Talk(SAY_STAGE_0_03a); m_uiUpdateTimer = 2000; instance->SetData(TYPE_EVENT, 122); break; @@ -945,27 +960,27 @@ class npc_varian_toc : public CreatureScript instance->SetData(TYPE_EVENT, 130); break; case 2020: - DoScriptText(SAY_STAGE_1_10, me); + Talk(SAY_STAGE_1_10); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 2030); break; case 3051: - DoScriptText(SAY_STAGE_2_02a, me); + Talk(SAY_STAGE_2_02a); m_uiUpdateTimer = 10000; instance->SetData(TYPE_EVENT, 3061); break; case 3071: - DoScriptText(SAY_STAGE_2_04a, me); + Talk(SAY_STAGE_2_04a); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 3081); break; case 3080: - DoScriptText(SAY_STAGE_2_05a, me); + Talk(SAY_STAGE_2_05a); m_uiUpdateTimer = 3000; instance->SetData(TYPE_EVENT, 3090); break; case 4020: - DoScriptText(SAY_STAGE_3_03a, me); + Talk(SAY_STAGE_3_03a); m_uiUpdateTimer = 5000; instance->SetData(TYPE_EVENT, 4040); break; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h index 99525b6fb32..f361c3521d1 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h @@ -162,6 +162,7 @@ enum eCreature { NPC_BARRENT = 34816, NPC_TIRION = 34996, + NPC_TIRION_FORDRING = 36095, NPC_FIZZLEBANG = 35458, NPC_GARROSH = 34995, NPC_VARIAN = 34990, diff --git a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp index 7778a79a816..99401c1d944 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp @@ -70,6 +70,7 @@ public: void Initialize() { + memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); uiTrollgore = 0; uiNovos = 0; uiDred = 0; @@ -190,16 +191,12 @@ public: { OUT_SAVE_INST_DATA; - std::string str_data; - std::ostringstream saveStream; saveStream << "D K " << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3]; - str_data = saveStream.str(); - OUT_SAVE_INST_DATA_COMPLETE; - return str_data; + return saveStream.str(); } void Load(const char* in) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp index f81ddbf6bf8..29a0a11af9b 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp @@ -104,6 +104,7 @@ public: if (me->GetEntry() == MOB_HORSEMEN[i]) id = Horsemen(i); caster = (id == HORSEMEN_LADY || id == HORSEMEN_SIR); + encounterActionReset = false; } Horsemen id; diff --git a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp index 152f0b2d647..5d430ae048d 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp @@ -58,6 +58,9 @@ public: Anomalus = 0; Keristrasza = 0; + AnomalusContainmentSphere = 0; + OrmoroksContainmentSphere = 0; + TelestrasContainmentSphere = 0; } void OnCreatureCreate(Creature* creature) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index 654d763ddbc..2f37fb06f24 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -134,6 +134,7 @@ class instance_ulduar : public InstanceMapScript elderCount = 0; conSpeedAtory = false; Unbroken = true; + _algalonSummoned = false; _summonAlgalon = false; memset(AlgalonSigilDoorGUID, 0, sizeof(AlgalonSigilDoorGUID)); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp index 191f4530e65..48667053373 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp @@ -101,6 +101,7 @@ public: boss_ingvar_the_plundererAI(Creature* creature) : ScriptedAI(creature) { instance = creature->GetInstanceScript(); + bIsUndead = false; } InstanceScript* instance; diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp index f0d64bb8344..a6ad7befc38 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp @@ -172,6 +172,7 @@ public: boss_skadiAI(Creature* creature) : ScriptedAI(creature), Summons(me) { instance = creature->GetInstanceScript(); + m_uiGraufGUID = 0; } InstanceScript* instance; @@ -207,7 +208,7 @@ public: Summons.DespawnAll(); me->SetSpeed(MOVE_FLIGHT, 3.0f); - if ((Unit::GetCreature((*me), m_uiGraufGUID) == NULL) && !me->IsMounted()) + if ((Unit::GetCreature(*me, m_uiGraufGUID) == NULL) && !me->IsMounted()) me->SummonCreature(CREATURE_GRAUF, Location[0].GetPositionX(), Location[0].GetPositionY(), Location[0].GetPositionZ(), 3.0f); if (instance) { @@ -221,7 +222,7 @@ public: me->SetCanFly(false); me->Dismount(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); - if (Unit::GetCreature((*me), m_uiGraufGUID) == NULL) + if (!Unit::GetCreature(*me, m_uiGraufGUID)) me->SummonCreature(CREATURE_GRAUF, Location[0].GetPositionX(), Location[0].GetPositionY(), Location[0].GetPositionZ(), 3.0f); } diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp index 5dacaff2d6b..39fd01a9269 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp @@ -121,6 +121,9 @@ public: m_uiActiveOrder[i] = m_uiActiveOrder[r]; m_uiActiveOrder[r] = temp; } + + m_uiActivedCreatureGUID = 0; + m_uiOrbGUID = 0; } bool m_bIsWalking; diff --git a/src/server/scripts/Northrend/grizzly_hills.cpp b/src/server/scripts/Northrend/grizzly_hills.cpp index 1a0f6b57375..4ca12bc82a1 100644 --- a/src/server/scripts/Northrend/grizzly_hills.cpp +++ b/src/server/scripts/Northrend/grizzly_hills.cpp @@ -600,100 +600,99 @@ enum eSmokeEmOut QUEST_SMOKE_EM_OUT_H = 12324, SPELL_SMOKE_BOMB = 49075, SPELL_CHOP = 43410, - NPC_VENTURE_CO_STABLES_KC = 27568, + SPELL_VENTURE_STRAGGLER_CREDIT = 49093, }; class npc_venture_co_straggler : public CreatureScript { -public: - npc_venture_co_straggler() : CreatureScript("npc_venture_co_straggler") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new npc_venture_co_stragglerAI(creature); - } + public: + npc_venture_co_straggler() : CreatureScript("npc_venture_co_straggler") { } - struct npc_venture_co_stragglerAI : public ScriptedAI - { - npc_venture_co_stragglerAI(Creature* creature) : ScriptedAI(creature) { } + struct npc_venture_co_stragglerAI : public ScriptedAI + { + npc_venture_co_stragglerAI(Creature* creature) : ScriptedAI(creature) { } - uint64 uiPlayerGUID; - uint32 uiRunAwayTimer; - uint32 uiTimer; - uint32 uiChopTimer; + uint64 uiPlayerGUID; + uint32 uiRunAwayTimer; + uint32 uiTimer; + uint32 uiChopTimer; - void Reset() - { - uiPlayerGUID = 0; - uiTimer = 0; - uiChopTimer = urand(10000, 12500); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); - me->SetReactState(REACT_AGGRESSIVE); - } + void Reset() + { + uiPlayerGUID = 0; + uiTimer = 0; + uiRunAwayTimer = 0; + uiChopTimer = urand(10000, 12500); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); + me->SetReactState(REACT_AGGRESSIVE); + } - void UpdateAI(const uint32 uiDiff) - { - if (uiRunAwayTimer <= uiDiff) + void UpdateAI(const uint32 uiDiff) { - if (Player* player = Unit::GetPlayer(*me, uiPlayerGUID)) + if (uiPlayerGUID && uiRunAwayTimer <= uiDiff) { - switch (uiTimer) + if (Player* player = Unit::GetPlayer(*me, uiPlayerGUID)) { - case 0: - if (player->GetQuestStatus(QUEST_SMOKE_EM_OUT_A) == QUEST_STATUS_INCOMPLETE || - player->GetQuestStatus(QUEST_SMOKE_EM_OUT_H) == QUEST_STATUS_INCOMPLETE) - player->KilledMonsterCredit(NPC_VENTURE_CO_STABLES_KC, 0); - me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-7, me->GetPositionY()+7, me->GetPositionZ()); - uiRunAwayTimer = 2500; - ++uiTimer; - break; - case 1: - DoScriptText(RAND(SAY_SEO1, SAY_SEO2, SAY_SEO3, SAY_SEO4, SAY_SEO5), me); - me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-7, me->GetPositionY()-5, me->GetPositionZ()); - uiRunAwayTimer = 2500; - ++uiTimer; - break; - case 2: - me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-5, me->GetPositionY()-5, me->GetPositionZ()); - uiRunAwayTimer = 2500; - ++uiTimer; - break; - case 3: - me->DisappearAndDie(); - uiTimer = 0; - break; + switch (uiTimer) + { + case 0: + DoCast(player, SPELL_VENTURE_STRAGGLER_CREDIT); + me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-7, me->GetPositionY()+7, me->GetPositionZ()); + uiRunAwayTimer = 2500; + ++uiTimer; + break; + case 1: + DoScriptText(RAND(SAY_SEO1, SAY_SEO2, SAY_SEO3, SAY_SEO4, SAY_SEO5), me); + me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-7, me->GetPositionY()-5, me->GetPositionZ()); + uiRunAwayTimer = 2500; + ++uiTimer; + break; + case 2: + me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-5, me->GetPositionY()-5, me->GetPositionZ()); + uiRunAwayTimer = 2500; + ++uiTimer; + break; + case 3: + me->DisappearAndDie(); + uiTimer = 0; + break; + } } } - } - else - uiRunAwayTimer -= uiDiff; + else if (uiRunAwayTimer) + uiRunAwayTimer -= uiDiff; - if (!UpdateVictim()) - return; + if (!UpdateVictim()) + return; - if (uiChopTimer <= uiDiff) - { - DoCast(me->getVictim(), SPELL_CHOP); - uiChopTimer = urand(10000, 12000); - } - else - uiChopTimer -= uiDiff; + if (uiChopTimer <= uiDiff) + { + DoCast(me->getVictim(), SPELL_CHOP); + uiChopTimer = urand(10000, 12000); + } + else + uiChopTimer -= uiDiff; - DoMeleeAttackIfReady(); - } + DoMeleeAttackIfReady(); + } - void SpellHit(Unit* pCaster, const SpellInfo* pSpell) - { - if (pCaster && pCaster->GetTypeId() == TYPEID_PLAYER && pSpell->Id == SPELL_SMOKE_BOMB) + void SpellHit(Unit* caster, SpellInfo const* spell) { - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); - me->SetReactState(REACT_PASSIVE); - me->CombatStop(false); - uiPlayerGUID = pCaster->GetGUID(); - uiRunAwayTimer = 3500; + if (spell->Id == SPELL_SMOKE_BOMB && caster->GetTypeId() == TYPEID_PLAYER) + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); + me->SetReactState(REACT_PASSIVE); + me->CombatStop(false); + uiPlayerGUID = caster->GetGUID(); + uiRunAwayTimer = 3500; + } } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_venture_co_stragglerAI(creature); } - }; }; void AddSC_grizzly_hills() diff --git a/src/server/scripts/Northrend/wintergrasp.cpp b/src/server/scripts/Northrend/wintergrasp.cpp new file mode 100644 index 00000000000..37994e40b63 --- /dev/null +++ b/src/server/scripts/Northrend/wintergrasp.cpp @@ -0,0 +1,565 @@ +/* Copyright (C) 2008 - 2009 Trinity <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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "BattlefieldMgr.h" +#include "BattlefieldWG.h" +#include "Battlefield.h" +#include "ScriptSystem.h" +#include "WorldSession.h" +#include "ObjectMgr.h" +#include "Vehicle.h" +#include "GameObjectAI.h" +#include "ScriptedCreature.h" +#include "ScriptedGossip.h" +#include "SpellScript.h" + +#define GOSSIP_HELLO_DEMO1 "Build catapult." +#define GOSSIP_HELLO_DEMO2 "Build demolisher." +#define GOSSIP_HELLO_DEMO3 "Build siege engine." +#define GOSSIP_HELLO_DEMO4 "I cannot build more!" + +enum WGqueuenpctext +{ + WG_NPCQUEUE_TEXT_H_NOWAR = 14775, + WG_NPCQUEUE_TEXT_H_QUEUE = 14790, + WG_NPCQUEUE_TEXT_H_WAR = 14777, + WG_NPCQUEUE_TEXT_A_NOWAR = 14782, + WG_NPCQUEUE_TEXT_A_QUEUE = 14791, + WG_NPCQUEUE_TEXT_A_WAR = 14781, + WG_NPCQUEUE_TEXTOPTION_JOIN = -1850507, +}; + +enum Spells +{ + // Demolisher engineers spells + SPELL_BUILD_SIEGE_VEHICLE_FORCE_HORDE = 61409, + SPELL_BUILD_SIEGE_VEHICLE_FORCE_ALLIANCE = 56662, + SPELL_BUILD_CATAPULT_FORCE = 56664, + SPELL_BUILD_DEMOLISHER_FORCE = 56659, + SPELL_ACTIVATE_CONTROL_ARMS = 49899, + SPELL_RIDE_WG_VEHICLE = 60968, + + SPELL_VEHICLE_TELEPORT = 49759, + + // Spirit guide + SPELL_CHANNEL_SPIRIT_HEAL = 22011, +}; + +enum CreatureIds +{ + NPC_GOBLIN_MECHANIC = 30400, + NPC_GNOMISH_ENGINEER = 30499, + + NPC_WINTERGRASP_CONTROL_ARMS = 27852, + + NPC_WORLD_TRIGGER_LARGE_AOI_NOT_IMMUNE_PC_NPC = 23472, +}; + +enum QuestIds +{ + QUEST_BONES_AND_ARROWS_HORDE_ATT = 13193, + QUEST_JINXING_THE_WALLS_HORDE_ATT = 13202, + QUEST_SLAY_THEM_ALL_HORDE_ATT = 13180, + QUEST_FUELING_THE_DEMOLISHERS_HORDE_ATT = 13200, + QUEST_HEALING_WITH_ROSES_HORDE_ATT = 13201, + QUEST_DEFEND_THE_SIEGE_HORDE_ATT = 13223, + + QUEST_BONES_AND_ARROWS_HORDE_DEF = 13199, + QUEST_WARDING_THE_WALLS_HORDE_DEF = 13192, + QUEST_SLAY_THEM_ALL_HORDE_DEF = 13178, + QUEST_FUELING_THE_DEMOLISHERS_HORDE_DEF = 13191, + QUEST_HEALING_WITH_ROSES_HORDE_DEF = 13194, + QUEST_TOPPLING_THE_TOWERS_HORDE_DEF = 13539, + QUEST_STOP_THE_SIEGE_HORDE_DEF = 13185, + + QUEST_BONES_AND_ARROWS_ALLIANCE_ATT = 13196, + QUEST_WARDING_THE_WARRIORS_ALLIANCE_ATT = 13198, + QUEST_NO_MERCY_FOR_THE_MERCILESS_ALLIANCE_ATT = 13179, + QUEST_DEFEND_THE_SIEGE_ALLIANCE_ATT = 13222, + QUEST_A_RARE_HERB_ALLIANCE_ATT = 13195, + + QUEST_BONES_AND_ARROWS_ALLIANCE_DEF = 13154, + QUEST_WARDING_THE_WARRIORS_ALLIANCE_DEF = 13153, + QUEST_NO_MERCY_FOR_THE_MERCILESS_ALLIANCE_DEF = 13177, + QUEST_SHOUTHERN_SABOTAGE_ALLIANCE_DEF = 13538, + QUEST_STOP_THE_SIEGE_ALLIANCE_DEF = 13186, + QUEST_A_RARE_HERB_ALLIANCE_DEF = 13156, +}; + +uint8 const MAX_WINTERGRASP_VEHICLES = 4; + +uint32 const vehiclesList[MAX_WINTERGRASP_VEHICLES] = +{ + NPC_WINTERGRASP_CATAPULT, + NPC_WINTERGRASP_DEMOLISHER, + NPC_WINTERGRASP_SIEGE_ENGINE_ALLIANCE, + NPC_WINTERGRASP_SIEGE_ENGINE_HORDE +}; + +class npc_wg_demolisher_engineer : public CreatureScript +{ + public: + npc_wg_demolisher_engineer() : CreatureScript("npc_wg_demolisher_engineer") { } + + bool OnGossipHello(Player* player, Creature* creature) + { + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); + + Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG); + + if (canBuild(creature)) + { + if (player->HasAura(SPELL_CORPORAL)) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_DEMO1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + else if (player->HasAura(SPELL_LIEUTENANT)) + { + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_DEMO1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_DEMO2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_DEMO3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + } + } + else + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_DEMO4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + + player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); + return true; + } + + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender */, uint32 action) + { + player->CLOSE_GOSSIP_MENU(); + + Battlefield* wintergrasp= sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG); + + if (canBuild(creature)) + { + switch (action - GOSSIP_ACTION_INFO_DEF) + { + case 0: + creature->CastSpell(player, SPELL_BUILD_CATAPULT_FORCE, true); + break; + case 1: + creature->CastSpell(player, SPELL_BUILD_DEMOLISHER_FORCE, true); + break; + case 2: + creature->CastSpell(player, player->GetTeamId() == TEAM_ALLIANCE ? SPELL_BUILD_SIEGE_VEHICLE_FORCE_ALLIANCE : SPELL_BUILD_SIEGE_VEHICLE_FORCE_HORDE, true); + break; + } + if (Creature* controlArms = creature->FindNearestCreature(NPC_WINTERGRASP_CONTROL_ARMS, 30.0f, true)) + creature->CastSpell(controlArms, SPELL_ACTIVATE_CONTROL_ARMS, true); + } + return true; + } + + private: + bool canBuild(Creature* creature) + { + Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG); + + if (!wintergrasp) + return false; + switch (creature->GetEntry()) + { + case NPC_GOBLIN_MECHANIC: + return (wintergrasp->GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H) > wintergrasp->GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); + case NPC_GNOMISH_ENGINEER: + return (wintergrasp->GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A) > wintergrasp->GetData(BATTLEFIELD_WG_DATA_VEHICLE_A)); + default: + return false; + } + } +}; + +class npc_wg_spirit_guide : public CreatureScript +{ + public: + npc_wg_spirit_guide() : CreatureScript("npc_wg_spirit_guide") { } + + bool OnGossipHello(Player* player, Creature* creature) + { + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); + + Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG); + if (!wintergrasp) + return true; + + GraveyardVect graveyard = wintergrasp->GetGraveyardVector(); + for (uint8 i = 0; i < graveyard.size(); i++) + if (graveyard[i]->GetControlTeamId() == player->GetTeamId()) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, sObjectMgr->GetTrinityStringForDBCLocale(((BfGraveyardWG*)graveyard[i])->GetTextId()), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + i); + + player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); + return true; + } + + bool OnGossipSelect(Player* player, Creature* /*creature */ , uint32 /*sender */ , uint32 action) + { + player->CLOSE_GOSSIP_MENU(); + + Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG); + if (wintergrasp) + { + GraveyardVect gy = wintergrasp->GetGraveyardVector(); + for (uint8 i = 0; i < gy.size(); i++) + if (action - GOSSIP_ACTION_INFO_DEF == i && gy[i]->GetControlTeamId() == player->GetTeamId()) + if (WorldSafeLocsEntry const* safeLoc = sWorldSafeLocsStore.LookupEntry(gy[i]->GetGraveyardId())) + player->TeleportTo(safeLoc->map_id, safeLoc->x, safeLoc->y, safeLoc->z, 0); + } + return true; + } + + struct npc_wg_spirit_guideAI : public ScriptedAI + { + npc_wg_spirit_guideAI(Creature* creature) : ScriptedAI(creature) + { } + + void UpdateAI(const uint32 /* diff */) + { + if (!me->HasUnitState(UNIT_STATE_CASTING)) + DoCast(me, SPELL_CHANNEL_SPIRIT_HEAL); + } + }; + + CreatureAI *GetAI(Creature* creature) const + { + return new npc_wg_spirit_guideAI(creature); + } +}; + +class npc_wg_queue : public CreatureScript +{ + public: + npc_wg_queue() : CreatureScript("npc_wg_queue") { } + + bool OnGossipHello(Player* player, Creature* creature) + { + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); + + Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG); + if (!wintergrasp) + return true; + + if (wintergrasp->IsWarTime()) + { + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, sObjectMgr->GetTrinityStringForDBCLocale(WG_NPCQUEUE_TEXTOPTION_JOIN), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(wintergrasp->GetDefenderTeam()? WG_NPCQUEUE_TEXT_H_WAR : WG_NPCQUEUE_TEXT_A_WAR, creature->GetGUID()); + } + else + { + uint32 timer = wintergrasp->GetTimer() / 1000; + player->SendUpdateWorldState(4354, time(NULL) + timer); + if (timer < 15 * MINUTE) + { + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, sObjectMgr->GetTrinityStringForDBCLocale(WG_NPCQUEUE_TEXTOPTION_JOIN), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(wintergrasp->GetDefenderTeam() ? WG_NPCQUEUE_TEXT_H_QUEUE : WG_NPCQUEUE_TEXT_A_QUEUE, creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(wintergrasp->GetDefenderTeam() ? WG_NPCQUEUE_TEXT_H_NOWAR : WG_NPCQUEUE_TEXT_A_NOWAR, creature->GetGUID()); + } + return true; + } + + bool OnGossipSelect(Player* player, Creature* /*creature */ , uint32 /*sender */ , uint32 /*action*/) + { + player->CLOSE_GOSSIP_MENU(); + + Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG); + if (!wintergrasp) + return true; + + if (wintergrasp->IsWarTime()) + wintergrasp->InvitePlayerToWar(player); + else + { + uint32 timer = wintergrasp->GetTimer() / 1000; + if (timer < 15 * MINUTE) + wintergrasp->InvitePlayerToQueue(player); + } + return true; + } +}; + +class go_wg_vehicle_teleporter : public GameObjectScript +{ + public: + go_wg_vehicle_teleporter() : GameObjectScript("go_wg_vehicle_teleporter") { } + + struct go_wg_vehicle_teleporterAI : public GameObjectAI + { + go_wg_vehicle_teleporterAI(GameObject* gameObject) : GameObjectAI(gameObject), + _checkTimer(1000) + { } + + void UpdateAI(uint32 diff) + { + if (_checkTimer <= diff) + { + // Tabulation madness in the hole! + for (uint8 i = 0; i < MAX_WINTERGRASP_VEHICLES; i++) + if (Creature* vehicleCreature = go->FindNearestCreature(vehiclesList[i], 3.0f, true)) + if (!vehicleCreature->HasAura(SPELL_VEHICLE_TELEPORT)) + if (Vehicle* vehicle = vehicleCreature->GetVehicle()) + if (Unit* passenger = vehicle->GetPassenger(0)) + if (go->GetUInt32Value(GAMEOBJECT_FACTION) == passenger->getFaction()) + if (Creature* teleportTrigger = vehicleCreature->FindNearestCreature(NPC_WORLD_TRIGGER_LARGE_AOI_NOT_IMMUNE_PC_NPC, 100.0f, true)) + teleportTrigger->CastSpell(vehicleCreature, SPELL_VEHICLE_TELEPORT, true); + + _checkTimer = 1000; + } + else _checkTimer -= diff; + } + private: + uint32 _checkTimer; + }; + + GameObjectAI* GetGameObjectAI(GameObject* go) const + { + return new go_wg_vehicle_teleporterAI(go); + } +}; + +class npc_wg_quest_giver : public CreatureScript +{ + public: + npc_wg_quest_giver() : CreatureScript("npc_wg_quest_giver") { } + + bool OnGossipHello(Player* player, Creature* creature) + { + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); + + Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG); + if (!wintergrasp) + return true; + + if (creature->isQuestGiver()) + { + QuestRelationBounds objectQR = sObjectMgr->GetCreatureQuestRelationBounds(creature->GetEntry()); + QuestRelationBounds objectQIR = sObjectMgr->GetCreatureQuestInvolvedRelationBounds(creature->GetEntry()); + + QuestMenu& qm = player->PlayerTalkClass->GetQuestMenu(); + qm.ClearMenu(); + + for (QuestRelations::const_iterator i = objectQIR.first; i != objectQIR.second; ++i) + { + uint32 quest_id = i->second; + QuestStatus status = player->GetQuestStatus(quest_id); + if (status == QUEST_STATUS_COMPLETE) + qm.AddMenuItem(quest_id, 4); + else if (status == QUEST_STATUS_INCOMPLETE) + qm.AddMenuItem(quest_id, 4); + //else if (status == QUEST_STATUS_AVAILABLE) + // qm.AddMenuItem(quest_id, 2); + } + + for (QuestRelations::const_iterator i = objectQR.first; i != objectQR.second; ++i) + { + uint32 questId = i->second; + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + if (!quest) + continue; + + switch (questId) + { + // Horde attacker + case QUEST_BONES_AND_ARROWS_HORDE_ATT: + case QUEST_JINXING_THE_WALLS_HORDE_ATT: + case QUEST_SLAY_THEM_ALL_HORDE_ATT: + case QUEST_FUELING_THE_DEMOLISHERS_HORDE_ATT: + case QUEST_HEALING_WITH_ROSES_HORDE_ATT: + case QUEST_DEFEND_THE_SIEGE_HORDE_ATT: + if (wintergrasp->GetAttackerTeam() == TEAM_HORDE) + { + QuestStatus status = player->GetQuestStatus(questId); + + if (quest->IsAutoComplete() && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 4); + else if (status == QUEST_STATUS_NONE && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 2); + } + break; + // Horde defender + case QUEST_BONES_AND_ARROWS_HORDE_DEF: + case QUEST_WARDING_THE_WALLS_HORDE_DEF: + case QUEST_SLAY_THEM_ALL_HORDE_DEF: + case QUEST_FUELING_THE_DEMOLISHERS_HORDE_DEF: + case QUEST_HEALING_WITH_ROSES_HORDE_DEF: + case QUEST_TOPPLING_THE_TOWERS_HORDE_DEF: + case QUEST_STOP_THE_SIEGE_HORDE_DEF: + if (wintergrasp->GetDefenderTeam() == TEAM_HORDE) + { + QuestStatus status = player->GetQuestStatus(questId); + + if (quest->IsAutoComplete() && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 4); + else if (status == QUEST_STATUS_NONE && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 2); + } + break; + // Alliance attacker + case QUEST_BONES_AND_ARROWS_ALLIANCE_ATT: + case QUEST_WARDING_THE_WARRIORS_ALLIANCE_ATT: + case QUEST_NO_MERCY_FOR_THE_MERCILESS_ALLIANCE_ATT: + case QUEST_DEFEND_THE_SIEGE_ALLIANCE_ATT: + case QUEST_A_RARE_HERB_ALLIANCE_ATT: + if (wintergrasp->GetAttackerTeam() == TEAM_ALLIANCE) + { + QuestStatus status = player->GetQuestStatus(questId); + + if (quest->IsAutoComplete() && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 4); + else if (status == QUEST_STATUS_NONE && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 2); + } + break; + // Alliance defender + case QUEST_BONES_AND_ARROWS_ALLIANCE_DEF: + case QUEST_WARDING_THE_WARRIORS_ALLIANCE_DEF: + case QUEST_NO_MERCY_FOR_THE_MERCILESS_ALLIANCE_DEF: + case QUEST_SHOUTHERN_SABOTAGE_ALLIANCE_DEF: + case QUEST_STOP_THE_SIEGE_ALLIANCE_DEF: + case QUEST_A_RARE_HERB_ALLIANCE_DEF: + if (wintergrasp->GetDefenderTeam() == TEAM_ALLIANCE) + { + QuestStatus status = player->GetQuestStatus(questId); + + if (quest->IsAutoComplete() && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 4); + else if (status == QUEST_STATUS_NONE && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 2); + } + break; + default: + QuestStatus status = player->GetQuestStatus(questId); + + if (quest->IsAutoComplete() && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 4); + else if (status == QUEST_STATUS_NONE && player->CanTakeQuest(quest, false)) + qm.AddMenuItem(questId, 2); + break; + } + } + } + player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); + return true; + } +}; + +class spell_wintergrasp_force_building : public SpellScriptLoader +{ + public: + spell_wintergrasp_force_building() : SpellScriptLoader("spell_wintergrasp_force_building") { } + + class spell_wintergrasp_force_building_SpellScript : public SpellScript + { + PrepareSpellScript(spell_wintergrasp_force_building_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_BUILD_CATAPULT_FORCE) + || !sSpellMgr->GetSpellInfo(SPELL_BUILD_DEMOLISHER_FORCE) + || !sSpellMgr->GetSpellInfo(SPELL_BUILD_SIEGE_VEHICLE_FORCE_HORDE) + || !sSpellMgr->GetSpellInfo(SPELL_BUILD_SIEGE_VEHICLE_FORCE_ALLIANCE)) + return false; + return true; + } + + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + GetHitUnit()->CastSpell(GetHitUnit(), GetEffectValue(), false); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_wintergrasp_force_building_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_wintergrasp_force_building_SpellScript(); + } +}; + +class spell_wintergrasp_grab_passenger : public SpellScriptLoader +{ + public: + spell_wintergrasp_grab_passenger() : SpellScriptLoader("spell_wintergrasp_grab_passenger") { } + + class spell_wintergrasp_grab_passenger_SpellScript : public SpellScript + { + PrepareSpellScript(spell_wintergrasp_grab_passenger_SpellScript); + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Player* target = GetHitPlayer()) + target->CastSpell(GetCaster(), SPELL_RIDE_WG_VEHICLE, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_wintergrasp_grab_passenger_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_wintergrasp_grab_passenger_SpellScript(); + } +}; + +class achievement_wg_didnt_stand_a_chance : public AchievementCriteriaScript +{ +public: + achievement_wg_didnt_stand_a_chance() : AchievementCriteriaScript("achievement_wg_didnt_stand_a_chance") { } + + bool OnCheck(Player* source, Unit* target) + { + if (!target) + return false; + + if (Player* victim = target->ToPlayer()) + { + if (!victim->IsMounted()) + return false; + + if (Vehicle* vehicle = source->GetVehicle()) + if (vehicle->GetVehicleInfo()->m_ID == 244) // Wintergrasp Tower Cannon + return true; + } + + return false; + } +}; + + + +void AddSC_wintergrasp() +{ + new npc_wg_queue(); + new npc_wg_spirit_guide(); + new npc_wg_demolisher_engineer(); + new npc_wg_quest_giver(); + new achievement_wg_didnt_stand_a_chance(); + new spell_wintergrasp_force_building(); + new spell_wintergrasp_grab_passenger(); + + new go_wg_vehicle_teleporter(); +} diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp index c1850ee821c..a1780d1d4a8 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp @@ -171,6 +171,7 @@ public: summonTraveler_Timer = 90000; banish_Timer = 17000; HelpYell = false; + sumportals = false; destroyPortals(); if (instance) diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp index 26ab54746be..dd0b5ea9160 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp @@ -200,16 +200,12 @@ public: std::string GetSaveData() { OUT_SAVE_INST_DATA; + std::ostringstream stream; stream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3]; - char* out = new char[stream.str().length() + 1]; - strcpy(out, stream.str().c_str()); - if (out) - { - OUT_SAVE_INST_DATA_COMPLETE; - return out; - } - return NULL; + + OUT_SAVE_INST_DATA_COMPLETE; + return stream.str(); } void Load(const char* in) diff --git a/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp b/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp index fdb386372d4..fa67659ca66 100644 --- a/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp +++ b/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp @@ -171,15 +171,9 @@ public: OUT_SAVE_INST_DATA; std::ostringstream stream; stream << m_auiEncounter[0] << ' ' << m_auiEncounter[1]; - char* out = new char[stream.str().length() + 1]; - strcpy(out, stream.str().c_str()); - if (out) - { - OUT_SAVE_INST_DATA_COMPLETE; - return out; - } - return NULL; + OUT_SAVE_INST_DATA_COMPLETE; + return stream.str(); } void Load(const char* in) diff --git a/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp b/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp index 78ffddca4d8..1230b7e88cf 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp @@ -166,16 +166,12 @@ class instance_the_eye : public InstanceMapScript std::string GetSaveData() { OUT_SAVE_INST_DATA; + std::ostringstream stream; stream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3]; - char* out = new char[stream.str().length() + 1]; - strcpy(out, stream.str().c_str()); - if (out) - { - OUT_SAVE_INST_DATA_COMPLETE; - return out; - } - return NULL; + + OUT_SAVE_INST_DATA_COMPLETE; + return stream.str(); } void Load(const char* in) diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 7d248b35853..0bf2e5664a0 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -531,6 +531,41 @@ class spell_pal_righteous_defense : public SpellScriptLoader } }; +class spell_pal_exorcism_and_holy_wrath_damage : public SpellScriptLoader +{ + public: + spell_pal_exorcism_and_holy_wrath_damage() : SpellScriptLoader("spell_pal_exorcism_and_holy_wrath_damage") { } + + class spell_pal_exorcism_and_holy_wrath_damage_AuraScript : public AuraScript + { + PrepareAuraScript(spell_pal_exorcism_and_holy_wrath_damage_AuraScript); + + void HandleEffectCalcSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod) + { + if (!spellMod) + { + spellMod = new SpellModifier(aurEff->GetBase()); + spellMod->op = SPELLMOD_DAMAGE; + spellMod->type = SPELLMOD_FLAT; + spellMod->spellId = GetId(); + spellMod->mask[1] = 0x200002; + } + + spellMod->value = aurEff->GetAmount(); + } + + void Register() + { + DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_pal_exorcism_and_holy_wrath_damage_AuraScript::HandleEffectCalcSpellMod, EFFECT_0, SPELL_AURA_DUMMY); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_pal_exorcism_and_holy_wrath_damage_AuraScript(); + } +}; + void AddSC_paladin_spell_scripts() { new spell_pal_ardent_defender(); @@ -543,4 +578,5 @@ void AddSC_paladin_spell_scripts() new spell_pal_divine_storm_dummy(); new spell_pal_lay_on_hands(); new spell_pal_righteous_defense(); + new spell_pal_exorcism_and_holy_wrath_damage(); } diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index bb0fd1e73ab..ad437c5e431 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -386,6 +386,34 @@ class spell_rog_deadly_poison : public SpellScriptLoader } }; +class spell_rog_shadowstep : public SpellScriptLoader +{ + public: + spell_rog_shadowstep() : SpellScriptLoader("spell_rog_shadowstep") { } + + class spell_rog_shadowstep_SpellScript : public SpellScript + { + PrepareSpellScript(spell_rog_shadowstep_SpellScript); + + SpellCastResult CheckCast() + { + if (GetCaster()->HasUnitState(UNIT_STATE_ROOT)) + return SPELL_FAILED_ROOTED; + return SPELL_CAST_OK; + } + + void Register() + { + OnCheckCast += SpellCheckCastFn(spell_rog_shadowstep_SpellScript::CheckCast); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_rog_shadowstep_SpellScript(); + } +}; + void AddSC_rogue_spell_scripts() { new spell_rog_cheat_death(); @@ -394,4 +422,5 @@ void AddSC_rogue_spell_scripts() new spell_rog_prey_on_the_weak(); new spell_rog_shiv(); new spell_rog_deadly_poison(); + new spell_rog_shadowstep(); } diff --git a/src/server/scripts/World/achievement_scripts.cpp b/src/server/scripts/World/achievement_scripts.cpp index 3dc737f0c95..60572ee3e6a 100755 --- a/src/server/scripts/World/achievement_scripts.cpp +++ b/src/server/scripts/World/achievement_scripts.cpp @@ -235,30 +235,6 @@ class achievement_bg_av_perfection : public AchievementCriteriaScript } }; -class achievement_wg_didnt_stand_a_chance : public AchievementCriteriaScript -{ -public: - achievement_wg_didnt_stand_a_chance() : AchievementCriteriaScript("achievement_wg_didnt_stand_a_chance") { } - - bool OnCheck(Player* source, Unit* target) - { - if (!target) - return false; - - if (Player* victim = target->ToPlayer()) - { - if (!victim->IsMounted()) - return false; - - if (Vehicle* vehicle = source->GetVehicle()) - if (vehicle->GetVehicleInfo()->m_ID == 244) // Wintergrasp Tower Cannon - return true; - } - - return false; - } -}; - class achievement_bg_sa_defense_of_ancients : public AchievementCriteriaScript { public: @@ -344,7 +320,6 @@ void AddSC_achievement_scripts() new achievement_bg_ic_mowed_down(); new achievement_bg_sa_artillery(); new achievement_sickly_gazelle(); - new achievement_wg_didnt_stand_a_chance(); new achievement_everything_counts(); new achievement_bg_av_perfection(); new achievement_arena_kills("achievement_arena_2v2_kills", ARENA_TYPE_2v2); |
