Use configuration values for arena directly instead of values cached in local variabl...
[getmangos.git] / src / game / Level1.cpp
blob04639eda83bcde7642ea46f4b0f1c93eb4a92bf4
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
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.
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.
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
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"
34 #include "Util.h"
35 #ifdef _DEBUG_VMAPS
36 #include "VMapFactory.h"
37 #endif
39 bool ChatHandler::HandleNpcSayCommand(const char* args)
41 if(!*args)
42 return false;
44 Creature* pCreature = getSelectedCreature();
45 if(!pCreature)
47 SendSysMessage(LANG_SELECT_CREATURE);
48 SetSentErrorMessage(true);
49 return false;
52 pCreature->Say(args, LANG_UNIVERSAL, 0);
54 return true;
57 bool ChatHandler::HandleNpcYellCommand(const char* args)
59 if(!*args)
60 return false;
62 Creature* pCreature = getSelectedCreature();
63 if(!pCreature)
65 SendSysMessage(LANG_SELECT_CREATURE);
66 SetSentErrorMessage(true);
67 return false;
70 pCreature->Yell(args, LANG_UNIVERSAL, 0);
72 return true;
75 //show text emote by creature in chat
76 bool ChatHandler::HandleNpcTextEmoteCommand(const char* args)
78 if(!*args)
79 return false;
81 Creature* pCreature = getSelectedCreature();
83 if(!pCreature)
85 SendSysMessage(LANG_SELECT_CREATURE);
86 SetSentErrorMessage(true);
87 return false;
90 pCreature->TextEmote(args, 0);
92 return true;
95 // make npc whisper to player
96 bool ChatHandler::HandleNpcWhisperCommand(const char* args)
98 if(!*args)
99 return false;
101 char* receiver_str = strtok((char*)args, " ");
102 char* text = strtok(NULL, "");
104 uint64 guid = m_session->GetPlayer()->GetSelection();
105 Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid);
107 if(!pCreature || !receiver_str || !text)
109 return false;
112 uint64 receiver_guid= atol(receiver_str);
114 // check online security
115 if (HasLowerSecurity(objmgr.GetPlayer(receiver_guid), 0))
116 return false;
118 pCreature->Whisper(text,receiver_guid);
120 return true;
123 // global announce
124 bool ChatHandler::HandleAnnounceCommand(const char* args)
126 if(!*args)
127 return false;
129 sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args);
130 return true;
133 //notification player at the screen
134 bool ChatHandler::HandleNotifyCommand(const char* args)
136 if(!*args)
137 return false;
139 std::string str = GetMangosString(LANG_GLOBAL_NOTIFY);
140 str += args;
142 WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
143 data << str;
144 sWorld.SendGlobalMessage(&data);
146 return true;
149 //Enable\Dissable GM Mode
150 bool ChatHandler::HandleGMmodeCommand(const char* args)
152 if(!*args)
154 if(m_session->GetPlayer()->isGameMaster())
155 m_session->SendNotification(LANG_GM_ON);
156 else
157 m_session->SendNotification(LANG_GM_OFF);
158 return true;
161 std::string argstr = (char*)args;
163 if (argstr == "on")
165 m_session->GetPlayer()->SetGameMaster(true);
166 m_session->SendNotification(LANG_GM_ON);
167 #ifdef _DEBUG_VMAPS
168 VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
169 vMapManager->processCommand("stoplog");
170 #endif
171 return true;
174 if (argstr == "off")
176 m_session->GetPlayer()->SetGameMaster(false);
177 m_session->SendNotification(LANG_GM_OFF);
178 #ifdef _DEBUG_VMAPS
179 VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
180 vMapManager->processCommand("startlog");
181 #endif
182 return true;
185 SendSysMessage(LANG_USE_BOL);
186 SetSentErrorMessage(true);
187 return false;
190 // Enables or disables hiding of the staff badge
191 bool ChatHandler::HandleGMChatCommand(const char* args)
193 if(!*args)
195 if(m_session->GetPlayer()->isGMChat())
196 m_session->SendNotification(LANG_GM_CHAT_ON);
197 else
198 m_session->SendNotification(LANG_GM_CHAT_OFF);
199 return true;
202 std::string argstr = (char*)args;
204 if (argstr == "on")
206 m_session->GetPlayer()->SetGMChat(true);
207 m_session->SendNotification(LANG_GM_CHAT_ON);
208 return true;
211 if (argstr == "off")
213 m_session->GetPlayer()->SetGMChat(false);
214 m_session->SendNotification(LANG_GM_CHAT_OFF);
215 return true;
218 SendSysMessage(LANG_USE_BOL);
219 SetSentErrorMessage(true);
220 return false;
223 //Enable\Dissable Invisible mode
224 bool ChatHandler::HandleVisibleCommand(const char* args)
226 if (!*args)
228 PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetMangosString(LANG_VISIBLE) : GetMangosString(LANG_INVISIBLE));
229 return true;
232 std::string argstr = (char*)args;
234 if (argstr == "on")
236 m_session->GetPlayer()->SetGMVisible(true);
237 m_session->SendNotification(LANG_INVISIBLE_VISIBLE);
238 return true;
241 if (argstr == "off")
243 m_session->SendNotification(LANG_INVISIBLE_INVISIBLE);
244 m_session->GetPlayer()->SetGMVisible(false);
245 return true;
248 SendSysMessage(LANG_USE_BOL);
249 SetSentErrorMessage(true);
250 return false;
253 bool ChatHandler::HandleGPSCommand(const char* args)
255 WorldObject *obj = NULL;
256 if (*args)
258 std::string name = args;
259 if(normalizePlayerName(name))
260 obj = objmgr.GetPlayer(name.c_str());
262 if(!obj)
264 SendSysMessage(LANG_PLAYER_NOT_FOUND);
265 SetSentErrorMessage(true);
266 return false;
269 else
271 obj = getSelectedUnit();
273 if(!obj)
275 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
276 SetSentErrorMessage(true);
277 return false;
280 CellPair cell_val = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
281 Cell cell(cell_val);
283 uint32 zone_id = obj->GetZoneId();
284 uint32 area_id = obj->GetAreaId();
286 MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId());
287 AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id);
288 AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id);
290 float zone_x = obj->GetPositionX();
291 float zone_y = obj->GetPositionY();
293 Map2ZoneCoordinates(zone_x,zone_y,zone_id);
295 Map const *map = obj->GetMap();
296 float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
297 float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
299 GridPair p = MaNGOS::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY());
301 int gx=63-p.x_coord;
302 int gy=63-p.y_coord;
304 uint32 have_map = Map::ExistMap(obj->GetMapId(),gx,gy) ? 1 : 0;
305 uint32 have_vmap = Map::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0;
307 PSendSysMessage(LANG_MAP_POSITION,
308 obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
309 zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
310 area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
311 obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
312 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
313 zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );
315 sLog.outDebug("Player %s GPS call for %s '%s' (%s: %u):",
316 GetName(),
317 (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(),
318 (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) );
320 sLog.outDebug(GetMangosString(LANG_MAP_POSITION),
321 obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
322 zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
323 area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
324 obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
325 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
326 zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );
328 return true;
331 //Summon Player
332 bool ChatHandler::HandleNamegoCommand(const char* args)
334 if(!*args)
335 return false;
337 std::string name = args;
339 if(!normalizePlayerName(name))
341 SendSysMessage(LANG_PLAYER_NOT_FOUND);
342 SetSentErrorMessage(true);
343 return false;
346 Player *chr = objmgr.GetPlayer(name.c_str());
347 if (chr)
349 // check online security
350 if (HasLowerSecurity(chr, 0))
351 return false;
353 if(chr->IsBeingTeleported()==true)
355 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
356 SetSentErrorMessage(true);
357 return false;
360 Map* pMap = m_session->GetPlayer()->GetMap();
362 if(pMap->IsBattleGroundOrArena())
364 // cannot summon to bg
365 PSendSysMessage(LANG_CANNOT_SUMMON_TO_BG,chr->GetName());
366 SetSentErrorMessage(true);
367 return false;
369 else if(pMap->IsDungeon())
371 Map* cMap = chr->GetMap();
372 if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() )
374 // cannot summon from instance to instance
375 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName());
376 SetSentErrorMessage(true);
377 return false;
380 // we are in instance, and can summon only player in our group with us as lead
381 if ( !m_session->GetPlayer()->GetGroup() || !chr->GetGroup() ||
382 (chr->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
383 (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) )
384 // the last check is a bit excessive, but let it be, just in case
386 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName());
387 SetSentErrorMessage(true);
388 return false;
392 PSendSysMessage(LANG_SUMMONING, chr->GetName(),"");
393 if (needReportToTarget(chr))
394 ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, GetName());
396 // stop flight if need
397 if(chr->isInFlight())
399 chr->GetMotionMaster()->MovementExpired();
400 chr->m_taxi.ClearTaxiDestinations();
402 // save only in non-flight case
403 else
404 chr->SaveRecallPosition();
406 // before GM
407 float x,y,z;
408 m_session->GetPlayer()->GetClosePoint(x,y,z,chr->GetObjectSize());
409 chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation());
411 else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
413 // check offline security
414 if (HasLowerSecurity(NULL, guid))
415 return false;
417 PSendSysMessage(LANG_SUMMONING, name.c_str(),GetMangosString(LANG_OFFLINE));
419 // in point where GM stay
420 Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(),
421 m_session->GetPlayer()->GetPositionX(),
422 m_session->GetPlayer()->GetPositionY(),
423 m_session->GetPlayer()->GetPositionZ(),
424 m_session->GetPlayer()->GetOrientation(),
425 m_session->GetPlayer()->GetZoneId(),
426 guid);
428 else
430 PSendSysMessage(LANG_NO_PLAYER, args);
431 SetSentErrorMessage(true);
434 return true;
437 //Teleport to Player
438 bool ChatHandler::HandleGonameCommand(const char* args)
440 if(!*args)
441 return false;
443 Player* _player = m_session->GetPlayer();
445 std::string name = args;
447 if(!normalizePlayerName(name))
449 SendSysMessage(LANG_PLAYER_NOT_FOUND);
450 SetSentErrorMessage(true);
451 return false;
454 Player *chr = objmgr.GetPlayer(name.c_str());
455 if (chr)
457 // check online security
458 if (HasLowerSecurity(chr, 0))
459 return false;
461 Map* cMap = chr->GetMap();
462 if(cMap->IsBattleGroundOrArena())
464 // only allow if gm mode is on
465 if (!_player->isGameMaster())
467 PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,chr->GetName());
468 SetSentErrorMessage(true);
469 return false;
471 // if already in a bg, don't let port to other
472 else if (_player->GetBattleGroundId())
474 PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chr->GetName());
475 SetSentErrorMessage(true);
476 return false;
478 // all's well, set bg id
479 // when porting out from the bg, it will be reset to 0
480 _player->SetBattleGroundId(chr->GetBattleGroundId());
482 else if(cMap->IsDungeon())
483 Map* cMap = chr->GetMap();
484 if(cMap->Instanceable())
486 // we have to go to instance, and can go to player only if:
487 // 1) we are in his group (either as leader or as member)
488 // 2) we are not bound to any group and have GM mode on
489 if (_player->GetGroup())
491 // we are in group, we can go only if we are in the player group
492 if (_player->GetGroup() != chr->GetGroup())
494 PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName());
495 SetSentErrorMessage(true);
496 return false;
499 else
501 // we are not in group, let's verify our GM mode
502 if (!_player->isGameMaster())
504 PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName());
505 SetSentErrorMessage(true);
506 return false;
510 // if the player or the player's group is bound to another instance
511 // the player will not be bound to another one
512 InstancePlayerBind *pBind = _player->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty());
513 if(!pBind)
515 Group *group = _player->GetGroup();
516 InstanceGroupBind *gBind = group ? group->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()) : NULL;
517 if(!gBind)
519 // if no bind exists, create a solo bind
520 InstanceSave *save = sInstanceSaveManager.GetInstanceSave(chr->GetInstanceId());
521 if(save) _player->BindToInstance(save, !save->CanReset());
525 _player->SetDifficulty(chr->GetDifficulty());
528 PSendSysMessage(LANG_APPEARING_AT, chr->GetName());
530 if (_player->IsVisibleGloballyFor(chr))
531 ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, _player->GetName());
533 // stop flight if need
534 if(_player->isInFlight())
536 _player->GetMotionMaster()->MovementExpired();
537 _player->m_taxi.ClearTaxiDestinations();
539 // save only in non-flight case
540 else
541 _player->SaveRecallPosition();
543 // to point to see at target with same orientation
544 float x,y,z;
545 chr->GetContactPoint(m_session->GetPlayer(),x,y,z);
547 _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), TELE_TO_GM_MODE);
549 return true;
552 if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
554 // check offline security
555 if (HasLowerSecurity(NULL, guid))
556 return false;
558 PSendSysMessage(LANG_APPEARING_AT, name.c_str());
560 // to point where player stay (if loaded)
561 float x,y,z,o;
562 uint32 map;
563 bool in_flight;
564 if(Player::LoadPositionFromDB(map,x,y,z,o,in_flight,guid))
566 // stop flight if need
567 if(_player->isInFlight())
569 _player->GetMotionMaster()->MovementExpired();
570 _player->m_taxi.ClearTaxiDestinations();
572 // save only in non-flight case
573 else
574 _player->SaveRecallPosition();
576 _player->TeleportTo(map, x, y, z,_player->GetOrientation());
577 return true;
581 PSendSysMessage(LANG_NO_PLAYER, args);
583 SetSentErrorMessage(true);
584 return false;
587 // Teleport player to last position
588 bool ChatHandler::HandleRecallCommand(const char* args)
590 Player* chr = NULL;
592 if(!*args)
594 chr = getSelectedPlayer();
595 if(!chr)
596 chr = m_session->GetPlayer();
598 // check online security
599 else if (HasLowerSecurity(chr, 0))
600 return false;
602 else
604 std::string name = args;
606 if(!normalizePlayerName(name))
608 SendSysMessage(LANG_PLAYER_NOT_FOUND);
609 SetSentErrorMessage(true);
610 return false;
613 chr = objmgr.GetPlayer(name.c_str());
615 if(!chr)
617 PSendSysMessage(LANG_NO_PLAYER, args);
618 SetSentErrorMessage(true);
619 return false;
622 // check online security
623 if (HasLowerSecurity(chr, 0))
624 return false;
627 if(chr->IsBeingTeleported())
629 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
630 SetSentErrorMessage(true);
631 return false;
634 // stop flight if need
635 if(chr->isInFlight())
637 chr->GetMotionMaster()->MovementExpired();
638 chr->m_taxi.ClearTaxiDestinations();
641 chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO);
642 return true;
645 //Edit Player KnownTitles
646 bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args)
648 if(!*args)
649 return false;
651 uint64 titles = 0;
653 sscanf((char*)args, I64FMTD, &titles);
655 Player *chr = getSelectedPlayer();
656 if (!chr)
658 SendSysMessage(LANG_NO_CHAR_SELECTED);
659 SetSentErrorMessage(true);
660 return false;
663 // check online security
664 if (HasLowerSecurity(chr, 0))
665 return false;
667 uint64 titles2 = titles;
669 for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i)
670 if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
671 titles2 &= ~(uint64(1) << tEntry->bit_index);
673 titles &= ~titles2; // remove not existed titles
675 chr->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles);
676 SendSysMessage(LANG_DONE);
678 return true;
681 //Edit Player HP
682 bool ChatHandler::HandleModifyHPCommand(const char* args)
684 if(!*args)
685 return false;
687 // char* pHp = strtok((char*)args, " ");
688 // if (!pHp)
689 // return false;
691 // char* pHpMax = strtok(NULL, " ");
692 // if (!pHpMax)
693 // return false;
695 // int32 hpm = atoi(pHpMax);
696 // int32 hp = atoi(pHp);
698 int32 hp = atoi((char*)args);
699 int32 hpm = atoi((char*)args);
701 if (hp <= 0 || hpm <= 0 || hpm < hp)
703 SendSysMessage(LANG_BAD_VALUE);
704 SetSentErrorMessage(true);
705 return false;
708 Player *chr = getSelectedPlayer();
709 if (chr == NULL)
711 SendSysMessage(LANG_NO_CHAR_SELECTED);
712 SetSentErrorMessage(true);
713 return false;
716 // check online security
717 if (HasLowerSecurity(chr, 0))
718 return false;
720 PSendSysMessage(LANG_YOU_CHANGE_HP, chr->GetName(), hp, hpm);
721 if (needReportToTarget(chr))
722 ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetName(), hp, hpm);
724 chr->SetMaxHealth( hpm );
725 chr->SetHealth( hp );
727 return true;
730 //Edit Player Mana
731 bool ChatHandler::HandleModifyManaCommand(const char* args)
733 if(!*args)
734 return false;
736 // char* pmana = strtok((char*)args, " ");
737 // if (!pmana)
738 // return false;
740 // char* pmanaMax = strtok(NULL, " ");
741 // if (!pmanaMax)
742 // return false;
744 // int32 manam = atoi(pmanaMax);
745 // int32 mana = atoi(pmana);
746 int32 mana = atoi((char*)args);
747 int32 manam = atoi((char*)args);
749 if (mana <= 0 || manam <= 0 || manam < mana)
751 SendSysMessage(LANG_BAD_VALUE);
752 SetSentErrorMessage(true);
753 return false;
756 Player *chr = getSelectedPlayer();
757 if (chr == NULL)
759 SendSysMessage(LANG_NO_CHAR_SELECTED);
760 SetSentErrorMessage(true);
761 return false;
764 // check online security
765 if (HasLowerSecurity(chr, 0))
766 return false;
768 PSendSysMessage(LANG_YOU_CHANGE_MANA, chr->GetName(), mana, manam);
769 if (needReportToTarget(chr))
770 ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetName(), mana, manam);
772 chr->SetMaxPower(POWER_MANA,manam );
773 chr->SetPower(POWER_MANA, mana );
775 return true;
778 //Edit Player Energy
779 bool ChatHandler::HandleModifyEnergyCommand(const char* args)
781 if(!*args)
782 return false;
784 // char* pmana = strtok((char*)args, " ");
785 // if (!pmana)
786 // return false;
788 // char* pmanaMax = strtok(NULL, " ");
789 // if (!pmanaMax)
790 // return false;
792 // int32 manam = atoi(pmanaMax);
793 // int32 mana = atoi(pmana);
795 int32 energy = atoi((char*)args)*10;
796 int32 energym = atoi((char*)args)*10;
798 if (energy <= 0 || energym <= 0 || energym < energy)
800 SendSysMessage(LANG_BAD_VALUE);
801 SetSentErrorMessage(true);
802 return false;
805 Player *chr = getSelectedPlayer();
806 if (!chr)
808 SendSysMessage(LANG_NO_CHAR_SELECTED);
809 SetSentErrorMessage(true);
810 return false;
813 // check online security
814 if (HasLowerSecurity(chr, 0))
815 return false;
817 PSendSysMessage(LANG_YOU_CHANGE_ENERGY, chr->GetName(), energy/10, energym/10);
818 if (needReportToTarget(chr))
819 ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetName(), energy/10, energym/10);
821 chr->SetMaxPower(POWER_ENERGY,energym );
822 chr->SetPower(POWER_ENERGY, energy );
824 sLog.outDetail(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY));
826 return true;
829 //Edit Player Rage
830 bool ChatHandler::HandleModifyRageCommand(const char* args)
832 if(!*args)
833 return false;
835 // char* pmana = strtok((char*)args, " ");
836 // if (!pmana)
837 // return false;
839 // char* pmanaMax = strtok(NULL, " ");
840 // if (!pmanaMax)
841 // return false;
843 // int32 manam = atoi(pmanaMax);
844 // int32 mana = atoi(pmana);
846 int32 rage = atoi((char*)args)*10;
847 int32 ragem = atoi((char*)args)*10;
849 if (rage <= 0 || ragem <= 0 || ragem < rage)
851 SendSysMessage(LANG_BAD_VALUE);
852 SetSentErrorMessage(true);
853 return false;
856 Player *chr = getSelectedPlayer();
857 if (chr == NULL)
859 SendSysMessage(LANG_NO_CHAR_SELECTED);
860 SetSentErrorMessage(true);
861 return false;
864 // check online security
865 if (HasLowerSecurity(chr, 0))
866 return false;
868 PSendSysMessage(LANG_YOU_CHANGE_RAGE, chr->GetName(), rage/10, ragem/10);
869 if (needReportToTarget(chr))
870 ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetName(), rage/10, ragem/10);
872 chr->SetMaxPower(POWER_RAGE,ragem );
873 chr->SetPower(POWER_RAGE, rage );
875 return true;
878 // Edit Player Runic Power
879 bool ChatHandler::HandleModifyRunicPowerCommand(const char* args)
881 if(!*args)
882 return false;
884 int32 rune = atoi((char*)args)*10;
885 int32 runem = atoi((char*)args)*10;
887 if (rune <= 0 || runem <= 0 || runem < rune)
889 SendSysMessage(LANG_BAD_VALUE);
890 SetSentErrorMessage(true);
891 return false;
894 Player *chr = getSelectedPlayer();
895 if (chr == NULL)
897 SendSysMessage(LANG_NO_CHAR_SELECTED);
898 SetSentErrorMessage(true);
899 return false;
902 PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, chr->GetName(), rune/10, runem/10);
903 if (needReportToTarget(chr))
904 ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetName(), rune/10, runem/10);
906 chr->SetMaxPower(POWER_RUNIC_POWER,runem );
907 chr->SetPower(POWER_RUNIC_POWER, rune );
909 return true;
912 //Edit Player Faction
913 bool ChatHandler::HandleModifyFactionCommand(const char* args)
915 if(!*args)
916 return false;
918 char* pfactionid = extractKeyFromLink((char*)args,"Hfaction");
920 Creature* chr = getSelectedCreature();
921 if(!chr)
923 SendSysMessage(LANG_SELECT_CREATURE);
924 SetSentErrorMessage(true);
925 return false;
928 if(!pfactionid)
930 if(chr)
932 uint32 factionid = chr->getFaction();
933 uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
934 uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
935 uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
936 PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
938 return true;
941 if( !chr )
943 SendSysMessage(LANG_NO_CHAR_SELECTED);
944 SetSentErrorMessage(true);
945 return false;
948 uint32 factionid = atoi(pfactionid);
949 uint32 flag;
951 char *pflag = strtok(NULL, " ");
952 if (!pflag)
953 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
954 else
955 flag = atoi(pflag);
957 char* pnpcflag = strtok(NULL, " ");
959 uint32 npcflag;
960 if(!pnpcflag)
961 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
962 else
963 npcflag = atoi(pnpcflag);
965 char* pdyflag = strtok(NULL, " ");
967 uint32 dyflag;
968 if(!pdyflag)
969 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
970 else
971 dyflag = atoi(pdyflag);
973 if(!sFactionTemplateStore.LookupEntry(factionid))
975 PSendSysMessage(LANG_WRONG_FACTION, factionid);
976 SetSentErrorMessage(true);
977 return false;
980 PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
982 chr->setFaction(factionid);
983 chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag);
984 chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag);
985 chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag);
987 return true;
990 //Edit Player Spell
991 bool ChatHandler::HandleModifySpellCommand(const char* args)
993 if(!*args) return false;
994 char* pspellflatid = strtok((char*)args, " ");
995 if (!pspellflatid)
996 return false;
998 char* pop = strtok(NULL, " ");
999 if (!pop)
1000 return false;
1002 char* pval = strtok(NULL, " ");
1003 if (!pval)
1004 return false;
1006 uint16 mark;
1008 char* pmark = strtok(NULL, " ");
1010 uint8 spellflatid = atoi(pspellflatid);
1011 uint8 op = atoi(pop);
1012 uint16 val = atoi(pval);
1013 if(!pmark)
1014 mark = 65535;
1015 else
1016 mark = atoi(pmark);
1018 Player *chr = getSelectedPlayer();
1019 if (chr == NULL)
1021 SendSysMessage(LANG_NO_CHAR_SELECTED);
1022 SetSentErrorMessage(true);
1023 return false;
1026 // check online security
1027 if (HasLowerSecurity(chr, 0))
1028 return false;
1030 PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, chr->GetName());
1031 if (needReportToTarget(chr))
1032 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, GetName(), spellflatid, val, mark);
1034 WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2));
1035 data << uint8(spellflatid);
1036 data << uint8(op);
1037 data << uint16(val);
1038 data << uint16(mark);
1039 chr->GetSession()->SendPacket(&data);
1041 return true;
1044 //Edit Player TP
1045 bool ChatHandler::HandleModifyTalentCommand (const char* args)
1047 if (!*args)
1048 return false;
1050 int tp = atoi((char*)args);
1051 if (tp>0)
1053 Player* player = getSelectedPlayer();
1054 if(!player)
1056 SendSysMessage(LANG_NO_CHAR_SELECTED);
1057 SetSentErrorMessage(true);
1058 return false;
1061 // check online security
1062 if (HasLowerSecurity(player, 0))
1063 return false;
1065 player->SetFreeTalentPoints(tp);
1066 return true;
1068 return false;
1071 //Enable On\OFF all taxi paths
1072 bool ChatHandler::HandleTaxiCheatCommand(const char* args)
1074 if (!*args)
1076 SendSysMessage(LANG_USE_BOL);
1077 SetSentErrorMessage(true);
1078 return false;
1081 std::string argstr = (char*)args;
1083 Player *chr = getSelectedPlayer();
1084 if (!chr)
1086 chr=m_session->GetPlayer();
1089 // check online security
1090 else if (HasLowerSecurity(chr, 0))
1091 return false;
1093 if (argstr == "on")
1095 chr->SetTaxiCheater(true);
1096 PSendSysMessage(LANG_YOU_GIVE_TAXIS, chr->GetName());
1097 if (needReportToTarget(chr))
1098 ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetName());
1099 return true;
1102 if (argstr == "off")
1104 chr->SetTaxiCheater(false);
1105 PSendSysMessage(LANG_YOU_REMOVE_TAXIS, chr->GetName());
1106 if (needReportToTarget(chr))
1107 ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetName());
1109 return true;
1112 SendSysMessage(LANG_USE_BOL);
1113 SetSentErrorMessage(true);
1114 return false;
1117 //Edit Player Aspeed
1118 bool ChatHandler::HandleModifyASpeedCommand(const char* args)
1120 if (!*args)
1121 return false;
1123 float ASpeed = (float)atof((char*)args);
1125 if (ASpeed > 10 || ASpeed < 0.1)
1127 SendSysMessage(LANG_BAD_VALUE);
1128 SetSentErrorMessage(true);
1129 return false;
1132 Player *chr = getSelectedPlayer();
1133 if (chr == NULL)
1135 SendSysMessage(LANG_NO_CHAR_SELECTED);
1136 SetSentErrorMessage(true);
1137 return false;
1140 // check online security
1141 if (HasLowerSecurity(chr, 0))
1142 return false;
1144 if(chr->isInFlight())
1146 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1147 SetSentErrorMessage(true);
1148 return false;
1151 PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName());
1152 if (needReportToTarget(chr))
1153 ChatHandler(chr).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, GetName(), ASpeed);
1155 chr->SetSpeed(MOVE_WALK, ASpeed,true);
1156 chr->SetSpeed(MOVE_RUN, ASpeed,true);
1157 chr->SetSpeed(MOVE_SWIM, ASpeed,true);
1158 //chr->SetSpeed(MOVE_TURN, ASpeed,true);
1159 chr->SetSpeed(MOVE_FLIGHT, ASpeed,true);
1160 return true;
1163 //Edit Player Speed
1164 bool ChatHandler::HandleModifySpeedCommand(const char* args)
1166 if (!*args)
1167 return false;
1169 float Speed = (float)atof((char*)args);
1171 if (Speed > 10 || Speed < 0.1)
1173 SendSysMessage(LANG_BAD_VALUE);
1174 SetSentErrorMessage(true);
1175 return false;
1178 Player *chr = getSelectedPlayer();
1179 if (chr == NULL)
1181 SendSysMessage(LANG_NO_CHAR_SELECTED);
1182 SetSentErrorMessage(true);
1183 return false;
1186 // check online security
1187 if (HasLowerSecurity(chr, 0))
1188 return false;
1190 if(chr->isInFlight())
1192 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1193 SetSentErrorMessage(true);
1194 return false;
1197 PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chr->GetName());
1198 if (needReportToTarget(chr))
1199 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetName(), Speed);
1201 chr->SetSpeed(MOVE_RUN,Speed,true);
1203 return true;
1206 //Edit Player Swim Speed
1207 bool ChatHandler::HandleModifySwimCommand(const char* args)
1209 if (!*args)
1210 return false;
1212 float Swim = (float)atof((char*)args);
1214 if (Swim > 10.0f || Swim < 0.01f)
1216 SendSysMessage(LANG_BAD_VALUE);
1217 SetSentErrorMessage(true);
1218 return false;
1221 Player *chr = getSelectedPlayer();
1222 if (chr == NULL)
1224 SendSysMessage(LANG_NO_CHAR_SELECTED);
1225 SetSentErrorMessage(true);
1226 return false;
1229 // check online security
1230 if (HasLowerSecurity(chr, 0))
1231 return false;
1233 if(chr->isInFlight())
1235 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1236 SetSentErrorMessage(true);
1237 return false;
1240 PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chr->GetName());
1241 if (needReportToTarget(chr))
1242 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetName(), Swim);
1244 chr->SetSpeed(MOVE_SWIM,Swim,true);
1246 return true;
1249 //Edit Player Walk Speed
1250 bool ChatHandler::HandleModifyBWalkCommand(const char* args)
1252 if (!*args)
1253 return false;
1255 float BSpeed = (float)atof((char*)args);
1257 if (BSpeed > 10.0f || BSpeed < 0.1f)
1259 SendSysMessage(LANG_BAD_VALUE);
1260 SetSentErrorMessage(true);
1261 return false;
1264 Player *chr = getSelectedPlayer();
1265 if (chr == NULL)
1267 SendSysMessage(LANG_NO_CHAR_SELECTED);
1268 SetSentErrorMessage(true);
1269 return false;
1272 // check online security
1273 if (HasLowerSecurity(chr, 0))
1274 return false;
1276 if(chr->isInFlight())
1278 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1279 SetSentErrorMessage(true);
1280 return false;
1283 PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chr->GetName());
1284 if (needReportToTarget(chr))
1285 ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetName(), BSpeed);
1287 chr->SetSpeed(MOVE_RUN_BACK,BSpeed,true);
1289 return true;
1292 //Edit Player Fly
1293 bool ChatHandler::HandleModifyFlyCommand(const char* args)
1295 if (!*args)
1296 return false;
1298 float FSpeed = (float)atof((char*)args);
1300 if (FSpeed > 10.0f || FSpeed < 0.1f)
1302 SendSysMessage(LANG_BAD_VALUE);
1303 SetSentErrorMessage(true);
1304 return false;
1307 Player *chr = getSelectedPlayer();
1308 if (chr == NULL)
1310 SendSysMessage(LANG_NO_CHAR_SELECTED);
1311 SetSentErrorMessage(true);
1312 return false;
1315 // check online security
1316 if (HasLowerSecurity(chr, 0))
1317 return false;
1319 PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, chr->GetName());
1320 if (needReportToTarget(chr))
1321 ChatHandler(chr).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, GetName(), FSpeed);
1323 chr->SetSpeed(MOVE_FLIGHT,FSpeed,true);
1325 return true;
1328 //Edit Player Scale
1329 bool ChatHandler::HandleModifyScaleCommand(const char* args)
1331 if (!*args)
1332 return false;
1334 float Scale = (float)atof((char*)args);
1335 if (Scale > 3.0f || Scale <= 0.0f)
1337 SendSysMessage(LANG_BAD_VALUE);
1338 SetSentErrorMessage(true);
1339 return false;
1342 Player *chr = getSelectedPlayer();
1343 if (chr == NULL)
1345 SendSysMessage(LANG_NO_CHAR_SELECTED);
1346 SetSentErrorMessage(true);
1347 return false;
1350 // check online security
1351 if (HasLowerSecurity(chr, 0))
1352 return false;
1354 PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, chr->GetName());
1355 if (needReportToTarget(chr))
1356 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetName(), Scale);
1358 chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale);
1360 return true;
1363 //Enable Player mount
1364 bool ChatHandler::HandleModifyMountCommand(const char* args)
1366 if(!*args)
1367 return false;
1369 uint16 mId = 1147;
1370 float speed = (float)15;
1371 uint32 num = 0;
1373 num = atoi((char*)args);
1374 switch(num)
1376 case 1:
1377 mId=14340;
1378 break;
1379 case 2:
1380 mId=4806;
1381 break;
1382 case 3:
1383 mId=6471;
1384 break;
1385 case 4:
1386 mId=12345;
1387 break;
1388 case 5:
1389 mId=6472;
1390 break;
1391 case 6:
1392 mId=6473;
1393 break;
1394 case 7:
1395 mId=10670;
1396 break;
1397 case 8:
1398 mId=10719;
1399 break;
1400 case 9:
1401 mId=10671;
1402 break;
1403 case 10:
1404 mId=10672;
1405 break;
1406 case 11:
1407 mId=10720;
1408 break;
1409 case 12:
1410 mId=14349;
1411 break;
1412 case 13:
1413 mId=11641;
1414 break;
1415 case 14:
1416 mId=12244;
1417 break;
1418 case 15:
1419 mId=12242;
1420 break;
1421 case 16:
1422 mId=14578;
1423 break;
1424 case 17:
1425 mId=14579;
1426 break;
1427 case 18:
1428 mId=14349;
1429 break;
1430 case 19:
1431 mId=12245;
1432 break;
1433 case 20:
1434 mId=14335;
1435 break;
1436 case 21:
1437 mId=207;
1438 break;
1439 case 22:
1440 mId=2328;
1441 break;
1442 case 23:
1443 mId=2327;
1444 break;
1445 case 24:
1446 mId=2326;
1447 break;
1448 case 25:
1449 mId=14573;
1450 break;
1451 case 26:
1452 mId=14574;
1453 break;
1454 case 27:
1455 mId=14575;
1456 break;
1457 case 28:
1458 mId=604;
1459 break;
1460 case 29:
1461 mId=1166;
1462 break;
1463 case 30:
1464 mId=2402;
1465 break;
1466 case 31:
1467 mId=2410;
1468 break;
1469 case 32:
1470 mId=2409;
1471 break;
1472 case 33:
1473 mId=2408;
1474 break;
1475 case 34:
1476 mId=2405;
1477 break;
1478 case 35:
1479 mId=14337;
1480 break;
1481 case 36:
1482 mId=6569;
1483 break;
1484 case 37:
1485 mId=10661;
1486 break;
1487 case 38:
1488 mId=10666;
1489 break;
1490 case 39:
1491 mId=9473;
1492 break;
1493 case 40:
1494 mId=9476;
1495 break;
1496 case 41:
1497 mId=9474;
1498 break;
1499 case 42:
1500 mId=14374;
1501 break;
1502 case 43:
1503 mId=14376;
1504 break;
1505 case 44:
1506 mId=14377;
1507 break;
1508 case 45:
1509 mId=2404;
1510 break;
1511 case 46:
1512 mId=2784;
1513 break;
1514 case 47:
1515 mId=2787;
1516 break;
1517 case 48:
1518 mId=2785;
1519 break;
1520 case 49:
1521 mId=2736;
1522 break;
1523 case 50:
1524 mId=2786;
1525 break;
1526 case 51:
1527 mId=14347;
1528 break;
1529 case 52:
1530 mId=14346;
1531 break;
1532 case 53:
1533 mId=14576;
1534 break;
1535 case 54:
1536 mId=9695;
1537 break;
1538 case 55:
1539 mId=9991;
1540 break;
1541 case 56:
1542 mId=6448;
1543 break;
1544 case 57:
1545 mId=6444;
1546 break;
1547 case 58:
1548 mId=6080;
1549 break;
1550 case 59:
1551 mId=6447;
1552 break;
1553 case 60:
1554 mId=4805;
1555 break;
1556 case 61:
1557 mId=9714;
1558 break;
1559 case 62:
1560 mId=6448;
1561 break;
1562 case 63:
1563 mId=6442;
1564 break;
1565 case 64:
1566 mId=14632;
1567 break;
1568 case 65:
1569 mId=14332;
1570 break;
1571 case 66:
1572 mId=14331;
1573 break;
1574 case 67:
1575 mId=8469;
1576 break;
1577 case 68:
1578 mId=2830;
1579 break;
1580 case 69:
1581 mId=2346;
1582 break;
1583 default:
1584 SendSysMessage(LANG_NO_MOUNT);
1585 SetSentErrorMessage(true);
1586 return false;
1589 Player *chr = getSelectedPlayer();
1590 if (chr == NULL)
1592 SendSysMessage(LANG_NO_CHAR_SELECTED);
1593 SetSentErrorMessage(true);
1594 return false;
1597 // check online security
1598 if (HasLowerSecurity(chr, 0))
1599 return false;
1601 PSendSysMessage(LANG_YOU_GIVE_MOUNT, chr->GetName());
1602 if (needReportToTarget(chr))
1603 ChatHandler(chr).PSendSysMessage(LANG_MOUNT_GIVED, GetName());
1605 chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 );
1606 chr->Mount(mId);
1608 WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) );
1609 data.append(chr->GetPackGUID());
1610 data << (uint32)0;
1611 data << (uint8)0; //new 2.1.0
1612 data << float(speed);
1613 chr->SendMessageToSet( &data, true );
1615 data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) );
1616 data.append(chr->GetPackGUID());
1617 data << (uint32)0;
1618 data << float(speed);
1619 chr->SendMessageToSet( &data, true );
1621 return true;
1624 //Edit Player money
1625 bool ChatHandler::HandleModifyMoneyCommand(const char* args)
1627 if (!*args)
1628 return false;
1630 Player *chr = getSelectedPlayer();
1631 if (chr == NULL)
1633 SendSysMessage(LANG_NO_CHAR_SELECTED);
1634 SetSentErrorMessage(true);
1635 return false;
1638 // check online security
1639 if (HasLowerSecurity(chr, 0))
1640 return false;
1642 int32 addmoney = atoi((char*)args);
1644 uint32 moneyuser = chr->GetMoney();
1646 if(addmoney < 0)
1648 int32 newmoney = moneyuser + addmoney;
1650 sLog.outDetail(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney);
1651 if(newmoney <= 0 )
1653 PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName());
1654 if (needReportToTarget(chr))
1655 ChatHandler(chr).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, GetName());
1657 chr->SetMoney(0);
1659 else
1661 PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), chr->GetName());
1662 if (needReportToTarget(chr))
1663 ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetName(), abs(addmoney));
1664 chr->SetMoney( newmoney );
1667 else
1669 PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, chr->GetName());
1670 if (needReportToTarget(chr))
1671 ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, GetName(), addmoney);
1672 chr->ModifyMoney( addmoney );
1675 sLog.outDetail(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() );
1677 return true;
1680 //Edit Unit field
1681 bool ChatHandler::HandleModifyBitCommand(const char* args)
1683 if( !*args )
1684 return false;
1686 Unit *unit = getSelectedUnit();
1687 if (!unit)
1689 SendSysMessage(LANG_NO_CHAR_SELECTED);
1690 SetSentErrorMessage(true);
1691 return false;
1694 // check online security
1695 if (unit->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player *)unit, 0))
1696 return false;
1698 char* pField = strtok((char*)args, " ");
1699 if (!pField)
1700 return false;
1702 char* pBit = strtok(NULL, " ");
1703 if (!pBit)
1704 return false;
1706 uint16 field = atoi(pField);
1707 uint32 bit = atoi(pBit);
1709 if (field < OBJECT_END || field >= unit->GetValuesCount())
1711 SendSysMessage(LANG_BAD_VALUE);
1712 SetSentErrorMessage(true);
1713 return false;
1715 if (bit < 1 || bit > 32)
1717 SendSysMessage(LANG_BAD_VALUE);
1718 SetSentErrorMessage(true);
1719 return false;
1722 if ( unit->HasFlag( field, (1<<(bit-1)) ) )
1724 unit->RemoveFlag( field, (1<<(bit-1)) );
1725 PSendSysMessage(LANG_REMOVE_BIT, bit, field);
1727 else
1729 unit->SetFlag( field, (1<<(bit-1)) );
1730 PSendSysMessage(LANG_SET_BIT, bit, field);
1732 return true;
1735 bool ChatHandler::HandleModifyHonorCommand (const char* args)
1737 if (!*args)
1738 return false;
1740 Player *target = getSelectedPlayer();
1741 if(!target)
1743 SendSysMessage(LANG_PLAYER_NOT_FOUND);
1744 SetSentErrorMessage(true);
1745 return false;
1748 // check online security
1749 if (HasLowerSecurity(target, 0))
1750 return false;
1752 int32 amount = (uint32)atoi(args);
1754 target->ModifyHonorPoints(amount);
1756 PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, target->GetName(), target->GetHonorPoints());
1758 return true;
1761 bool ChatHandler::HandleTeleCommand(const char * args)
1763 if(!*args)
1764 return false;
1766 Player* _player = m_session->GetPlayer();
1768 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
1769 GameTele const* tele = extractGameTeleFromLink((char*)args);
1771 if (!tele)
1773 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
1774 SetSentErrorMessage(true);
1775 return false;
1778 // stop flight if need
1779 if(_player->isInFlight())
1781 _player->GetMotionMaster()->MovementExpired();
1782 _player->m_taxi.ClearTaxiDestinations();
1784 // save only in non-flight case
1785 else
1786 _player->SaveRecallPosition();
1788 _player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
1789 return true;
1792 bool ChatHandler::HandleLookupAreaCommand(const char* args)
1794 if (!*args)
1795 return false;
1797 std::string namepart = args;
1798 std::wstring wnamepart;
1800 if (!Utf8toWStr (namepart,wnamepart))
1801 return false;
1803 uint32 counter = 0; // Counter for figure out that we found smth.
1805 // converting string that we try to find to lower case
1806 wstrToLower (wnamepart);
1808 // Search in AreaTable.dbc
1809 for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag)
1811 AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag);
1812 if (areaEntry)
1814 int loc = m_session ? m_session->GetSessionDbcLocale () : sWorld.GetDefaultDbcLocale();
1815 std::string name = areaEntry->area_name[loc];
1816 if (name.empty())
1817 continue;
1819 if (!Utf8FitTo (name, wnamepart))
1821 loc = 0;
1822 for(; loc < MAX_LOCALE; ++loc)
1824 if (m_session && loc==m_session->GetSessionDbcLocale ())
1825 continue;
1827 name = areaEntry->area_name[loc];
1828 if (name.empty ())
1829 continue;
1831 if (Utf8FitTo (name, wnamepart))
1832 break;
1836 if (loc < MAX_LOCALE)
1838 // send area in "id - [name]" format
1839 std::ostringstream ss;
1840 if (m_session)
1841 ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r";
1842 else
1843 ss << areaEntry->ID << " - " << name << " " << localeNames[loc];
1845 SendSysMessage (ss.str ().c_str());
1847 ++counter;
1852 if (counter == 0) // if counter == 0 then we found nth
1853 SendSysMessage (LANG_COMMAND_NOAREAFOUND);
1855 return true;
1858 //Find tele in game_tele order by name
1859 bool ChatHandler::HandleLookupTeleCommand(const char * args)
1861 if(!*args)
1863 SendSysMessage(LANG_COMMAND_TELE_PARAMETER);
1864 SetSentErrorMessage(true);
1865 return false;
1868 char const* str = strtok((char*)args, " ");
1869 if(!str)
1870 return false;
1872 std::string namepart = str;
1873 std::wstring wnamepart;
1875 if(!Utf8toWStr(namepart,wnamepart))
1876 return false;
1878 // converting string that we try to find to lower case
1879 wstrToLower( wnamepart );
1881 std::ostringstream reply;
1883 GameTeleMap const & teleMap = objmgr.GetGameTeleMap();
1884 for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr)
1886 GameTele const* tele = &itr->second;
1888 if(tele->wnameLow.find(wnamepart) == std::wstring::npos)
1889 continue;
1891 if (m_session)
1892 reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n";
1893 else
1894 reply << " " << itr->first << " " << tele->name << "\n";
1897 if(reply.str().empty())
1898 SendSysMessage(LANG_COMMAND_TELE_NOLOCATION);
1899 else
1900 PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str());
1902 return true;
1905 //Enable\Dissable accept whispers (for GM)
1906 bool ChatHandler::HandleWhispersCommand(const char* args)
1908 if(!*args)
1910 PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF));
1911 return true;
1914 std::string argstr = (char*)args;
1915 // whisper on
1916 if (argstr == "on")
1918 m_session->GetPlayer()->SetAcceptWhispers(true);
1919 SendSysMessage(LANG_COMMAND_WHISPERON);
1920 return true;
1923 // whisper off
1924 if (argstr == "off")
1926 m_session->GetPlayer()->SetAcceptWhispers(false);
1927 SendSysMessage(LANG_COMMAND_WHISPEROFF);
1928 return true;
1931 SendSysMessage(LANG_USE_BOL);
1932 SetSentErrorMessage(true);
1933 return false;
1936 //Play sound
1937 bool ChatHandler::HandlePlaySoundCommand(const char* args)
1939 // USAGE: .debug playsound #soundid
1940 // #soundid - ID decimal number from SoundEntries.dbc (1st column)
1941 // this file have about 5000 sounds.
1942 // In this realization only caller can hear this sound.
1943 if( *args )
1945 uint32 dwSoundId = atoi((char*)args);
1947 if( !sSoundEntriesStore.LookupEntry(dwSoundId) )
1949 PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
1950 SetSentErrorMessage(true);
1951 return false;
1954 WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8);
1955 data << uint32(dwSoundId) << m_session->GetPlayer()->GetGUID();
1956 m_session->SendPacket(&data);
1958 PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
1959 return true;
1962 return false;
1965 //Save all players in the world
1966 bool ChatHandler::HandleSaveAllCommand(const char* /*args*/)
1968 ObjectAccessor::Instance().SaveAllPlayers();
1969 SendSysMessage(LANG_PLAYERS_SAVED);
1970 return true;
1973 //Send mail by command
1974 bool ChatHandler::HandleSendMailCommand(const char* args)
1976 if(!*args)
1977 return false;
1979 // format: name "subject text" "mail text"
1981 char* pName = strtok((char*)args, " ");
1982 if(!pName)
1983 return false;
1985 char* tail1 = strtok(NULL, "");
1986 if(!tail1)
1987 return false;
1989 char* msgSubject;
1990 if(*tail1=='"')
1991 msgSubject = strtok(tail1+1, "\"");
1992 else
1994 char* space = strtok(tail1, "\"");
1995 if(!space)
1996 return false;
1997 msgSubject = strtok(NULL, "\"");
2000 if (!msgSubject)
2001 return false;
2003 char* tail2 = strtok(NULL, "");
2004 if(!tail2)
2005 return false;
2007 char* msgText;
2008 if(*tail2=='"')
2009 msgText = strtok(tail2+1, "\"");
2010 else
2012 char* space = strtok(tail2, "\"");
2013 if(!space)
2014 return false;
2015 msgText = strtok(NULL, "\"");
2018 if (!msgText)
2019 return false;
2021 // pName, msgSubject, msgText isn't NUL after prev. check
2022 std::string name = pName;
2023 std::string subject = msgSubject;
2024 std::string text = msgText;
2026 if(!normalizePlayerName(name))
2028 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2029 SetSentErrorMessage(true);
2030 return false;
2033 uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name);
2034 if(!receiver_guid)
2036 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2037 SetSentErrorMessage(true);
2038 return false;
2041 // from console show not existed sender
2042 uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0;
2044 uint32 messagetype = MAIL_NORMAL;
2045 uint32 stationery = MAIL_STATIONERY_GM;
2046 uint32 itemTextId = !text.empty() ? objmgr.CreateItemText( text ) : 0;
2048 Player *receiver = objmgr.GetPlayer(receiver_guid);
2050 WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE);
2052 PSendSysMessage(LANG_MAIL_SENT, name.c_str());
2053 return true;
2056 // teleport player to given game_tele.entry
2057 bool ChatHandler::HandleNameTeleCommand(const char * args)
2059 if(!*args)
2060 return false;
2062 char* pName = strtok((char*)args, " ");
2064 if(!pName)
2065 return false;
2067 std::string name = pName;
2069 if(!normalizePlayerName(name))
2071 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2072 SetSentErrorMessage(true);
2073 return false;
2076 char* tail = strtok(NULL, "");
2077 if(!tail)
2078 return false;
2080 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
2081 GameTele const* tele = extractGameTeleFromLink(tail);
2082 if(!tele)
2084 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
2085 SetSentErrorMessage(true);
2086 return false;
2089 Player *chr = objmgr.GetPlayer(name.c_str());
2090 if (chr)
2092 // check online security
2093 if (HasLowerSecurity(chr, 0))
2094 return false;
2096 if(chr->IsBeingTeleported()==true)
2098 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
2099 SetSentErrorMessage(true);
2100 return false;
2103 PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", tele->name.c_str());
2104 if (needReportToTarget(chr))
2105 ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetName());
2107 // stop flight if need
2108 if(chr->isInFlight())
2110 chr->GetMotionMaster()->MovementExpired();
2111 chr->m_taxi.ClearTaxiDestinations();
2113 // save only in non-flight case
2114 else
2115 chr->SaveRecallPosition();
2117 chr->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);
2119 else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()))
2121 // check offline security
2122 if (HasLowerSecurity(NULL, guid))
2123 return false;
2125 PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str());
2126 Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,
2127 MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),guid);
2129 else
2130 PSendSysMessage(LANG_NO_PLAYER, name.c_str());
2132 return true;
2135 //Teleport group to given game_tele.entry
2136 bool ChatHandler::HandleGroupTeleCommand(const char * args)
2138 if(!*args)
2139 return false;
2141 Player *player = getSelectedPlayer();
2142 if (!player)
2144 SendSysMessage(LANG_NO_CHAR_SELECTED);
2145 SetSentErrorMessage(true);
2146 return false;
2149 // check online security
2150 if (HasLowerSecurity(player, 0))
2151 return false;
2153 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
2154 GameTele const* tele = extractGameTeleFromLink((char*)args);
2155 if(!tele)
2157 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
2158 SetSentErrorMessage(true);
2159 return false;
2162 Group *grp = player->GetGroup();
2163 if(!grp)
2165 PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName());
2166 SetSentErrorMessage(true);
2167 return false;
2170 for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
2172 Player *pl = itr->getSource();
2174 if(!pl || !pl->GetSession() )
2175 continue;
2177 // check online security
2178 if (HasLowerSecurity(pl, 0))
2179 return false;
2181 if(pl->IsBeingTeleported())
2183 PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName());
2184 continue;
2187 PSendSysMessage(LANG_TELEPORTING_TO, pl->GetName(),"", tele->name.c_str());
2188 if (needReportToTarget(pl))
2189 ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetName());
2191 // stop flight if need
2192 if(pl->isInFlight())
2194 pl->GetMotionMaster()->MovementExpired();
2195 pl->m_taxi.ClearTaxiDestinations();
2197 // save only in non-flight case
2198 else
2199 pl->SaveRecallPosition();
2201 pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
2204 return true;
2207 //Summon group of player
2208 bool ChatHandler::HandleGroupgoCommand(const char* args)
2210 if(!*args)
2211 return false;
2213 std::string name = args;
2215 if(!normalizePlayerName(name))
2217 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2218 SetSentErrorMessage(true);
2219 return false;
2222 Player *player = objmgr.GetPlayer(name.c_str());
2223 if (!player)
2225 PSendSysMessage(LANG_NO_PLAYER, args);
2226 SetSentErrorMessage(true);
2227 return false;
2230 // check online security
2231 if (HasLowerSecurity(player, 0))
2232 return false;
2234 Group *grp = player->GetGroup();
2236 if(!grp)
2238 PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName());
2239 SetSentErrorMessage(true);
2240 return false;
2243 Map* gmMap = m_session->GetPlayer()->GetMap();
2244 bool to_instance = gmMap->Instanceable();
2246 // we are in instance, and can summon only player in our group with us as lead
2247 if ( to_instance && (
2248 !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
2249 (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) )
2250 // the last check is a bit excessive, but let it be, just in case
2252 SendSysMessage(LANG_CANNOT_SUMMON_TO_INST);
2253 SetSentErrorMessage(true);
2254 return false;
2257 for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
2259 Player *pl = itr->getSource();
2261 if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() )
2262 continue;
2264 // check online security
2265 if (HasLowerSecurity(pl, 0))
2266 return false;
2268 if(pl->IsBeingTeleported()==true)
2270 PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName());
2271 SetSentErrorMessage(true);
2272 return false;
2275 if (to_instance)
2277 Map* plMap = pl->GetMap();
2279 if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() )
2281 // cannot summon from instance to instance
2282 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,pl->GetName());
2283 SetSentErrorMessage(true);
2284 return false;
2288 PSendSysMessage(LANG_SUMMONING, pl->GetName(),"");
2289 if (needReportToTarget(pl))
2290 ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, GetName());
2292 // stop flight if need
2293 if(pl->isInFlight())
2295 pl->GetMotionMaster()->MovementExpired();
2296 pl->m_taxi.ClearTaxiDestinations();
2298 // save only in non-flight case
2299 else
2300 pl->SaveRecallPosition();
2302 // before GM
2303 float x,y,z;
2304 m_session->GetPlayer()->GetClosePoint(x,y,z,pl->GetObjectSize());
2305 pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation());
2308 return true;
2311 //teleport at coordinates
2312 bool ChatHandler::HandleGoXYCommand(const char* args)
2314 if(!*args)
2315 return false;
2317 Player* _player = m_session->GetPlayer();
2319 char* px = strtok((char*)args, " ");
2320 char* py = strtok(NULL, " ");
2321 char* pmapid = strtok(NULL, " ");
2323 if (!px || !py)
2324 return false;
2326 float x = (float)atof(px);
2327 float y = (float)atof(py);
2328 uint32 mapid;
2329 if (pmapid)
2330 mapid = (uint32)atoi(pmapid);
2331 else mapid = _player->GetMapId();
2333 if(!MapManager::IsValidMapCoord(mapid,x,y))
2335 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2336 SetSentErrorMessage(true);
2337 return false;
2340 // stop flight if need
2341 if(_player->isInFlight())
2343 _player->GetMotionMaster()->MovementExpired();
2344 _player->m_taxi.ClearTaxiDestinations();
2346 // save only in non-flight case
2347 else
2348 _player->SaveRecallPosition();
2350 Map const *map = MapManager::Instance().GetBaseMap(mapid);
2351 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2353 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2355 return true;
2358 //teleport at coordinates, including Z
2359 bool ChatHandler::HandleGoXYZCommand(const char* args)
2361 if(!*args)
2362 return false;
2364 Player* _player = m_session->GetPlayer();
2366 char* px = strtok((char*)args, " ");
2367 char* py = strtok(NULL, " ");
2368 char* pz = strtok(NULL, " ");
2369 char* pmapid = strtok(NULL, " ");
2371 if (!px || !py || !pz)
2372 return false;
2374 float x = (float)atof(px);
2375 float y = (float)atof(py);
2376 float z = (float)atof(pz);
2377 uint32 mapid;
2378 if (pmapid)
2379 mapid = (uint32)atoi(pmapid);
2380 else
2381 mapid = _player->GetMapId();
2383 if(!MapManager::IsValidMapCoord(mapid,x,y,z))
2385 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2386 SetSentErrorMessage(true);
2387 return false;
2390 // stop flight if need
2391 if(_player->isInFlight())
2393 _player->GetMotionMaster()->MovementExpired();
2394 _player->m_taxi.ClearTaxiDestinations();
2396 // save only in non-flight case
2397 else
2398 _player->SaveRecallPosition();
2400 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2402 return true;
2405 //teleport at coordinates
2406 bool ChatHandler::HandleGoZoneXYCommand(const char* args)
2408 if(!*args)
2409 return false;
2411 Player* _player = m_session->GetPlayer();
2413 char* px = strtok((char*)args, " ");
2414 char* py = strtok(NULL, " ");
2415 char* tail = strtok(NULL,"");
2417 char* cAreaId = extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
2419 if (!px || !py)
2420 return false;
2422 float x = (float)atof(px);
2423 float y = (float)atof(py);
2424 uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId();
2426 AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid);
2428 if( x<0 || x>100 || y<0 || y>100 || !areaEntry )
2430 PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid);
2431 SetSentErrorMessage(true);
2432 return false;
2435 // update to parent zone if exist (client map show only zones without parents)
2436 AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry;
2438 Map const *map = MapManager::Instance().GetBaseMap(zoneEntry->mapid);
2440 if(map->Instanceable())
2442 PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[m_session->GetSessionDbcLocale()],map->GetId(),map->GetMapName());
2443 SetSentErrorMessage(true);
2444 return false;
2447 Zone2MapCoordinates(x,y,zoneEntry->ID);
2449 if(!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y))
2451 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid);
2452 SetSentErrorMessage(true);
2453 return false;
2456 // stop flight if need
2457 if(_player->isInFlight())
2459 _player->GetMotionMaster()->MovementExpired();
2460 _player->m_taxi.ClearTaxiDestinations();
2462 // save only in non-flight case
2463 else
2464 _player->SaveRecallPosition();
2466 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2467 _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation());
2469 return true;
2472 //teleport to grid
2473 bool ChatHandler::HandleGoGridCommand(const char* args)
2475 if(!*args) return false;
2476 Player* _player = m_session->GetPlayer();
2478 char* px = strtok((char*)args, " ");
2479 char* py = strtok(NULL, " ");
2480 char* pmapid = strtok(NULL, " ");
2482 if (!px || !py)
2483 return false;
2485 float grid_x = (float)atof(px);
2486 float grid_y = (float)atof(py);
2487 uint32 mapid;
2488 if (pmapid)
2489 mapid = (uint32)atoi(pmapid);
2490 else mapid = _player->GetMapId();
2492 // center of grid
2493 float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
2494 float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
2496 if(!MapManager::IsValidMapCoord(mapid,x,y))
2498 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2499 SetSentErrorMessage(true);
2500 return false;
2503 // stop flight if need
2504 if(_player->isInFlight())
2506 _player->GetMotionMaster()->MovementExpired();
2507 _player->m_taxi.ClearTaxiDestinations();
2509 // save only in non-flight case
2510 else
2511 _player->SaveRecallPosition();
2513 Map const *map = MapManager::Instance().GetBaseMap(mapid);
2514 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2515 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2517 return true;
2520 bool ChatHandler::HandleDrunkCommand(const char* args)
2522 if(!*args) return false;
2524 uint32 drunklevel = (uint32)atoi(args);
2525 if(drunklevel > 100)
2526 drunklevel = 100;
2528 uint16 drunkMod = drunklevel * 0xFFFF / 100;
2530 m_session->GetPlayer()->SetDrunkValue(drunkMod);
2532 return true;