[37] | 1 | /* |
---|
[44] | 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[37] | 3 | * |
---|
[44] | 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
---|
| 5 | * |
---|
[37] | 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[37] | 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[37] | 19 | */ |
---|
| 20 | |
---|
| 21 | #include "Common.h" |
---|
| 22 | #include "Database/DatabaseEnv.h" |
---|
| 23 | #include "WorldPacket.h" |
---|
| 24 | #include "WorldSession.h" |
---|
| 25 | #include "World.h" |
---|
| 26 | #include "ObjectMgr.h" |
---|
| 27 | #include "Player.h" |
---|
| 28 | #include "Opcodes.h" |
---|
| 29 | #include "Chat.h" |
---|
| 30 | #include "Log.h" |
---|
| 31 | #include "MapManager.h" |
---|
| 32 | #include "ObjectAccessor.h" |
---|
| 33 | #include "Language.h" |
---|
| 34 | #include "CellImpl.h" |
---|
| 35 | #include "InstanceSaveMgr.h" |
---|
| 36 | #include "Util.h" |
---|
| 37 | #ifdef _DEBUG_VMAPS |
---|
| 38 | #include "VMapFactory.h" |
---|
| 39 | #endif |
---|
| 40 | |
---|
| 41 | bool ChatHandler::HandleSayCommand(const char* args) |
---|
| 42 | { |
---|
| 43 | if(!*args) |
---|
| 44 | return false; |
---|
| 45 | |
---|
| 46 | Creature* pCreature = getSelectedCreature(); |
---|
| 47 | if(!pCreature) |
---|
| 48 | { |
---|
| 49 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 50 | SetSentErrorMessage(true); |
---|
| 51 | return false; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | pCreature->Say(args, LANG_UNIVERSAL, 0); |
---|
| 55 | |
---|
| 56 | return true; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | bool ChatHandler::HandleYellCommand(const char* args) |
---|
| 60 | { |
---|
| 61 | if(!*args) |
---|
| 62 | return false; |
---|
| 63 | |
---|
| 64 | Creature* pCreature = getSelectedCreature(); |
---|
| 65 | if(!pCreature) |
---|
| 66 | { |
---|
| 67 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 68 | SetSentErrorMessage(true); |
---|
| 69 | return false; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | pCreature->Yell(args, LANG_UNIVERSAL, 0); |
---|
| 73 | |
---|
| 74 | return true; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | //show text emote by creature in chat |
---|
| 78 | bool ChatHandler::HandleTextEmoteCommand(const char* args) |
---|
| 79 | { |
---|
| 80 | if(!*args) |
---|
| 81 | return false; |
---|
| 82 | |
---|
| 83 | Creature* pCreature = getSelectedCreature(); |
---|
| 84 | |
---|
| 85 | if(!pCreature) |
---|
| 86 | { |
---|
| 87 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 88 | SetSentErrorMessage(true); |
---|
| 89 | return false; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | pCreature->TextEmote(args, 0); |
---|
| 93 | |
---|
| 94 | return true; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | // make npc whisper to player |
---|
| 98 | bool ChatHandler::HandleNpcWhisperCommand(const char* args) |
---|
| 99 | { |
---|
| 100 | if(!*args) |
---|
| 101 | return false; |
---|
| 102 | |
---|
| 103 | char* receiver_str = strtok((char*)args, " "); |
---|
| 104 | char* text = strtok(NULL, ""); |
---|
| 105 | |
---|
| 106 | uint64 guid = m_session->GetPlayer()->GetSelection(); |
---|
| 107 | Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); |
---|
| 108 | |
---|
| 109 | if(!pCreature || !receiver_str || !text) |
---|
| 110 | { |
---|
| 111 | return false; |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | uint64 receiver_guid= atol(receiver_str); |
---|
| 115 | |
---|
| 116 | pCreature->Whisper(text,receiver_guid); |
---|
| 117 | |
---|
| 118 | return true; |
---|
| 119 | } |
---|
| 120 | |
---|
[40] | 121 | bool ChatHandler::HandleNameAnnounceCommand(const char* args) |
---|
| 122 | { |
---|
| 123 | WorldPacket data; |
---|
| 124 | if(!*args) |
---|
| 125 | return false; |
---|
[42] | 126 | //char str[1024]; |
---|
[44] | 127 | //sprintf(str, GetTrinityString(LANG_ANNOUNCE_COLOR), m_session->GetPlayer()->GetName(), args); |
---|
[40] | 128 | sWorld.SendWorldText(LANG_ANNOUNCE_COLOR, m_session->GetPlayer()->GetName(), args); |
---|
| 129 | return true; |
---|
| 130 | } |
---|
| 131 | |
---|
[37] | 132 | // global announce |
---|
| 133 | bool ChatHandler::HandleAnnounceCommand(const char* args) |
---|
| 134 | { |
---|
| 135 | if(!*args) |
---|
| 136 | return false; |
---|
| 137 | |
---|
| 138 | sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args); |
---|
[39] | 139 | |
---|
[37] | 140 | return true; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | //notification player at the screen |
---|
| 144 | bool ChatHandler::HandleNotifyCommand(const char* args) |
---|
| 145 | { |
---|
| 146 | if(!*args) |
---|
| 147 | return false; |
---|
| 148 | |
---|
[44] | 149 | std::string str = GetTrinityString(LANG_GLOBAL_NOTIFY); |
---|
[37] | 150 | str += args; |
---|
| 151 | |
---|
| 152 | WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); |
---|
| 153 | data << str; |
---|
| 154 | sWorld.SendGlobalMessage(&data); |
---|
| 155 | |
---|
| 156 | return true; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | //Enable\Dissable GM Mode |
---|
| 160 | bool ChatHandler::HandleGMmodeCommand(const char* args) |
---|
| 161 | { |
---|
| 162 | if(!*args) |
---|
| 163 | { |
---|
| 164 | if(m_session->GetPlayer()->isGameMaster()) |
---|
| 165 | m_session->SendNotification(LANG_GM_ON); |
---|
| 166 | else |
---|
| 167 | m_session->SendNotification(LANG_GM_OFF); |
---|
| 168 | return true; |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | std::string argstr = (char*)args; |
---|
| 172 | |
---|
| 173 | if (argstr == "on") |
---|
| 174 | { |
---|
| 175 | m_session->GetPlayer()->SetGameMaster(true); |
---|
| 176 | m_session->SendNotification(LANG_GM_ON); |
---|
| 177 | #ifdef _DEBUG_VMAPS |
---|
| 178 | VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); |
---|
| 179 | vMapManager->processCommand("stoplog"); |
---|
| 180 | #endif |
---|
| 181 | return true; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | if (argstr == "off") |
---|
| 185 | { |
---|
| 186 | m_session->GetPlayer()->SetGameMaster(false); |
---|
| 187 | m_session->SendNotification(LANG_GM_OFF); |
---|
| 188 | #ifdef _DEBUG_VMAPS |
---|
| 189 | VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); |
---|
| 190 | vMapManager->processCommand("startlog"); |
---|
| 191 | #endif |
---|
| 192 | return true; |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | SendSysMessage(LANG_USE_BOL); |
---|
| 196 | SetSentErrorMessage(true); |
---|
| 197 | return false; |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | // Enables or disables hiding of the staff badge |
---|
| 201 | bool ChatHandler::HandleGMChatCommand(const char* args) |
---|
| 202 | { |
---|
| 203 | if(!*args) |
---|
| 204 | { |
---|
| 205 | if(m_session->GetPlayer()->isGMChat()) |
---|
| 206 | m_session->SendNotification(LANG_GM_CHAT_ON); |
---|
| 207 | else |
---|
| 208 | m_session->SendNotification(LANG_GM_CHAT_OFF); |
---|
| 209 | return true; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | std::string argstr = (char*)args; |
---|
| 213 | |
---|
| 214 | if (argstr == "on") |
---|
| 215 | { |
---|
| 216 | m_session->GetPlayer()->SetGMChat(true); |
---|
| 217 | m_session->SendNotification(LANG_GM_CHAT_ON); |
---|
| 218 | return true; |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | if (argstr == "off") |
---|
| 222 | { |
---|
| 223 | m_session->GetPlayer()->SetGMChat(false); |
---|
| 224 | m_session->SendNotification(LANG_GM_CHAT_OFF); |
---|
| 225 | return true; |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | SendSysMessage(LANG_USE_BOL); |
---|
| 229 | SetSentErrorMessage(true); |
---|
| 230 | return false; |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | |
---|
| 234 | //Enable\Dissable Invisible mode |
---|
| 235 | bool ChatHandler::HandleVisibleCommand(const char* args) |
---|
| 236 | { |
---|
| 237 | if (!*args) |
---|
| 238 | { |
---|
[44] | 239 | PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetTrinityString(LANG_VISIBLE) : GetTrinityString(LANG_INVISIBLE)); |
---|
[37] | 240 | return true; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | std::string argstr = (char*)args; |
---|
| 244 | |
---|
| 245 | if (argstr == "on") |
---|
| 246 | { |
---|
| 247 | m_session->GetPlayer()->SetGMVisible(true); |
---|
| 248 | m_session->SendNotification(LANG_INVISIBLE_VISIBLE); |
---|
| 249 | return true; |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | if (argstr == "off") |
---|
| 253 | { |
---|
| 254 | m_session->SendNotification(LANG_INVISIBLE_INVISIBLE); |
---|
| 255 | m_session->GetPlayer()->SetGMVisible(false); |
---|
| 256 | return true; |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | SendSysMessage(LANG_USE_BOL); |
---|
| 260 | SetSentErrorMessage(true); |
---|
| 261 | return false; |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | bool ChatHandler::HandleGPSCommand(const char* args) |
---|
| 265 | { |
---|
| 266 | WorldObject *obj = NULL; |
---|
| 267 | if (*args) |
---|
| 268 | { |
---|
| 269 | std::string name = args; |
---|
| 270 | if(normalizePlayerName(name)) |
---|
| 271 | obj = objmgr.GetPlayer(name.c_str()); |
---|
| 272 | |
---|
| 273 | if(!obj) |
---|
| 274 | { |
---|
| 275 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 276 | SetSentErrorMessage(true); |
---|
| 277 | return false; |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | else |
---|
| 281 | { |
---|
| 282 | obj = getSelectedUnit(); |
---|
| 283 | |
---|
| 284 | if(!obj) |
---|
| 285 | { |
---|
| 286 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 287 | SetSentErrorMessage(true); |
---|
| 288 | return false; |
---|
| 289 | } |
---|
| 290 | } |
---|
[44] | 291 | CellPair cell_val = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); |
---|
[37] | 292 | Cell cell(cell_val); |
---|
| 293 | |
---|
| 294 | uint32 zone_id = obj->GetZoneId(); |
---|
| 295 | uint32 area_id = obj->GetAreaId(); |
---|
| 296 | |
---|
| 297 | MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId()); |
---|
| 298 | AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id); |
---|
| 299 | AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id); |
---|
| 300 | |
---|
| 301 | float zone_x = obj->GetPositionX(); |
---|
| 302 | float zone_y = obj->GetPositionY(); |
---|
| 303 | |
---|
| 304 | Map2ZoneCoordinates(zone_x,zone_y,zone_id); |
---|
| 305 | |
---|
| 306 | Map const *map = MapManager::Instance().GetMap(obj->GetMapId(), obj); |
---|
| 307 | float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT); |
---|
| 308 | float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()); |
---|
| 309 | |
---|
[44] | 310 | GridPair p = Trinity::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY()); |
---|
[37] | 311 | |
---|
| 312 | int gx=63-p.x_coord; |
---|
| 313 | int gy=63-p.y_coord; |
---|
| 314 | |
---|
| 315 | uint32 have_map = Map::ExistMap(obj->GetMapId(),gx,gy) ? 1 : 0; |
---|
| 316 | uint32 have_vmap = Map::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0; |
---|
| 317 | |
---|
| 318 | PSendSysMessage(LANG_MAP_POSITION, |
---|
| 319 | obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "<unknown>" ), |
---|
| 320 | zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ), |
---|
| 321 | area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ), |
---|
| 322 | obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), |
---|
| 323 | cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), |
---|
| 324 | zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); |
---|
| 325 | |
---|
| 326 | sLog.outDebug("Player %s GPS call for %s '%s' (%s: %u):", |
---|
| 327 | m_session->GetPlayer()->GetName(), |
---|
| 328 | (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(), |
---|
| 329 | (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) ); |
---|
[44] | 330 | sLog.outDebug(GetTrinityString(LANG_MAP_POSITION), |
---|
[37] | 331 | obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), |
---|
| 332 | zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), |
---|
| 333 | area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), |
---|
| 334 | obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), |
---|
| 335 | cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), |
---|
| 336 | zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); |
---|
| 337 | |
---|
| 338 | return true; |
---|
| 339 | } |
---|
| 340 | |
---|
| 341 | //Summon Player |
---|
| 342 | bool ChatHandler::HandleNamegoCommand(const char* args) |
---|
| 343 | { |
---|
| 344 | if(!*args) |
---|
| 345 | return false; |
---|
| 346 | |
---|
| 347 | std::string name = args; |
---|
| 348 | |
---|
| 349 | if(!normalizePlayerName(name)) |
---|
| 350 | { |
---|
| 351 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 352 | SetSentErrorMessage(true); |
---|
| 353 | return false; |
---|
| 354 | } |
---|
| 355 | |
---|
| 356 | Player *chr = objmgr.GetPlayer(name.c_str()); |
---|
| 357 | if (chr) |
---|
| 358 | { |
---|
| 359 | if(chr->IsBeingTeleported()==true) |
---|
| 360 | { |
---|
| 361 | PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); |
---|
| 362 | SetSentErrorMessage(true); |
---|
| 363 | return false; |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | Map* pMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); |
---|
| 367 | |
---|
| 368 | if(pMap->IsBattleGroundOrArena()) |
---|
| 369 | { |
---|
| 370 | // cannot summon to bg |
---|
| 371 | SendSysMessage(LANG_CANNOT_SUMMON_TO_BG); |
---|
| 372 | SetSentErrorMessage(true); |
---|
| 373 | return false; |
---|
| 374 | } |
---|
| 375 | else if(pMap->IsDungeon()) |
---|
| 376 | { |
---|
| 377 | Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr); |
---|
| 378 | if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() ) |
---|
| 379 | { |
---|
| 380 | // cannot summon from instance to instance |
---|
| 381 | PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName()); |
---|
| 382 | SetSentErrorMessage(true); |
---|
| 383 | return false; |
---|
| 384 | } |
---|
| 385 | |
---|
| 386 | // we are in instance, and can summon only player in our group with us as lead |
---|
| 387 | if ( !m_session->GetPlayer()->GetGroup() || !chr->GetGroup() || |
---|
| 388 | (chr->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) || |
---|
| 389 | (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) |
---|
| 390 | // the last check is a bit excessive, but let it be, just in case |
---|
| 391 | { |
---|
| 392 | PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName()); |
---|
| 393 | SetSentErrorMessage(true); |
---|
| 394 | return false; |
---|
| 395 | } |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | PSendSysMessage(LANG_SUMMONING, chr->GetName(),""); |
---|
| 399 | |
---|
| 400 | if (m_session->GetPlayer()->IsVisibleGloballyFor(chr)) |
---|
| 401 | ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, m_session->GetPlayer()->GetName()); |
---|
| 402 | |
---|
| 403 | // stop flight if need |
---|
| 404 | if(chr->isInFlight()) |
---|
| 405 | { |
---|
| 406 | chr->GetMotionMaster()->MovementExpired(); |
---|
| 407 | chr->m_taxi.ClearTaxiDestinations(); |
---|
| 408 | } |
---|
| 409 | // save only in non-flight case |
---|
| 410 | else |
---|
| 411 | chr->SaveRecallPosition(); |
---|
| 412 | |
---|
| 413 | // before GM |
---|
| 414 | float x,y,z; |
---|
| 415 | m_session->GetPlayer()->GetClosePoint(x,y,z,chr->GetObjectSize()); |
---|
| 416 | chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation()); |
---|
| 417 | } |
---|
| 418 | else if (uint64 guid = objmgr.GetPlayerGUIDByName(name)) |
---|
| 419 | { |
---|
[44] | 420 | PSendSysMessage(LANG_SUMMONING, name.c_str(),GetTrinityString(LANG_OFFLINE)); |
---|
[37] | 421 | |
---|
| 422 | // in point where GM stay |
---|
| 423 | Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(), |
---|
| 424 | m_session->GetPlayer()->GetPositionX(), |
---|
| 425 | m_session->GetPlayer()->GetPositionY(), |
---|
| 426 | m_session->GetPlayer()->GetPositionZ(), |
---|
| 427 | m_session->GetPlayer()->GetOrientation(), |
---|
| 428 | m_session->GetPlayer()->GetZoneId(), |
---|
| 429 | guid); |
---|
| 430 | } |
---|
| 431 | else |
---|
| 432 | { |
---|
| 433 | PSendSysMessage(LANG_NO_PLAYER, args); |
---|
| 434 | SetSentErrorMessage(true); |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | return true; |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | //Teleport to Player |
---|
| 441 | bool ChatHandler::HandleGonameCommand(const char* args) |
---|
| 442 | { |
---|
| 443 | if(!*args) |
---|
| 444 | return false; |
---|
| 445 | |
---|
| 446 | Player* _player = m_session->GetPlayer(); |
---|
| 447 | |
---|
| 448 | std::string name = args; |
---|
| 449 | |
---|
| 450 | if(!normalizePlayerName(name)) |
---|
| 451 | { |
---|
| 452 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 453 | SetSentErrorMessage(true); |
---|
| 454 | return false; |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | Player *chr = objmgr.GetPlayer(name.c_str()); |
---|
| 458 | if (chr) |
---|
| 459 | { |
---|
| 460 | Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr); |
---|
| 461 | if(cMap->IsBattleGroundOrArena()) |
---|
| 462 | { |
---|
| 463 | // only allow if gm mode is on |
---|
| 464 | if (!_player->isGameMaster()) |
---|
| 465 | { |
---|
| 466 | SendSysMessage(LANG_CANNOT_GO_TO_BG_GM); |
---|
| 467 | SetSentErrorMessage(true); |
---|
| 468 | return false; |
---|
| 469 | } |
---|
| 470 | // if already in a bg, don't let port to other |
---|
| 471 | else if (_player->GetBattleGroundId()) |
---|
| 472 | { |
---|
| 473 | SendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG); |
---|
| 474 | SetSentErrorMessage(true); |
---|
| 475 | return false; |
---|
| 476 | } |
---|
| 477 | // all's well, set bg id |
---|
| 478 | // when porting out from the bg, it will be reset to 0 |
---|
| 479 | _player->SetBattleGroundId(chr->GetBattleGroundId()); |
---|
| 480 | } |
---|
| 481 | else if(cMap->IsDungeon()) |
---|
| 482 | { |
---|
| 483 | Map* pMap = MapManager::Instance().GetMap(_player->GetMapId(),_player); |
---|
| 484 | |
---|
| 485 | // we have to go to instance, and can go to player only if: |
---|
| 486 | // 1) we are in his group (either as leader or as member) |
---|
| 487 | // 2) we are not bound to any group and have GM mode on |
---|
| 488 | if (_player->GetGroup()) |
---|
| 489 | { |
---|
| 490 | // we are in group, we can go only if we are in the player group |
---|
| 491 | if (_player->GetGroup() != chr->GetGroup()) |
---|
| 492 | { |
---|
| 493 | PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName()); |
---|
| 494 | SetSentErrorMessage(true); |
---|
| 495 | return false; |
---|
| 496 | } |
---|
| 497 | } |
---|
| 498 | else |
---|
| 499 | { |
---|
| 500 | // we are not in group, let's verify our GM mode |
---|
| 501 | if (!_player->isGameMaster()) |
---|
| 502 | { |
---|
| 503 | PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName()); |
---|
| 504 | SetSentErrorMessage(true); |
---|
| 505 | return false; |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | // if the player or the player's group is bound to another instance |
---|
| 510 | // the player will not be bound to another one |
---|
| 511 | InstancePlayerBind *pBind = _player->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()); |
---|
| 512 | if(!pBind) |
---|
| 513 | { |
---|
| 514 | Group *group = _player->GetGroup(); |
---|
| 515 | InstanceGroupBind *gBind = group ? group->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()) : NULL; |
---|
| 516 | if(!gBind) |
---|
| 517 | { |
---|
| 518 | // if no bind exists, create a solo bind |
---|
| 519 | InstanceSave *save = sInstanceSaveManager.GetInstanceSave(chr->GetInstanceId()); |
---|
| 520 | if(save) _player->BindToInstance(save, !save->CanReset()); |
---|
| 521 | } |
---|
| 522 | } |
---|
| 523 | |
---|
| 524 | _player->SetDifficulty(chr->GetDifficulty()); |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | PSendSysMessage(LANG_APPEARING_AT, chr->GetName()); |
---|
| 528 | |
---|
| 529 | if (_player->IsVisibleGloballyFor(chr)) |
---|
| 530 | ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, _player->GetName()); |
---|
| 531 | |
---|
| 532 | // stop flight if need |
---|
| 533 | if(_player->isInFlight()) |
---|
| 534 | { |
---|
| 535 | _player->GetMotionMaster()->MovementExpired(); |
---|
| 536 | _player->m_taxi.ClearTaxiDestinations(); |
---|
| 537 | } |
---|
| 538 | // save only in non-flight case |
---|
| 539 | else |
---|
| 540 | _player->SaveRecallPosition(); |
---|
| 541 | |
---|
| 542 | // to point to see at target with same orientation |
---|
| 543 | float x,y,z; |
---|
| 544 | chr->GetContactPoint(m_session->GetPlayer(),x,y,z); |
---|
| 545 | |
---|
| 546 | _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), TELE_TO_GM_MODE); |
---|
| 547 | |
---|
| 548 | return true; |
---|
| 549 | } |
---|
| 550 | |
---|
| 551 | if (uint64 guid = objmgr.GetPlayerGUIDByName(name)) |
---|
| 552 | { |
---|
| 553 | PSendSysMessage(LANG_APPEARING_AT, name.c_str()); |
---|
| 554 | |
---|
| 555 | // to point where player stay (if loaded) |
---|
| 556 | float x,y,z,o; |
---|
| 557 | uint32 map; |
---|
| 558 | bool in_flight; |
---|
| 559 | if(Player::LoadPositionFromDB(map,x,y,z,o,in_flight,guid)) |
---|
| 560 | { |
---|
| 561 | // stop flight if need |
---|
| 562 | if(_player->isInFlight()) |
---|
| 563 | { |
---|
| 564 | _player->GetMotionMaster()->MovementExpired(); |
---|
| 565 | _player->m_taxi.ClearTaxiDestinations(); |
---|
| 566 | } |
---|
| 567 | // save only in non-flight case |
---|
| 568 | else |
---|
| 569 | _player->SaveRecallPosition(); |
---|
| 570 | |
---|
| 571 | _player->TeleportTo(map, x, y, z,_player->GetOrientation()); |
---|
| 572 | return true; |
---|
| 573 | } |
---|
| 574 | } |
---|
| 575 | |
---|
| 576 | PSendSysMessage(LANG_NO_PLAYER, args); |
---|
| 577 | |
---|
| 578 | SetSentErrorMessage(true); |
---|
| 579 | return false; |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | // Teleport player to last position |
---|
| 583 | bool ChatHandler::HandleRecallCommand(const char* args) |
---|
| 584 | { |
---|
| 585 | Player* chr = NULL; |
---|
| 586 | |
---|
| 587 | if(!*args) |
---|
| 588 | { |
---|
| 589 | chr = getSelectedPlayer(); |
---|
| 590 | if(!chr) |
---|
| 591 | chr = m_session->GetPlayer(); |
---|
| 592 | } |
---|
| 593 | else |
---|
| 594 | { |
---|
| 595 | std::string name = args; |
---|
| 596 | |
---|
| 597 | if(!normalizePlayerName(name)) |
---|
| 598 | { |
---|
| 599 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 600 | SetSentErrorMessage(true); |
---|
| 601 | return false; |
---|
| 602 | } |
---|
| 603 | |
---|
| 604 | chr = objmgr.GetPlayer(name.c_str()); |
---|
| 605 | |
---|
| 606 | if(!chr) |
---|
| 607 | { |
---|
| 608 | PSendSysMessage(LANG_NO_PLAYER, args); |
---|
| 609 | SetSentErrorMessage(true); |
---|
| 610 | return false; |
---|
| 611 | } |
---|
| 612 | } |
---|
| 613 | |
---|
| 614 | if(chr->IsBeingTeleported()) |
---|
| 615 | { |
---|
| 616 | PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); |
---|
| 617 | SetSentErrorMessage(true); |
---|
| 618 | return false; |
---|
| 619 | } |
---|
| 620 | |
---|
| 621 | // stop flight if need |
---|
| 622 | if(chr->isInFlight()) |
---|
| 623 | { |
---|
| 624 | chr->GetMotionMaster()->MovementExpired(); |
---|
| 625 | chr->m_taxi.ClearTaxiDestinations(); |
---|
| 626 | } |
---|
| 627 | |
---|
| 628 | chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO); |
---|
| 629 | return true; |
---|
| 630 | } |
---|
| 631 | |
---|
| 632 | //Edit Player KnownTitles |
---|
| 633 | bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args) |
---|
| 634 | { |
---|
| 635 | if(!*args) |
---|
| 636 | return false; |
---|
| 637 | |
---|
| 638 | uint64 titles = 0; |
---|
| 639 | |
---|
| 640 | sscanf((char*)args, I64FMTD, &titles); |
---|
| 641 | |
---|
| 642 | Player *chr = getSelectedPlayer(); |
---|
| 643 | if (!chr) |
---|
| 644 | { |
---|
| 645 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 646 | SetSentErrorMessage(true); |
---|
| 647 | return false; |
---|
| 648 | } |
---|
| 649 | |
---|
| 650 | uint64 titles2 = titles; |
---|
| 651 | |
---|
| 652 | for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i) |
---|
| 653 | if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) |
---|
| 654 | titles2 &= ~(uint64(1) << tEntry->bit_index); |
---|
| 655 | |
---|
| 656 | titles &= ~titles2; // remove not existed titles |
---|
| 657 | |
---|
| 658 | chr->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); |
---|
| 659 | SendSysMessage(LANG_DONE); |
---|
| 660 | |
---|
| 661 | return true; |
---|
| 662 | } |
---|
| 663 | |
---|
| 664 | //Edit Player HP |
---|
| 665 | bool ChatHandler::HandleModifyHPCommand(const char* args) |
---|
| 666 | { |
---|
| 667 | if(!*args) |
---|
| 668 | return false; |
---|
| 669 | |
---|
| 670 | // char* pHp = strtok((char*)args, " "); |
---|
| 671 | // if (!pHp) |
---|
| 672 | // return false; |
---|
| 673 | |
---|
| 674 | // char* pHpMax = strtok(NULL, " "); |
---|
| 675 | // if (!pHpMax) |
---|
| 676 | // return false; |
---|
| 677 | |
---|
| 678 | // int32 hpm = atoi(pHpMax); |
---|
| 679 | // int32 hp = atoi(pHp); |
---|
| 680 | |
---|
| 681 | int32 hp = atoi((char*)args); |
---|
| 682 | int32 hpm = atoi((char*)args); |
---|
| 683 | |
---|
| 684 | if (hp <= 0 || hpm <= 0 || hpm < hp) |
---|
| 685 | { |
---|
| 686 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 687 | SetSentErrorMessage(true); |
---|
| 688 | return false; |
---|
| 689 | } |
---|
| 690 | |
---|
| 691 | Player *chr = getSelectedPlayer(); |
---|
| 692 | if (chr == NULL) |
---|
| 693 | { |
---|
| 694 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 695 | SetSentErrorMessage(true); |
---|
| 696 | return false; |
---|
| 697 | } |
---|
| 698 | |
---|
| 699 | PSendSysMessage(LANG_YOU_CHANGE_HP, chr->GetName(), hp, hpm); |
---|
| 700 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, m_session->GetPlayer()->GetName(), hp, hpm); |
---|
| 701 | |
---|
| 702 | chr->SetMaxHealth( hpm ); |
---|
| 703 | chr->SetHealth( hp ); |
---|
| 704 | |
---|
| 705 | return true; |
---|
| 706 | } |
---|
| 707 | |
---|
| 708 | //Edit Player Mana |
---|
| 709 | bool ChatHandler::HandleModifyManaCommand(const char* args) |
---|
| 710 | { |
---|
| 711 | if(!*args) |
---|
| 712 | return false; |
---|
| 713 | |
---|
| 714 | // char* pmana = strtok((char*)args, " "); |
---|
| 715 | // if (!pmana) |
---|
| 716 | // return false; |
---|
| 717 | |
---|
| 718 | // char* pmanaMax = strtok(NULL, " "); |
---|
| 719 | // if (!pmanaMax) |
---|
| 720 | // return false; |
---|
| 721 | |
---|
| 722 | // int32 manam = atoi(pmanaMax); |
---|
| 723 | // int32 mana = atoi(pmana); |
---|
| 724 | int32 mana = atoi((char*)args); |
---|
| 725 | int32 manam = atoi((char*)args); |
---|
| 726 | |
---|
| 727 | if (mana <= 0 || manam <= 0 || manam < mana) |
---|
| 728 | { |
---|
| 729 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 730 | SetSentErrorMessage(true); |
---|
| 731 | return false; |
---|
| 732 | } |
---|
| 733 | |
---|
| 734 | Player *chr = getSelectedPlayer(); |
---|
| 735 | if (chr == NULL) |
---|
| 736 | { |
---|
| 737 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 738 | SetSentErrorMessage(true); |
---|
| 739 | return false; |
---|
| 740 | } |
---|
| 741 | |
---|
| 742 | PSendSysMessage(LANG_YOU_CHANGE_MANA, chr->GetName(), mana, manam); |
---|
| 743 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, m_session->GetPlayer()->GetName(), mana, manam); |
---|
| 744 | |
---|
| 745 | chr->SetMaxPower(POWER_MANA,manam ); |
---|
| 746 | chr->SetPower(POWER_MANA, mana ); |
---|
| 747 | |
---|
| 748 | return true; |
---|
| 749 | } |
---|
| 750 | |
---|
| 751 | //Edit Player Energy |
---|
| 752 | bool ChatHandler::HandleModifyEnergyCommand(const char* args) |
---|
| 753 | { |
---|
| 754 | if(!*args) |
---|
| 755 | return false; |
---|
| 756 | |
---|
| 757 | // char* pmana = strtok((char*)args, " "); |
---|
| 758 | // if (!pmana) |
---|
| 759 | // return false; |
---|
| 760 | |
---|
| 761 | // char* pmanaMax = strtok(NULL, " "); |
---|
| 762 | // if (!pmanaMax) |
---|
| 763 | // return false; |
---|
| 764 | |
---|
| 765 | // int32 manam = atoi(pmanaMax); |
---|
| 766 | // int32 mana = atoi(pmana); |
---|
| 767 | |
---|
| 768 | int32 energy = atoi((char*)args)*10; |
---|
| 769 | int32 energym = atoi((char*)args)*10; |
---|
| 770 | |
---|
| 771 | if (energy <= 0 || energym <= 0 || energym < energy) |
---|
| 772 | { |
---|
| 773 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 774 | SetSentErrorMessage(true); |
---|
| 775 | return false; |
---|
| 776 | } |
---|
| 777 | |
---|
| 778 | Player *chr = getSelectedPlayer(); |
---|
| 779 | if (!chr) |
---|
| 780 | { |
---|
| 781 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 782 | SetSentErrorMessage(true); |
---|
| 783 | return false; |
---|
| 784 | } |
---|
| 785 | |
---|
| 786 | PSendSysMessage(LANG_YOU_CHANGE_ENERGY, chr->GetName(), energy/10, energym/10); |
---|
| 787 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, m_session->GetPlayer()->GetName(), energy/10, energym/10); |
---|
| 788 | |
---|
| 789 | chr->SetMaxPower(POWER_ENERGY,energym ); |
---|
| 790 | chr->SetPower(POWER_ENERGY, energy ); |
---|
| 791 | |
---|
[44] | 792 | sLog.outDetail(GetTrinityString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); |
---|
[37] | 793 | |
---|
| 794 | return true; |
---|
| 795 | } |
---|
| 796 | |
---|
| 797 | //Edit Player Rage |
---|
| 798 | bool ChatHandler::HandleModifyRageCommand(const char* args) |
---|
| 799 | { |
---|
| 800 | if(!*args) |
---|
| 801 | return false; |
---|
| 802 | |
---|
| 803 | // char* pmana = strtok((char*)args, " "); |
---|
| 804 | // if (!pmana) |
---|
| 805 | // return false; |
---|
| 806 | |
---|
| 807 | // char* pmanaMax = strtok(NULL, " "); |
---|
| 808 | // if (!pmanaMax) |
---|
| 809 | // return false; |
---|
| 810 | |
---|
| 811 | // int32 manam = atoi(pmanaMax); |
---|
| 812 | // int32 mana = atoi(pmana); |
---|
| 813 | |
---|
| 814 | int32 rage = atoi((char*)args)*10; |
---|
| 815 | int32 ragem = atoi((char*)args)*10; |
---|
| 816 | |
---|
| 817 | if (rage <= 0 || ragem <= 0 || ragem < rage) |
---|
| 818 | { |
---|
| 819 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 820 | SetSentErrorMessage(true); |
---|
| 821 | return false; |
---|
| 822 | } |
---|
| 823 | |
---|
| 824 | Player *chr = getSelectedPlayer(); |
---|
| 825 | if (chr == NULL) |
---|
| 826 | { |
---|
| 827 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 828 | SetSentErrorMessage(true); |
---|
| 829 | return false; |
---|
| 830 | } |
---|
| 831 | |
---|
| 832 | PSendSysMessage(LANG_YOU_CHANGE_RAGE, chr->GetName(), rage/10, ragem/10); |
---|
[44] | 833 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_RAGE_CHANGED), m_session->GetPlayer()->GetName(), rage/10, ragem/10); |
---|
[37] | 834 | |
---|
| 835 | chr->SetMaxPower(POWER_RAGE,ragem ); |
---|
| 836 | chr->SetPower(POWER_RAGE, rage ); |
---|
| 837 | |
---|
| 838 | return true; |
---|
| 839 | } |
---|
| 840 | |
---|
| 841 | //Edit Player Faction |
---|
| 842 | bool ChatHandler::HandleModifyFactionCommand(const char* args) |
---|
| 843 | { |
---|
| 844 | if(!*args) |
---|
| 845 | return false; |
---|
| 846 | |
---|
| 847 | char* pfactionid = extractKeyFromLink((char*)args,"Hfaction"); |
---|
| 848 | |
---|
| 849 | Creature* chr = getSelectedCreature(); |
---|
| 850 | if(!chr) |
---|
| 851 | { |
---|
| 852 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
| 853 | SetSentErrorMessage(true); |
---|
| 854 | return false; |
---|
| 855 | } |
---|
| 856 | |
---|
| 857 | if(!pfactionid) |
---|
| 858 | { |
---|
| 859 | if(chr) |
---|
| 860 | { |
---|
| 861 | uint32 factionid = chr->getFaction(); |
---|
| 862 | uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); |
---|
| 863 | uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); |
---|
| 864 | uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); |
---|
| 865 | PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); |
---|
| 866 | } |
---|
| 867 | return true; |
---|
| 868 | } |
---|
| 869 | |
---|
| 870 | if( !chr ) |
---|
| 871 | { |
---|
| 872 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 873 | SetSentErrorMessage(true); |
---|
| 874 | return false; |
---|
| 875 | } |
---|
| 876 | |
---|
| 877 | uint32 factionid = atoi(pfactionid); |
---|
| 878 | uint32 flag; |
---|
| 879 | |
---|
| 880 | char *pflag = strtok(NULL, " "); |
---|
| 881 | if (!pflag) |
---|
| 882 | flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); |
---|
| 883 | else |
---|
| 884 | flag = atoi(pflag); |
---|
| 885 | |
---|
| 886 | char* pnpcflag = strtok(NULL, " "); |
---|
| 887 | |
---|
| 888 | uint32 npcflag; |
---|
| 889 | if(!pnpcflag) |
---|
| 890 | npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); |
---|
| 891 | else |
---|
| 892 | npcflag = atoi(pnpcflag); |
---|
| 893 | |
---|
| 894 | char* pdyflag = strtok(NULL, " "); |
---|
| 895 | |
---|
| 896 | uint32 dyflag; |
---|
| 897 | if(!pdyflag) |
---|
| 898 | dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); |
---|
| 899 | else |
---|
| 900 | dyflag = atoi(pdyflag); |
---|
| 901 | |
---|
| 902 | if(!sFactionTemplateStore.LookupEntry(factionid)) |
---|
| 903 | { |
---|
| 904 | PSendSysMessage(LANG_WRONG_FACTION, factionid); |
---|
| 905 | SetSentErrorMessage(true); |
---|
| 906 | return false; |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); |
---|
| 910 | |
---|
| 911 | //sprintf((char*)buf,"%s changed your Faction to %i.", m_session->GetPlayer()->GetName(), factionid); |
---|
| 912 | //FillSystemMessageData(&data, m_session, buf); |
---|
| 913 | |
---|
| 914 | //chr->GetSession()->SendPacket(&data); |
---|
| 915 | |
---|
| 916 | chr->setFaction(factionid); |
---|
| 917 | chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag); |
---|
| 918 | chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag); |
---|
| 919 | chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag); |
---|
| 920 | |
---|
| 921 | return true; |
---|
| 922 | } |
---|
| 923 | |
---|
| 924 | //Edit Player Spell |
---|
| 925 | bool ChatHandler::HandleModifySpellCommand(const char* args) |
---|
| 926 | { |
---|
| 927 | if(!*args) return false; |
---|
| 928 | char* pspellflatid = strtok((char*)args, " "); |
---|
| 929 | if (!pspellflatid) |
---|
| 930 | return false; |
---|
| 931 | |
---|
| 932 | char* pop = strtok(NULL, " "); |
---|
| 933 | if (!pop) |
---|
| 934 | return false; |
---|
| 935 | |
---|
| 936 | char* pval = strtok(NULL, " "); |
---|
| 937 | if (!pval) |
---|
| 938 | return false; |
---|
| 939 | |
---|
| 940 | uint16 mark; |
---|
| 941 | |
---|
| 942 | char* pmark = strtok(NULL, " "); |
---|
| 943 | |
---|
| 944 | uint8 spellflatid = atoi(pspellflatid); |
---|
| 945 | uint8 op = atoi(pop); |
---|
| 946 | uint16 val = atoi(pval); |
---|
| 947 | if(!pmark) |
---|
| 948 | mark = 65535; |
---|
| 949 | else |
---|
| 950 | mark = atoi(pmark); |
---|
| 951 | |
---|
| 952 | Player *chr = getSelectedPlayer(); |
---|
| 953 | if (chr == NULL) |
---|
| 954 | { |
---|
| 955 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 956 | SetSentErrorMessage(true); |
---|
| 957 | return false; |
---|
| 958 | } |
---|
| 959 | |
---|
| 960 | PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, chr->GetName()); |
---|
| 961 | if(chr != m_session->GetPlayer()) |
---|
| 962 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, m_session->GetPlayer()->GetName(), spellflatid, val, mark); |
---|
| 963 | |
---|
| 964 | WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2)); |
---|
| 965 | data << uint8(spellflatid); |
---|
| 966 | data << uint8(op); |
---|
| 967 | data << uint16(val); |
---|
| 968 | data << uint16(mark); |
---|
| 969 | chr->GetSession()->SendPacket(&data); |
---|
| 970 | |
---|
| 971 | return true; |
---|
| 972 | } |
---|
| 973 | |
---|
| 974 | //Edit Player TP |
---|
| 975 | bool ChatHandler::HandleModifyTalentCommand (const char* args) |
---|
| 976 | { |
---|
| 977 | if (!*args) |
---|
| 978 | return false; |
---|
| 979 | |
---|
| 980 | int tp = atoi((char*)args); |
---|
| 981 | if (tp>0) |
---|
| 982 | { |
---|
| 983 | Player* player = getSelectedPlayer(); |
---|
| 984 | if(!player) |
---|
| 985 | { |
---|
| 986 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 987 | SetSentErrorMessage(true); |
---|
| 988 | return false; |
---|
| 989 | } |
---|
| 990 | player->SetFreeTalentPoints(tp); |
---|
| 991 | return true; |
---|
| 992 | } |
---|
| 993 | return false; |
---|
| 994 | } |
---|
| 995 | |
---|
| 996 | //Enable On\OFF all taxi paths |
---|
| 997 | bool ChatHandler::HandleTaxiCheatCommand(const char* args) |
---|
| 998 | { |
---|
| 999 | if (!*args) |
---|
| 1000 | { |
---|
| 1001 | SendSysMessage(LANG_USE_BOL); |
---|
| 1002 | SetSentErrorMessage(true); |
---|
| 1003 | return false; |
---|
| 1004 | } |
---|
| 1005 | |
---|
| 1006 | std::string argstr = (char*)args; |
---|
| 1007 | |
---|
| 1008 | Player *chr = getSelectedPlayer(); |
---|
| 1009 | if (!chr) |
---|
| 1010 | { |
---|
| 1011 | chr=m_session->GetPlayer(); |
---|
| 1012 | } |
---|
| 1013 | |
---|
| 1014 | if (argstr == "on") |
---|
| 1015 | { |
---|
| 1016 | chr->SetTaxiCheater(true); |
---|
| 1017 | PSendSysMessage(LANG_YOU_GIVE_TAXIS, chr->GetName()); |
---|
| 1018 | |
---|
| 1019 | if(chr != m_session->GetPlayer()) |
---|
| 1020 | // to send localized data to target |
---|
[44] | 1021 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_TAXIS_ADDED), m_session->GetPlayer()->GetName()); |
---|
[37] | 1022 | return true; |
---|
| 1023 | } |
---|
| 1024 | |
---|
| 1025 | if (argstr == "off") |
---|
| 1026 | { |
---|
| 1027 | chr->SetTaxiCheater(false); |
---|
| 1028 | PSendSysMessage(LANG_YOU_REMOVE_TAXIS, chr->GetName()); |
---|
| 1029 | |
---|
| 1030 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1031 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_TAXIS_REMOVED), m_session->GetPlayer()->GetName()); |
---|
[37] | 1032 | |
---|
| 1033 | return true; |
---|
| 1034 | } |
---|
| 1035 | |
---|
| 1036 | SendSysMessage(LANG_USE_BOL); |
---|
| 1037 | SetSentErrorMessage(true); |
---|
| 1038 | return false; |
---|
| 1039 | } |
---|
| 1040 | |
---|
| 1041 | //Edit Player Aspeed |
---|
| 1042 | bool ChatHandler::HandleModifyASpeedCommand(const char* args) |
---|
| 1043 | { |
---|
| 1044 | if (!*args) |
---|
| 1045 | return false; |
---|
| 1046 | |
---|
| 1047 | float ASpeed = (float)atof((char*)args); |
---|
| 1048 | |
---|
| 1049 | if (ASpeed > 10 || ASpeed < 0.1) |
---|
| 1050 | { |
---|
| 1051 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 1052 | SetSentErrorMessage(true); |
---|
| 1053 | return false; |
---|
| 1054 | } |
---|
| 1055 | |
---|
| 1056 | Player *chr = getSelectedPlayer(); |
---|
| 1057 | if (chr == NULL) |
---|
| 1058 | { |
---|
| 1059 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1060 | SetSentErrorMessage(true); |
---|
| 1061 | return false; |
---|
| 1062 | } |
---|
| 1063 | |
---|
| 1064 | if(chr->isInFlight()) |
---|
| 1065 | { |
---|
| 1066 | PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); |
---|
| 1067 | SetSentErrorMessage(true); |
---|
| 1068 | return false; |
---|
| 1069 | } |
---|
| 1070 | |
---|
| 1071 | PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName()); |
---|
| 1072 | |
---|
| 1073 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1074 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_ASPEED_CHANGED), m_session->GetPlayer()->GetName(), ASpeed); |
---|
[37] | 1075 | |
---|
| 1076 | chr->SetSpeed(MOVE_WALK, ASpeed,true); |
---|
| 1077 | chr->SetSpeed(MOVE_RUN, ASpeed,true); |
---|
| 1078 | chr->SetSpeed(MOVE_SWIM, ASpeed,true); |
---|
| 1079 | //chr->SetSpeed(MOVE_TURN, ASpeed,true); |
---|
| 1080 | chr->SetSpeed(MOVE_FLY, ASpeed,true); |
---|
| 1081 | return true; |
---|
| 1082 | } |
---|
| 1083 | |
---|
| 1084 | //Edit Player Speed |
---|
| 1085 | bool ChatHandler::HandleModifySpeedCommand(const char* args) |
---|
| 1086 | { |
---|
| 1087 | if (!*args) |
---|
| 1088 | return false; |
---|
| 1089 | |
---|
| 1090 | float Speed = (float)atof((char*)args); |
---|
| 1091 | |
---|
| 1092 | if (Speed > 10 || Speed < 0.1) |
---|
| 1093 | { |
---|
| 1094 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 1095 | SetSentErrorMessage(true); |
---|
| 1096 | return false; |
---|
| 1097 | } |
---|
| 1098 | |
---|
| 1099 | Player *chr = getSelectedPlayer(); |
---|
| 1100 | if (chr == NULL) |
---|
| 1101 | { |
---|
| 1102 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1103 | SetSentErrorMessage(true); |
---|
| 1104 | return false; |
---|
| 1105 | } |
---|
| 1106 | |
---|
| 1107 | if(chr->isInFlight()) |
---|
| 1108 | { |
---|
| 1109 | PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); |
---|
| 1110 | SetSentErrorMessage(true); |
---|
| 1111 | return false; |
---|
| 1112 | } |
---|
| 1113 | |
---|
| 1114 | PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chr->GetName()); |
---|
| 1115 | |
---|
| 1116 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1117 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_SPEED_CHANGED), m_session->GetPlayer()->GetName(), Speed); |
---|
[37] | 1118 | |
---|
| 1119 | chr->SetSpeed(MOVE_RUN,Speed,true); |
---|
| 1120 | |
---|
| 1121 | return true; |
---|
| 1122 | } |
---|
| 1123 | |
---|
| 1124 | //Edit Player Swim Speed |
---|
| 1125 | bool ChatHandler::HandleModifySwimCommand(const char* args) |
---|
| 1126 | { |
---|
| 1127 | if (!*args) |
---|
| 1128 | return false; |
---|
| 1129 | |
---|
| 1130 | float Swim = (float)atof((char*)args); |
---|
| 1131 | |
---|
| 1132 | if (Swim > 10.0f || Swim < 0.01f) |
---|
| 1133 | { |
---|
| 1134 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 1135 | SetSentErrorMessage(true); |
---|
| 1136 | return false; |
---|
| 1137 | } |
---|
| 1138 | |
---|
| 1139 | Player *chr = getSelectedPlayer(); |
---|
| 1140 | if (chr == NULL) |
---|
| 1141 | { |
---|
| 1142 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1143 | SetSentErrorMessage(true); |
---|
| 1144 | return false; |
---|
| 1145 | } |
---|
| 1146 | |
---|
| 1147 | if(chr->isInFlight()) |
---|
| 1148 | { |
---|
| 1149 | PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); |
---|
| 1150 | SetSentErrorMessage(true); |
---|
| 1151 | return false; |
---|
| 1152 | } |
---|
| 1153 | |
---|
| 1154 | PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chr->GetName()); |
---|
| 1155 | |
---|
| 1156 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1157 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_SWIM_SPEED_CHANGED), m_session->GetPlayer()->GetName(), Swim); |
---|
[37] | 1158 | |
---|
| 1159 | chr->SetSpeed(MOVE_SWIM,Swim,true); |
---|
| 1160 | |
---|
| 1161 | return true; |
---|
| 1162 | } |
---|
| 1163 | |
---|
| 1164 | //Edit Player Walk Speed |
---|
| 1165 | bool ChatHandler::HandleModifyBWalkCommand(const char* args) |
---|
| 1166 | { |
---|
| 1167 | if (!*args) |
---|
| 1168 | return false; |
---|
| 1169 | |
---|
| 1170 | float BSpeed = (float)atof((char*)args); |
---|
| 1171 | |
---|
| 1172 | if (BSpeed > 10.0f || BSpeed < 0.1f) |
---|
| 1173 | { |
---|
| 1174 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 1175 | SetSentErrorMessage(true); |
---|
| 1176 | return false; |
---|
| 1177 | } |
---|
| 1178 | |
---|
| 1179 | Player *chr = getSelectedPlayer(); |
---|
| 1180 | if (chr == NULL) |
---|
| 1181 | { |
---|
| 1182 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1183 | SetSentErrorMessage(true); |
---|
| 1184 | return false; |
---|
| 1185 | } |
---|
| 1186 | |
---|
| 1187 | if(chr->isInFlight()) |
---|
| 1188 | { |
---|
| 1189 | PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); |
---|
| 1190 | SetSentErrorMessage(true); |
---|
| 1191 | return false; |
---|
| 1192 | } |
---|
| 1193 | |
---|
| 1194 | PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chr->GetName()); |
---|
| 1195 | |
---|
| 1196 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1197 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_BACK_SPEED_CHANGED), m_session->GetPlayer()->GetName(), BSpeed); |
---|
[37] | 1198 | |
---|
| 1199 | chr->SetSpeed(MOVE_WALKBACK,BSpeed,true); |
---|
| 1200 | |
---|
| 1201 | return true; |
---|
| 1202 | } |
---|
| 1203 | |
---|
| 1204 | //Edit Player Fly |
---|
| 1205 | bool ChatHandler::HandleModifyFlyCommand(const char* args) |
---|
| 1206 | { |
---|
| 1207 | if (!*args) |
---|
| 1208 | return false; |
---|
| 1209 | |
---|
| 1210 | float FSpeed = (float)atof((char*)args); |
---|
| 1211 | |
---|
| 1212 | if (FSpeed > 10.0f || FSpeed < 0.1f) |
---|
| 1213 | { |
---|
| 1214 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 1215 | SetSentErrorMessage(true); |
---|
| 1216 | return false; |
---|
| 1217 | } |
---|
| 1218 | |
---|
| 1219 | Player *chr = getSelectedPlayer(); |
---|
| 1220 | if (chr == NULL) |
---|
| 1221 | { |
---|
| 1222 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1223 | SetSentErrorMessage(true); |
---|
| 1224 | return false; |
---|
| 1225 | } |
---|
| 1226 | |
---|
| 1227 | PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, chr->GetName()); |
---|
| 1228 | |
---|
| 1229 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1230 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_FLY_SPEED_CHANGED), m_session->GetPlayer()->GetName(), FSpeed); |
---|
[37] | 1231 | |
---|
| 1232 | chr->SetSpeed(MOVE_FLY,FSpeed,true); |
---|
| 1233 | |
---|
| 1234 | return true; |
---|
| 1235 | } |
---|
| 1236 | |
---|
| 1237 | //Edit Player Scale |
---|
| 1238 | bool ChatHandler::HandleModifyScaleCommand(const char* args) |
---|
| 1239 | { |
---|
| 1240 | if (!*args) |
---|
| 1241 | return false; |
---|
| 1242 | |
---|
| 1243 | float Scale = (float)atof((char*)args); |
---|
[72] | 1244 | if (Scale > 10.0f || Scale <= 0.0f) |
---|
[37] | 1245 | { |
---|
| 1246 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 1247 | SetSentErrorMessage(true); |
---|
| 1248 | return false; |
---|
| 1249 | } |
---|
| 1250 | |
---|
| 1251 | Player *chr = getSelectedPlayer(); |
---|
| 1252 | if (chr == NULL) |
---|
| 1253 | { |
---|
| 1254 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1255 | SetSentErrorMessage(true); |
---|
| 1256 | return false; |
---|
| 1257 | } |
---|
| 1258 | |
---|
| 1259 | PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, chr->GetName()); |
---|
| 1260 | |
---|
| 1261 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1262 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_SIZE_CHANGED), m_session->GetPlayer()->GetName(), Scale); |
---|
[37] | 1263 | |
---|
| 1264 | chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale); |
---|
| 1265 | |
---|
| 1266 | return true; |
---|
| 1267 | } |
---|
| 1268 | |
---|
| 1269 | //Enable Player mount |
---|
| 1270 | bool ChatHandler::HandleModifyMountCommand(const char* args) |
---|
| 1271 | { |
---|
| 1272 | if(!*args) |
---|
| 1273 | return false; |
---|
| 1274 | |
---|
| 1275 | uint16 mId = 1147; |
---|
| 1276 | float speed = (float)15; |
---|
| 1277 | uint32 num = 0; |
---|
| 1278 | |
---|
| 1279 | num = atoi((char*)args); |
---|
| 1280 | switch(num) |
---|
| 1281 | { |
---|
| 1282 | case 1: |
---|
| 1283 | mId=14340; |
---|
| 1284 | break; |
---|
| 1285 | case 2: |
---|
| 1286 | mId=4806; |
---|
| 1287 | break; |
---|
| 1288 | case 3: |
---|
| 1289 | mId=6471; |
---|
| 1290 | break; |
---|
| 1291 | case 4: |
---|
| 1292 | mId=12345; |
---|
| 1293 | break; |
---|
| 1294 | case 5: |
---|
| 1295 | mId=6472; |
---|
| 1296 | break; |
---|
| 1297 | case 6: |
---|
| 1298 | mId=6473; |
---|
| 1299 | break; |
---|
| 1300 | case 7: |
---|
| 1301 | mId=10670; |
---|
| 1302 | break; |
---|
| 1303 | case 8: |
---|
| 1304 | mId=10719; |
---|
| 1305 | break; |
---|
| 1306 | case 9: |
---|
| 1307 | mId=10671; |
---|
| 1308 | break; |
---|
| 1309 | case 10: |
---|
| 1310 | mId=10672; |
---|
| 1311 | break; |
---|
| 1312 | case 11: |
---|
| 1313 | mId=10720; |
---|
| 1314 | break; |
---|
| 1315 | case 12: |
---|
| 1316 | mId=14349; |
---|
| 1317 | break; |
---|
| 1318 | case 13: |
---|
| 1319 | mId=11641; |
---|
| 1320 | break; |
---|
| 1321 | case 14: |
---|
| 1322 | mId=12244; |
---|
| 1323 | break; |
---|
| 1324 | case 15: |
---|
| 1325 | mId=12242; |
---|
| 1326 | break; |
---|
| 1327 | case 16: |
---|
| 1328 | mId=14578; |
---|
| 1329 | break; |
---|
| 1330 | case 17: |
---|
| 1331 | mId=14579; |
---|
| 1332 | break; |
---|
| 1333 | case 18: |
---|
| 1334 | mId=14349; |
---|
| 1335 | break; |
---|
| 1336 | case 19: |
---|
| 1337 | mId=12245; |
---|
| 1338 | break; |
---|
| 1339 | case 20: |
---|
| 1340 | mId=14335; |
---|
| 1341 | break; |
---|
| 1342 | case 21: |
---|
| 1343 | mId=207; |
---|
| 1344 | break; |
---|
| 1345 | case 22: |
---|
| 1346 | mId=2328; |
---|
| 1347 | break; |
---|
| 1348 | case 23: |
---|
| 1349 | mId=2327; |
---|
| 1350 | break; |
---|
| 1351 | case 24: |
---|
| 1352 | mId=2326; |
---|
| 1353 | break; |
---|
| 1354 | case 25: |
---|
| 1355 | mId=14573; |
---|
| 1356 | break; |
---|
| 1357 | case 26: |
---|
| 1358 | mId=14574; |
---|
| 1359 | break; |
---|
| 1360 | case 27: |
---|
| 1361 | mId=14575; |
---|
| 1362 | break; |
---|
| 1363 | case 28: |
---|
| 1364 | mId=604; |
---|
| 1365 | break; |
---|
| 1366 | case 29: |
---|
| 1367 | mId=1166; |
---|
| 1368 | break; |
---|
| 1369 | case 30: |
---|
| 1370 | mId=2402; |
---|
| 1371 | break; |
---|
| 1372 | case 31: |
---|
| 1373 | mId=2410; |
---|
| 1374 | break; |
---|
| 1375 | case 32: |
---|
| 1376 | mId=2409; |
---|
| 1377 | break; |
---|
| 1378 | case 33: |
---|
| 1379 | mId=2408; |
---|
| 1380 | break; |
---|
| 1381 | case 34: |
---|
| 1382 | mId=2405; |
---|
| 1383 | break; |
---|
| 1384 | case 35: |
---|
| 1385 | mId=14337; |
---|
| 1386 | break; |
---|
| 1387 | case 36: |
---|
| 1388 | mId=6569; |
---|
| 1389 | break; |
---|
| 1390 | case 37: |
---|
| 1391 | mId=10661; |
---|
| 1392 | break; |
---|
| 1393 | case 38: |
---|
| 1394 | mId=10666; |
---|
| 1395 | break; |
---|
| 1396 | case 39: |
---|
| 1397 | mId=9473; |
---|
| 1398 | break; |
---|
| 1399 | case 40: |
---|
| 1400 | mId=9476; |
---|
| 1401 | break; |
---|
| 1402 | case 41: |
---|
| 1403 | mId=9474; |
---|
| 1404 | break; |
---|
| 1405 | case 42: |
---|
| 1406 | mId=14374; |
---|
| 1407 | break; |
---|
| 1408 | case 43: |
---|
| 1409 | mId=14376; |
---|
| 1410 | break; |
---|
| 1411 | case 44: |
---|
| 1412 | mId=14377; |
---|
| 1413 | break; |
---|
| 1414 | case 45: |
---|
| 1415 | mId=2404; |
---|
| 1416 | break; |
---|
| 1417 | case 46: |
---|
| 1418 | mId=2784; |
---|
| 1419 | break; |
---|
| 1420 | case 47: |
---|
| 1421 | mId=2787; |
---|
| 1422 | break; |
---|
| 1423 | case 48: |
---|
| 1424 | mId=2785; |
---|
| 1425 | break; |
---|
| 1426 | case 49: |
---|
| 1427 | mId=2736; |
---|
| 1428 | break; |
---|
| 1429 | case 50: |
---|
| 1430 | mId=2786; |
---|
| 1431 | break; |
---|
| 1432 | case 51: |
---|
| 1433 | mId=14347; |
---|
| 1434 | break; |
---|
| 1435 | case 52: |
---|
| 1436 | mId=14346; |
---|
| 1437 | break; |
---|
| 1438 | case 53: |
---|
| 1439 | mId=14576; |
---|
| 1440 | break; |
---|
| 1441 | case 54: |
---|
| 1442 | mId=9695; |
---|
| 1443 | break; |
---|
| 1444 | case 55: |
---|
| 1445 | mId=9991; |
---|
| 1446 | break; |
---|
| 1447 | case 56: |
---|
| 1448 | mId=6448; |
---|
| 1449 | break; |
---|
| 1450 | case 57: |
---|
| 1451 | mId=6444; |
---|
| 1452 | break; |
---|
| 1453 | case 58: |
---|
| 1454 | mId=6080; |
---|
| 1455 | break; |
---|
| 1456 | case 59: |
---|
| 1457 | mId=6447; |
---|
| 1458 | break; |
---|
| 1459 | case 60: |
---|
| 1460 | mId=4805; |
---|
| 1461 | break; |
---|
| 1462 | case 61: |
---|
| 1463 | mId=9714; |
---|
| 1464 | break; |
---|
| 1465 | case 62: |
---|
| 1466 | mId=6448; |
---|
| 1467 | break; |
---|
| 1468 | case 63: |
---|
| 1469 | mId=6442; |
---|
| 1470 | break; |
---|
| 1471 | case 64: |
---|
| 1472 | mId=14632; |
---|
| 1473 | break; |
---|
| 1474 | case 65: |
---|
| 1475 | mId=14332; |
---|
| 1476 | break; |
---|
| 1477 | case 66: |
---|
| 1478 | mId=14331; |
---|
| 1479 | break; |
---|
| 1480 | case 67: |
---|
| 1481 | mId=8469; |
---|
| 1482 | break; |
---|
| 1483 | case 68: |
---|
| 1484 | mId=2830; |
---|
| 1485 | break; |
---|
| 1486 | case 69: |
---|
| 1487 | mId=2346; |
---|
| 1488 | break; |
---|
| 1489 | default: |
---|
| 1490 | SendSysMessage(LANG_NO_MOUNT); |
---|
| 1491 | SetSentErrorMessage(true); |
---|
| 1492 | return false; |
---|
| 1493 | } |
---|
| 1494 | |
---|
| 1495 | Player *chr = getSelectedPlayer(); |
---|
| 1496 | if (chr == NULL) |
---|
| 1497 | { |
---|
| 1498 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1499 | SetSentErrorMessage(true); |
---|
| 1500 | return false; |
---|
| 1501 | } |
---|
| 1502 | |
---|
| 1503 | PSendSysMessage(LANG_YOU_GIVE_MOUNT, chr->GetName()); |
---|
| 1504 | |
---|
| 1505 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1506 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_MOUNT_GIVED), m_session->GetPlayer()->GetName()); |
---|
[37] | 1507 | |
---|
| 1508 | chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 ); |
---|
| 1509 | chr->Mount(mId); |
---|
| 1510 | |
---|
| 1511 | WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) ); |
---|
| 1512 | data.append(chr->GetPackGUID()); |
---|
| 1513 | data << (uint32)0; |
---|
| 1514 | data << (uint8)0; //new 2.1.0 |
---|
| 1515 | data << float(speed); |
---|
| 1516 | chr->SendMessageToSet( &data, true ); |
---|
| 1517 | |
---|
| 1518 | data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) ); |
---|
| 1519 | data.append(chr->GetPackGUID()); |
---|
| 1520 | data << (uint32)0; |
---|
| 1521 | data << float(speed); |
---|
| 1522 | chr->SendMessageToSet( &data, true ); |
---|
| 1523 | |
---|
| 1524 | return true; |
---|
| 1525 | } |
---|
| 1526 | |
---|
| 1527 | //Edit Player money |
---|
| 1528 | bool ChatHandler::HandleModifyMoneyCommand(const char* args) |
---|
| 1529 | { |
---|
| 1530 | if (!*args) |
---|
| 1531 | return false; |
---|
| 1532 | |
---|
| 1533 | Player *chr = getSelectedPlayer(); |
---|
| 1534 | if (chr == NULL) |
---|
| 1535 | { |
---|
| 1536 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1537 | SetSentErrorMessage(true); |
---|
| 1538 | return false; |
---|
| 1539 | } |
---|
| 1540 | |
---|
| 1541 | int32 addmoney = atoi((char*)args); |
---|
| 1542 | |
---|
| 1543 | uint32 moneyuser = chr->GetMoney(); |
---|
| 1544 | |
---|
| 1545 | if(addmoney < 0) |
---|
| 1546 | { |
---|
| 1547 | int32 newmoney = moneyuser + addmoney; |
---|
| 1548 | |
---|
[44] | 1549 | sLog.outDetail(GetTrinityString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); |
---|
[37] | 1550 | if(newmoney <= 0 ) |
---|
| 1551 | { |
---|
| 1552 | PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName()); |
---|
| 1553 | |
---|
| 1554 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1555 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_ALL_MONEY_GONE), m_session->GetPlayer()->GetName()); |
---|
[37] | 1556 | |
---|
| 1557 | chr->SetMoney(0); |
---|
| 1558 | } |
---|
| 1559 | else |
---|
| 1560 | { |
---|
| 1561 | PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), chr->GetName()); |
---|
| 1562 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1563 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_MONEY_TAKEN), m_session->GetPlayer()->GetName(), abs(addmoney)); |
---|
[37] | 1564 | chr->SetMoney( newmoney ); |
---|
| 1565 | } |
---|
| 1566 | } |
---|
| 1567 | else |
---|
| 1568 | { |
---|
| 1569 | PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, chr->GetName()); |
---|
| 1570 | if(chr != m_session->GetPlayer()) |
---|
[44] | 1571 | ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetTrinityString(LANG_YOURS_MONEY_GIVEN), m_session->GetPlayer()->GetName(), addmoney); |
---|
[37] | 1572 | chr->ModifyMoney( addmoney ); |
---|
| 1573 | } |
---|
| 1574 | |
---|
[44] | 1575 | sLog.outDetail(GetTrinityString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() ); |
---|
[37] | 1576 | |
---|
| 1577 | return true; |
---|
| 1578 | } |
---|
| 1579 | |
---|
| 1580 | //Edit Player field |
---|
| 1581 | bool ChatHandler::HandleModifyBitCommand(const char* args) |
---|
| 1582 | { |
---|
| 1583 | if( !*args ) |
---|
| 1584 | return false; |
---|
| 1585 | |
---|
| 1586 | Player *chr = getSelectedPlayer(); |
---|
| 1587 | if (chr == NULL) |
---|
| 1588 | { |
---|
| 1589 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 1590 | SetSentErrorMessage(true); |
---|
| 1591 | return false; |
---|
| 1592 | } |
---|
| 1593 | |
---|
| 1594 | char* pField = strtok((char*)args, " "); |
---|
| 1595 | if (!pField) |
---|
| 1596 | return false; |
---|
| 1597 | |
---|
| 1598 | char* pBit = strtok(NULL, " "); |
---|
| 1599 | if (!pBit) |
---|
| 1600 | return false; |
---|
| 1601 | |
---|
| 1602 | uint16 field = atoi(pField); |
---|
| 1603 | uint32 bit = atoi(pBit); |
---|
| 1604 | |
---|
| 1605 | if (field < 1 || field >= PLAYER_END) |
---|
| 1606 | { |
---|
| 1607 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 1608 | SetSentErrorMessage(true); |
---|
| 1609 | return false; |
---|
| 1610 | } |
---|
| 1611 | |
---|
| 1612 | if (bit < 1 || bit > 32) |
---|
| 1613 | { |
---|
| 1614 | SendSysMessage(LANG_BAD_VALUE); |
---|
| 1615 | SetSentErrorMessage(true); |
---|
| 1616 | return false; |
---|
| 1617 | } |
---|
| 1618 | |
---|
| 1619 | if ( chr->HasFlag( field, (1<<(bit-1)) ) ) |
---|
| 1620 | { |
---|
| 1621 | chr->RemoveFlag( field, (1<<(bit-1)) ); |
---|
| 1622 | PSendSysMessage(LANG_REMOVE_BIT, bit, field); |
---|
| 1623 | } |
---|
| 1624 | else |
---|
| 1625 | { |
---|
| 1626 | chr->SetFlag( field, (1<<(bit-1)) ); |
---|
| 1627 | PSendSysMessage(LANG_SET_BIT, bit, field); |
---|
| 1628 | } |
---|
| 1629 | |
---|
| 1630 | return true; |
---|
| 1631 | } |
---|
| 1632 | |
---|
| 1633 | bool ChatHandler::HandleModifyHonorCommand (const char* args) |
---|
| 1634 | { |
---|
| 1635 | if (!*args) |
---|
| 1636 | return false; |
---|
| 1637 | |
---|
| 1638 | Player *target = getSelectedPlayer(); |
---|
| 1639 | if(!target) |
---|
| 1640 | { |
---|
| 1641 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 1642 | SetSentErrorMessage(true); |
---|
| 1643 | return false; |
---|
| 1644 | } |
---|
| 1645 | |
---|
| 1646 | int32 amount = (uint32)atoi(args); |
---|
| 1647 | |
---|
| 1648 | target->ModifyHonorPoints(amount); |
---|
| 1649 | |
---|
| 1650 | PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, target->GetName(), target->GetHonorPoints()); |
---|
| 1651 | |
---|
| 1652 | return true; |
---|
| 1653 | } |
---|
| 1654 | |
---|
| 1655 | bool ChatHandler::HandleTeleCommand(const char * args) |
---|
| 1656 | { |
---|
| 1657 | if(!*args) |
---|
| 1658 | return false; |
---|
| 1659 | |
---|
| 1660 | Player* _player = m_session->GetPlayer(); |
---|
| 1661 | |
---|
| 1662 | // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r |
---|
| 1663 | GameTele const* tele = extractGameTeleFromLink((char*)args); |
---|
| 1664 | if (!tele) |
---|
| 1665 | { |
---|
| 1666 | SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); |
---|
| 1667 | SetSentErrorMessage(true); |
---|
| 1668 | return false; |
---|
| 1669 | } |
---|
| 1670 | |
---|
| 1671 | MapEntry const * me = sMapStore.LookupEntry(tele->mapId); |
---|
| 1672 | if(!me || me->IsBattleGroundOrArena()) |
---|
| 1673 | { |
---|
| 1674 | SendSysMessage(LANG_CANNOT_TELE_TO_BG); |
---|
| 1675 | SetSentErrorMessage(true); |
---|
| 1676 | return false; |
---|
| 1677 | } |
---|
| 1678 | |
---|
| 1679 | // stop flight if need |
---|
| 1680 | if(_player->isInFlight()) |
---|
| 1681 | { |
---|
| 1682 | _player->GetMotionMaster()->MovementExpired(); |
---|
| 1683 | _player->m_taxi.ClearTaxiDestinations(); |
---|
| 1684 | } |
---|
| 1685 | // save only in non-flight case |
---|
| 1686 | else |
---|
| 1687 | _player->SaveRecallPosition(); |
---|
| 1688 | |
---|
| 1689 | _player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); |
---|
| 1690 | return true; |
---|
| 1691 | } |
---|
| 1692 | |
---|
| 1693 | bool ChatHandler::HandleLookupAreaCommand(const char* args) |
---|
| 1694 | { |
---|
| 1695 | if(!*args) |
---|
| 1696 | return false; |
---|
| 1697 | |
---|
| 1698 | std::string namepart = args; |
---|
| 1699 | std::wstring wnamepart; |
---|
| 1700 | |
---|
| 1701 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 1702 | return false; |
---|
| 1703 | |
---|
| 1704 | uint32 counter = 0; // Counter for figure out that we found smth. |
---|
| 1705 | |
---|
| 1706 | // converting string that we try to find to lower case |
---|
| 1707 | wstrToLower( wnamepart ); |
---|
| 1708 | |
---|
| 1709 | // Search in AreaTable.dbc |
---|
| 1710 | for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows(); ++areaflag) |
---|
| 1711 | { |
---|
| 1712 | AreaTableEntry const *areaEntry = sAreaStore.LookupEntry(areaflag); |
---|
| 1713 | if(areaEntry) |
---|
| 1714 | { |
---|
| 1715 | int loc = m_session->GetSessionDbcLocale(); |
---|
| 1716 | std::string name = areaEntry->area_name[loc]; |
---|
| 1717 | if(name.empty()) |
---|
| 1718 | continue; |
---|
| 1719 | |
---|
| 1720 | if(!Utf8FitTo(name, wnamepart)) |
---|
| 1721 | { |
---|
| 1722 | loc = 0; |
---|
| 1723 | for(; loc < MAX_LOCALE; ++loc) |
---|
| 1724 | { |
---|
| 1725 | if(loc==m_session->GetSessionDbcLocale()) |
---|
| 1726 | continue; |
---|
| 1727 | |
---|
| 1728 | name = areaEntry->area_name[loc]; |
---|
| 1729 | if(name.empty()) |
---|
| 1730 | continue; |
---|
| 1731 | |
---|
| 1732 | if (Utf8FitTo(name, wnamepart)) |
---|
| 1733 | break; |
---|
| 1734 | } |
---|
| 1735 | } |
---|
| 1736 | |
---|
| 1737 | if(loc < MAX_LOCALE) |
---|
| 1738 | { |
---|
| 1739 | // send area in "id - [name]" format |
---|
| 1740 | std::ostringstream ss; |
---|
| 1741 | ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r"; |
---|
| 1742 | |
---|
| 1743 | SendSysMessage(ss.str().c_str()); |
---|
| 1744 | |
---|
| 1745 | ++counter; |
---|
| 1746 | } |
---|
| 1747 | } |
---|
| 1748 | } |
---|
| 1749 | if (counter == 0) // if counter == 0 then we found nth |
---|
| 1750 | SendSysMessage(LANG_COMMAND_NOAREAFOUND); |
---|
| 1751 | return true; |
---|
| 1752 | } |
---|
| 1753 | |
---|
| 1754 | //Find tele in game_tele order by name |
---|
| 1755 | bool ChatHandler::HandleLookupTeleCommand(const char * args) |
---|
| 1756 | { |
---|
| 1757 | if(!*args) |
---|
| 1758 | { |
---|
| 1759 | SendSysMessage(LANG_COMMAND_TELE_PARAMETER); |
---|
| 1760 | SetSentErrorMessage(true); |
---|
| 1761 | return false; |
---|
| 1762 | } |
---|
| 1763 | char const* str = strtok((char*)args, " "); |
---|
| 1764 | if(!str) |
---|
| 1765 | return false; |
---|
| 1766 | |
---|
| 1767 | std::string namepart = str; |
---|
| 1768 | std::wstring wnamepart; |
---|
| 1769 | |
---|
| 1770 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
| 1771 | return false; |
---|
| 1772 | |
---|
| 1773 | // converting string that we try to find to lower case |
---|
| 1774 | wstrToLower( wnamepart ); |
---|
| 1775 | |
---|
| 1776 | GameTeleMap const & teleMap = objmgr.GetGameTeleMap(); |
---|
| 1777 | |
---|
| 1778 | std::ostringstream reply; |
---|
| 1779 | for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr) |
---|
| 1780 | { |
---|
| 1781 | GameTele const* tele = &itr->second; |
---|
| 1782 | |
---|
| 1783 | if(tele->wnameLow.find(wnamepart) == std::wstring::npos) |
---|
| 1784 | continue; |
---|
| 1785 | |
---|
| 1786 | reply << " |cffffffff|Htele:"; |
---|
| 1787 | reply << itr->first; |
---|
| 1788 | reply << "|h["; |
---|
| 1789 | reply << tele->name; |
---|
| 1790 | reply << "]|h|r\n"; |
---|
| 1791 | } |
---|
| 1792 | |
---|
| 1793 | if(reply.str().empty()) |
---|
| 1794 | SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); |
---|
| 1795 | else |
---|
| 1796 | PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str()); |
---|
| 1797 | |
---|
| 1798 | return true; |
---|
| 1799 | } |
---|
| 1800 | |
---|
| 1801 | //Enable\Dissable accept whispers (for GM) |
---|
| 1802 | bool ChatHandler::HandleWhispersCommand(const char* args) |
---|
| 1803 | { |
---|
| 1804 | if(!*args) |
---|
| 1805 | { |
---|
[44] | 1806 | PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF)); |
---|
[37] | 1807 | return true; |
---|
| 1808 | } |
---|
| 1809 | |
---|
| 1810 | std::string argstr = (char*)args; |
---|
| 1811 | // whisper on |
---|
| 1812 | if (argstr == "on") |
---|
| 1813 | { |
---|
| 1814 | m_session->GetPlayer()->SetAcceptWhispers(true); |
---|
| 1815 | SendSysMessage(LANG_COMMAND_WHISPERON); |
---|
| 1816 | return true; |
---|
| 1817 | } |
---|
| 1818 | |
---|
| 1819 | // whisper off |
---|
| 1820 | if (argstr == "off") |
---|
| 1821 | { |
---|
| 1822 | m_session->GetPlayer()->SetAcceptWhispers(false); |
---|
| 1823 | SendSysMessage(LANG_COMMAND_WHISPEROFF); |
---|
| 1824 | return true; |
---|
| 1825 | } |
---|
| 1826 | |
---|
| 1827 | SendSysMessage(LANG_USE_BOL); |
---|
| 1828 | SetSentErrorMessage(true); |
---|
| 1829 | return false; |
---|
| 1830 | } |
---|
| 1831 | |
---|
| 1832 | //Play sound |
---|
| 1833 | bool ChatHandler::HandlePlaySoundCommand(const char* args) |
---|
| 1834 | { |
---|
| 1835 | // USAGE: .debug playsound #soundid |
---|
| 1836 | // #soundid - ID decimal number from SoundEntries.dbc (1st column) |
---|
| 1837 | // this file have about 5000 sounds. |
---|
| 1838 | // In this realization only caller can hear this sound. |
---|
| 1839 | if( *args ) |
---|
| 1840 | { |
---|
| 1841 | uint32 dwSoundId = atoi((char*)args); |
---|
| 1842 | |
---|
| 1843 | if( !sSoundEntriesStore.LookupEntry(dwSoundId) ) |
---|
| 1844 | { |
---|
| 1845 | PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); |
---|
| 1846 | SetSentErrorMessage(true); |
---|
| 1847 | return false; |
---|
| 1848 | } |
---|
| 1849 | |
---|
| 1850 | WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8); |
---|
| 1851 | data << uint32(dwSoundId) << m_session->GetPlayer()->GetGUID(); |
---|
| 1852 | m_session->SendPacket(&data); |
---|
| 1853 | |
---|
| 1854 | PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); |
---|
| 1855 | return true; |
---|
| 1856 | } |
---|
| 1857 | |
---|
| 1858 | return false; |
---|
| 1859 | } |
---|
| 1860 | |
---|
| 1861 | //Save all players in the world |
---|
| 1862 | bool ChatHandler::HandleSaveAllCommand(const char* /*args*/) |
---|
| 1863 | { |
---|
| 1864 | ObjectAccessor::Instance().SaveAllPlayers(); |
---|
| 1865 | SendSysMessage(LANG_PLAYERS_SAVED); |
---|
| 1866 | return true; |
---|
| 1867 | } |
---|
| 1868 | |
---|
| 1869 | //Send mail by command |
---|
| 1870 | bool ChatHandler::HandleSendMailCommand(const char* args) |
---|
| 1871 | { |
---|
| 1872 | if(!*args) |
---|
| 1873 | return false; |
---|
| 1874 | |
---|
| 1875 | // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12] |
---|
| 1876 | |
---|
| 1877 | char* pName = strtok((char*)args, " "); |
---|
| 1878 | if(!pName) |
---|
| 1879 | return false; |
---|
| 1880 | |
---|
| 1881 | char* tail1 = strtok(NULL, ""); |
---|
| 1882 | if(!tail1) |
---|
| 1883 | return false; |
---|
| 1884 | |
---|
| 1885 | char* msgSubject; |
---|
| 1886 | if(*tail1=='"') |
---|
| 1887 | msgSubject = strtok(tail1+1, "\""); |
---|
| 1888 | else |
---|
| 1889 | { |
---|
| 1890 | char* space = strtok(tail1, "\""); |
---|
| 1891 | if(!space) |
---|
| 1892 | return false; |
---|
| 1893 | msgSubject = strtok(NULL, "\""); |
---|
| 1894 | } |
---|
| 1895 | |
---|
| 1896 | if (!msgSubject) |
---|
| 1897 | return false; |
---|
| 1898 | |
---|
| 1899 | char* tail2 = strtok(NULL, ""); |
---|
| 1900 | if(!tail2) |
---|
| 1901 | return false; |
---|
| 1902 | |
---|
| 1903 | char* msgText; |
---|
| 1904 | if(*tail2=='"') |
---|
| 1905 | msgText = strtok(tail2+1, "\""); |
---|
| 1906 | else |
---|
| 1907 | { |
---|
| 1908 | char* space = strtok(tail2, "\""); |
---|
| 1909 | if(!space) |
---|
| 1910 | return false; |
---|
| 1911 | msgText = strtok(NULL, "\""); |
---|
| 1912 | } |
---|
| 1913 | |
---|
| 1914 | if (!msgText) |
---|
| 1915 | return false; |
---|
| 1916 | |
---|
| 1917 | // pName, msgSubject, msgText isn't NUL after prev. check |
---|
| 1918 | std::string name = pName; |
---|
| 1919 | std::string subject = msgSubject; |
---|
| 1920 | std::string text = msgText; |
---|
| 1921 | |
---|
| 1922 | // extract items |
---|
| 1923 | typedef std::pair<uint32,uint32> ItemPair; |
---|
| 1924 | typedef std::list< ItemPair > ItemPairs; |
---|
| 1925 | ItemPairs items; |
---|
| 1926 | |
---|
| 1927 | // get all tail string |
---|
| 1928 | char* tail = strtok(NULL, ""); |
---|
| 1929 | |
---|
| 1930 | // get from tail next item str |
---|
| 1931 | while(char* itemStr = strtok(tail, " ")) |
---|
| 1932 | { |
---|
| 1933 | // and get new tail |
---|
| 1934 | tail = strtok(NULL, ""); |
---|
| 1935 | |
---|
| 1936 | // parse item str |
---|
| 1937 | char* itemIdStr = strtok(itemStr, ":"); |
---|
| 1938 | char* itemCountStr = strtok(NULL, " "); |
---|
| 1939 | |
---|
| 1940 | uint32 item_id = atoi(itemIdStr); |
---|
| 1941 | if(!item_id) |
---|
| 1942 | return false; |
---|
| 1943 | |
---|
| 1944 | ItemPrototype const* item_proto = objmgr.GetItemPrototype(item_id); |
---|
| 1945 | if(!item_proto) |
---|
| 1946 | { |
---|
| 1947 | PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); |
---|
| 1948 | SetSentErrorMessage(true); |
---|
| 1949 | return false; |
---|
| 1950 | } |
---|
| 1951 | |
---|
| 1952 | uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1; |
---|
| 1953 | if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount) |
---|
| 1954 | { |
---|
| 1955 | PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id); |
---|
| 1956 | SetSentErrorMessage(true); |
---|
| 1957 | return false; |
---|
| 1958 | } |
---|
| 1959 | |
---|
| 1960 | while(item_count > item_proto->Stackable) |
---|
| 1961 | { |
---|
| 1962 | items.push_back(ItemPair(item_id,item_proto->Stackable)); |
---|
| 1963 | item_count -= item_proto->Stackable; |
---|
| 1964 | } |
---|
| 1965 | |
---|
| 1966 | items.push_back(ItemPair(item_id,item_count)); |
---|
| 1967 | |
---|
| 1968 | if(items.size() > MAX_MAIL_ITEMS) |
---|
| 1969 | { |
---|
| 1970 | PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); |
---|
| 1971 | SetSentErrorMessage(true); |
---|
| 1972 | return false; |
---|
| 1973 | } |
---|
| 1974 | } |
---|
| 1975 | |
---|
| 1976 | if(!normalizePlayerName(name)) |
---|
| 1977 | { |
---|
| 1978 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 1979 | SetSentErrorMessage(true); |
---|
| 1980 | return false; |
---|
| 1981 | } |
---|
| 1982 | |
---|
| 1983 | uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name); |
---|
| 1984 | if(!receiver_guid) |
---|
| 1985 | { |
---|
| 1986 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 1987 | SetSentErrorMessage(true); |
---|
| 1988 | return false; |
---|
| 1989 | } |
---|
| 1990 | |
---|
| 1991 | uint32 mailId = objmgr.GenerateMailID(); |
---|
| 1992 | uint32 sender_guidlo = m_session->GetPlayer()->GetGUIDLow(); |
---|
| 1993 | uint32 messagetype = MAIL_NORMAL; |
---|
| 1994 | uint32 stationery = MAIL_STATIONERY_GM; |
---|
| 1995 | uint32 itemTextId = 0; |
---|
| 1996 | if (!text.empty()) |
---|
| 1997 | { |
---|
| 1998 | itemTextId = objmgr.CreateItemText( text ); |
---|
| 1999 | } |
---|
| 2000 | |
---|
| 2001 | Player *receiver = objmgr.GetPlayer(receiver_guid); |
---|
| 2002 | |
---|
| 2003 | // fill mail |
---|
| 2004 | MailItemsInfo mi; // item list preparing |
---|
| 2005 | |
---|
| 2006 | for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) |
---|
| 2007 | { |
---|
| 2008 | if(Item* item = Item::CreateItem(itr->first,itr->second,m_session->GetPlayer())) |
---|
| 2009 | { |
---|
| 2010 | item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted |
---|
| 2011 | mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); |
---|
| 2012 | } |
---|
| 2013 | } |
---|
| 2014 | |
---|
| 2015 | WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE); |
---|
| 2016 | |
---|
| 2017 | PSendSysMessage(LANG_MAIL_SENT, name.c_str()); |
---|
| 2018 | return true; |
---|
| 2019 | } |
---|
| 2020 | |
---|
| 2021 | // teleport player to given game_tele.entry |
---|
| 2022 | bool ChatHandler::HandleNameTeleCommand(const char * args) |
---|
| 2023 | { |
---|
| 2024 | if(!*args) |
---|
| 2025 | return false; |
---|
| 2026 | |
---|
| 2027 | char* pName = strtok((char*)args, " "); |
---|
| 2028 | |
---|
| 2029 | if(!pName) |
---|
| 2030 | return false; |
---|
| 2031 | |
---|
| 2032 | std::string name = pName; |
---|
| 2033 | |
---|
| 2034 | if(!normalizePlayerName(name)) |
---|
| 2035 | { |
---|
| 2036 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2037 | SetSentErrorMessage(true); |
---|
| 2038 | return false; |
---|
| 2039 | } |
---|
| 2040 | |
---|
| 2041 | char* tail = strtok(NULL, ""); |
---|
| 2042 | if(!tail) |
---|
| 2043 | return false; |
---|
| 2044 | |
---|
| 2045 | // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r |
---|
| 2046 | GameTele const* tele = extractGameTeleFromLink(tail); |
---|
| 2047 | if(!tele) |
---|
| 2048 | { |
---|
| 2049 | SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); |
---|
| 2050 | SetSentErrorMessage(true); |
---|
| 2051 | return false; |
---|
| 2052 | } |
---|
| 2053 | |
---|
| 2054 | MapEntry const * me = sMapStore.LookupEntry(tele->mapId); |
---|
| 2055 | if(!me || me->IsBattleGroundOrArena()) |
---|
| 2056 | { |
---|
| 2057 | SendSysMessage(LANG_CANNOT_TELE_TO_BG); |
---|
| 2058 | SetSentErrorMessage(true); |
---|
| 2059 | return false; |
---|
| 2060 | } |
---|
| 2061 | |
---|
| 2062 | Player *chr = objmgr.GetPlayer(name.c_str()); |
---|
| 2063 | if (chr) |
---|
| 2064 | { |
---|
| 2065 | |
---|
| 2066 | if(chr->IsBeingTeleported()==true) |
---|
| 2067 | { |
---|
| 2068 | PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); |
---|
| 2069 | SetSentErrorMessage(true); |
---|
| 2070 | return false; |
---|
| 2071 | } |
---|
| 2072 | |
---|
| 2073 | PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", tele->name.c_str()); |
---|
| 2074 | |
---|
| 2075 | if (m_session->GetPlayer()->IsVisibleGloballyFor(chr)) |
---|
| 2076 | ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName()); |
---|
| 2077 | |
---|
| 2078 | // stop flight if need |
---|
| 2079 | if(chr->isInFlight()) |
---|
| 2080 | { |
---|
| 2081 | chr->GetMotionMaster()->MovementExpired(); |
---|
| 2082 | chr->m_taxi.ClearTaxiDestinations(); |
---|
| 2083 | } |
---|
| 2084 | // save only in non-flight case |
---|
| 2085 | else |
---|
| 2086 | chr->SaveRecallPosition(); |
---|
| 2087 | |
---|
| 2088 | chr->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation); |
---|
| 2089 | } |
---|
| 2090 | else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str())) |
---|
| 2091 | { |
---|
[44] | 2092 | PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetTrinityString(LANG_OFFLINE), tele->name.c_str()); |
---|
[37] | 2093 | Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y),guid); |
---|
| 2094 | } |
---|
| 2095 | else |
---|
| 2096 | PSendSysMessage(LANG_NO_PLAYER, name.c_str()); |
---|
| 2097 | |
---|
| 2098 | return true; |
---|
| 2099 | } |
---|
| 2100 | |
---|
| 2101 | //Teleport group to given game_tele.entry |
---|
| 2102 | bool ChatHandler::HandleGroupTeleCommand(const char * args) |
---|
| 2103 | { |
---|
| 2104 | if(!*args) |
---|
| 2105 | return false; |
---|
| 2106 | |
---|
| 2107 | Player *player = getSelectedPlayer(); |
---|
| 2108 | if (!player) |
---|
| 2109 | { |
---|
| 2110 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
| 2111 | SetSentErrorMessage(true); |
---|
| 2112 | return false; |
---|
| 2113 | } |
---|
| 2114 | |
---|
| 2115 | // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r |
---|
| 2116 | GameTele const* tele = extractGameTeleFromLink((char*)args); |
---|
| 2117 | if(!tele) |
---|
| 2118 | { |
---|
| 2119 | SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); |
---|
| 2120 | SetSentErrorMessage(true); |
---|
| 2121 | return false; |
---|
| 2122 | } |
---|
| 2123 | |
---|
| 2124 | MapEntry const * me = sMapStore.LookupEntry(tele->mapId); |
---|
| 2125 | if(!me || me->IsBattleGroundOrArena()) |
---|
| 2126 | { |
---|
| 2127 | SendSysMessage(LANG_CANNOT_TELE_TO_BG); |
---|
| 2128 | SetSentErrorMessage(true); |
---|
| 2129 | return false; |
---|
| 2130 | } |
---|
| 2131 | Group *grp = player->GetGroup(); |
---|
| 2132 | if(!grp) |
---|
| 2133 | { |
---|
| 2134 | PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName()); |
---|
| 2135 | SetSentErrorMessage(true); |
---|
| 2136 | return false; |
---|
| 2137 | } |
---|
| 2138 | |
---|
| 2139 | for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) |
---|
| 2140 | { |
---|
| 2141 | Player *pl = itr->getSource(); |
---|
| 2142 | |
---|
| 2143 | if(!pl || !pl->GetSession() ) |
---|
| 2144 | continue; |
---|
| 2145 | |
---|
| 2146 | if(pl->IsBeingTeleported()) |
---|
| 2147 | { |
---|
| 2148 | PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName()); |
---|
| 2149 | continue; |
---|
| 2150 | } |
---|
| 2151 | |
---|
| 2152 | PSendSysMessage(LANG_TELEPORTING_TO, pl->GetName(),"", tele->name.c_str()); |
---|
| 2153 | |
---|
| 2154 | if (m_session->GetPlayer() != pl && m_session->GetPlayer()->IsVisibleGloballyFor(pl)) |
---|
| 2155 | ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName()); |
---|
| 2156 | |
---|
| 2157 | // stop flight if need |
---|
| 2158 | if(pl->isInFlight()) |
---|
| 2159 | { |
---|
| 2160 | pl->GetMotionMaster()->MovementExpired(); |
---|
| 2161 | pl->m_taxi.ClearTaxiDestinations(); |
---|
| 2162 | } |
---|
| 2163 | // save only in non-flight case |
---|
| 2164 | else |
---|
| 2165 | pl->SaveRecallPosition(); |
---|
| 2166 | |
---|
| 2167 | pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); |
---|
| 2168 | } |
---|
| 2169 | |
---|
| 2170 | return true; |
---|
| 2171 | } |
---|
| 2172 | |
---|
| 2173 | //Summon group of player |
---|
| 2174 | bool ChatHandler::HandleGroupgoCommand(const char* args) |
---|
| 2175 | { |
---|
| 2176 | if(!*args) |
---|
| 2177 | return false; |
---|
| 2178 | |
---|
| 2179 | std::string name = args; |
---|
| 2180 | |
---|
| 2181 | if(!normalizePlayerName(name)) |
---|
| 2182 | { |
---|
| 2183 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
| 2184 | SetSentErrorMessage(true); |
---|
| 2185 | return false; |
---|
| 2186 | } |
---|
| 2187 | |
---|
| 2188 | Player *player = objmgr.GetPlayer(name.c_str()); |
---|
| 2189 | if (!player) |
---|
| 2190 | { |
---|
| 2191 | PSendSysMessage(LANG_NO_PLAYER, args); |
---|
| 2192 | SetSentErrorMessage(true); |
---|
| 2193 | return false; |
---|
| 2194 | } |
---|
| 2195 | |
---|
| 2196 | Group *grp = player->GetGroup(); |
---|
| 2197 | |
---|
| 2198 | if(!grp) |
---|
| 2199 | { |
---|
| 2200 | PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName()); |
---|
| 2201 | SetSentErrorMessage(true); |
---|
| 2202 | return false; |
---|
| 2203 | } |
---|
| 2204 | |
---|
| 2205 | Map* gmMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); |
---|
| 2206 | bool to_instance = gmMap->Instanceable(); |
---|
| 2207 | |
---|
| 2208 | // we are in instance, and can summon only player in our group with us as lead |
---|
| 2209 | if ( to_instance && ( |
---|
| 2210 | !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) || |
---|
| 2211 | (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) ) |
---|
| 2212 | // the last check is a bit excessive, but let it be, just in case |
---|
| 2213 | { |
---|
| 2214 | SendSysMessage(LANG_CANNOT_SUMMON_TO_INST); |
---|
| 2215 | SetSentErrorMessage(true); |
---|
| 2216 | return false; |
---|
| 2217 | } |
---|
| 2218 | |
---|
| 2219 | for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) |
---|
| 2220 | { |
---|
| 2221 | Player *pl = itr->getSource(); |
---|
| 2222 | |
---|
| 2223 | if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() ) |
---|
| 2224 | continue; |
---|
| 2225 | |
---|
| 2226 | if(pl->IsBeingTeleported()==true) |
---|
| 2227 | { |
---|
| 2228 | PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName()); |
---|
| 2229 | SetSentErrorMessage(true); |
---|
| 2230 | return false; |
---|
| 2231 | } |
---|
| 2232 | |
---|
| 2233 | if (to_instance) |
---|
| 2234 | { |
---|
| 2235 | Map* plMap = MapManager::Instance().GetMap(pl->GetMapId(),pl); |
---|
| 2236 | |
---|
| 2237 | if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() ) |
---|
| 2238 | { |
---|
| 2239 | // cannot summon from instance to instance |
---|
| 2240 | PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,pl->GetName()); |
---|
| 2241 | SetSentErrorMessage(true); |
---|
| 2242 | return false; |
---|
| 2243 | } |
---|
| 2244 | } |
---|
| 2245 | |
---|
| 2246 | PSendSysMessage(LANG_SUMMONING, pl->GetName(),""); |
---|
| 2247 | |
---|
| 2248 | if (m_session->GetPlayer()->IsVisibleGloballyFor(pl)) |
---|
| 2249 | ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, m_session->GetPlayer()->GetName()); |
---|
| 2250 | |
---|
| 2251 | // stop flight if need |
---|
| 2252 | if(pl->isInFlight()) |
---|
| 2253 | { |
---|
| 2254 | pl->GetMotionMaster()->MovementExpired(); |
---|
| 2255 | pl->m_taxi.ClearTaxiDestinations(); |
---|
| 2256 | } |
---|
| 2257 | // save only in non-flight case |
---|
| 2258 | else |
---|
| 2259 | pl->SaveRecallPosition(); |
---|
| 2260 | |
---|
| 2261 | // before GM |
---|
| 2262 | float x,y,z; |
---|
| 2263 | m_session->GetPlayer()->GetClosePoint(x,y,z,pl->GetObjectSize()); |
---|
| 2264 | pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation()); |
---|
| 2265 | } |
---|
| 2266 | |
---|
| 2267 | return true; |
---|
| 2268 | } |
---|
| 2269 | |
---|
| 2270 | //teleport at coordinates |
---|
| 2271 | bool ChatHandler::HandleGoXYCommand(const char* args) |
---|
| 2272 | { |
---|
| 2273 | if(!*args) |
---|
| 2274 | return false; |
---|
| 2275 | |
---|
| 2276 | Player* _player = m_session->GetPlayer(); |
---|
| 2277 | |
---|
| 2278 | char* px = strtok((char*)args, " "); |
---|
| 2279 | char* py = strtok(NULL, " "); |
---|
| 2280 | char* pmapid = strtok(NULL, " "); |
---|
| 2281 | |
---|
| 2282 | if (!px || !py) |
---|
| 2283 | return false; |
---|
| 2284 | |
---|
| 2285 | float x = (float)atof(px); |
---|
| 2286 | float y = (float)atof(py); |
---|
| 2287 | uint32 mapid; |
---|
| 2288 | if (pmapid) |
---|
| 2289 | mapid = (uint32)atoi(pmapid); |
---|
| 2290 | else mapid = _player->GetMapId(); |
---|
| 2291 | |
---|
| 2292 | if(!MapManager::IsValidMapCoord(mapid,x,y)) |
---|
| 2293 | { |
---|
| 2294 | PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); |
---|
| 2295 | SetSentErrorMessage(true); |
---|
| 2296 | return false; |
---|
| 2297 | } |
---|
| 2298 | |
---|
| 2299 | // stop flight if need |
---|
| 2300 | if(_player->isInFlight()) |
---|
| 2301 | { |
---|
| 2302 | _player->GetMotionMaster()->MovementExpired(); |
---|
| 2303 | _player->m_taxi.ClearTaxiDestinations(); |
---|
| 2304 | } |
---|
| 2305 | // save only in non-flight case |
---|
| 2306 | else |
---|
| 2307 | _player->SaveRecallPosition(); |
---|
| 2308 | |
---|
| 2309 | Map const *map = MapManager::Instance().GetBaseMap(mapid); |
---|
| 2310 | float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); |
---|
| 2311 | |
---|
| 2312 | _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); |
---|
| 2313 | |
---|
| 2314 | return true; |
---|
| 2315 | } |
---|
| 2316 | |
---|
| 2317 | //teleport at coordinates, including Z |
---|
| 2318 | bool ChatHandler::HandleGoXYZCommand(const char* args) |
---|
| 2319 | { |
---|
| 2320 | if(!*args) |
---|
| 2321 | return false; |
---|
| 2322 | |
---|
| 2323 | Player* _player = m_session->GetPlayer(); |
---|
| 2324 | |
---|
| 2325 | char* px = strtok((char*)args, " "); |
---|
| 2326 | char* py = strtok(NULL, " "); |
---|
| 2327 | char* pz = strtok(NULL, " "); |
---|
| 2328 | char* pmapid = strtok(NULL, " "); |
---|
| 2329 | |
---|
| 2330 | if (!px || !py || !pz) |
---|
| 2331 | return false; |
---|
| 2332 | |
---|
| 2333 | float x = (float)atof(px); |
---|
| 2334 | float y = (float)atof(py); |
---|
| 2335 | float z = (float)atof(pz); |
---|
| 2336 | uint32 mapid; |
---|
| 2337 | if (pmapid) |
---|
| 2338 | mapid = (uint32)atoi(pmapid); |
---|
| 2339 | else |
---|
| 2340 | mapid = _player->GetMapId(); |
---|
| 2341 | |
---|
| 2342 | if(!MapManager::IsValidMapCoord(mapid,x,y,z)) |
---|
| 2343 | { |
---|
| 2344 | PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); |
---|
| 2345 | SetSentErrorMessage(true); |
---|
| 2346 | return false; |
---|
| 2347 | } |
---|
| 2348 | |
---|
| 2349 | // stop flight if need |
---|
| 2350 | if(_player->isInFlight()) |
---|
| 2351 | { |
---|
| 2352 | _player->GetMotionMaster()->MovementExpired(); |
---|
| 2353 | _player->m_taxi.ClearTaxiDestinations(); |
---|
| 2354 | } |
---|
| 2355 | // save only in non-flight case |
---|
| 2356 | else |
---|
| 2357 | _player->SaveRecallPosition(); |
---|
| 2358 | |
---|
| 2359 | _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); |
---|
| 2360 | |
---|
| 2361 | return true; |
---|
| 2362 | } |
---|
| 2363 | |
---|
| 2364 | //teleport at coordinates |
---|
| 2365 | bool ChatHandler::HandleGoZoneXYCommand(const char* args) |
---|
| 2366 | { |
---|
| 2367 | if(!*args) |
---|
| 2368 | return false; |
---|
| 2369 | |
---|
| 2370 | Player* _player = m_session->GetPlayer(); |
---|
| 2371 | |
---|
| 2372 | char* px = strtok((char*)args, " "); |
---|
| 2373 | char* py = strtok(NULL, " "); |
---|
| 2374 | char* tail = strtok(NULL,""); |
---|
| 2375 | |
---|
| 2376 | char* cAreaId = extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r |
---|
| 2377 | |
---|
| 2378 | if (!px || !py) |
---|
| 2379 | return false; |
---|
| 2380 | |
---|
| 2381 | float x = (float)atof(px); |
---|
| 2382 | float y = (float)atof(py); |
---|
| 2383 | uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId(); |
---|
| 2384 | |
---|
| 2385 | AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); |
---|
| 2386 | |
---|
| 2387 | if( x<0 || x>100 || y<0 || y>100 || !areaEntry ) |
---|
| 2388 | { |
---|
| 2389 | PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid); |
---|
| 2390 | SetSentErrorMessage(true); |
---|
| 2391 | return false; |
---|
| 2392 | } |
---|
| 2393 | |
---|
| 2394 | // update to parent zone if exist (client map show only zones without parents) |
---|
| 2395 | AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; |
---|
| 2396 | |
---|
| 2397 | Map const *map = MapManager::Instance().GetBaseMap(zoneEntry->mapid); |
---|
| 2398 | |
---|
| 2399 | if(map->Instanceable()) |
---|
| 2400 | { |
---|
| 2401 | PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[m_session->GetSessionDbcLocale()],map->GetId(),map->GetMapName()); |
---|
| 2402 | SetSentErrorMessage(true); |
---|
| 2403 | return false; |
---|
| 2404 | } |
---|
| 2405 | |
---|
| 2406 | Zone2MapCoordinates(x,y,zoneEntry->ID); |
---|
| 2407 | |
---|
| 2408 | if(!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y)) |
---|
| 2409 | { |
---|
| 2410 | PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid); |
---|
| 2411 | SetSentErrorMessage(true); |
---|
| 2412 | return false; |
---|
| 2413 | } |
---|
| 2414 | |
---|
| 2415 | // stop flight if need |
---|
| 2416 | if(_player->isInFlight()) |
---|
| 2417 | { |
---|
| 2418 | _player->GetMotionMaster()->MovementExpired(); |
---|
| 2419 | _player->m_taxi.ClearTaxiDestinations(); |
---|
| 2420 | } |
---|
| 2421 | // save only in non-flight case |
---|
| 2422 | else |
---|
| 2423 | _player->SaveRecallPosition(); |
---|
| 2424 | |
---|
| 2425 | float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); |
---|
| 2426 | _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation()); |
---|
| 2427 | |
---|
| 2428 | return true; |
---|
| 2429 | } |
---|
| 2430 | |
---|
| 2431 | //teleport to grid |
---|
| 2432 | bool ChatHandler::HandleGoGridCommand(const char* args) |
---|
| 2433 | { |
---|
| 2434 | if(!*args) return false; |
---|
| 2435 | Player* _player = m_session->GetPlayer(); |
---|
| 2436 | |
---|
| 2437 | char* px = strtok((char*)args, " "); |
---|
| 2438 | char* py = strtok(NULL, " "); |
---|
| 2439 | char* pmapid = strtok(NULL, " "); |
---|
| 2440 | |
---|
| 2441 | if (!px || !py) |
---|
| 2442 | return false; |
---|
| 2443 | |
---|
| 2444 | float grid_x = (float)atof(px); |
---|
| 2445 | float grid_y = (float)atof(py); |
---|
| 2446 | uint32 mapid; |
---|
| 2447 | if (pmapid) |
---|
| 2448 | mapid = (uint32)atoi(pmapid); |
---|
| 2449 | else mapid = _player->GetMapId(); |
---|
| 2450 | |
---|
| 2451 | // center of grid |
---|
| 2452 | float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; |
---|
| 2453 | float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; |
---|
| 2454 | |
---|
| 2455 | if(!MapManager::IsValidMapCoord(mapid,x,y)) |
---|
| 2456 | { |
---|
| 2457 | PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); |
---|
| 2458 | SetSentErrorMessage(true); |
---|
| 2459 | return false; |
---|
| 2460 | } |
---|
| 2461 | |
---|
| 2462 | // stop flight if need |
---|
| 2463 | if(_player->isInFlight()) |
---|
| 2464 | { |
---|
| 2465 | _player->GetMotionMaster()->MovementExpired(); |
---|
| 2466 | _player->m_taxi.ClearTaxiDestinations(); |
---|
| 2467 | } |
---|
| 2468 | // save only in non-flight case |
---|
| 2469 | else |
---|
| 2470 | _player->SaveRecallPosition(); |
---|
| 2471 | |
---|
| 2472 | Map const *map = MapManager::Instance().GetBaseMap(mapid); |
---|
| 2473 | float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); |
---|
| 2474 | _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); |
---|
| 2475 | |
---|
| 2476 | return true; |
---|
| 2477 | } |
---|
| 2478 | |
---|
| 2479 | bool ChatHandler::HandleDrunkCommand(const char* args) |
---|
| 2480 | { |
---|
| 2481 | if(!*args) return false; |
---|
| 2482 | |
---|
| 2483 | uint32 drunklevel = (uint32)atoi(args); |
---|
| 2484 | if(drunklevel > 100) |
---|
| 2485 | drunklevel = 100; |
---|
| 2486 | |
---|
| 2487 | uint16 drunkMod = drunklevel * 0xFFFF / 100; |
---|
| 2488 | |
---|
| 2489 | m_session->GetPlayer()->SetDrunkValue(drunkMod); |
---|
| 2490 | |
---|
| 2491 | return true; |
---|
| 2492 | } |
---|