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