Show not available command with available subcommands in 'help' and 'commands' output.
[getmangos.git] / src / game / Level1.cpp
blob57330eefffe2e335650c1e59cfec4222c0aaaab6
1 /*
2 * Copyright (C) 2005-2008 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::HandleSayCommand(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::HandleYellCommand(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::HandleTextEmoteCommand(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 pCreature->Whisper(text,receiver_guid);
116 return true;
119 // global announce
120 bool ChatHandler::HandleAnnounceCommand(const char* args)
122 if(!*args)
123 return false;
125 sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args);
126 return true;
129 //notification player at the screen
130 bool ChatHandler::HandleNotifyCommand(const char* args)
132 if(!*args)
133 return false;
135 std::string str = GetMangosString(LANG_GLOBAL_NOTIFY);
136 str += args;
138 WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
139 data << str;
140 sWorld.SendGlobalMessage(&data);
142 return true;
145 //Enable\Dissable GM Mode
146 bool ChatHandler::HandleGMmodeCommand(const char* args)
148 if(!*args)
150 if(m_session->GetPlayer()->isGameMaster())
151 m_session->SendNotification(LANG_GM_ON);
152 else
153 m_session->SendNotification(LANG_GM_OFF);
154 return true;
157 std::string argstr = (char*)args;
159 if (argstr == "on")
161 m_session->GetPlayer()->SetGameMaster(true);
162 m_session->SendNotification(LANG_GM_ON);
163 #ifdef _DEBUG_VMAPS
164 VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
165 vMapManager->processCommand("stoplog");
166 #endif
167 return true;
170 if (argstr == "off")
172 m_session->GetPlayer()->SetGameMaster(false);
173 m_session->SendNotification(LANG_GM_OFF);
174 #ifdef _DEBUG_VMAPS
175 VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
176 vMapManager->processCommand("startlog");
177 #endif
178 return true;
181 SendSysMessage(LANG_USE_BOL);
182 SetSentErrorMessage(true);
183 return false;
186 // Enables or disables hiding of the staff badge
187 bool ChatHandler::HandleGMChatCommand(const char* args)
189 if(!*args)
191 if(m_session->GetPlayer()->isGMChat())
192 m_session->SendNotification(LANG_GM_CHAT_ON);
193 else
194 m_session->SendNotification(LANG_GM_CHAT_OFF);
195 return true;
198 std::string argstr = (char*)args;
200 if (argstr == "on")
202 m_session->GetPlayer()->SetGMChat(true);
203 m_session->SendNotification(LANG_GM_CHAT_ON);
204 return true;
207 if (argstr == "off")
209 m_session->GetPlayer()->SetGMChat(false);
210 m_session->SendNotification(LANG_GM_CHAT_OFF);
211 return true;
214 SendSysMessage(LANG_USE_BOL);
215 SetSentErrorMessage(true);
216 return false;
219 //Enable\Dissable Invisible mode
220 bool ChatHandler::HandleVisibleCommand(const char* args)
222 if (!*args)
224 PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetMangosString(LANG_VISIBLE) : GetMangosString(LANG_INVISIBLE));
225 return true;
228 std::string argstr = (char*)args;
230 if (argstr == "on")
232 m_session->GetPlayer()->SetGMVisible(true);
233 m_session->SendNotification(LANG_INVISIBLE_VISIBLE);
234 return true;
237 if (argstr == "off")
239 m_session->SendNotification(LANG_INVISIBLE_INVISIBLE);
240 m_session->GetPlayer()->SetGMVisible(false);
241 return true;
244 SendSysMessage(LANG_USE_BOL);
245 SetSentErrorMessage(true);
246 return false;
249 bool ChatHandler::HandleGPSCommand(const char* args)
251 WorldObject *obj = NULL;
252 if (*args)
254 std::string name = args;
255 if(normalizePlayerName(name))
256 obj = objmgr.GetPlayer(name.c_str());
258 if(!obj)
260 SendSysMessage(LANG_PLAYER_NOT_FOUND);
261 SetSentErrorMessage(true);
262 return false;
265 else
267 obj = getSelectedUnit();
269 if(!obj)
271 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
272 SetSentErrorMessage(true);
273 return false;
276 CellPair cell_val = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
277 Cell cell(cell_val);
279 uint32 zone_id = obj->GetZoneId();
280 uint32 area_id = obj->GetAreaId();
282 MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId());
283 AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id);
284 AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id);
286 float zone_x = obj->GetPositionX();
287 float zone_y = obj->GetPositionY();
289 Map2ZoneCoordinates(zone_x,zone_y,zone_id);
291 Map const *map = MapManager::Instance().GetMap(obj->GetMapId(), obj);
292 float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
293 float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
295 GridPair p = MaNGOS::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY());
297 int gx=63-p.x_coord;
298 int gy=63-p.y_coord;
300 uint32 have_map = Map::ExistMap(obj->GetMapId(),gx,gy) ? 1 : 0;
301 uint32 have_vmap = Map::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0;
303 PSendSysMessage(LANG_MAP_POSITION,
304 obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
305 zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
306 area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
307 obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
308 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
309 zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );
311 sLog.outDebug("Player %s GPS call for %s '%s' (%s: %u):",
312 m_session->GetPlayer()->GetName(),
313 (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(),
314 (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) );
315 sLog.outDebug(GetMangosString(LANG_MAP_POSITION),
316 obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
317 zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
318 area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
319 obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
320 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
321 zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );
323 return true;
326 //Summon Player
327 bool ChatHandler::HandleNamegoCommand(const char* args)
329 if(!*args)
330 return false;
332 std::string name = args;
334 if(!normalizePlayerName(name))
336 SendSysMessage(LANG_PLAYER_NOT_FOUND);
337 SetSentErrorMessage(true);
338 return false;
341 Player *chr = objmgr.GetPlayer(name.c_str());
342 if (chr)
344 if(chr->IsBeingTeleported()==true)
346 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
347 SetSentErrorMessage(true);
348 return false;
351 Map* pMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer());
353 if(pMap->Instanceable())
355 Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr);
356 if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() )
358 // cannot summon from instance to instance
359 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName());
360 SetSentErrorMessage(true);
361 return false;
364 // we are in instance, and can summon only player in our group with us as lead
365 if ( !m_session->GetPlayer()->GetGroup() || !chr->GetGroup() ||
366 (chr->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
367 (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) )
368 // the last check is a bit excessive, but let it be, just in case
370 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName());
371 SetSentErrorMessage(true);
372 return false;
376 PSendSysMessage(LANG_SUMMONING, chr->GetName(),"");
378 if (m_session->GetPlayer()->IsVisibleGloballyFor(chr))
379 ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, m_session->GetPlayer()->GetName());
381 // stop flight if need
382 if(chr->isInFlight())
384 chr->GetMotionMaster()->MovementExpired();
385 chr->m_taxi.ClearTaxiDestinations();
387 // save only in non-flight case
388 else
389 chr->SaveRecallPosition();
391 // before GM
392 float x,y,z;
393 m_session->GetPlayer()->GetClosePoint(x,y,z,chr->GetObjectSize());
394 chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation());
396 else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
398 PSendSysMessage(LANG_SUMMONING, name.c_str(),GetMangosString(LANG_OFFLINE));
400 // in point where GM stay
401 Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(),
402 m_session->GetPlayer()->GetPositionX(),
403 m_session->GetPlayer()->GetPositionY(),
404 m_session->GetPlayer()->GetPositionZ(),
405 m_session->GetPlayer()->GetOrientation(),
406 m_session->GetPlayer()->GetZoneId(),
407 guid);
409 else
411 PSendSysMessage(LANG_NO_PLAYER, args);
412 SetSentErrorMessage(true);
415 return true;
418 //Teleport to Player
419 bool ChatHandler::HandleGonameCommand(const char* args)
421 if(!*args)
422 return false;
424 Player* _player = m_session->GetPlayer();
426 std::string name = args;
428 if(!normalizePlayerName(name))
430 SendSysMessage(LANG_PLAYER_NOT_FOUND);
431 SetSentErrorMessage(true);
432 return false;
435 Player *chr = objmgr.GetPlayer(name.c_str());
436 if (chr)
438 Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr);
439 if(cMap->Instanceable())
441 Map* pMap = MapManager::Instance().GetMap(_player->GetMapId(),_player);
443 // we have to go to instance, and can go to player only if:
444 // 1) we are in his group (either as leader or as member)
445 // 2) we are not bound to any group and have GM mode on
446 if (_player->GetGroup())
448 // we are in group, we can go only if we are in the player group
449 if (_player->GetGroup() != chr->GetGroup())
451 PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName());
452 SetSentErrorMessage(true);
453 return false;
456 else
458 // we are not in group, let's verify our GM mode
459 if (!_player->isGameMaster())
461 PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName());
462 SetSentErrorMessage(true);
463 return false;
467 // if the player or the player's group is bound to another instance
468 // the player will not be bound to another one
469 InstancePlayerBind *pBind = _player->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty());
470 if(!pBind)
472 Group *group = _player->GetGroup();
473 InstanceGroupBind *gBind = group ? group->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()) : NULL;
474 if(!gBind)
476 // if no bind exists, create a solo bind
477 InstanceSave *save = sInstanceSaveManager.GetInstanceSave(chr->GetInstanceId());
478 if(save) _player->BindToInstance(save, !save->CanReset());
482 _player->SetDifficulty(chr->GetDifficulty());
485 PSendSysMessage(LANG_APPEARING_AT, chr->GetName());
487 if (_player->IsVisibleGloballyFor(chr))
488 ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, _player->GetName());
490 // stop flight if need
491 if(_player->isInFlight())
493 _player->GetMotionMaster()->MovementExpired();
494 _player->m_taxi.ClearTaxiDestinations();
496 // save only in non-flight case
497 else
498 _player->SaveRecallPosition();
500 // to point to see at target with same orientation
501 float x,y,z;
502 chr->GetContactPoint(m_session->GetPlayer(),x,y,z);
504 _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), TELE_TO_GM_MODE);
506 return true;
509 if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
511 PSendSysMessage(LANG_APPEARING_AT, name.c_str());
513 // to point where player stay (if loaded)
514 float x,y,z,o;
515 uint32 map;
516 bool in_flight;
517 if(Player::LoadPositionFromDB(map,x,y,z,o,in_flight,guid))
519 // stop flight if need
520 if(_player->isInFlight())
522 _player->GetMotionMaster()->MovementExpired();
523 _player->m_taxi.ClearTaxiDestinations();
525 // save only in non-flight case
526 else
527 _player->SaveRecallPosition();
529 _player->TeleportTo(map, x, y, z,_player->GetOrientation());
530 return true;
534 PSendSysMessage(LANG_NO_PLAYER, args);
536 SetSentErrorMessage(true);
537 return false;
540 // Teleport player to last position
541 bool ChatHandler::HandleRecallCommand(const char* args)
543 Player* chr = NULL;
545 if(!*args)
547 chr = getSelectedPlayer();
548 if(!chr)
549 chr = m_session->GetPlayer();
551 else
553 std::string name = args;
555 if(!normalizePlayerName(name))
557 SendSysMessage(LANG_PLAYER_NOT_FOUND);
558 SetSentErrorMessage(true);
559 return false;
562 chr = objmgr.GetPlayer(name.c_str());
564 if(!chr)
566 PSendSysMessage(LANG_NO_PLAYER, args);
567 SetSentErrorMessage(true);
568 return false;
572 if(chr->IsBeingTeleported())
574 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
575 SetSentErrorMessage(true);
576 return false;
579 // stop flight if need
580 if(chr->isInFlight())
582 chr->GetMotionMaster()->MovementExpired();
583 chr->m_taxi.ClearTaxiDestinations();
586 chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO);
587 return true;
590 //Edit Player KnownTitles
591 bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args)
593 if(!*args)
594 return false;
596 uint64 titles = 0;
598 sscanf((char*)args, I64FMTD, &titles);
600 Player *chr = getSelectedPlayer();
601 if (!chr)
603 SendSysMessage(LANG_NO_CHAR_SELECTED);
604 SetSentErrorMessage(true);
605 return false;
608 uint64 titles2 = titles;
610 for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i)
611 if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
612 titles2 &= ~(uint64(1) << tEntry->bit_index);
614 titles &= ~titles2; // remove not existed titles
616 chr->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles);
617 SendSysMessage(LANG_DONE);
619 return true;
622 //Edit Player HP
623 bool ChatHandler::HandleModifyHPCommand(const char* args)
625 if(!*args)
626 return false;
628 // char* pHp = strtok((char*)args, " ");
629 // if (!pHp)
630 // return false;
632 // char* pHpMax = strtok(NULL, " ");
633 // if (!pHpMax)
634 // return false;
636 // int32 hpm = atoi(pHpMax);
637 // int32 hp = atoi(pHp);
639 int32 hp = atoi((char*)args);
640 int32 hpm = atoi((char*)args);
642 if (hp <= 0 || hpm <= 0 || hpm < hp)
644 SendSysMessage(LANG_BAD_VALUE);
645 SetSentErrorMessage(true);
646 return false;
649 Player *chr = getSelectedPlayer();
650 if (chr == NULL)
652 SendSysMessage(LANG_NO_CHAR_SELECTED);
653 SetSentErrorMessage(true);
654 return false;
657 PSendSysMessage(LANG_YOU_CHANGE_HP, chr->GetName(), hp, hpm);
658 ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, m_session->GetPlayer()->GetName(), hp, hpm);
660 chr->SetMaxHealth( hpm );
661 chr->SetHealth( hp );
663 return true;
666 //Edit Player Mana
667 bool ChatHandler::HandleModifyManaCommand(const char* args)
669 if(!*args)
670 return false;
672 // char* pmana = strtok((char*)args, " ");
673 // if (!pmana)
674 // return false;
676 // char* pmanaMax = strtok(NULL, " ");
677 // if (!pmanaMax)
678 // return false;
680 // int32 manam = atoi(pmanaMax);
681 // int32 mana = atoi(pmana);
682 int32 mana = atoi((char*)args);
683 int32 manam = atoi((char*)args);
685 if (mana <= 0 || manam <= 0 || manam < mana)
687 SendSysMessage(LANG_BAD_VALUE);
688 SetSentErrorMessage(true);
689 return false;
692 Player *chr = getSelectedPlayer();
693 if (chr == NULL)
695 SendSysMessage(LANG_NO_CHAR_SELECTED);
696 SetSentErrorMessage(true);
697 return false;
700 PSendSysMessage(LANG_YOU_CHANGE_MANA, chr->GetName(), mana, manam);
701 ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, m_session->GetPlayer()->GetName(), mana, manam);
703 chr->SetMaxPower(POWER_MANA,manam );
704 chr->SetPower(POWER_MANA, mana );
706 return true;
709 //Edit Player Energy
710 bool ChatHandler::HandleModifyEnergyCommand(const char* args)
712 if(!*args)
713 return false;
715 // char* pmana = strtok((char*)args, " ");
716 // if (!pmana)
717 // return false;
719 // char* pmanaMax = strtok(NULL, " ");
720 // if (!pmanaMax)
721 // return false;
723 // int32 manam = atoi(pmanaMax);
724 // int32 mana = atoi(pmana);
726 int32 energy = atoi((char*)args)*10;
727 int32 energym = atoi((char*)args)*10;
729 if (energy <= 0 || energym <= 0 || energym < energy)
731 SendSysMessage(LANG_BAD_VALUE);
732 SetSentErrorMessage(true);
733 return false;
736 Player *chr = getSelectedPlayer();
737 if (!chr)
739 SendSysMessage(LANG_NO_CHAR_SELECTED);
740 SetSentErrorMessage(true);
741 return false;
744 PSendSysMessage(LANG_YOU_CHANGE_ENERGY, chr->GetName(), energy/10, energym/10);
745 ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, m_session->GetPlayer()->GetName(), energy/10, energym/10);
747 chr->SetMaxPower(POWER_ENERGY,energym );
748 chr->SetPower(POWER_ENERGY, energy );
750 sLog.outDetail(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY));
752 return true;
755 //Edit Player Rage
756 bool ChatHandler::HandleModifyRageCommand(const char* args)
758 if(!*args)
759 return false;
761 // char* pmana = strtok((char*)args, " ");
762 // if (!pmana)
763 // return false;
765 // char* pmanaMax = strtok(NULL, " ");
766 // if (!pmanaMax)
767 // return false;
769 // int32 manam = atoi(pmanaMax);
770 // int32 mana = atoi(pmana);
772 int32 rage = atoi((char*)args)*10;
773 int32 ragem = atoi((char*)args)*10;
775 if (rage <= 0 || ragem <= 0 || ragem < rage)
777 SendSysMessage(LANG_BAD_VALUE);
778 SetSentErrorMessage(true);
779 return false;
782 Player *chr = getSelectedPlayer();
783 if (chr == NULL)
785 SendSysMessage(LANG_NO_CHAR_SELECTED);
786 SetSentErrorMessage(true);
787 return false;
790 PSendSysMessage(LANG_YOU_CHANGE_RAGE, chr->GetName(), rage/10, ragem/10);
791 // Special case: I use GetMangosString here to get local of destination char ;)
792 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_RAGE_CHANGED), m_session->GetPlayer()->GetName(), rage/10, ragem/10);
794 chr->SetMaxPower(POWER_RAGE,ragem );
795 chr->SetPower(POWER_RAGE, rage );
797 return true;
800 //Edit Player Faction
801 bool ChatHandler::HandleModifyFactionCommand(const char* args)
803 if(!*args)
804 return false;
806 char* pfactionid = extractKeyFromLink((char*)args,"Hfaction");
808 Creature* chr = getSelectedCreature();
809 if(!chr)
811 SendSysMessage(LANG_SELECT_CREATURE);
812 SetSentErrorMessage(true);
813 return false;
816 if(!pfactionid)
818 if(chr)
820 uint32 factionid = chr->getFaction();
821 uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
822 uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
823 uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
824 PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
826 return true;
829 if( !chr )
831 SendSysMessage(LANG_NO_CHAR_SELECTED);
832 SetSentErrorMessage(true);
833 return false;
836 uint32 factionid = atoi(pfactionid);
837 uint32 flag;
839 char *pflag = strtok(NULL, " ");
840 if (!pflag)
841 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
842 else
843 flag = atoi(pflag);
845 char* pnpcflag = strtok(NULL, " ");
847 uint32 npcflag;
848 if(!pnpcflag)
849 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
850 else
851 npcflag = atoi(pnpcflag);
853 char* pdyflag = strtok(NULL, " ");
855 uint32 dyflag;
856 if(!pdyflag)
857 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
858 else
859 dyflag = atoi(pdyflag);
861 if(!sFactionTemplateStore.LookupEntry(factionid))
863 PSendSysMessage(LANG_WRONG_FACTION, factionid);
864 SetSentErrorMessage(true);
865 return false;
868 PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
870 //sprintf((char*)buf,"%s changed your Faction to %i.", m_session->GetPlayer()->GetName(), factionid);
871 //FillSystemMessageData(&data, m_session, buf);
873 //chr->GetSession()->SendPacket(&data);
875 chr->setFaction(factionid);
876 chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag);
877 chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag);
878 chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag);
880 return true;
883 //Edit Player Spell
884 bool ChatHandler::HandleModifySpellCommand(const char* args)
886 if(!*args) return false;
887 char* pspellflatid = strtok((char*)args, " ");
888 if (!pspellflatid)
889 return false;
891 char* pop = strtok(NULL, " ");
892 if (!pop)
893 return false;
895 char* pval = strtok(NULL, " ");
896 if (!pval)
897 return false;
899 uint16 mark;
901 char* pmark = strtok(NULL, " ");
903 uint8 spellflatid = atoi(pspellflatid);
904 uint8 op = atoi(pop);
905 uint16 val = atoi(pval);
906 if(!pmark)
907 mark = 65535;
908 else
909 mark = atoi(pmark);
911 Player *chr = getSelectedPlayer();
912 if (chr == NULL)
914 SendSysMessage(LANG_NO_CHAR_SELECTED);
915 SetSentErrorMessage(true);
916 return false;
919 PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, chr->GetName());
920 if(chr != m_session->GetPlayer())
921 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, m_session->GetPlayer()->GetName(), spellflatid, val, mark);
923 WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2));
924 data << uint8(spellflatid);
925 data << uint8(op);
926 data << uint16(val);
927 data << uint16(mark);
928 chr->GetSession()->SendPacket(&data);
930 return true;
933 //Edit Player TP
934 bool ChatHandler::HandleModifyTalentCommand (const char* args)
936 if (!*args)
937 return false;
939 int tp = atoi((char*)args);
940 if (tp>0)
942 Player* player = getSelectedPlayer();
943 if(!player)
945 SendSysMessage(LANG_NO_CHAR_SELECTED);
946 SetSentErrorMessage(true);
947 return false;
949 player->SetFreeTalentPoints(tp);
950 return true;
952 return false;
955 //Enable On\OFF all taxi paths
956 bool ChatHandler::HandleTaxiCheatCommand(const char* args)
958 if (!*args)
960 SendSysMessage(LANG_USE_BOL);
961 SetSentErrorMessage(true);
962 return false;
965 std::string argstr = (char*)args;
967 Player *chr = getSelectedPlayer();
968 if (!chr)
970 chr=m_session->GetPlayer();
973 if (argstr == "on")
975 chr->SetTaxiCheater(true);
976 PSendSysMessage(LANG_YOU_GIVE_TAXIS, chr->GetName());
978 if(chr != m_session->GetPlayer())
979 // to send localized data to target
980 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_TAXIS_ADDED), m_session->GetPlayer()->GetName());
981 return true;
984 if (argstr == "off")
986 chr->SetTaxiCheater(false);
987 PSendSysMessage(LANG_YOU_REMOVE_TAXIS, chr->GetName());
989 if(chr != m_session->GetPlayer())
990 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_TAXIS_REMOVED), m_session->GetPlayer()->GetName());
992 return true;
995 SendSysMessage(LANG_USE_BOL);
996 SetSentErrorMessage(true);
997 return false;
1000 //Edit Player Aspeed
1001 bool ChatHandler::HandleModifyASpeedCommand(const char* args)
1003 if (!*args)
1004 return false;
1006 float ASpeed = (float)atof((char*)args);
1008 if (ASpeed > 10 || ASpeed < 0.1)
1010 SendSysMessage(LANG_BAD_VALUE);
1011 SetSentErrorMessage(true);
1012 return false;
1015 Player *chr = getSelectedPlayer();
1016 if (chr == NULL)
1018 SendSysMessage(LANG_NO_CHAR_SELECTED);
1019 SetSentErrorMessage(true);
1020 return false;
1023 if(chr->isInFlight())
1025 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1026 SetSentErrorMessage(true);
1027 return false;
1030 PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName());
1032 if(chr != m_session->GetPlayer())
1033 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_ASPEED_CHANGED), m_session->GetPlayer()->GetName(), ASpeed);
1035 chr->SetSpeed(MOVE_WALK, ASpeed,true);
1036 chr->SetSpeed(MOVE_RUN, ASpeed,true);
1037 chr->SetSpeed(MOVE_SWIM, ASpeed,true);
1038 //chr->SetSpeed(MOVE_TURN, ASpeed,true);
1039 chr->SetSpeed(MOVE_FLY, ASpeed,true);
1040 return true;
1043 //Edit Player Speed
1044 bool ChatHandler::HandleModifySpeedCommand(const char* args)
1046 if (!*args)
1047 return false;
1049 float Speed = (float)atof((char*)args);
1051 if (Speed > 10 || Speed < 0.1)
1053 SendSysMessage(LANG_BAD_VALUE);
1054 SetSentErrorMessage(true);
1055 return false;
1058 Player *chr = getSelectedPlayer();
1059 if (chr == NULL)
1061 SendSysMessage(LANG_NO_CHAR_SELECTED);
1062 SetSentErrorMessage(true);
1063 return false;
1066 if(chr->isInFlight())
1068 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1069 SetSentErrorMessage(true);
1070 return false;
1073 PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chr->GetName());
1075 if(chr != m_session->GetPlayer())
1076 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SPEED_CHANGED), m_session->GetPlayer()->GetName(), Speed);
1078 chr->SetSpeed(MOVE_RUN,Speed,true);
1080 return true;
1083 //Edit Player Swim Speed
1084 bool ChatHandler::HandleModifySwimCommand(const char* args)
1086 if (!*args)
1087 return false;
1089 float Swim = (float)atof((char*)args);
1091 if (Swim > 10.0f || Swim < 0.01f)
1093 SendSysMessage(LANG_BAD_VALUE);
1094 SetSentErrorMessage(true);
1095 return false;
1098 Player *chr = getSelectedPlayer();
1099 if (chr == NULL)
1101 SendSysMessage(LANG_NO_CHAR_SELECTED);
1102 SetSentErrorMessage(true);
1103 return false;
1106 if(chr->isInFlight())
1108 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1109 SetSentErrorMessage(true);
1110 return false;
1113 PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chr->GetName());
1115 if(chr != m_session->GetPlayer())
1116 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SWIM_SPEED_CHANGED), m_session->GetPlayer()->GetName(), Swim);
1118 chr->SetSpeed(MOVE_SWIM,Swim,true);
1120 return true;
1123 //Edit Player Walk Speed
1124 bool ChatHandler::HandleModifyBWalkCommand(const char* args)
1126 if (!*args)
1127 return false;
1129 float BSpeed = (float)atof((char*)args);
1131 if (BSpeed > 10.0f || BSpeed < 0.1f)
1133 SendSysMessage(LANG_BAD_VALUE);
1134 SetSentErrorMessage(true);
1135 return false;
1138 Player *chr = getSelectedPlayer();
1139 if (chr == NULL)
1141 SendSysMessage(LANG_NO_CHAR_SELECTED);
1142 SetSentErrorMessage(true);
1143 return false;
1146 if(chr->isInFlight())
1148 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1149 SetSentErrorMessage(true);
1150 return false;
1153 PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chr->GetName());
1155 if(chr != m_session->GetPlayer())
1156 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_BACK_SPEED_CHANGED), m_session->GetPlayer()->GetName(), BSpeed);
1158 chr->SetSpeed(MOVE_WALKBACK,BSpeed,true);
1160 return true;
1163 //Edit Player Fly
1164 bool ChatHandler::HandleModifyFlyCommand(const char* args)
1166 if (!*args)
1167 return false;
1169 float FSpeed = (float)atof((char*)args);
1171 if (FSpeed > 10.0f || FSpeed < 0.1f)
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 PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, chr->GetName());
1188 if(chr != m_session->GetPlayer())
1189 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_FLY_SPEED_CHANGED), m_session->GetPlayer()->GetName(), FSpeed);
1191 chr->SetSpeed(MOVE_FLY,FSpeed,true);
1193 return true;
1196 //Edit Player Scale
1197 bool ChatHandler::HandleModifyScaleCommand(const char* args)
1199 if (!*args)
1200 return false;
1202 float Scale = (float)atof((char*)args);
1203 if (Scale > 3.0f || Scale <= 0.0f)
1205 SendSysMessage(LANG_BAD_VALUE);
1206 SetSentErrorMessage(true);
1207 return false;
1210 Player *chr = getSelectedPlayer();
1211 if (chr == NULL)
1213 SendSysMessage(LANG_NO_CHAR_SELECTED);
1214 SetSentErrorMessage(true);
1215 return false;
1218 PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, chr->GetName());
1220 if(chr != m_session->GetPlayer())
1221 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SIZE_CHANGED), m_session->GetPlayer()->GetName(), Scale);
1223 chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale);
1225 return true;
1228 //Enable Player mount
1229 bool ChatHandler::HandleModifyMountCommand(const char* args)
1231 if(!*args)
1232 return false;
1234 uint16 mId = 1147;
1235 float speed = (float)15;
1236 uint32 num = 0;
1238 num = atoi((char*)args);
1239 switch(num)
1241 case 1:
1242 mId=14340;
1243 break;
1244 case 2:
1245 mId=4806;
1246 break;
1247 case 3:
1248 mId=6471;
1249 break;
1250 case 4:
1251 mId=12345;
1252 break;
1253 case 5:
1254 mId=6472;
1255 break;
1256 case 6:
1257 mId=6473;
1258 break;
1259 case 7:
1260 mId=10670;
1261 break;
1262 case 8:
1263 mId=10719;
1264 break;
1265 case 9:
1266 mId=10671;
1267 break;
1268 case 10:
1269 mId=10672;
1270 break;
1271 case 11:
1272 mId=10720;
1273 break;
1274 case 12:
1275 mId=14349;
1276 break;
1277 case 13:
1278 mId=11641;
1279 break;
1280 case 14:
1281 mId=12244;
1282 break;
1283 case 15:
1284 mId=12242;
1285 break;
1286 case 16:
1287 mId=14578;
1288 break;
1289 case 17:
1290 mId=14579;
1291 break;
1292 case 18:
1293 mId=14349;
1294 break;
1295 case 19:
1296 mId=12245;
1297 break;
1298 case 20:
1299 mId=14335;
1300 break;
1301 case 21:
1302 mId=207;
1303 break;
1304 case 22:
1305 mId=2328;
1306 break;
1307 case 23:
1308 mId=2327;
1309 break;
1310 case 24:
1311 mId=2326;
1312 break;
1313 case 25:
1314 mId=14573;
1315 break;
1316 case 26:
1317 mId=14574;
1318 break;
1319 case 27:
1320 mId=14575;
1321 break;
1322 case 28:
1323 mId=604;
1324 break;
1325 case 29:
1326 mId=1166;
1327 break;
1328 case 30:
1329 mId=2402;
1330 break;
1331 case 31:
1332 mId=2410;
1333 break;
1334 case 32:
1335 mId=2409;
1336 break;
1337 case 33:
1338 mId=2408;
1339 break;
1340 case 34:
1341 mId=2405;
1342 break;
1343 case 35:
1344 mId=14337;
1345 break;
1346 case 36:
1347 mId=6569;
1348 break;
1349 case 37:
1350 mId=10661;
1351 break;
1352 case 38:
1353 mId=10666;
1354 break;
1355 case 39:
1356 mId=9473;
1357 break;
1358 case 40:
1359 mId=9476;
1360 break;
1361 case 41:
1362 mId=9474;
1363 break;
1364 case 42:
1365 mId=14374;
1366 break;
1367 case 43:
1368 mId=14376;
1369 break;
1370 case 44:
1371 mId=14377;
1372 break;
1373 case 45:
1374 mId=2404;
1375 break;
1376 case 46:
1377 mId=2784;
1378 break;
1379 case 47:
1380 mId=2787;
1381 break;
1382 case 48:
1383 mId=2785;
1384 break;
1385 case 49:
1386 mId=2736;
1387 break;
1388 case 50:
1389 mId=2786;
1390 break;
1391 case 51:
1392 mId=14347;
1393 break;
1394 case 52:
1395 mId=14346;
1396 break;
1397 case 53:
1398 mId=14576;
1399 break;
1400 case 54:
1401 mId=9695;
1402 break;
1403 case 55:
1404 mId=9991;
1405 break;
1406 case 56:
1407 mId=6448;
1408 break;
1409 case 57:
1410 mId=6444;
1411 break;
1412 case 58:
1413 mId=6080;
1414 break;
1415 case 59:
1416 mId=6447;
1417 break;
1418 case 60:
1419 mId=4805;
1420 break;
1421 case 61:
1422 mId=9714;
1423 break;
1424 case 62:
1425 mId=6448;
1426 break;
1427 case 63:
1428 mId=6442;
1429 break;
1430 case 64:
1431 mId=14632;
1432 break;
1433 case 65:
1434 mId=14332;
1435 break;
1436 case 66:
1437 mId=14331;
1438 break;
1439 case 67:
1440 mId=8469;
1441 break;
1442 case 68:
1443 mId=2830;
1444 break;
1445 case 69:
1446 mId=2346;
1447 break;
1448 default:
1449 SendSysMessage(LANG_NO_MOUNT);
1450 SetSentErrorMessage(true);
1451 return false;
1454 Player *chr = getSelectedPlayer();
1455 if (chr == NULL)
1457 SendSysMessage(LANG_NO_CHAR_SELECTED);
1458 SetSentErrorMessage(true);
1459 return false;
1462 PSendSysMessage(LANG_YOU_GIVE_MOUNT, chr->GetName());
1464 if(chr != m_session->GetPlayer())
1465 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_MOUNT_GIVED), m_session->GetPlayer()->GetName());
1467 chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 );
1468 chr->Mount(mId);
1470 WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) );
1471 data.append(chr->GetPackGUID());
1472 data << (uint32)0;
1473 data << (uint8)0; //new 2.1.0
1474 data << float(speed);
1475 chr->SendMessageToSet( &data, true );
1477 data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) );
1478 data.append(chr->GetPackGUID());
1479 data << (uint32)0;
1480 data << float(speed);
1481 chr->SendMessageToSet( &data, true );
1483 return true;
1486 //Edit Player money
1487 bool ChatHandler::HandleModifyMoneyCommand(const char* args)
1489 if (!*args)
1490 return false;
1492 Player *chr = getSelectedPlayer();
1493 if (chr == NULL)
1495 SendSysMessage(LANG_NO_CHAR_SELECTED);
1496 SetSentErrorMessage(true);
1497 return false;
1500 int32 addmoney = atoi((char*)args);
1502 uint32 moneyuser = chr->GetMoney();
1504 if(addmoney < 0)
1506 int32 newmoney = moneyuser + addmoney;
1508 sLog.outDetail(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney);
1509 if(newmoney <= 0 )
1511 PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName());
1513 if(chr != m_session->GetPlayer())
1514 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_ALL_MONEY_GONE), m_session->GetPlayer()->GetName());
1516 chr->SetMoney(0);
1518 else
1520 PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), chr->GetName());
1521 if(chr != m_session->GetPlayer())
1522 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_MONEY_TAKEN), m_session->GetPlayer()->GetName(), abs(addmoney));
1523 chr->SetMoney( newmoney );
1526 else
1528 PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, chr->GetName());
1529 if(chr != m_session->GetPlayer())
1530 ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_MONEY_GIVEN), m_session->GetPlayer()->GetName(), addmoney);
1531 chr->ModifyMoney( addmoney );
1534 sLog.outDetail(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() );
1536 return true;
1539 //Edit Player field
1540 bool ChatHandler::HandleModifyBitCommand(const char* args)
1542 if( !*args )
1543 return false;
1545 Player *chr = getSelectedPlayer();
1546 if (chr == NULL)
1548 SendSysMessage(LANG_NO_CHAR_SELECTED);
1549 SetSentErrorMessage(true);
1550 return false;
1553 char* pField = strtok((char*)args, " ");
1554 if (!pField)
1555 return false;
1557 char* pBit = strtok(NULL, " ");
1558 if (!pBit)
1559 return false;
1561 uint16 field = atoi(pField);
1562 uint32 bit = atoi(pBit);
1564 if (field < 1 || field >= PLAYER_END)
1566 SendSysMessage(LANG_BAD_VALUE);
1567 SetSentErrorMessage(true);
1568 return false;
1571 if (bit < 1 || bit > 32)
1573 SendSysMessage(LANG_BAD_VALUE);
1574 SetSentErrorMessage(true);
1575 return false;
1578 if ( chr->HasFlag( field, (1<<(bit-1)) ) )
1580 chr->RemoveFlag( field, (1<<(bit-1)) );
1581 PSendSysMessage(LANG_REMOVE_BIT, bit, field);
1583 else
1585 chr->SetFlag( field, (1<<(bit-1)) );
1586 PSendSysMessage(LANG_SET_BIT, bit, field);
1589 return true;
1592 bool ChatHandler::HandleModifyHonorCommand (const char* args)
1594 if (!*args)
1595 return false;
1597 Player *target = getSelectedPlayer();
1598 if(!target)
1600 SendSysMessage(LANG_PLAYER_NOT_FOUND);
1601 SetSentErrorMessage(true);
1602 return false;
1605 int32 amount = (uint32)atoi(args);
1607 target->ModifyHonorPoints(amount);
1609 PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, target->GetName(), target->GetHonorPoints());
1611 return true;
1614 bool ChatHandler::HandleTeleCommand(const char * args)
1616 if(!*args)
1617 return false;
1619 Player* _player = m_session->GetPlayer();
1621 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
1622 GameTele const* tele = extractGameTeleFromLink((char*)args);
1624 if (!tele)
1626 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
1627 SetSentErrorMessage(true);
1628 return false;
1631 // stop flight if need
1632 if(_player->isInFlight())
1634 _player->GetMotionMaster()->MovementExpired();
1635 _player->m_taxi.ClearTaxiDestinations();
1637 // save only in non-flight case
1638 else
1639 _player->SaveRecallPosition();
1641 _player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
1642 return true;
1645 bool ChatHandler::HandleLookupAreaCommand(const char* args)
1647 if(!*args)
1648 return false;
1650 std::string namepart = args;
1651 std::wstring wnamepart;
1653 if(!Utf8toWStr(namepart,wnamepart))
1654 return false;
1656 uint32 counter = 0; // Counter for figure out that we found smth.
1658 // converting string that we try to find to lower case
1659 wstrToLower( wnamepart );
1661 // Search in AreaTable.dbc
1662 for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows(); ++areaflag)
1664 AreaTableEntry const *areaEntry = sAreaStore.LookupEntry(areaflag);
1665 if(areaEntry)
1667 int loc = m_session->GetSessionDbcLocale();
1668 std::string name = areaEntry->area_name[loc];
1669 if(name.empty())
1670 continue;
1672 if(!Utf8FitTo(name, wnamepart))
1674 loc = 0;
1675 for(; loc < MAX_LOCALE; ++loc)
1677 if(loc==m_session->GetSessionDbcLocale())
1678 continue;
1680 name = areaEntry->area_name[loc];
1681 if(name.empty())
1682 continue;
1684 if (Utf8FitTo(name, wnamepart))
1685 break;
1689 if(loc < MAX_LOCALE)
1691 // send area in "id - [name]" format
1692 std::ostringstream ss;
1693 ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r";
1695 SendSysMessage(ss.str().c_str());
1697 ++counter;
1701 if (counter == 0) // if counter == 0 then we found nth
1702 SendSysMessage(LANG_COMMAND_NOAREAFOUND);
1703 return true;
1706 //Find tele in game_tele order by name
1707 bool ChatHandler::HandleLookupTeleCommand(const char * args)
1709 if(!*args)
1711 SendSysMessage(LANG_COMMAND_TELE_PARAMETER);
1712 SetSentErrorMessage(true);
1713 return false;
1715 char const* str = strtok((char*)args, " ");
1716 if(!str)
1717 return false;
1719 std::string namepart = str;
1720 std::wstring wnamepart;
1722 if(!Utf8toWStr(namepart,wnamepart))
1723 return false;
1725 // converting string that we try to find to lower case
1726 wstrToLower( wnamepart );
1728 GameTeleMap const & teleMap = objmgr.GetGameTeleMap();
1730 std::ostringstream reply;
1731 for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr)
1733 GameTele const* tele = &itr->second;
1735 if(tele->wnameLow.find(wnamepart) == std::wstring::npos)
1736 continue;
1738 reply << " |cffffffff|Htele:";
1739 reply << itr->first;
1740 reply << "|h[";
1741 reply << tele->name;
1742 reply << "]|h|r\n";
1745 if(reply.str().empty())
1746 SendSysMessage(LANG_COMMAND_TELE_NOLOCATION);
1747 else
1748 PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str());
1750 return true;
1753 //Enable\Dissable accept whispers (for GM)
1754 bool ChatHandler::HandleWhispersCommand(const char* args)
1756 if(!*args)
1758 PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF));
1759 return true;
1762 std::string argstr = (char*)args;
1763 // whisper on
1764 if (argstr == "on")
1766 m_session->GetPlayer()->SetAcceptWhispers(true);
1767 SendSysMessage(LANG_COMMAND_WHISPERON);
1768 return true;
1771 // whisper off
1772 if (argstr == "off")
1774 m_session->GetPlayer()->SetAcceptWhispers(false);
1775 SendSysMessage(LANG_COMMAND_WHISPEROFF);
1776 return true;
1779 SendSysMessage(LANG_USE_BOL);
1780 SetSentErrorMessage(true);
1781 return false;
1784 //Play sound
1785 bool ChatHandler::HandlePlaySoundCommand(const char* args)
1787 // USAGE: .debug playsound #soundid
1788 // #soundid - ID decimal number from SoundEntries.dbc (1st column)
1789 // this file have about 5000 sounds.
1790 // In this realization only caller can hear this sound.
1791 if( *args )
1793 uint32 dwSoundId = atoi((char*)args);
1795 if( !sSoundEntriesStore.LookupEntry(dwSoundId) )
1797 PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
1798 SetSentErrorMessage(true);
1799 return false;
1802 WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8);
1803 data << uint32(dwSoundId) << m_session->GetPlayer()->GetGUID();
1804 m_session->SendPacket(&data);
1806 PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
1807 return true;
1810 return false;
1813 //Save all players in the world
1814 bool ChatHandler::HandleSaveAllCommand(const char* /*args*/)
1816 ObjectAccessor::Instance().SaveAllPlayers();
1817 SendSysMessage(LANG_PLAYERS_SAVED);
1818 return true;
1821 //Send mail by command
1822 bool ChatHandler::HandleSendMailCommand(const char* args)
1824 if(!*args)
1825 return false;
1827 // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
1829 char* pName = strtok((char*)args, " ");
1830 if(!pName)
1831 return false;
1833 char* tail1 = strtok(NULL, "");
1834 if(!tail1)
1835 return false;
1837 char* msgSubject;
1838 if(*tail1=='"')
1839 msgSubject = strtok(tail1+1, "\"");
1840 else
1842 char* space = strtok(tail1, "\"");
1843 if(!space)
1844 return false;
1845 msgSubject = strtok(NULL, "\"");
1848 if (!msgSubject)
1849 return false;
1851 char* tail2 = strtok(NULL, "");
1852 if(!tail2)
1853 return false;
1855 char* msgText;
1856 if(*tail2=='"')
1857 msgText = strtok(tail2+1, "\"");
1858 else
1860 char* space = strtok(tail2, "\"");
1861 if(!space)
1862 return false;
1863 msgText = strtok(NULL, "\"");
1866 if (!msgText)
1867 return false;
1869 // pName, msgSubject, msgText isn't NUL after prev. check
1870 std::string name = pName;
1871 std::string subject = msgSubject;
1872 std::string text = msgText;
1874 // extract items
1875 typedef std::pair<uint32,uint32> ItemPair;
1876 typedef std::list< ItemPair > ItemPairs;
1877 ItemPairs items;
1879 // get all tail string
1880 char* tail = strtok(NULL, "");
1882 // get from tail next item str
1883 while(char* itemStr = strtok(tail, " "))
1885 // and get new tail
1886 tail = strtok(NULL, "");
1888 // parse item str
1889 char* itemIdStr = strtok(itemStr, ":");
1890 char* itemCountStr = strtok(NULL, " ");
1892 uint32 item_id = atoi(itemIdStr);
1893 if(!item_id)
1894 return false;
1896 ItemPrototype const* item_proto = objmgr.GetItemPrototype(item_id);
1897 if(!item_proto)
1899 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id);
1900 SetSentErrorMessage(true);
1901 return false;
1904 uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1;
1905 if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount)
1907 PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id);
1908 SetSentErrorMessage(true);
1909 return false;
1912 while(item_count > item_proto->Stackable)
1914 items.push_back(ItemPair(item_id,item_proto->Stackable));
1915 item_count -= item_proto->Stackable;
1918 items.push_back(ItemPair(item_id,item_count));
1920 if(items.size() > MAX_MAIL_ITEMS)
1922 PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS);
1923 SetSentErrorMessage(true);
1924 return false;
1928 if(!normalizePlayerName(name))
1930 SendSysMessage(LANG_PLAYER_NOT_FOUND);
1931 SetSentErrorMessage(true);
1932 return false;
1935 uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name);
1936 if(!receiver_guid)
1938 SendSysMessage(LANG_PLAYER_NOT_FOUND);
1939 SetSentErrorMessage(true);
1940 return false;
1943 uint32 mailId = objmgr.GenerateMailID();
1944 uint32 sender_guidlo = m_session->GetPlayer()->GetGUIDLow();
1945 uint32 messagetype = MAIL_NORMAL;
1946 uint32 stationery = MAIL_STATIONERY_GM;
1947 uint32 itemTextId = 0;
1948 if (!text.empty())
1950 itemTextId = objmgr.CreateItemText( text );
1953 Player *receiver = objmgr.GetPlayer(receiver_guid);
1955 // fill mail
1956 MailItemsInfo mi; // item list preparing
1958 for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr)
1960 if(Item* item = Item::CreateItem(itr->first,itr->second,m_session->GetPlayer()))
1962 item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
1963 mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item);
1967 WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
1969 PSendSysMessage(LANG_MAIL_SENT, name.c_str());
1970 return true;
1973 // teleport player to given game_tele.entry
1974 bool ChatHandler::HandleNameTeleCommand(const char * args)
1976 if(!*args)
1977 return false;
1979 char* pName = strtok((char*)args, " ");
1981 if(!pName)
1982 return false;
1984 std::string name = pName;
1986 if(!normalizePlayerName(name))
1988 SendSysMessage(LANG_PLAYER_NOT_FOUND);
1989 SetSentErrorMessage(true);
1990 return false;
1993 char* tail = strtok(NULL, "");
1994 if(!tail)
1995 return false;
1997 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
1998 GameTele const* tele = extractGameTeleFromLink(tail);
1999 if(!tele)
2001 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
2002 SetSentErrorMessage(true);
2003 return false;
2006 Player *chr = objmgr.GetPlayer(name.c_str());
2007 if (chr)
2010 if(chr->IsBeingTeleported()==true)
2012 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
2013 SetSentErrorMessage(true);
2014 return false;
2017 PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", tele->name.c_str());
2019 if (m_session)
2021 if(m_session->GetPlayer()->IsVisibleGloballyFor(chr))
2022 ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName());
2024 else
2025 ChatHandler(chr).SendSysMessage(LANG_TELEPORTED_TO_BY_CONSOLE);
2027 // stop flight if need
2028 if(chr->isInFlight())
2030 chr->GetMotionMaster()->MovementExpired();
2031 chr->m_taxi.ClearTaxiDestinations();
2033 // save only in non-flight case
2034 else
2035 chr->SaveRecallPosition();
2037 chr->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);
2039 else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()))
2041 PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str());
2042 Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y),guid);
2044 else
2045 PSendSysMessage(LANG_NO_PLAYER, name.c_str());
2047 return true;
2050 //Teleport group to given game_tele.entry
2051 bool ChatHandler::HandleGroupTeleCommand(const char * args)
2053 if(!*args)
2054 return false;
2056 Player *player = getSelectedPlayer();
2057 if (!player)
2059 SendSysMessage(LANG_NO_CHAR_SELECTED);
2060 SetSentErrorMessage(true);
2061 return false;
2064 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
2065 GameTele const* tele = extractGameTeleFromLink((char*)args);
2066 if(!tele)
2068 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
2069 SetSentErrorMessage(true);
2070 return false;
2073 Group *grp = player->GetGroup();
2074 if(!grp)
2076 PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName());
2077 SetSentErrorMessage(true);
2078 return false;
2081 for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
2083 Player *pl = itr->getSource();
2085 if(!pl || !pl->GetSession() )
2086 continue;
2088 if(pl->IsBeingTeleported())
2090 PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName());
2091 continue;
2094 PSendSysMessage(LANG_TELEPORTING_TO, pl->GetName(),"", tele->name.c_str());
2096 if (m_session->GetPlayer() != pl && m_session->GetPlayer()->IsVisibleGloballyFor(pl))
2097 ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName());
2099 // stop flight if need
2100 if(pl->isInFlight())
2102 pl->GetMotionMaster()->MovementExpired();
2103 pl->m_taxi.ClearTaxiDestinations();
2105 // save only in non-flight case
2106 else
2107 pl->SaveRecallPosition();
2109 pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
2112 return true;
2115 //Summon group of player
2116 bool ChatHandler::HandleGroupgoCommand(const char* args)
2118 if(!*args)
2119 return false;
2121 std::string name = args;
2123 if(!normalizePlayerName(name))
2125 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2126 SetSentErrorMessage(true);
2127 return false;
2130 Player *player = objmgr.GetPlayer(name.c_str());
2131 if (!player)
2133 PSendSysMessage(LANG_NO_PLAYER, args);
2134 SetSentErrorMessage(true);
2135 return false;
2138 Group *grp = player->GetGroup();
2140 if(!grp)
2142 PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName());
2143 SetSentErrorMessage(true);
2144 return false;
2147 Map* gmMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer());
2148 bool to_instance = gmMap->Instanceable();
2150 // we are in instance, and can summon only player in our group with us as lead
2151 if ( to_instance && (
2152 !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
2153 (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) )
2154 // the last check is a bit excessive, but let it be, just in case
2156 SendSysMessage(LANG_CANNOT_SUMMON_TO_INST);
2157 SetSentErrorMessage(true);
2158 return false;
2161 for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
2163 Player *pl = itr->getSource();
2165 if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() )
2166 continue;
2168 if(pl->IsBeingTeleported()==true)
2170 PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName());
2171 SetSentErrorMessage(true);
2172 return false;
2175 if (to_instance)
2177 Map* plMap = MapManager::Instance().GetMap(pl->GetMapId(),pl);
2179 if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() )
2181 // cannot summon from instance to instance
2182 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,pl->GetName());
2183 SetSentErrorMessage(true);
2184 return false;
2188 PSendSysMessage(LANG_SUMMONING, pl->GetName(),"");
2190 if (m_session->GetPlayer()->IsVisibleGloballyFor(pl))
2191 ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, m_session->GetPlayer()->GetName());
2193 // stop flight if need
2194 if(pl->isInFlight())
2196 pl->GetMotionMaster()->MovementExpired();
2197 pl->m_taxi.ClearTaxiDestinations();
2199 // save only in non-flight case
2200 else
2201 pl->SaveRecallPosition();
2203 // before GM
2204 float x,y,z;
2205 m_session->GetPlayer()->GetClosePoint(x,y,z,pl->GetObjectSize());
2206 pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation());
2209 return true;
2212 //teleport at coordinates
2213 bool ChatHandler::HandleGoXYCommand(const char* args)
2215 if(!*args)
2216 return false;
2218 Player* _player = m_session->GetPlayer();
2220 char* px = strtok((char*)args, " ");
2221 char* py = strtok(NULL, " ");
2222 char* pmapid = strtok(NULL, " ");
2224 if (!px || !py)
2225 return false;
2227 float x = (float)atof(px);
2228 float y = (float)atof(py);
2229 uint32 mapid;
2230 if (pmapid)
2231 mapid = (uint32)atoi(pmapid);
2232 else mapid = _player->GetMapId();
2234 if(!MapManager::IsValidMapCoord(mapid,x,y))
2236 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2237 SetSentErrorMessage(true);
2238 return false;
2241 // stop flight if need
2242 if(_player->isInFlight())
2244 _player->GetMotionMaster()->MovementExpired();
2245 _player->m_taxi.ClearTaxiDestinations();
2247 // save only in non-flight case
2248 else
2249 _player->SaveRecallPosition();
2251 Map const *map = MapManager::Instance().GetBaseMap(mapid);
2252 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2254 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2256 return true;
2259 //teleport at coordinates, including Z
2260 bool ChatHandler::HandleGoXYZCommand(const char* args)
2262 if(!*args)
2263 return false;
2265 Player* _player = m_session->GetPlayer();
2267 char* px = strtok((char*)args, " ");
2268 char* py = strtok(NULL, " ");
2269 char* pz = strtok(NULL, " ");
2270 char* pmapid = strtok(NULL, " ");
2272 if (!px || !py || !pz)
2273 return false;
2275 float x = (float)atof(px);
2276 float y = (float)atof(py);
2277 float z = (float)atof(pz);
2278 uint32 mapid;
2279 if (pmapid)
2280 mapid = (uint32)atoi(pmapid);
2281 else
2282 mapid = _player->GetMapId();
2284 if(!MapManager::IsValidMapCoord(mapid,x,y,z))
2286 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2287 SetSentErrorMessage(true);
2288 return false;
2291 // stop flight if need
2292 if(_player->isInFlight())
2294 _player->GetMotionMaster()->MovementExpired();
2295 _player->m_taxi.ClearTaxiDestinations();
2297 // save only in non-flight case
2298 else
2299 _player->SaveRecallPosition();
2301 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2303 return true;
2306 //teleport at coordinates
2307 bool ChatHandler::HandleGoZoneXYCommand(const char* args)
2309 if(!*args)
2310 return false;
2312 Player* _player = m_session->GetPlayer();
2314 char* px = strtok((char*)args, " ");
2315 char* py = strtok(NULL, " ");
2316 char* tail = strtok(NULL,"");
2318 char* cAreaId = extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
2320 if (!px || !py)
2321 return false;
2323 float x = (float)atof(px);
2324 float y = (float)atof(py);
2325 uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId();
2327 AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid);
2329 if( x<0 || x>100 || y<0 || y>100 || !areaEntry )
2331 PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid);
2332 SetSentErrorMessage(true);
2333 return false;
2336 // update to parent zone if exist (client map show only zones without parents)
2337 AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry;
2339 Map const *map = MapManager::Instance().GetBaseMap(zoneEntry->mapid);
2341 if(map->Instanceable())
2343 PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[m_session->GetSessionDbcLocale()],map->GetId(),map->GetMapName());
2344 SetSentErrorMessage(true);
2345 return false;
2348 Zone2MapCoordinates(x,y,zoneEntry->ID);
2350 if(!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y))
2352 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid);
2353 SetSentErrorMessage(true);
2354 return false;
2357 // stop flight if need
2358 if(_player->isInFlight())
2360 _player->GetMotionMaster()->MovementExpired();
2361 _player->m_taxi.ClearTaxiDestinations();
2363 // save only in non-flight case
2364 else
2365 _player->SaveRecallPosition();
2367 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2368 _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation());
2370 return true;
2373 //teleport to grid
2374 bool ChatHandler::HandleGoGridCommand(const char* args)
2376 if(!*args) return false;
2377 Player* _player = m_session->GetPlayer();
2379 char* px = strtok((char*)args, " ");
2380 char* py = strtok(NULL, " ");
2381 char* pmapid = strtok(NULL, " ");
2383 if (!px || !py)
2384 return false;
2386 float grid_x = (float)atof(px);
2387 float grid_y = (float)atof(py);
2388 uint32 mapid;
2389 if (pmapid)
2390 mapid = (uint32)atoi(pmapid);
2391 else mapid = _player->GetMapId();
2393 // center of grid
2394 float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
2395 float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
2397 if(!MapManager::IsValidMapCoord(mapid,x,y))
2399 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2400 SetSentErrorMessage(true);
2401 return false;
2404 // stop flight if need
2405 if(_player->isInFlight())
2407 _player->GetMotionMaster()->MovementExpired();
2408 _player->m_taxi.ClearTaxiDestinations();
2410 // save only in non-flight case
2411 else
2412 _player->SaveRecallPosition();
2414 Map const *map = MapManager::Instance().GetBaseMap(mapid);
2415 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2416 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2418 return true;
2421 bool ChatHandler::HandleDrunkCommand(const char* args)
2423 if(!*args) return false;
2425 uint32 drunklevel = (uint32)atoi(args);
2426 if(drunklevel > 100)
2427 drunklevel = 100;
2429 uint16 drunkMod = drunklevel * 0xFFFF / 100;
2431 m_session->GetPlayer()->SetDrunkValue(drunkMod);
2433 return true;