PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/src/game/Level1.cpp

https://github.com/fanatix/fanatix-core
C++ | 2561 lines | 1930 code | 441 blank | 190 comment | 374 complexity | d6964f3422d59ff862de8f292b369053 MD5 | raw file
Possible License(s): GPL-2.0, CC-BY-SA-3.0

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
  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. #include "Common.h"
  19. #include "Database/DatabaseEnv.h"
  20. #include "WorldPacket.h"
  21. #include "WorldSession.h"
  22. #include "World.h"
  23. #include "ObjectMgr.h"
  24. #include "Player.h"
  25. #include "Opcodes.h"
  26. #include "Chat.h"
  27. #include "Log.h"
  28. #include "MapManager.h"
  29. #include "ObjectAccessor.h"
  30. #include "Language.h"
  31. #include "CellImpl.h"
  32. #include "InstanceSaveMgr.h"
  33. #include "Util.h"
  34. #ifdef _DEBUG_VMAPS
  35. #include "VMapFactory.h"
  36. #endif
  37. //-----------------------Npc Commands-----------------------
  38. bool ChatHandler::HandleNpcSayCommand(const char* args)
  39. {
  40. if(!*args)
  41. return false;
  42. Creature* pCreature = getSelectedCreature();
  43. if(!pCreature)
  44. {
  45. SendSysMessage(LANG_SELECT_CREATURE);
  46. SetSentErrorMessage(true);
  47. return false;
  48. }
  49. pCreature->MonsterSay(args, LANG_UNIVERSAL, 0);
  50. return true;
  51. }
  52. bool ChatHandler::HandleNpcYellCommand(const char* args)
  53. {
  54. if(!*args)
  55. return false;
  56. Creature* pCreature = getSelectedCreature();
  57. if(!pCreature)
  58. {
  59. SendSysMessage(LANG_SELECT_CREATURE);
  60. SetSentErrorMessage(true);
  61. return false;
  62. }
  63. pCreature->MonsterYell(args, LANG_UNIVERSAL, 0);
  64. return true;
  65. }
  66. //show text emote by creature in chat
  67. bool ChatHandler::HandleNpcTextEmoteCommand(const char* args)
  68. {
  69. if(!*args)
  70. return false;
  71. Creature* pCreature = getSelectedCreature();
  72. if(!pCreature)
  73. {
  74. SendSysMessage(LANG_SELECT_CREATURE);
  75. SetSentErrorMessage(true);
  76. return false;
  77. }
  78. pCreature->MonsterTextEmote(args, 0);
  79. return true;
  80. }
  81. // make npc whisper to player
  82. bool ChatHandler::HandleNpcWhisperCommand(const char* args)
  83. {
  84. if(!*args)
  85. return false;
  86. char* receiver_str = strtok((char*)args, " ");
  87. char* text = strtok(NULL, "");
  88. uint64 guid = m_session->GetPlayer()->GetSelection();
  89. Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid);
  90. if(!pCreature || !receiver_str || !text)
  91. {
  92. return false;
  93. }
  94. uint64 receiver_guid= atol(receiver_str);
  95. // check online security
  96. if (HasLowerSecurity(objmgr.GetPlayer(receiver_guid), 0))
  97. return false;
  98. pCreature->MonsterWhisper(text,receiver_guid);
  99. return true;
  100. }
  101. //----------------------------------------------------------
  102. // global announce
  103. bool ChatHandler::HandleSysAnnounceCommand(const char* args)
  104. {
  105. if(!*args)
  106. return false;
  107. if(m_session)
  108. sWorld.SendWorldText(LANG_SYSTEMMESSAGE,m_session->GetPlayerName(),args);
  109. else
  110. sWorld.SendWorldText(LANG_SYSTEMMESSAGE,"console",args);
  111. return true;
  112. }
  113. bool ChatHandler::HandleAnnounceCommand(const char* args)
  114. {
  115. if(!*args)
  116. return false;
  117. sWorld.SendWorldText(LANG_ANNOUNCE_COLOR, m_session->GetPlayer()->GetName(), args);
  118. return true;
  119. }
  120. //notification player at the screen
  121. bool ChatHandler::HandleNotifyCommand(const char* args)
  122. {
  123. if(!*args)
  124. return false;
  125. std::string str = GetMangosString(LANG_GLOBAL_NOTIFY);
  126. str += args;
  127. WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
  128. data << str;
  129. sWorld.SendGlobalMessage(&data);
  130. return true;
  131. }
  132. //Enable\Dissable GM Mode
  133. bool ChatHandler::HandleGMCommand(const char* args)
  134. {
  135. if(!*args)
  136. {
  137. if(m_session->GetPlayer()->isGameMaster())
  138. m_session->SendNotification(LANG_GM_ON);
  139. else
  140. m_session->SendNotification(LANG_GM_OFF);
  141. return true;
  142. }
  143. std::string argstr = (char*)args;
  144. if (argstr == "on")
  145. {
  146. m_session->GetPlayer()->SetGameMaster(true);
  147. m_session->SendNotification(LANG_GM_ON);
  148. #ifdef _DEBUG_VMAPS
  149. VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
  150. vMapManager->processCommand("stoplog");
  151. #endif
  152. return true;
  153. }
  154. if (argstr == "off")
  155. {
  156. m_session->GetPlayer()->SetGameMaster(false);
  157. m_session->SendNotification(LANG_GM_OFF);
  158. #ifdef _DEBUG_VMAPS
  159. VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
  160. vMapManager->processCommand("startlog");
  161. #endif
  162. return true;
  163. }
  164. SendSysMessage(LANG_USE_BOL);
  165. SetSentErrorMessage(true);
  166. return false;
  167. }
  168. // Enables or disables hiding of the staff badge
  169. bool ChatHandler::HandleGMChatCommand(const char* args)
  170. {
  171. if(!*args)
  172. {
  173. if(m_session->GetPlayer()->isGMChat())
  174. m_session->SendNotification(LANG_GM_CHAT_ON);
  175. else
  176. m_session->SendNotification(LANG_GM_CHAT_OFF);
  177. return true;
  178. }
  179. std::string argstr = (char*)args;
  180. if (argstr == "on")
  181. {
  182. m_session->GetPlayer()->SetGMChat(true);
  183. m_session->SendNotification(LANG_GM_CHAT_ON);
  184. return true;
  185. }
  186. if (argstr == "off")
  187. {
  188. m_session->GetPlayer()->SetGMChat(false);
  189. m_session->SendNotification(LANG_GM_CHAT_OFF);
  190. return true;
  191. }
  192. SendSysMessage(LANG_USE_BOL);
  193. SetSentErrorMessage(true);
  194. return false;
  195. }
  196. //Enable\Dissable Invisible mode
  197. bool ChatHandler::HandleGMVisibleCommand(const char* args)
  198. {
  199. if (!*args)
  200. {
  201. PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetMangosString(LANG_VISIBLE) : GetMangosString(LANG_INVISIBLE));
  202. return true;
  203. }
  204. std::string argstr = (char*)args;
  205. if (argstr == "on")
  206. {
  207. m_session->GetPlayer()->SetGMVisible(true);
  208. m_session->SendNotification(LANG_INVISIBLE_VISIBLE);
  209. return true;
  210. }
  211. if (argstr == "off")
  212. {
  213. m_session->SendNotification(LANG_INVISIBLE_INVISIBLE);
  214. m_session->GetPlayer()->SetGMVisible(false);
  215. return true;
  216. }
  217. SendSysMessage(LANG_USE_BOL);
  218. SetSentErrorMessage(true);
  219. return false;
  220. }
  221. bool ChatHandler::HandleGPSCommand(const char* args)
  222. {
  223. WorldObject *obj = NULL;
  224. if (*args)
  225. {
  226. uint64 guid = extractGuidFromLink((char*)args);
  227. if(guid)
  228. obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*m_session->GetPlayer(),guid,TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
  229. if(!obj)
  230. {
  231. SendSysMessage(LANG_PLAYER_NOT_FOUND);
  232. SetSentErrorMessage(true);
  233. return false;
  234. }
  235. }
  236. else
  237. {
  238. obj = getSelectedUnit();
  239. if(!obj)
  240. {
  241. SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
  242. SetSentErrorMessage(true);
  243. return false;
  244. }
  245. }
  246. CellPair cell_val = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
  247. Cell cell(cell_val);
  248. uint32 zone_id, area_id;
  249. obj->GetZoneAndAreaId(zone_id,area_id);
  250. MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId());
  251. AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id);
  252. AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id);
  253. float zone_x = obj->GetPositionX();
  254. float zone_y = obj->GetPositionY();
  255. Map2ZoneCoordinates(zone_x,zone_y,zone_id);
  256. Map const *map = obj->GetMap();
  257. float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
  258. float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
  259. GridPair p = MaNGOS::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY());
  260. int gx=63-p.x_coord;
  261. int gy=63-p.y_coord;
  262. uint32 have_map = Map::ExistMap(obj->GetMapId(),gx,gy) ? 1 : 0;
  263. uint32 have_vmap = Map::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0;
  264. PSendSysMessage(LANG_MAP_POSITION,
  265. obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
  266. zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
  267. area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
  268. obj->GetPhaseMask(),
  269. obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
  270. cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
  271. zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );
  272. sLog.outDebug("Player %s GPS call for %s '%s' (%s: %u):",
  273. m_session ? GetNameLink().c_str() : GetMangosString(LANG_CONSOLE_COMMAND),
  274. (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(),
  275. (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) );
  276. sLog.outDebug(GetMangosString(LANG_MAP_POSITION),
  277. obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
  278. zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
  279. area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
  280. obj->GetPhaseMask(),
  281. obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
  282. cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
  283. zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );
  284. LiquidData liquid_status;
  285. ZLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status);
  286. if (res)
  287. {
  288. PSendSysMessage(LANG_LIQUID_STATUS, liquid_status.level, liquid_status.depth_level, liquid_status.type, res);
  289. }
  290. return true;
  291. }
  292. //Summon Player
  293. bool ChatHandler::HandleNamegoCommand(const char* args)
  294. {
  295. if(!*args)
  296. return false;
  297. std::string name = extractPlayerNameFromLink((char*)args);
  298. if(name.empty())
  299. {
  300. SendSysMessage(LANG_PLAYER_NOT_FOUND);
  301. SetSentErrorMessage(true);
  302. return false;
  303. }
  304. Player *chr = objmgr.GetPlayer(name.c_str());
  305. if (chr)
  306. {
  307. std::string nameLink = playerLink(name);
  308. // check online security
  309. if (HasLowerSecurity(chr, 0))
  310. return false;
  311. if(chr->IsBeingTeleported()==true)
  312. {
  313. PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str());
  314. SetSentErrorMessage(true);
  315. return false;
  316. }
  317. Map* pMap = m_session->GetPlayer()->GetMap();
  318. if(pMap->IsBattleGroundOrArena())
  319. {
  320. // only allow if gm mode is on
  321. if (!chr->isGameMaster())
  322. {
  323. PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,chr->GetName());
  324. SetSentErrorMessage(true);
  325. return false;
  326. }
  327. // if both players are in different bgs
  328. else if (chr->GetBattleGroundId() && m_session->GetPlayer()->GetBattleGroundId() != chr->GetBattleGroundId())
  329. {
  330. PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chr->GetName());
  331. SetSentErrorMessage(true);
  332. return false;
  333. }
  334. // all's well, set bg id
  335. // when porting out from the bg, it will be reset to 0
  336. chr->SetBattleGroundId(m_session->GetPlayer()->GetBattleGroundId(), m_session->GetPlayer()->GetBattleGroundTypeId());
  337. // remember current position as entry point for return at bg end teleportation
  338. chr->SetBattleGroundEntryPoint(chr->GetMapId(),chr->GetPositionX(),chr->GetPositionY(),chr->GetPositionZ(),chr->GetOrientation());
  339. }
  340. else if(pMap->IsDungeon())
  341. {
  342. Map* cMap = chr->GetMap();
  343. if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() )
  344. {
  345. // cannot summon from instance to instance
  346. PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str());
  347. SetSentErrorMessage(true);
  348. return false;
  349. }
  350. // we are in instance, and can summon only player in our group with us as lead
  351. if ( !m_session->GetPlayer()->GetGroup() || !chr->GetGroup() ||
  352. (chr->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
  353. (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) )
  354. // the last check is a bit excessive, but let it be, just in case
  355. {
  356. PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str());
  357. SetSentErrorMessage(true);
  358. return false;
  359. }
  360. }
  361. PSendSysMessage(LANG_SUMMONING, nameLink.c_str(),"");
  362. if (needReportToTarget(chr))
  363. ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str());
  364. // stop flight if need
  365. if(chr->isInFlight())
  366. {
  367. chr->GetMotionMaster()->MovementExpired();
  368. chr->m_taxi.ClearTaxiDestinations();
  369. }
  370. // save only in non-flight case
  371. else
  372. chr->SaveRecallPosition();
  373. // before GM
  374. float x,y,z;
  375. m_session->GetPlayer()->GetClosePoint(x,y,z,chr->GetObjectSize());
  376. chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation());
  377. }
  378. else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
  379. {
  380. // check offline security
  381. if (HasLowerSecurity(NULL, guid))
  382. return false;
  383. std::string nameLink = playerLink(name);
  384. PSendSysMessage(LANG_SUMMONING, nameLink.c_str(),GetMangosString(LANG_OFFLINE));
  385. // in point where GM stay
  386. Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(),
  387. m_session->GetPlayer()->GetPositionX(),
  388. m_session->GetPlayer()->GetPositionY(),
  389. m_session->GetPlayer()->GetPositionZ(),
  390. m_session->GetPlayer()->GetOrientation(),
  391. m_session->GetPlayer()->GetZoneId(),
  392. guid);
  393. }
  394. else
  395. {
  396. PSendSysMessage(LANG_NO_PLAYER, args);
  397. SetSentErrorMessage(true);
  398. }
  399. return true;
  400. }
  401. //Teleport to Player
  402. bool ChatHandler::HandleGonameCommand(const char* args)
  403. {
  404. if(!*args)
  405. return false;
  406. Player* _player = m_session->GetPlayer();
  407. std::string name = extractPlayerNameFromLink((char*)args);
  408. if(name.empty())
  409. {
  410. SendSysMessage(LANG_PLAYER_NOT_FOUND);
  411. SetSentErrorMessage(true);
  412. return false;
  413. }
  414. Player *chr = objmgr.GetPlayer(name.c_str());
  415. if (chr)
  416. {
  417. // check online security
  418. if (HasLowerSecurity(chr, 0))
  419. return false;
  420. std::string chrNameLink = playerLink(name);
  421. Map* cMap = chr->GetMap();
  422. if(cMap->IsBattleGroundOrArena())
  423. {
  424. // only allow if gm mode is on
  425. if (!_player->isGameMaster())
  426. {
  427. PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,chrNameLink.c_str());
  428. SetSentErrorMessage(true);
  429. return false;
  430. }
  431. // if both players are in different bgs
  432. else if (_player->GetBattleGroundId() && _player->GetBattleGroundId() != chr->GetBattleGroundId())
  433. {
  434. PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chrNameLink.c_str());
  435. SetSentErrorMessage(true);
  436. return false;
  437. }
  438. // all's well, set bg id
  439. // when porting out from the bg, it will be reset to 0
  440. _player->SetBattleGroundId(chr->GetBattleGroundId(), chr->GetBattleGroundTypeId());
  441. // remember current position as entry point for return at bg end teleportation
  442. _player->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
  443. }
  444. else if(cMap->IsDungeon())
  445. {
  446. // we have to go to instance, and can go to player only if:
  447. // 1) we are in his group (either as leader or as member)
  448. // 2) we are not bound to any group and have GM mode on
  449. if (_player->GetGroup())
  450. {
  451. // we are in group, we can go only if we are in the player group
  452. if (_player->GetGroup() != chr->GetGroup())
  453. {
  454. PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chrNameLink.c_str());
  455. SetSentErrorMessage(true);
  456. return false;
  457. }
  458. }
  459. else
  460. {
  461. // we are not in group, let's verify our GM mode
  462. if (!_player->isGameMaster())
  463. {
  464. PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chrNameLink.c_str());
  465. SetSentErrorMessage(true);
  466. return false;
  467. }
  468. }
  469. // if the player or the player's group is bound to another instance
  470. // the player will not be bound to another one
  471. InstancePlayerBind *pBind = _player->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty());
  472. if(!pBind)
  473. {
  474. Group *group = _player->GetGroup();
  475. InstanceGroupBind *gBind = group ? group->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()) : NULL;
  476. if(!gBind)
  477. {
  478. // if no bind exists, create a solo bind
  479. InstanceSave *save = sInstanceSaveManager.GetInstanceSave(chr->GetInstanceId());
  480. if(save) _player->BindToInstance(save, !save->CanReset());
  481. }
  482. }
  483. _player->SetDifficulty(chr->GetDifficulty());
  484. }
  485. PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str());
  486. if (_player->IsVisibleGloballyFor(chr))
  487. ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, GetNameLink().c_str());
  488. // stop flight if need
  489. if(_player->isInFlight())
  490. {
  491. _player->GetMotionMaster()->MovementExpired();
  492. _player->m_taxi.ClearTaxiDestinations();
  493. }
  494. // save only in non-flight case
  495. else
  496. _player->SaveRecallPosition();
  497. // to point to see at target with same orientation
  498. float x,y,z;
  499. chr->GetContactPoint(m_session->GetPlayer(),x,y,z);
  500. _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), TELE_TO_GM_MODE);
  501. return true;
  502. }
  503. if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
  504. {
  505. // check offline security
  506. if (HasLowerSecurity(NULL, guid))
  507. return false;
  508. std::string nameLink = playerLink(name);
  509. PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
  510. // to point where player stay (if loaded)
  511. float x,y,z,o;
  512. uint32 map;
  513. bool in_flight;
  514. if(Player::LoadPositionFromDB(map,x,y,z,o,in_flight,guid))
  515. {
  516. // stop flight if need
  517. if(_player->isInFlight())
  518. {
  519. _player->GetMotionMaster()->MovementExpired();
  520. _player->m_taxi.ClearTaxiDestinations();
  521. }
  522. // save only in non-flight case
  523. else
  524. _player->SaveRecallPosition();
  525. _player->TeleportTo(map, x, y, z,_player->GetOrientation());
  526. return true;
  527. }
  528. }
  529. PSendSysMessage(LANG_NO_PLAYER, args);
  530. SetSentErrorMessage(true);
  531. return false;
  532. }
  533. // Teleport player to last position
  534. bool ChatHandler::HandleRecallCommand(const char* args)
  535. {
  536. Player* chr = NULL;
  537. if(!*args)
  538. {
  539. chr = getSelectedPlayer();
  540. if(!chr)
  541. chr = m_session->GetPlayer();
  542. // check online security
  543. else if (HasLowerSecurity(chr, 0))
  544. return false;
  545. }
  546. else
  547. {
  548. std::string name = extractPlayerNameFromLink((char*)args);
  549. if(name.empty())
  550. {
  551. SendSysMessage(LANG_PLAYER_NOT_FOUND);
  552. SetSentErrorMessage(true);
  553. return false;
  554. }
  555. chr = objmgr.GetPlayer(name.c_str());
  556. if(!chr)
  557. {
  558. PSendSysMessage(LANG_NO_PLAYER, args);
  559. SetSentErrorMessage(true);
  560. return false;
  561. }
  562. // check online security
  563. if (HasLowerSecurity(chr, 0))
  564. return false;
  565. }
  566. if(chr->IsBeingTeleported())
  567. {
  568. PSendSysMessage(LANG_IS_TELEPORTED, GetNameLink(chr).c_str());
  569. SetSentErrorMessage(true);
  570. return false;
  571. }
  572. // stop flight if need
  573. if(chr->isInFlight())
  574. {
  575. chr->GetMotionMaster()->MovementExpired();
  576. chr->m_taxi.ClearTaxiDestinations();
  577. }
  578. chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO);
  579. return true;
  580. }
  581. //Edit Player KnownTitles
  582. bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args)
  583. {
  584. if(!*args)
  585. return false;
  586. uint64 titles = 0;
  587. sscanf((char*)args, I64FMTD, &titles);
  588. Player *chr = getSelectedPlayer();
  589. if (!chr)
  590. {
  591. SendSysMessage(LANG_NO_CHAR_SELECTED);
  592. SetSentErrorMessage(true);
  593. return false;
  594. }
  595. // check online security
  596. if (HasLowerSecurity(chr, 0))
  597. return false;
  598. uint64 titles2 = titles;
  599. for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i)
  600. if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
  601. titles2 &= ~(uint64(1) << tEntry->bit_index);
  602. titles &= ~titles2; // remove not existed titles
  603. chr->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles);
  604. SendSysMessage(LANG_DONE);
  605. return true;
  606. }
  607. //Edit Player HP
  608. bool ChatHandler::HandleModifyHPCommand(const char* args)
  609. {
  610. if(!*args)
  611. return false;
  612. // char* pHp = strtok((char*)args, " ");
  613. // if (!pHp)
  614. // return false;
  615. // char* pHpMax = strtok(NULL, " ");
  616. // if (!pHpMax)
  617. // return false;
  618. // int32 hpm = atoi(pHpMax);
  619. // int32 hp = atoi(pHp);
  620. int32 hp = atoi((char*)args);
  621. int32 hpm = atoi((char*)args);
  622. if (hp <= 0 || hpm <= 0 || hpm < hp)
  623. {
  624. SendSysMessage(LANG_BAD_VALUE);
  625. SetSentErrorMessage(true);
  626. return false;
  627. }
  628. Player *chr = getSelectedPlayer();
  629. if (chr == NULL)
  630. {
  631. SendSysMessage(LANG_NO_CHAR_SELECTED);
  632. SetSentErrorMessage(true);
  633. return false;
  634. }
  635. // check online security
  636. if (HasLowerSecurity(chr, 0))
  637. return false;
  638. PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink(chr).c_str(), hp, hpm);
  639. if (needReportToTarget(chr))
  640. ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm);
  641. chr->SetMaxHealth( hpm );
  642. chr->SetHealth( hp );
  643. return true;
  644. }
  645. //Edit Player Mana
  646. bool ChatHandler::HandleModifyManaCommand(const char* args)
  647. {
  648. if(!*args)
  649. return false;
  650. // char* pmana = strtok((char*)args, " ");
  651. // if (!pmana)
  652. // return false;
  653. // char* pmanaMax = strtok(NULL, " ");
  654. // if (!pmanaMax)
  655. // return false;
  656. // int32 manam = atoi(pmanaMax);
  657. // int32 mana = atoi(pmana);
  658. int32 mana = atoi((char*)args);
  659. int32 manam = atoi((char*)args);
  660. if (mana <= 0 || manam <= 0 || manam < mana)
  661. {
  662. SendSysMessage(LANG_BAD_VALUE);
  663. SetSentErrorMessage(true);
  664. return false;
  665. }
  666. Player *chr = getSelectedPlayer();
  667. if (chr == NULL)
  668. {
  669. SendSysMessage(LANG_NO_CHAR_SELECTED);
  670. SetSentErrorMessage(true);
  671. return false;
  672. }
  673. // check online security
  674. if (HasLowerSecurity(chr, 0))
  675. return false;
  676. PSendSysMessage(LANG_YOU_CHANGE_MANA, GetNameLink(chr).c_str(), mana, manam);
  677. if (needReportToTarget(chr))
  678. ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam);
  679. chr->SetMaxPower(POWER_MANA,manam );
  680. chr->SetPower(POWER_MANA, mana );
  681. return true;
  682. }
  683. //Edit Player Energy
  684. bool ChatHandler::HandleModifyEnergyCommand(const char* args)
  685. {
  686. if(!*args)
  687. return false;
  688. // char* pmana = strtok((char*)args, " ");
  689. // if (!pmana)
  690. // return false;
  691. // char* pmanaMax = strtok(NULL, " ");
  692. // if (!pmanaMax)
  693. // return false;
  694. // int32 manam = atoi(pmanaMax);
  695. // int32 mana = atoi(pmana);
  696. int32 energy = atoi((char*)args)*10;
  697. int32 energym = atoi((char*)args)*10;
  698. if (energy <= 0 || energym <= 0 || energym < energy)
  699. {
  700. SendSysMessage(LANG_BAD_VALUE);
  701. SetSentErrorMessage(true);
  702. return false;
  703. }
  704. Player *chr = getSelectedPlayer();
  705. if (!chr)
  706. {
  707. SendSysMessage(LANG_NO_CHAR_SELECTED);
  708. SetSentErrorMessage(true);
  709. return false;
  710. }
  711. // check online security
  712. if (HasLowerSecurity(chr, 0))
  713. return false;
  714. PSendSysMessage(LANG_YOU_CHANGE_ENERGY, GetNameLink(chr).c_str(), energy/10, energym/10);
  715. if (needReportToTarget(chr))
  716. ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetNameLink().c_str(), energy/10, energym/10);
  717. chr->SetMaxPower(POWER_ENERGY,energym );
  718. chr->SetPower(POWER_ENERGY, energy );
  719. sLog.outDetail(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY));
  720. return true;
  721. }
  722. //Edit Player Rage
  723. bool ChatHandler::HandleModifyRageCommand(const char* args)
  724. {
  725. if(!*args)
  726. return false;
  727. // char* pmana = strtok((char*)args, " ");
  728. // if (!pmana)
  729. // return false;
  730. // char* pmanaMax = strtok(NULL, " ");
  731. // if (!pmanaMax)
  732. // return false;
  733. // int32 manam = atoi(pmanaMax);
  734. // int32 mana = atoi(pmana);
  735. int32 rage = atoi((char*)args)*10;
  736. int32 ragem = atoi((char*)args)*10;
  737. if (rage <= 0 || ragem <= 0 || ragem < rage)
  738. {
  739. SendSysMessage(LANG_BAD_VALUE);
  740. SetSentErrorMessage(true);
  741. return false;
  742. }
  743. Player *chr = getSelectedPlayer();
  744. if (chr == NULL)
  745. {
  746. SendSysMessage(LANG_NO_CHAR_SELECTED);
  747. SetSentErrorMessage(true);
  748. return false;
  749. }
  750. // check online security
  751. if (HasLowerSecurity(chr, 0))
  752. return false;
  753. PSendSysMessage(LANG_YOU_CHANGE_RAGE, GetNameLink(chr).c_str(), rage/10, ragem/10);
  754. if (needReportToTarget(chr))
  755. ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetNameLink().c_str(), rage/10, ragem/10);
  756. chr->SetMaxPower(POWER_RAGE,ragem );
  757. chr->SetPower(POWER_RAGE, rage );
  758. return true;
  759. }
  760. // Edit Player Runic Power
  761. bool ChatHandler::HandleModifyRunicPowerCommand(const char* args)
  762. {
  763. if(!*args)
  764. return false;
  765. int32 rune = atoi((char*)args)*10;
  766. int32 runem = atoi((char*)args)*10;
  767. if (rune <= 0 || runem <= 0 || runem < rune)
  768. {
  769. SendSysMessage(LANG_BAD_VALUE);
  770. SetSentErrorMessage(true);
  771. return false;
  772. }
  773. Player *chr = getSelectedPlayer();
  774. if (chr == NULL)
  775. {
  776. SendSysMessage(LANG_NO_CHAR_SELECTED);
  777. SetSentErrorMessage(true);
  778. return false;
  779. }
  780. PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, GetNameLink(chr).c_str(), rune/10, runem/10);
  781. if (needReportToTarget(chr))
  782. ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetNameLink().c_str(), rune/10, runem/10);
  783. chr->SetMaxPower(POWER_RUNIC_POWER,runem );
  784. chr->SetPower(POWER_RUNIC_POWER, rune );
  785. return true;
  786. }
  787. //Edit Player Faction
  788. bool ChatHandler::HandleModifyFactionCommand(const char* args)
  789. {
  790. if(!*args)
  791. return false;
  792. char* pfactionid = extractKeyFromLink((char*)args,"Hfaction");
  793. Creature* chr = getSelectedCreature();
  794. if(!chr)
  795. {
  796. SendSysMessage(LANG_SELECT_CREATURE);
  797. SetSentErrorMessage(true);
  798. return false;
  799. }
  800. if(!pfactionid)
  801. {
  802. if(chr)
  803. {
  804. uint32 factionid = chr->getFaction();
  805. uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
  806. uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
  807. uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
  808. PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
  809. }
  810. return true;
  811. }
  812. if( !chr )
  813. {
  814. SendSysMessage(LANG_NO_CHAR_SELECTED);
  815. SetSentErrorMessage(true);
  816. return false;
  817. }
  818. uint32 factionid = atoi(pfactionid);
  819. uint32 flag;
  820. char *pflag = strtok(NULL, " ");
  821. if (!pflag)
  822. flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
  823. else
  824. flag = atoi(pflag);
  825. char* pnpcflag = strtok(NULL, " ");
  826. uint32 npcflag;
  827. if(!pnpcflag)
  828. npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
  829. else
  830. npcflag = atoi(pnpcflag);
  831. char* pdyflag = strtok(NULL, " ");
  832. uint32 dyflag;
  833. if(!pdyflag)
  834. dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
  835. else
  836. dyflag = atoi(pdyflag);
  837. if(!sFactionTemplateStore.LookupEntry(factionid))
  838. {
  839. PSendSysMessage(LANG_WRONG_FACTION, factionid);
  840. SetSentErrorMessage(true);
  841. return false;
  842. }
  843. PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
  844. chr->setFaction(factionid);
  845. chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag);
  846. chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag);
  847. chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag);
  848. return true;
  849. }
  850. //Edit Player Spell
  851. bool ChatHandler::HandleModifySpellCommand(const char* args)
  852. {
  853. if(!*args) return false;
  854. char* pspellflatid = strtok((char*)args, " ");
  855. if (!pspellflatid)
  856. return false;
  857. char* pop = strtok(NULL, " ");
  858. if (!pop)
  859. return false;
  860. char* pval = strtok(NULL, " ");
  861. if (!pval)
  862. return false;
  863. uint16 mark;
  864. char* pmark = strtok(NULL, " ");
  865. uint8 spellflatid = atoi(pspellflatid);
  866. uint8 op = atoi(pop);
  867. uint16 val = atoi(pval);
  868. if(!pmark)
  869. mark = 65535;
  870. else
  871. mark = atoi(pmark);
  872. Player *chr = getSelectedPlayer();
  873. if (chr == NULL)
  874. {
  875. SendSysMessage(LANG_NO_CHAR_SELECTED);
  876. SetSentErrorMessage(true);
  877. return false;
  878. }
  879. // check online security
  880. if (HasLowerSecurity(chr, 0))
  881. return false;
  882. PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, GetNameLink(chr).c_str());
  883. if (needReportToTarget(chr))
  884. ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, GetNameLink().c_str(), spellflatid, val, mark);
  885. WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2));
  886. data << uint8(spellflatid);
  887. data << uint8(op);
  888. data << uint16(val);
  889. data << uint16(mark);
  890. chr->GetSession()->SendPacket(&data);
  891. return true;
  892. }
  893. //Edit Player TP
  894. bool ChatHandler::HandleModifyTalentCommand (const char* args)
  895. {
  896. if (!*args)
  897. return false;
  898. int tp = atoi((char*)args);
  899. if (tp>0)
  900. {
  901. Player* player = getSelectedPlayer();
  902. if(!player)
  903. {
  904. SendSysMessage(LANG_NO_CHAR_SELECTED);
  905. SetSentErrorMessage(true);
  906. return false;
  907. }
  908. // check online security
  909. if (HasLowerSecurity(player, 0))
  910. return false;
  911. player->SetFreeTalentPoints(tp);
  912. return true;
  913. }
  914. return false;
  915. }
  916. //Enable On\OFF all taxi paths
  917. bool ChatHandler::HandleTaxiCheatCommand(const char* args)
  918. {
  919. if (!*args)
  920. {
  921. SendSysMessage(LANG_USE_BOL);
  922. SetSentErrorMessage(true);
  923. return false;
  924. }
  925. std::string argstr = (char*)args;
  926. Player *chr = getSelectedPlayer();
  927. if (!chr)
  928. {
  929. chr=m_session->GetPlayer();
  930. }
  931. // check online security
  932. else if (HasLowerSecurity(chr, 0))
  933. return false;
  934. if (argstr == "on")
  935. {
  936. chr->SetTaxiCheater(true);
  937. PSendSysMessage(LANG_YOU_GIVE_TAXIS, GetNameLink(chr).c_str());
  938. if (needReportToTarget(chr))
  939. ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetNameLink().c_str());
  940. return true;
  941. }
  942. if (argstr == "off")
  943. {
  944. chr->SetTaxiCheater(false);
  945. PSendSysMessage(LANG_YOU_REMOVE_TAXIS, GetNameLink(chr).c_str());
  946. if (needReportToTarget(chr))
  947. ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetNameLink().c_str());
  948. return true;
  949. }
  950. SendSysMessage(LANG_USE_BOL);
  951. SetSentErrorMessage(true);
  952. return false;
  953. }
  954. //Edit Player Aspeed
  955. bool ChatHandler::HandleModifyASpeedCommand(const char* args)
  956. {
  957. if (!*args)
  958. return false;
  959. float ASpeed = (float)atof((char*)args);
  960. if (ASpeed > 10 || ASpeed < 0.1)
  961. {
  962. SendSysMessage(LANG_BAD_VALUE);
  963. SetSentErrorMessage(true);
  964. return false;
  965. }
  966. Player *chr = getSelectedPlayer();
  967. if (chr == NULL)
  968. {
  969. SendSysMessage(LANG_NO_CHAR_SELECTED);
  970. SetSentErrorMessage(true);
  971. return false;
  972. }
  973. // check online security
  974. if (HasLowerSecurity(chr, 0))
  975. return false;
  976. std::string chrNameLink = GetNameLink(chr);
  977. if(chr->isInFlight())
  978. {
  979. PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());
  980. SetSentErrorMessage(true);
  981. return false;
  982. }
  983. PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chrNameLink.c_str());
  984. if (needReportToTarget(chr))
  985. ChatHandler(chr).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, GetNameLink().c_str(), ASpeed);
  986. chr->SetSpeed(MOVE_WALK, ASpeed,true);
  987. chr->SetSpeed(MOVE_RUN, ASpeed,true);
  988. chr->SetSpeed(MOVE_SWIM, ASpeed,true);
  989. //chr->SetSpeed(MOVE_TURN, ASpeed,true);
  990. chr->SetSpeed(MOVE_FLIGHT, ASpeed,true);
  991. return true;
  992. }
  993. //Edit Player Speed
  994. bool ChatHandler::HandleModifySpeedCommand(const char* args)
  995. {
  996. if (!*args)
  997. return false;
  998. float Speed = (float)atof((char*)args);
  999. if (Speed > 10 || Speed < 0.1)
  1000. {
  1001. SendSysMessage(LANG_BAD_VALUE);
  1002. SetSentErrorMessage(true);
  1003. return false;
  1004. }
  1005. Player *chr = getSelectedPlayer();
  1006. if (chr == NULL)
  1007. {
  1008. SendSysMessage(LANG_NO_CHAR_SELECTED);
  1009. SetSentErrorMessage(true);
  1010. return false;
  1011. }
  1012. // check online security
  1013. if (HasLowerSecurity(chr, 0))
  1014. return false;
  1015. std::string chrNameLink = GetNameLink(chr);
  1016. if(chr->isInFlight())
  1017. {
  1018. PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());
  1019. SetSentErrorMessage(true);
  1020. return false;
  1021. }
  1022. PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chrNameLink.c_str());
  1023. if (needReportToTarget(chr))
  1024. ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetNameLink().c_str(), Speed);
  1025. chr->SetSpeed(MOVE_RUN,Speed,true);
  1026. return true;
  1027. }
  1028. //Edit Player Swim Speed
  1029. bool ChatHandler::HandleModifySwimCommand(const char* args)
  1030. {
  1031. if (!*args)
  1032. return false;
  1033. float Swim = (float)atof((char*)args);
  1034. if (Swim > 10.0f || Swim < 0.01f)
  1035. {
  1036. SendSysMessage(LANG_BAD_VALUE);
  1037. SetSentErrorMessage(true);
  1038. return false;
  1039. }
  1040. Player *chr = getSelectedPlayer();
  1041. if (chr == NULL)
  1042. {
  1043. SendSysMessage(LANG_NO_CHAR_SELECTED);
  1044. SetSentErrorMessage(true);
  1045. return false;
  1046. }
  1047. // check online security
  1048. if (HasLowerSecurity(chr, 0))
  1049. return false;
  1050. std::string chrNameLink = GetNameLink(chr);
  1051. if(chr->isInFlight())
  1052. {
  1053. PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());
  1054. SetSentErrorMessage(true);
  1055. return false;
  1056. }
  1057. PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chrNameLink.c_str());
  1058. if (needReportToTarget(chr))
  1059. ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetNameLink().c_str(), Swim);
  1060. chr->SetSpeed(MOVE_SWIM,Swim,true);
  1061. return true;
  1062. }
  1063. //Edit Player Walk Speed
  1064. bool ChatHandler::HandleModifyBWalkCommand(const char* args)
  1065. {
  1066. if (!*args)
  1067. return false;
  1068. float BSpeed = (float)atof((char*)args);
  1069. if (BSpeed > 10.0f || BSpeed < 0.1f)
  1070. {
  1071. SendSysMessage(LANG_BAD_VALUE);
  1072. SetSentErrorMessage(true);
  1073. return false;
  1074. }
  1075. Player *chr = getSelectedPlayer();
  1076. if (chr == NULL)
  1077. {
  1078. SendSysMessage(LANG_NO_CHAR_SELECTED);
  1079. SetSentErrorMessage(true);
  1080. return false;
  1081. }
  1082. // check online security
  1083. if (HasLowerSecurity(chr, 0))
  1084. return false;
  1085. std::string chrNameLink = GetNameLink(chr);
  1086. if(chr->isInFlight())
  1087. {
  1088. PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());
  1089. SetSentErrorMessage(true);
  1090. return false;
  1091. }
  1092. PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chrNameLink.c_str());
  1093. if (needReportToTarget(chr))
  1094. ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetNameLink().c_str(), BSpeed);
  1095. chr->SetSpeed(MOVE_RUN_BACK,BSpeed,true);
  1096. return true;
  1097. }
  1098. //Edit Player Fly
  1099. bool ChatHandler::HandleModifyFlyCommand(const char* args)
  1100. {
  1101. if (!*args)
  1102. return false;
  1103. float FSpeed = (float)atof((char*)args);
  1104. if (FSpeed > 10.0f || FSpeed < 0.1f)
  1105. {
  1106. SendSysMessage(LANG_BAD_VALUE);
  1107. SetSentErrorMessage(true);
  1108. return false;
  1109. }
  1110. Player *chr = getSelectedPlayer();
  1111. if (chr == NULL)
  1112. {
  1113. SendSysMessage(LANG_NO_CHAR_SELECTED);
  1114. SetSentErrorMessage(true);
  1115. return false;
  1116. }
  1117. // check online security
  1118. if (HasLowerSecurity(chr, 0))
  1119. return false;
  1120. PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, GetNameLink(chr).c_str());
  1121. if (needReportToTarget(chr))
  1122. ChatHandler(chr).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, GetNameLink().c_str(), FSpeed);
  1123. chr->SetSpeed(MOVE_FLIGHT,FSpeed,true);
  1124. return true;
  1125. }
  1126. //Edit Player Scale
  1127. bool ChatHandler::HandleModifyScaleCommand(const char* args)
  1128. {
  1129. if (!*args)
  1130. return false;
  1131. float Scale = (float)atof((char*)args);
  1132. if (Scale > 3.0f || Scale <= 0.0f)
  1133. {
  1134. SendSysMessage(LANG_BAD_VALUE);
  1135. SetSentErrorMessage(true);
  1136. return false;
  1137. }
  1138. Player *chr = getSelectedPlayer();
  1139. if (chr == NULL)
  1140. {
  1141. SendSysMessage(LANG_NO_CHAR_SELECTED);
  1142. SetSentErrorMessage(true);
  1143. return false;
  1144. }
  1145. // check online security
  1146. if (HasLowerSecurity(chr, 0))
  1147. return false;
  1148. PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, GetNameLink(chr).c_str());
  1149. if (needReportToTarget(chr))
  1150. ChatHandler(chr).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetNameLink().c_str(), Scale);
  1151. chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale);
  1152. return true;
  1153. }
  1154. //Enable Player mount
  1155. bool ChatHandler::HandleModifyMountCommand(const char* args)
  1156. {
  1157. if(!*args)
  1158. return false;
  1159. uint16 mId = 1147;
  1160. float speed = (float)15;
  1161. uint32 num = 0;
  1162. num = atoi((char*)args);
  1163. switch(num)
  1164. {
  1165. case 1:
  1166. mId=14340;
  1167. break;
  1168. case 2:
  1169. mId=4806;
  1170. break;
  1171. case 3:
  1172. mId=6471;
  1173. break;
  1174. case 4:
  1175. mId=12345;
  1176. break;
  1177. case 5:
  1178. mId=6472;
  1179. break;
  1180. case 6:
  1181. mId=6473;
  1182. break;
  1183. case 7:
  1184. mId=10670;
  1185. break;
  1186. case 8:
  1187. mId=10719;
  1188. break;
  1189. case 9:
  1190. mId=10671;
  1191. break;
  1192. case 10:
  1193. mId=10672;
  1194. break;
  1195. case 11:
  1196. mId=10720;
  1197. break;
  1198. case 12:
  1199. mId=14349;
  1200. break;
  1201. case 13:
  1202. mId=11641;
  1203. break;
  1204. case 14:
  1205. mId=12244;
  1206. break;
  1207. case 15:
  1208. mId=12242;
  1209. break;
  1210. case 16:
  1211. mId=14578;
  1212. break;
  1213. case 17:
  1214. mId=14579;
  1215. break;
  1216. case 18:
  1217. mId=14349;
  1218. break;
  1219. case 19:
  1220. mId=12245;
  1221. break;
  1222. case 20:
  1223. mId=14335;
  1224. break;
  1225. case 21:
  1226. mId=207;
  1227. break;
  1228. case 22:
  1229. mId=2328;
  1230. break;
  1231. case 23:
  1232. mId=2327;
  1233. break;
  1234. case 24:
  1235. mId=2326;
  1236. break;
  1237. case 25:
  1238. mId=14573;
  1239. break;
  1240. case 26:
  1241. mId=14574;
  1242. break;
  1243. case 27:
  1244. mId=14575;
  1245. break;
  1246. case 28:
  1247. mId=604;
  1248. break;
  1249. case 29:
  1250. mId=1166;
  1251. break;
  1252. case 30:
  1253. mId=2402;
  1254. break;
  1255. case 31:
  1256. mId=2410;
  1257. break;
  1258. case 32:
  1259. mId=2409;
  1260. break;
  1261. case 33:
  1262. mId=2408;
  1263. break;
  1264. case 34:
  1265. mId=2405;
  1266. break;
  1267. case 35:
  1268. mId=14337;
  1269. break;
  1270. case 36:
  1271. mId=6569;
  1272. break;
  1273. case 37:
  1274. mId=10661;
  1275. break;
  1276. case 38:
  1277. mId=10666;
  1278. break;
  1279. case 39:
  1280. mId=9473;
  1281. break;
  1282. case 40:
  1283. mId=9476;
  1284. break;
  1285. case 41:
  1286. mId=9474;
  1287. break;
  1288. case 42:
  1289. mId=14374;
  1290. break;
  1291. case 43:
  1292. mId=14376;
  1293. break;
  1294. case 44:
  1295. mId=14377;
  1296. break;
  1297. case 45:
  1298. mId=2404;
  1299. break;
  1300. case 46:
  1301. mId=2784;
  1302. break;
  1303. case 47:
  1304. mId=2787;
  1305. break;
  1306. case 48:
  1307. mId=2785;
  1308. break;
  1309. case 49:
  1310. mId=2736;
  1311. break;
  1312. case 50:
  1313. mId=2786;
  1314. break;
  1315. case 51:
  1316. mId=14347;
  1317. break;
  1318. case 52:
  1319. mId=14346;
  1320. break;
  1321. case 53:
  1322. mId=14576;
  1323. break;
  1324. case 54:
  1325. mId=9695;
  1326. break;
  1327. case 55:
  1328. mId=9991;
  1329. break;
  1330. case 56:
  1331. mId=6448;
  1332. break;
  1333. case 57:
  1334. mId=6444;
  1335. break;
  1336. case 58:
  1337. mId=6080;
  1338. break;
  1339. case 59:
  1340. mId=6447;
  1341. break;
  1342. case 60:
  1343. mId=4805;
  1344. break;
  1345. case 61:
  1346. mId=9714;
  1347. break;
  1348. case 62:
  1349. mId=6448;
  1350. break;
  1351. case 63:
  1352. mId=6442;
  1353. break;
  1354. case 64:
  1355. mId=14632;
  1356. break;
  1357. case 65:
  1358. mId=14332;
  1359. break;
  1360. case 66:
  1361. mId=14331;
  1362. break;
  1363. case 67:
  1364. mId=8469;
  1365. break;
  1366. case 68:
  1367. mId=2830;
  1368. break;
  1369. case 69:
  1370. mId=2346;
  1371. break;
  1372. default:
  1373. SendSysMessage(LANG_NO_MOUNT);
  1374. SetSentErrorMessage(true);
  1375. return false;
  1376. }
  1377. Player *chr = getSelectedPlayer();
  1378. if (chr == NULL)
  1379. {
  1380. SendSysMessage(LANG_NO_CHAR_SELECTED);
  1381. SetSentErrorMessage(true);
  1382. return false;
  1383. }
  1384. // check online security
  1385. if (HasLowerSecurity(chr, 0))
  1386. return false;
  1387. PSendSysMessage(LANG_YOU_GIVE_MOUNT, GetNameLink(chr).c_str());
  1388. if (needReportToTarget(chr))
  1389. ChatHandler(chr).PSendSysMessage(LANG_MOUNT_GIVED, GetNameLink().c_str());
  1390. chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 );
  1391. chr->Mount(mId);
  1392. WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) );
  1393. data.append(chr->GetPackGUID());
  1394. data << (uint32)0;
  1395. data << (uint8)0; //new 2.1.0
  1396. data << float(speed);
  1397. chr->SendMessageToSet( &data, true );
  1398. data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) );
  1399. data.append(chr->GetPackGUID());
  1400. data << (uint32)0;
  1401. data << float(speed);
  1402. chr->SendMessageToSet( &data, true );
  1403. return true;
  1404. }
  1405. //Edit Player money
  1406. bool ChatHandler::HandleModifyMoneyCommand(const char* args)
  1407. {
  1408. if (!*args)
  1409. return false;
  1410. Player *chr = getSelectedPlayer();
  1411. if (chr == NULL)
  1412. {
  1413. SendSysMessage(LANG_NO_CHAR_SELECTED);
  1414. SetSentErrorMessage(true);
  1415. return false;
  1416. }
  1417. // check online security
  1418. if (HasLowerSecurity(chr, 0))
  1419. return false;
  1420. int32 addmoney = atoi((char*)args);
  1421. uint32 moneyuser = chr->GetMoney();
  1422. if(addmoney < 0)
  1423. {
  1424. int32 newmoney = moneyuser + addmoney;
  1425. sLog.outDetail(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney);
  1426. if(newmoney <= 0 )
  1427. {
  1428. PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, GetNameLink(chr).c_str());
  1429. if (needReportToTarget(chr))
  1430. ChatHandler(chr).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, GetNameLink().c_str());
  1431. chr->SetMoney(0);
  1432. }
  1433. else
  1434. {
  1435. PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), GetNameLink(chr).c_str());
  1436. if (needReportToTarget(chr))
  1437. ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetNameLink().c_str(), abs(addmoney));
  1438. chr->SetMoney( newmoney );
  1439. }
  1440. }
  1441. else
  1442. {
  1443. PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, GetNameLink(chr).c_str());
  1444. if (needReportToTarget(chr))
  1445. ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, GetNameLink().c_str(), addmoney);
  1446. chr->ModifyMoney( addmoney );
  1447. }
  1448. sLog.outDetail(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() );
  1449. return true;
  1450. }
  1451. //Edit Unit field
  1452. bool ChatHandler::HandleModifyBitCommand(const char* args)
  1453. {
  1454. if( !*args )
  1455. return false;
  1456. Unit *unit = getSelectedUnit();
  1457. if (!unit)
  1458. {
  1459. SendSysMessage(LANG_NO_CHAR_SELECTED);
  1460. SetSentErrorMessage(true);
  1461. return false;
  1462. }
  1463. // check online security
  1464. if (unit->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player *)unit, 0))
  1465. return false;
  1466. char* pField = strtok((char*)args, " ");
  1467. if (!pField)
  1468. return false;
  1469. char* pBit = strtok(NULL, " ");
  1470. if (!pBit)
  1471. return false;
  1472. uint16 field = atoi(pField);
  1473. uint32 bit = atoi(pBit);
  1474. if (field < OBJECT_END || field >= unit->GetValuesCount())
  1475. {
  1476. SendSysMessage(LANG_BAD_VALUE);
  1477. SetSentErrorMessage(true);
  1478. return false;
  1479. }
  1480. if (bit < 1 || bit > 32)
  1481. {
  1482. SendSysMessage(LANG_BAD_VALUE);
  1483. SetSentErrorMessage(true);
  1484. return false;
  1485. }
  1486. if ( unit->HasFlag( field, (1<<(bit-1)) ) )
  1487. {
  1488. unit->RemoveFlag( field, (1<<(bit-1)) );
  1489. PSendSysMessage(LANG_REMOVE_BIT, bit, field);
  1490. }
  1491. else
  1492. {
  1493. unit->SetFlag( field, (1<<(bit-1)) );
  1494. PSendSysMessage(LANG_SET_BIT, bit, field);
  1495. }
  1496. return true;
  1497. }
  1498. bool ChatHandler::HandleModifyHonorCommand (const char* args)
  1499. {
  1500. if (!*args)
  1501. return false;
  1502. Player *target = getSelectedPlayer();
  1503. if(!target)
  1504. {
  1505. SendSysMessage(LANG_PLAYER_NOT_FOUND);
  1506. SetSentErrorMessage(true);
  1507. return false;
  1508. }
  1509. // check online security
  1510. if (HasLowerSecurity(target, 0))
  1511. return false;
  1512. int32 amount = (uint32)atoi(args);
  1513. target->ModifyHonorPoints(amount);
  1514. PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, GetNameLink(target).c_str(), target->GetHonorPoints());
  1515. return true;
  1516. }
  1517. bool ChatHandler::HandleTeleCommand(const char * args)
  1518. {
  1519. if(!*args)
  1520. return false;
  1521. Player* _player = m_session->GetPlayer();
  1522. // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
  1523. GameTele const* tele = extractGameTeleFromLink((char*)args);
  1524. if (!tele)
  1525. {
  1526. SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
  1527. SetSentErrorMessage(true);
  1528. return false;
  1529. }
  1530. // stop flight if need
  1531. if(_player->isInFlight())
  1532. {
  1533. _player->GetMotionMaster()->MovementExpired();
  1534. _player->m_taxi.ClearTaxiDestinations();
  1535. }
  1536. // save only in non-flight case
  1537. else
  1538. _player->SaveRecallPosition();
  1539. _player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
  1540. return true;
  1541. }
  1542. bool ChatHandler::HandleLookupAreaCommand(const char* args)
  1543. {
  1544. if (!*args)
  1545. return false;
  1546. std::string namepart = args;
  1547. std::wstring wnamepart;
  1548. if (!Utf8toWStr (namepart,wnamepart))
  1549. return false;
  1550. uint32 counter = 0; // Counter for figure out that we found smth.
  1551. // converting string that we try to find to lower case
  1552. wstrToLower (wnamepart);
  1553. // Search in AreaTable.dbc
  1554. for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag)
  1555. {
  1556. AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag);
  1557. if (areaEntry)
  1558. {
  1559. int loc = m_session ? m_session->GetSessionDbcLocale () : sWorld.GetDefaultDbcLocale();
  1560. std::string name = areaEntry->area_name[loc];
  1561. if (name.empty())
  1562. continue;
  1563. if (!Utf8FitTo (name, wnamepart))
  1564. {
  1565. loc = 0;
  1566. for(;

Large files files are truncated, but you can click here to view the full file