AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
misc_commandscript Class Reference
Inheritance diagram for misc_commandscript:
CommandScript ScriptObject

Public Member Functions

 misc_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleSkirmishCommand (ChatHandler *handler, std::vector< std::string_view > args)
 
static bool HandleCommentatorCommand (ChatHandler *handler, Optional< bool > enableArg)
 
static bool HandleDevCommand (ChatHandler *handler, Optional< bool > enableArg)
 
static bool HandleGPSCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleAuraCommand (ChatHandler *handler, SpellInfo const *spell)
 
static bool HandleUnAuraCommand (ChatHandler *handler, Variant< SpellInfo const *, std::string_view > spells)
 
static bool HandleAppearCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleSummonCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleGroupSummonCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleCommandsCommand (ChatHandler *handler)
 
static bool HandleDieCommand (ChatHandler *handler)
 
static bool HandleReviveCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleDismountCommand (ChatHandler *handler)
 
static bool HandleGUIDCommand (ChatHandler *handler)
 
static bool HandleHelpCommand (ChatHandler *handler, Tail cmd)
 
static bool HandleCooldownCommand (ChatHandler *handler, Optional< SpellInfo const * > spell)
 
static bool HandleGetDistanceCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleRecallCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleSaveCommand (ChatHandler *handler)
 
static bool HandleSaveAllCommand (ChatHandler *handler)
 
static bool HandleKickPlayerCommand (ChatHandler *handler, Optional< PlayerIdentifier > target, Optional< std::string_view > reason)
 
static bool HandleUnstuckCommand (ChatHandler *handler, Optional< PlayerIdentifier > target, Optional< std::string_view > location)
 
static bool HandleLinkGraveCommand (ChatHandler *handler, uint32 graveyardId, Optional< std::string_view > team)
 
static bool HandleNearGraveCommand (ChatHandler *handler, Optional< std::string_view > team)
 
static bool HandleShowAreaCommand (ChatHandler *handler, uint32 areaID)
 
static bool HandleHideAreaCommand (ChatHandler *handler, uint32 areaID)
 
static bool HandleAddItemCommand (ChatHandler *handler, Optional< PlayerIdentifier > player, ItemTemplate const *itemTemplate, Optional< int32 > _count)
 
static bool HandleAddItemSetCommand (ChatHandler *handler, Variant< Hyperlink< itemset >, uint32 > itemSetId)
 
static bool HandleChangeWeather (ChatHandler *handler, uint32 type, float grade)
 
static bool HandleMaxSkillCommand (ChatHandler *handler)
 
static bool HandleSetSkillCommand (ChatHandler *handler, Variant< Hyperlink< skill >, uint32 > skillId, int32 level, Optional< uint16 > maxPureSkill)
 
static bool HandlePInfoCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleRespawnCommand (ChatHandler *handler)
 
static bool HandleRespawnAllCommand (ChatHandler *handler)
 
static bool HandleMuteCommand (ChatHandler *handler, Optional< PlayerIdentifier > player, std::string notSpeakTime, Tail muteReason)
 
static bool HandleUnmuteCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleMuteInfoCommand (ChatHandler *handler, std::string accountName)
 
static bool HandleMuteInfoHelper (ChatHandler *handler, uint32 accountId, char const *accountName)
 
static bool HandleMovegensCommand (ChatHandler *handler)
 
static bool HandleComeToMeCommand (ChatHandler *handler)
 
static bool HandleDamageCommand (ChatHandler *handler, uint32 damage)
 
static bool HandleCombatStopCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleFlushArenaPointsCommand (ChatHandler *)
 
static bool HandleFreezeCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleUnFreezeCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandlePlayAllCommand (ChatHandler *handler, uint32 soundId)
 
static bool HandlePossessCommand (ChatHandler *handler)
 
static bool HandleUnPossessCommand (ChatHandler *handler)
 
static bool HandleBindSightCommand (ChatHandler *handler)
 
static bool HandleUnbindSightCommand (ChatHandler *handler)
 
static bool HandleMailBoxCommand (ChatHandler *handler)
 
static bool HandleStringCommand (ChatHandler *handler, uint32 id, Optional< uint8 > locale)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ misc_commandscript()

misc_commandscript::misc_commandscript ( )
inline
87: CommandScript("misc_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable misc_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

90 {
91 static ChatCommandTable commandTable =
92 {
93 { "commentator", HandleCommentatorCommand, SEC_MODERATOR, Console::No },
94 { "dev", HandleDevCommand, SEC_ADMINISTRATOR, Console::No },
95 { "gps", HandleGPSCommand, SEC_MODERATOR, Console::No },
96 { "aura", HandleAuraCommand, SEC_GAMEMASTER, Console::No },
97 { "unaura", HandleUnAuraCommand, SEC_GAMEMASTER, Console::No },
98 { "appear", HandleAppearCommand, SEC_MODERATOR, Console::No },
99 { "summon", HandleSummonCommand, SEC_GAMEMASTER, Console::No },
100 { "groupsummon", HandleGroupSummonCommand, SEC_GAMEMASTER, Console::No },
101 { "commands", HandleCommandsCommand, SEC_PLAYER, Console::Yes },
102 { "die", HandleDieCommand, SEC_GAMEMASTER, Console::No },
103 { "revive", HandleReviveCommand, SEC_GAMEMASTER, Console::Yes },
104 { "dismount", HandleDismountCommand, SEC_PLAYER, Console::No },
105 { "guid", HandleGUIDCommand, SEC_GAMEMASTER, Console::No },
106 { "help", HandleHelpCommand, SEC_PLAYER, Console::Yes },
107 { "cooldown", HandleCooldownCommand, SEC_GAMEMASTER, Console::No },
108 { "distance", HandleGetDistanceCommand, SEC_ADMINISTRATOR, Console::No },
109 { "recall", HandleRecallCommand, SEC_GAMEMASTER, Console::No },
110 { "save", HandleSaveCommand, SEC_PLAYER, Console::No },
111 { "saveall", HandleSaveAllCommand, SEC_GAMEMASTER, Console::Yes },
112 { "kick", HandleKickPlayerCommand, SEC_GAMEMASTER, Console::Yes },
113 { "unstuck", HandleUnstuckCommand, SEC_GAMEMASTER, Console::Yes },
114 { "linkgrave", HandleLinkGraveCommand, SEC_ADMINISTRATOR, Console::No },
115 { "neargrave", HandleNearGraveCommand, SEC_GAMEMASTER, Console::No },
116 { "showarea", HandleShowAreaCommand, SEC_GAMEMASTER, Console::No },
117 { "hidearea", HandleHideAreaCommand, SEC_ADMINISTRATOR, Console::No },
118 { "additem", HandleAddItemCommand, SEC_GAMEMASTER, Console::Yes },
119 { "additem set", HandleAddItemSetCommand, SEC_GAMEMASTER, Console::No },
120 { "wchange", HandleChangeWeather, SEC_ADMINISTRATOR, Console::No },
121 { "maxskill", HandleMaxSkillCommand, SEC_GAMEMASTER, Console::No },
122 { "setskill", HandleSetSkillCommand, SEC_GAMEMASTER, Console::No },
123 { "pinfo", HandlePInfoCommand, SEC_GAMEMASTER, Console::Yes },
124 { "respawn", HandleRespawnCommand, SEC_GAMEMASTER, Console::No },
125 { "respawn all", HandleRespawnAllCommand, SEC_GAMEMASTER, Console::No },
126 { "mute", HandleMuteCommand, SEC_GAMEMASTER, Console::Yes },
127 { "mutehistory", HandleMuteInfoCommand, SEC_GAMEMASTER, Console::Yes },
128 { "unmute", HandleUnmuteCommand, SEC_GAMEMASTER, Console::Yes },
129 { "movegens", HandleMovegensCommand, SEC_ADMINISTRATOR, Console::No },
130 { "cometome", HandleComeToMeCommand, SEC_ADMINISTRATOR, Console::No },
131 { "damage", HandleDamageCommand, SEC_GAMEMASTER, Console::No },
132 { "combatstop", HandleCombatStopCommand, SEC_GAMEMASTER, Console::Yes },
133 { "flusharenapoints", HandleFlushArenaPointsCommand, SEC_ADMINISTRATOR, Console::Yes },
134 { "freeze", HandleFreezeCommand, SEC_GAMEMASTER, Console::No },
135 { "unfreeze", HandleUnFreezeCommand, SEC_GAMEMASTER, Console::No },
136 { "possess", HandlePossessCommand, SEC_GAMEMASTER, Console::No },
137 { "unpossess", HandleUnPossessCommand, SEC_GAMEMASTER, Console::No },
138 { "bindsight", HandleBindSightCommand, SEC_ADMINISTRATOR, Console::No },
139 { "unbindsight", HandleUnbindSightCommand, SEC_ADMINISTRATOR, Console::No },
140 { "playall", HandlePlayAllCommand, SEC_GAMEMASTER, Console::No },
141 { "skirmish", HandleSkirmishCommand, SEC_ADMINISTRATOR, Console::No },
142 { "mailbox", HandleMailBoxCommand, SEC_MODERATOR, Console::No },
143 { "string", HandleStringCommand, SEC_GAMEMASTER, Console::No }
144 };
145
146 return commandTable;
147 }
@ SEC_PLAYER
Definition: Common.h:59
@ SEC_ADMINISTRATOR
Definition: Common.h:62
@ SEC_GAMEMASTER
Definition: Common.h:61
@ SEC_MODERATOR
Definition: Common.h:60
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleCommentatorCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition: cs_misc.cpp:451
static bool HandleDevCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition: cs_misc.cpp:495
static bool HandleDamageCommand(ChatHandler *handler, uint32 damage)
Definition: cs_misc.cpp:2734
static bool HandleSaveCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1284
static bool HandleLinkGraveCommand(ChatHandler *handler, uint32 graveyardId, Optional< std::string_view > team)
Definition: cs_misc.cpp:1432
static bool HandlePlayAllCommand(ChatHandler *handler, uint32 soundId)
Definition: cs_misc.cpp:2893
static bool HandleAddItemCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, ItemTemplate const *itemTemplate, Optional< int32 > _count)
Definition: cs_misc.cpp:1622
static bool HandleAuraCommand(ChatHandler *handler, SpellInfo const *spell)
Definition: cs_misc.cpp:631
static bool HandleUnstuckCommand(ChatHandler *handler, Optional< PlayerIdentifier > target, Optional< std::string_view > location)
Definition: cs_misc.cpp:1369
static bool HandleRespawnAllCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2344
static bool HandleSkirmishCommand(ChatHandler *handler, std::vector< std::string_view > args)
Definition: cs_misc.cpp:149
static bool HandleUnbindSightCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2943
static bool HandleShowAreaCommand(ChatHandler *handler, uint32 areaID)
Definition: cs_misc.cpp:1560
static bool HandleStringCommand(ChatHandler *handler, uint32 id, Optional< uint8 > locale)
Definition: cs_misc.cpp:2963
static bool HandleChangeWeather(ChatHandler *handler, uint32 type, float grade)
Definition: cs_misc.cpp:1785
static bool HandlePInfoCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1873
static bool HandleSummonCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:840
static bool HandleCooldownCommand(ChatHandler *handler, Optional< SpellInfo const * > spell)
Definition: cs_misc.cpp:1189
static bool HandleReviveCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1110
static bool HandleCommandsCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1067
static bool HandleMailBoxCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2956
static bool HandleDieCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1073
static bool HandleAppearCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:691
static bool HandleHelpCommand(ChatHandler *handler, Tail cmd)
Definition: cs_misc.cpp:1177
static bool HandleRespawnCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2320
static bool HandleNearGraveCommand(ChatHandler *handler, Optional< std::string_view > team)
Definition: cs_misc.cpp:1483
static bool HandleMovegensCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2584
static bool HandleGUIDCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1163
static bool HandleAddItemSetCommand(ChatHandler *handler, Variant< Hyperlink< itemset >, uint32 > itemSetId)
Definition: cs_misc.cpp:1724
static bool HandleSaveAllCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1315
static bool HandleGPSCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:540
static bool HandleKickPlayerCommand(ChatHandler *handler, Optional< PlayerIdentifier > target, Optional< std::string_view > reason)
Definition: cs_misc.cpp:1323
static bool HandleHideAreaCommand(ChatHandler *handler, uint32 areaID)
Definition: cs_misc.cpp:1591
static bool HandleSetSkillCommand(ChatHandler *handler, Variant< Hyperlink< skill >, uint32 > skillId, int32 level, Optional< uint16 > maxPureSkill)
Definition: cs_misc.cpp:1829
static bool HandleUnmuteCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2484
static bool HandleRecallCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1247
static bool HandleBindSightCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2931
static bool HandleComeToMeCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2718
static bool HandleUnPossessCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2919
static bool HandleDismountCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1139
static bool HandleGroupSummonCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:962
static bool HandleCombatStopCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2776
static bool HandleUnAuraCommand(ChatHandler *handler, Variant< SpellInfo const *, std::string_view > spells)
Definition: cs_misc.cpp:657
static bool HandleGetDistanceCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1219
static bool HandleMaxSkillCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1815
static bool HandleFlushArenaPointsCommand(ChatHandler *)
Definition: cs_misc.cpp:2802
static bool HandleFreezeCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2808
static bool HandleMuteInfoCommand(ChatHandler *handler, std::string accountName)
Definition: cs_misc.cpp:2543
static bool HandleUnFreezeCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2851
static bool HandleMuteCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, std::string notSpeakTime, Tail muteReason)
Definition: cs_misc.cpp:2360
static bool HandlePossessCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2907

References HandleAddItemCommand(), HandleAddItemSetCommand(), HandleAppearCommand(), HandleAuraCommand(), HandleBindSightCommand(), HandleChangeWeather(), HandleCombatStopCommand(), HandleComeToMeCommand(), HandleCommandsCommand(), HandleCommentatorCommand(), HandleCooldownCommand(), HandleDamageCommand(), HandleDevCommand(), HandleDieCommand(), HandleDismountCommand(), HandleFlushArenaPointsCommand(), HandleFreezeCommand(), HandleGetDistanceCommand(), HandleGPSCommand(), HandleGroupSummonCommand(), HandleGUIDCommand(), HandleHelpCommand(), HandleHideAreaCommand(), HandleKickPlayerCommand(), HandleLinkGraveCommand(), HandleMailBoxCommand(), HandleMaxSkillCommand(), HandleMovegensCommand(), HandleMuteCommand(), HandleMuteInfoCommand(), HandleNearGraveCommand(), HandlePInfoCommand(), HandlePlayAllCommand(), HandlePossessCommand(), HandleRecallCommand(), HandleRespawnAllCommand(), HandleRespawnCommand(), HandleReviveCommand(), HandleSaveAllCommand(), HandleSaveCommand(), HandleSetSkillCommand(), HandleShowAreaCommand(), HandleSkirmishCommand(), HandleStringCommand(), HandleSummonCommand(), HandleUnAuraCommand(), HandleUnbindSightCommand(), HandleUnFreezeCommand(), HandleUnmuteCommand(), HandleUnPossessCommand(), HandleUnstuckCommand(), SEC_ADMINISTRATOR, SEC_GAMEMASTER, SEC_MODERATOR, and SEC_PLAYER.

◆ HandleAddItemCommand()

static bool misc_commandscript::HandleAddItemCommand ( ChatHandler handler,
Optional< PlayerIdentifier player,
ItemTemplate const *  itemTemplate,
Optional< int32 _count 
)
inlinestatic
1623 {
1624 if (!sObjectMgr->GetItemTemplate(itemTemplate->ItemId))
1625 {
1626 handler->SendErrorMessage(LANG_COMMAND_ITEMIDINVALID, itemTemplate->ItemId);
1627 return false;
1628 }
1629
1630 uint32 itemId = itemTemplate->ItemId;
1631 int32 count = 1;
1632
1633 if (_count)
1634 count = *_count;
1635
1636 if (!count)
1637 count = 1;
1638
1639 if (!player)
1640 player = PlayerIdentifier::FromTargetOrSelf(handler);
1641
1642 if (!player)
1643 return false;
1644
1645 Player* playerTarget = player->GetConnectedPlayer();
1646
1647 if (!playerTarget)
1648 return false;
1649
1650 // Subtract
1651 if (count < 0)
1652 {
1653 // Only have scam check on player accounts
1654 if (playerTarget->GetSession()->GetSecurity() == SEC_PLAYER)
1655 {
1656 if (!playerTarget->HasItemCount(itemId, 0))
1657 {
1658 // output that player don't have any items to destroy
1659 handler->SendErrorMessage(LANG_REMOVEITEM_FAILURE, handler->GetNameLink(playerTarget).c_str(), itemId);
1660 return false;
1661 }
1662
1663 if (!playerTarget->HasItemCount(itemId, -count))
1664 {
1665 // output that player don't have as many items that you want to destroy
1666 handler->SendErrorMessage(LANG_REMOVEITEM_ERROR, handler->GetNameLink(playerTarget).c_str(), itemId);
1667 return false;
1668 }
1669 }
1670
1671 // output successful amount of destroyed items
1672 playerTarget->DestroyItemCount(itemId, -count, true, false);
1673 handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str());
1674 return true;
1675 }
1676
1677 // Adding items
1678 uint32 noSpaceForCount = 0;
1679
1680 // check space and find places
1681 ItemPosCountVec dest;
1682 InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
1683
1684 if (msg != EQUIP_ERR_OK) // convert to possible store amount
1685 count -= noSpaceForCount;
1686
1687 if (!count || dest.empty()) // can't add any
1688 {
1689 handler->SendErrorMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
1690 return false;
1691 }
1692
1693 Item* item = playerTarget->StoreNewItem(dest, itemId, true);
1694
1695 Player* p = handler->GetSession()->GetPlayer();
1696 // remove binding (let GM give it to another player later)
1697 if (p && p == playerTarget)
1698 {
1699 for (auto const& itemPos : dest)
1700 {
1701 if (Item* item1 = p->GetItemByPos(itemPos.pos))
1702 {
1703 item1->SetBinding(false);
1704 }
1705 }
1706 }
1707
1708 if (p && count && item)
1709 {
1710 p->SendNewItem(item, count, false, true);
1711
1712 if (p != playerTarget)
1713 {
1714 playerTarget->SendNewItem(item, count, true, false);
1715 }
1716 }
1717
1718 if (noSpaceForCount)
1719 handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
1720
1721 return true;
1722 }
std::int32_t int32
Definition: Define.h:104
std::uint32_t uint32
Definition: Define.h:108
InventoryResult
Definition: Item.h:40
@ EQUIP_ERR_OK
Definition: Item.h:41
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:772
@ NULL_BAG
Definition: Unit.h:210
@ NULL_SLOT
Definition: Unit.h:211
#define sObjectMgr
Definition: ObjectMgr.h:1640
@ LANG_ITEM_CANNOT_CREATE
Definition: Language.h:520
@ LANG_REMOVEITEM_FAILURE
Definition: Language.h:1333
@ LANG_REMOVEITEM_ERROR
Definition: Language.h:1334
@ LANG_REMOVEITEM
Definition: Language.h:519
@ LANG_COMMAND_ITEMIDINVALID
Definition: Language.h:450
virtual std::string GetNameLink() const
Definition: Chat.h:101
WorldSession * GetSession()
Definition: Chat.h:139
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:152
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:188
Definition: Item.h:214
Definition: Player.h:1056
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition: PlayerStorage.cpp:683
WorldSession * GetSession() const
Definition: Player.h:1961
Item * GetItemByPos(uint16 pos) const
Definition: PlayerStorage.cpp:469
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast=false, bool sendChatMessage=true)
Definition: PlayerStorage.cpp:4770
void DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check=false)
Definition: PlayerStorage.cpp:3143
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0)
Definition: PlayerStorage.cpp:2546
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition: Player.h:1260
AccountTypes GetSecurity() const
Definition: WorldSession.h:361
Player * GetPlayer() const
Definition: WorldSession.h:364

References Player::CanStoreNewItem(), Player::DestroyItemCount(), EQUIP_ERR_OK, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), Player::GetItemByPos(), ChatHandler::GetNameLink(), WorldSession::GetPlayer(), WorldSession::GetSecurity(), ChatHandler::GetSession(), Player::GetSession(), Player::HasItemCount(), ItemTemplate::ItemId, LANG_COMMAND_ITEMIDINVALID, LANG_ITEM_CANNOT_CREATE, LANG_REMOVEITEM, LANG_REMOVEITEM_ERROR, LANG_REMOVEITEM_FAILURE, NULL_BAG, NULL_SLOT, ChatHandler::PSendSysMessage(), SEC_PLAYER, ChatHandler::SendErrorMessage(), Player::SendNewItem(), sObjectMgr, and Player::StoreNewItem().

Referenced by GetCommands().

◆ HandleAddItemSetCommand()

static bool misc_commandscript::HandleAddItemSetCommand ( ChatHandler handler,
Variant< Hyperlink< itemset >, uint32 itemSetId 
)
inlinestatic
1725 {
1726 // prevent generation all items with itemset field value '0'
1727 if (!*itemSetId)
1728 {
1730 return false;
1731 }
1732
1733 Player* player = handler->GetSession()->GetPlayer();
1734 Player* playerTarget = handler->getSelectedPlayer();
1735
1736 if (!playerTarget)
1737 {
1738 playerTarget = player;
1739 }
1740
1741 bool found = false;
1742
1743 for (auto const& [itemid, itemTemplate] : *sObjectMgr->GetItemTemplateStore())
1744 {
1745 if (itemTemplate.ItemSet == uint32(itemSetId))
1746 {
1747 found = true;
1748 ItemPosCountVec dest;
1749 InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemTemplate.ItemId, 1);
1750
1751 if (msg == EQUIP_ERR_OK)
1752 {
1753 Item* item = playerTarget->StoreNewItem(dest, itemTemplate.ItemId, true);
1754
1755 // remove binding (let GM give it to another player later)
1756 if (player == playerTarget)
1757 {
1758 item->SetBinding(false);
1759 }
1760
1761 player->SendNewItem(item, 1, false, true);
1762
1763 if (player != playerTarget)
1764 {
1765 playerTarget->SendNewItem(item, 1, true, false);
1766 }
1767 }
1768 else
1769 {
1770 player->SendEquipError(msg, nullptr, nullptr, itemTemplate.ItemId);
1771 handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemTemplate.ItemId, 1);
1772 }
1773 }
1774 }
1775
1776 if (!found)
1777 {
1779 return false;
1780 }
1781
1782 return true;
1783 }
@ LANG_NO_ITEMS_FROM_ITEMSET_FOUND
Definition: Language.h:525
Player * getSelectedPlayer() const
Definition: Chat.cpp:310
void SetBinding(bool val)
Definition: Item.h:229
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=nullptr, uint32 itemid=0)
Definition: PlayerStorage.cpp:4043

References Player::CanStoreNewItem(), EQUIP_ERR_OK, WorldSession::GetPlayer(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), LANG_ITEM_CANNOT_CREATE, LANG_NO_ITEMS_FROM_ITEMSET_FOUND, NULL_BAG, NULL_SLOT, ChatHandler::PSendSysMessage(), Player::SendEquipError(), ChatHandler::SendErrorMessage(), Player::SendNewItem(), Item::SetBinding(), sObjectMgr, and Player::StoreNewItem().

Referenced by GetCommands().

◆ HandleAppearCommand()

static bool misc_commandscript::HandleAppearCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
692 {
693 if (!target)
694 {
695 target = PlayerIdentifier::FromTarget(handler);
696 }
697
698 if (!target)
699 {
700 return false;
701 }
702
703 Player* _player = handler->GetSession()->GetPlayer();
704 if (target->GetGUID() == _player->GetGUID())
705 {
707 return false;
708 }
709
710 std::string nameLink = handler->playerLink(target->GetName());
711
712 if (target->IsConnected())
713 {
714 auto targetPlayer = target->GetConnectedPlayer();
715
716 // check online security
717 if (handler->HasLowerSecurity(targetPlayer))
718 {
719 return false;
720 }
721
722 Map* map = targetPlayer->GetMap();
723 if (map->IsBattlegroundOrArena())
724 {
725 // only allow if gm mode is on
726 if (!_player->IsGameMaster())
727 {
728 handler->SendErrorMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str());
729 return false;
730 }
731
732 if (!_player->GetMap()->IsBattlegroundOrArena())
733 {
734 _player->SetEntryPoint();
735 }
736
737 _player->SetBattlegroundId(targetPlayer->GetBattlegroundId(), targetPlayer->GetBattlegroundTypeId(), PLAYER_MAX_BATTLEGROUND_QUEUES, false, false, TEAM_NEUTRAL);
738 }
739 else if (map->IsDungeon())
740 {
741 // we have to go to instance, and can go to player only if:
742 // 1) we are in his group (either as leader or as member)
743 // 2) we are not bound to any group and have GM mode on
744 if (_player->GetGroup())
745 {
746 // we are in group, we can go only if we are in the player group
747 if (_player->GetGroup() != targetPlayer->GetGroup())
748 {
749 handler->SendErrorMessage(LANG_CANNOT_GO_TO_INST_PARTY, nameLink.c_str());
750 return false;
751 }
752 }
753 else
754 {
755 // we are not in group, let's verify our GM mode
756 if (!_player->IsGameMaster())
757 {
758 handler->SendErrorMessage(LANG_CANNOT_GO_TO_INST_GM, nameLink.c_str());
759 return false;
760 }
761 }
762
763 // if the GM is bound to another instance, he will not be bound to another one
764 InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(_player->GetGUID(), targetPlayer->GetMapId(), targetPlayer->GetDifficulty(map->IsRaid()));
765 if (!bind)
766 {
767 if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetConnectedPlayer()->GetInstanceId()))
768 {
769 sInstanceSaveMgr->PlayerBindToInstance(_player->GetGUID(), save, !save->CanReset(), _player);
770 }
771 }
772
773 if (map->IsRaid())
774 {
775 _player->SetRaidDifficulty(targetPlayer->GetRaidDifficulty());
776 }
777 else
778 {
779 _player->SetDungeonDifficulty(targetPlayer->GetDungeonDifficulty());
780 }
781 }
782
783 handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
784
785 // stop flight if need
786 if (_player->IsInFlight())
787 {
788 _player->GetMotionMaster()->MovementExpired();
789 _player->CleanupAfterTaxiFlight();
790 }
791 else // save only in non-flight case
792 {
793 _player->SaveRecallPosition();
794 }
795
796 if (_player->TeleportTo(targetPlayer->GetMapId(), targetPlayer->GetPositionX(), targetPlayer->GetPositionY(), targetPlayer->GetPositionZ() + 0.25f, _player->GetOrientation(), TELE_TO_GM_MODE, targetPlayer))
797 {
798 _player->SetPhaseMask(targetPlayer->GetPhaseMask() | 1, false);
799 }
800 }
801 else
802 {
803 // check offline security
804 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
805 {
806 return false;
807 }
808
809 handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
810
811 // to point where player stay (if loaded)
812 float x, y, z, o;
813 uint32 map;
814 bool in_flight;
815
816 if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, target->GetGUID().GetCounter()))
817 {
818 return false;
819 }
820
821 // stop flight if need
822 if (_player->IsInFlight())
823 {
824 _player->GetMotionMaster()->MovementExpired();
825 _player->CleanupAfterTaxiFlight();
826 }
827 // save only in non-flight case
828 else
829 {
830 _player->SaveRecallPosition();
831 }
832
833 _player->TeleportTo(map, x, y, z, _player->GetOrientation());
834 }
835
836 return true;
837 }
@ TELE_TO_GM_MODE
Definition: Player.h:814
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
@ LANG_CANNOT_GO_TO_INST_PARTY
Definition: Language.h:136
@ LANG_CANT_TELEPORT_SELF
Definition: Language.h:211
@ LANG_APPEARING_AT
Definition: Language.h:145
@ LANG_CANNOT_GO_TO_INST_GM
Definition: Language.h:137
@ LANG_CANNOT_GO_TO_BG_GM
Definition: Language.h:689
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:176
std::string playerLink(std::string const &name) const
Definition: Chat.h:128
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:53
static Optional< PlayerIdentifier > FromTarget(ChatHandler *handler)
Definition: ChatCommandTags.cpp:138
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
Map * GetMap() const
Definition: Object.h:517
float GetOrientation() const
Definition: Position.h:120
void SetDungeonDifficulty(Difficulty dungeon_difficulty)
Definition: Player.h:1887
void SetEntryPoint()
Definition: Player.cpp:11200
void SetRaidDifficulty(Difficulty raid_difficulty)
Definition: Player.h:1888
void SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
Definition: Player.cpp:12227
void SaveRecallPosition()
Definition: Player.cpp:5577
Group * GetGroup()
Definition: Player.h:2431
bool IsGameMaster() const
Definition: Player.h:1148
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1314
static bool LoadPositionFromDB(uint32 &mapid, float &x, float &y, float &z, float &o, bool &in_flight, ObjectGuid::LowType guid)
Definition: PlayerStorage.cpp:4895
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10346
MotionMaster * GetMotionMaster()
Definition: Unit.h:2276
bool IsInFlight() const
Definition: Unit.h:1690
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:19313
Definition: InstanceSaveMgr.h:39
Definition: InstanceSaveMgr.h:56
Definition: Map.h:313
bool IsDungeon() const
Definition: Map.h:448
bool IsBattlegroundOrArena() const
Definition: Map.h:456
bool IsRaid() const
Definition: Map.h:450
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178

References Player::CleanupAfterTaxiFlight(), Acore::ChatCommands::PlayerIdentifier::FromTarget(), Player::GetGroup(), Object::GetGUID(), WorldObject::GetMap(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), ChatHandler::HasLowerSecurity(), Map::IsBattlegroundOrArena(), Map::IsDungeon(), Player::IsGameMaster(), Unit::IsInFlight(), Map::IsRaid(), LANG_APPEARING_AT, LANG_CANNOT_GO_TO_BG_GM, LANG_CANNOT_GO_TO_INST_GM, LANG_CANNOT_GO_TO_INST_PARTY, LANG_CANT_TELEPORT_SELF, Player::LoadPositionFromDB(), MotionMaster::MovementExpired(), PLAYER_MAX_BATTLEGROUND_QUEUES, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), Player::SetBattlegroundId(), Player::SetDungeonDifficulty(), Player::SetEntryPoint(), Unit::SetPhaseMask(), Player::SetRaidDifficulty(), sInstanceSaveMgr, TEAM_NEUTRAL, TELE_TO_GM_MODE, and Player::TeleportTo().

Referenced by GetCommands().

◆ HandleAuraCommand()

static bool misc_commandscript::HandleAuraCommand ( ChatHandler handler,
SpellInfo const *  spell 
)
inlinestatic
632 {
633 if (!spell)
634 {
636 return false;
637 }
638
639 if (!SpellMgr::IsSpellValid(spell))
640 {
641 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
642 return false;
643 }
644
645 Unit* target = handler->getSelectedUnit();
646 if (!target)
647 {
649 return false;
650 }
651
652 Aura::TryRefreshStackOrCreate(spell, MAX_EFFECT_MASK, target, target);
653
654 return true;
655 }
@ LANG_COMMAND_NOSPELLFOUND
Definition: Language.h:460
@ LANG_SELECT_CHAR_OR_CREATURE
Definition: Language.h:31
@ LANG_COMMAND_SPELL_BROKEN
Definition: Language.h:503
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1636
Unit * getSelectedUnit() const
Definition: Chat.cpp:322
Definition: Unit.h:1302
static Aura * TryRefreshStackOrCreate(SpellInfo const *spellproto, uint8 tryEffMask, WorldObject *owner, Unit *caster, int32 *baseAmount=nullptr, Item *castItem=nullptr, ObjectGuid casterGUID=ObjectGuid::Empty, bool *refresh=nullptr, bool periodicReset=false)
Definition: SpellAuras.cpp:326
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition: SpellMgr.cpp:442

References ChatHandler::getSelectedUnit(), SpellInfo::Id, SpellMgr::IsSpellValid(), LANG_COMMAND_NOSPELLFOUND, LANG_COMMAND_SPELL_BROKEN, LANG_SELECT_CHAR_OR_CREATURE, MAX_EFFECT_MASK, ChatHandler::SendErrorMessage(), and Aura::TryRefreshStackOrCreate().

Referenced by GetCommands().

◆ HandleBindSightCommand()

static bool misc_commandscript::HandleBindSightCommand ( ChatHandler handler)
inlinestatic
2932 {
2933 Unit* unit = handler->getSelectedUnit();
2934 if (!unit)
2935 {
2936 return false;
2937 }
2938
2939 handler->GetSession()->GetPlayer()->CastSpell(unit, 6277, true);
2940 return true;
2941 }
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169

References Unit::CastSpell(), WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), and ChatHandler::GetSession().

Referenced by GetCommands().

◆ HandleChangeWeather()

static bool misc_commandscript::HandleChangeWeather ( ChatHandler handler,
uint32  type,
float  grade 
)
inlinestatic
1786 {
1787 // Weather is OFF
1788 if (!sWorld->getBoolConfig(CONFIG_WEATHER))
1789 {
1791 return false;
1792 }
1793
1794 Player* player = handler->GetSession()->GetPlayer();
1795 uint32 zoneid = player->GetZoneId();
1796
1797 Weather* weather = WeatherMgr::FindWeather(zoneid);
1798
1799 if (!weather)
1800 {
1801 weather = WeatherMgr::AddWeather(zoneid);
1802 }
1803
1804 if (!weather)
1805 {
1807 return false;
1808 }
1809
1810 weather->SetWeather(WeatherType(type), grade);
1811
1812 return true;
1813 }
@ LANG_NO_WEATHER
Definition: Language.h:415
@ LANG_WEATHER_DISABLED
Definition: Language.h:416
@ CONFIG_WEATHER
Definition: IWorld.h:99
WeatherType
Definition: SharedDefines.h:3137
#define sWorld
Definition: World.h:447
Weather * AddWeather(uint32 zone_id)
Add a Weather object to the list.
Definition: WeatherMgr.cpp:67
void SetWeather(WeatherType type, float grade)
Set the weather.
Definition: Weather.cpp:261
Weather * FindWeather(uint32 id)
Find a Weather object by the given zoneid.
Definition: WeatherMgr.cpp:50
uint32 GetZoneId() const
Definition: Object.cpp:3100
Weather for one zone.
Definition: Weather.h:65

References WeatherMgr::AddWeather(), CONFIG_WEATHER, WeatherMgr::FindWeather(), WorldSession::GetPlayer(), ChatHandler::GetSession(), WorldObject::GetZoneId(), LANG_NO_WEATHER, LANG_WEATHER_DISABLED, ChatHandler::SendErrorMessage(), Weather::SetWeather(), and sWorld.

Referenced by GetCommands().

◆ HandleCombatStopCommand()

static bool misc_commandscript::HandleCombatStopCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
2777 {
2778 if (!target)
2779 {
2780 target = PlayerIdentifier::FromTargetOrSelf(handler);
2781 }
2782
2783 if (!target || !target->IsConnected())
2784 {
2786 return false;
2787 }
2788
2789 Player* playerTarget = target->GetConnectedPlayer();
2790
2791 // check online security
2792 if (handler->HasLowerSecurity(playerTarget))
2793 {
2794 return false;
2795 }
2796
2797 playerTarget->CombatStop();
2798 playerTarget->getHostileRefMgr().deleteReferences();
2799 return true;
2800 }
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:522
void deleteReferences(bool removeFromMap=false)
Definition: HostileRefMgr.cpp:125
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10440
HostileRefMgr & getHostileRefMgr()
Definition: Unit.h:2163

References Unit::CombatStop(), HostileRefMgr::deleteReferences(), Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), Unit::getHostileRefMgr(), ChatHandler::HasLowerSecurity(), LANG_PLAYER_NOT_FOUND, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleComeToMeCommand()

static bool misc_commandscript::HandleComeToMeCommand ( ChatHandler handler)
inlinestatic
2719 {
2720 Creature* caster = handler->getSelectedCreature();
2721 if (!caster)
2722 {
2724 return false;
2725 }
2726
2727 Player* player = handler->GetSession()->GetPlayer();
2728
2729 caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
2730
2731 return true;
2732 }
@ LANG_SELECT_CREATURE
Definition: Language.h:32
Creature * getSelectedCreature() const
Definition: Chat.cpp:346
Definition: Creature.h:46
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
void MovePoint(uint32 id, const Position &pos, bool generatePath=true, bool forceDestination=true)
Definition: MotionMaster.h:211

References Unit::GetMotionMaster(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), LANG_SELECT_CREATURE, MotionMaster::MovePoint(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleCommandsCommand()

static bool misc_commandscript::HandleCommandsCommand ( ChatHandler handler)
inlinestatic
1068 {
1069 SendCommandHelpFor(*handler, "");
1070 return true;
1071 }
AC_GAME_API void SendCommandHelpFor(ChatHandler &handler, std::string_view cmd)
Definition: ChatCommand.cpp:536

References Acore::ChatCommands::SendCommandHelpFor().

Referenced by GetCommands().

◆ HandleCommentatorCommand()

static bool misc_commandscript::HandleCommentatorCommand ( ChatHandler handler,
Optional< bool >  enableArg 
)
inlinestatic
452 {
453 WorldSession* session = handler->GetSession();
454
455 if (!session)
456 {
457 return false;
458 }
459
460 auto SetCommentatorMod = [&](bool enable)
461 {
462 session->SendNotification(enable ? "Commentator mode on" : "Commentator mode off");
463 session->GetPlayer()->SetCommentator(enable);
464 };
465
466 if (!enableArg)
467 {
468 if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->IsCommentator())
469 {
470 SetCommentatorMod(true);
471 }
472 else
473 {
474 SetCommentatorMod(false);
475 }
476
477 return true;
478 }
479
480 if (*enableArg)
481 {
482 SetCommentatorMod(true);
483 return true;
484 }
485 else
486 {
487 SetCommentatorMod(false);
488 return true;
489 }
490
492 return false;
493 }
@ LANG_USE_BOL
Definition: Language.h:303
bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:276
bool IsCommentator() const
Definition: Player.h:1142
void SetCommentator(bool on)
Definition: Player.h:1143
Player session in the World.
Definition: WorldSession.h:330
void SendNotification(const char *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:785

References WorldSession::GetPlayer(), WorldSession::GetSecurity(), ChatHandler::GetSession(), Player::IsCommentator(), AccountMgr::IsPlayerAccount(), LANG_USE_BOL, ChatHandler::SendErrorMessage(), WorldSession::SendNotification(), and Player::SetCommentator().

Referenced by GetCommands().

◆ HandleCooldownCommand()

static bool misc_commandscript::HandleCooldownCommand ( ChatHandler handler,
Optional< SpellInfo const * >  spell 
)
inlinestatic
1190 {
1191 Player* target = handler->getSelectedPlayer();
1192 if (!target)
1193 {
1195 return false;
1196 }
1197
1198 std::string nameLink = handler->GetNameLink(target);
1199
1200 if (!spell)
1201 {
1202 target->RemoveAllSpellCooldown();
1203 handler->PSendSysMessage(LANG_REMOVEALL_COOLDOWN, nameLink.c_str());
1204 }
1205 else
1206 {
1207 if (!SpellMgr::IsSpellValid(*spell))
1208 {
1209 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell.value()->Id);
1210 return false;
1211 }
1212
1213 target->RemoveSpellCooldown(spell.value()->Id, true);
1214 handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spell.value()->Id, target == handler->GetSession()->GetPlayer() ? handler->GetAcoreString(LANG_YOU) : nameLink.c_str());
1215 }
1216 return true;
1217 }
@ LANG_YOU
Definition: Language.h:76
@ LANG_REMOVE_COOLDOWN
Definition: Language.h:515
@ LANG_REMOVEALL_COOLDOWN
Definition: Language.h:514
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:42
void RemoveAllSpellCooldown()
Definition: Player.cpp:3526
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition: Player.cpp:3475

References ChatHandler::GetAcoreString(), ChatHandler::GetNameLink(), WorldSession::GetPlayer(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), SpellMgr::IsSpellValid(), LANG_COMMAND_SPELL_BROKEN, LANG_PLAYER_NOT_FOUND, LANG_REMOVE_COOLDOWN, LANG_REMOVEALL_COOLDOWN, LANG_YOU, ChatHandler::PSendSysMessage(), Player::RemoveAllSpellCooldown(), Player::RemoveSpellCooldown(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleDamageCommand()

static bool misc_commandscript::HandleDamageCommand ( ChatHandler handler,
uint32  damage 
)
inlinestatic
2735 {
2736 Unit* target = handler->getSelectedUnit();
2737 if (!target || !handler->GetSession()->GetPlayer()->GetTarget())
2738 {
2740 return false;
2741 }
2742
2743 if (target->GetTypeId() == TYPEID_PLAYER)
2744 {
2745 if (handler->HasLowerSecurity(target->ToPlayer()))
2746 {
2747 return false;
2748 }
2749 }
2750
2751 if (!target->IsAlive())
2752 {
2753 return true;
2754 }
2755
2756 if (!damage)
2757 {
2758 return true;
2759 }
2760
2761 if (target->GetTypeId() == TYPEID_UNIT && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard
2762 {
2763 target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth());
2764 }
2765
2766 Unit::DealDamage(handler->GetSession()->GetPlayer(), target, damage, nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false, true);
2767
2768 if (target != handler->GetSession()->GetPlayer())
2769 {
2771 }
2772
2773 return true;
2774 }
@ SEC_CONSOLE
Definition: Common.h:63
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ VICTIMSTATE_HIT
Definition: Unit.h:167
@ HITINFO_AFFECTS_VICTIM
Definition: Unit.h:181
@ DIRECT_DAMAGE
Definition: Unit.h:435
@ SPELL_SCHOOL_MASK_NORMAL
Definition: SharedDefines.h:297
void LowerPlayerDamageReq(uint32 unDamage, bool damagedByPlayer=true)
Definition: Creature.cpp:3706
Player * ToPlayer()
Definition: Object.h:195
TypeID GetTypeId() const
Definition: Object.h:121
Creature * ToCreature()
Definition: Object.h:197
void SendAttackStateUpdate(CalcDamageInfo *damageInfo)
Definition: Unit.cpp:6417
uint32 GetMaxHealth() const
Definition: Unit.h:1455
bool IsAlive() const
Definition: Unit.h:1822
ObjectGuid GetTarget() const
Definition: Unit.h:2447
static uint32 DealDamage(Unit *attacker, Unit *victim, uint32 damage, CleanDamage const *cleanDamage=nullptr, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=nullptr, bool durabilityLoss=true, bool allowGM=false, Spell const *spell=nullptr)
Definition: Unit.cpp:815

References Unit::DealDamage(), DIRECT_DAMAGE, Unit::GetMaxHealth(), WorldSession::GetPlayer(), WorldSession::GetSecurity(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), Unit::GetTarget(), Object::GetTypeId(), ChatHandler::HasLowerSecurity(), HITINFO_AFFECTS_VICTIM, Unit::IsAlive(), LANG_SELECT_CHAR_OR_CREATURE, Creature::LowerPlayerDamageReq(), SEC_CONSOLE, Unit::SendAttackStateUpdate(), ChatHandler::SendErrorMessage(), SPELL_SCHOOL_MASK_NORMAL, Object::ToCreature(), Object::ToPlayer(), TYPEID_PLAYER, TYPEID_UNIT, and VICTIMSTATE_HIT.

Referenced by GetCommands().

◆ HandleDevCommand()

static bool misc_commandscript::HandleDevCommand ( ChatHandler handler,
Optional< bool >  enableArg 
)
inlinestatic
496 {
497 WorldSession* session = handler->GetSession();
498
499 if (!session)
500 {
501 return false;
502 }
503
504 auto SetDevMod = [&](bool enable)
505 {
506 session->SendNotification(enable ? LANG_DEV_ON : LANG_DEV_OFF);
507 session->GetPlayer()->SetDeveloper(enable);
508 sScriptMgr->OnHandleDevCommand(handler->GetSession()->GetPlayer(), enable);
509 };
510
511 if (!enableArg)
512 {
513 if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->IsDeveloper())
514 {
515 SetDevMod(true);
516 }
517 else
518 {
519 SetDevMod(false);
520 }
521
522 return true;
523 }
524
525 if (*enableArg)
526 {
527 SetDevMod(true);
528 return true;
529 }
530 else
531 {
532 SetDevMod(false);
533 return true;
534 }
535
537 return false;
538 }
@ LANG_DEV_ON
Definition: Language.h:908
@ LANG_DEV_OFF
Definition: Language.h:909
#define sScriptMgr
Definition: ScriptMgr.h:698
void SetDeveloper(bool on)
Definition: Player.h:1145
bool IsDeveloper() const
Definition: Player.h:1144

References WorldSession::GetPlayer(), WorldSession::GetSecurity(), ChatHandler::GetSession(), Player::IsDeveloper(), AccountMgr::IsPlayerAccount(), LANG_DEV_OFF, LANG_DEV_ON, LANG_USE_BOL, ChatHandler::SendErrorMessage(), WorldSession::SendNotification(), Player::SetDeveloper(), and sScriptMgr.

Referenced by GetCommands().

◆ HandleDieCommand()

static bool misc_commandscript::HandleDieCommand ( ChatHandler handler)
inlinestatic
1074 {
1075 Unit* target = handler->getSelectedUnit();
1076
1077 if (!target || !handler->GetSession()->GetPlayer()->GetTarget())
1078 {
1080 return false;
1081 }
1082
1083 if (target->GetTypeId() == TYPEID_PLAYER)
1084 {
1085 if (handler->HasLowerSecurity(target->ToPlayer()))
1086 {
1087 return false;
1088 }
1089 }
1090
1091 if (target->IsAlive())
1092 {
1093 if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE))
1094 {
1095 if (target->GetTypeId() == TYPEID_UNIT && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard
1096 {
1097 target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth());
1098 }
1099 Unit::Kill(handler->GetSession()->GetPlayer(), target);
1100 }
1101 else
1102 {
1103 Unit::DealDamage(handler->GetSession()->GetPlayer(), target, target->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false, true);
1104 }
1105 }
1106
1107 return true;
1108 }
@ CONFIG_DIE_COMMAND_MODE
Definition: IWorld.h:112
static void Kill(Unit *killer, Unit *victim, bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition: Unit.cpp:17956
uint32 GetHealth() const
Definition: Unit.h:1454

References CONFIG_DIE_COMMAND_MODE, Unit::DealDamage(), DIRECT_DAMAGE, Unit::GetHealth(), Unit::GetMaxHealth(), WorldSession::GetPlayer(), WorldSession::GetSecurity(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), Unit::GetTarget(), Object::GetTypeId(), ChatHandler::HasLowerSecurity(), Unit::IsAlive(), Unit::Kill(), LANG_SELECT_CHAR_OR_CREATURE, Creature::LowerPlayerDamageReq(), SEC_CONSOLE, ChatHandler::SendErrorMessage(), SPELL_SCHOOL_MASK_NORMAL, sWorld, Object::ToCreature(), Object::ToPlayer(), TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by GetCommands().

◆ HandleDismountCommand()

static bool misc_commandscript::HandleDismountCommand ( ChatHandler handler)
inlinestatic
1140 {
1141 Player* player = handler->GetSession()->GetPlayer();
1142
1143 // If player is not mounted, so go out :)
1144 if (!player->IsMounted())
1145 {
1147 return false;
1148 }
1149
1150 if (player->IsInFlight())
1151 {
1153 return false;
1154 }
1155
1156 player->Dismount();
1158 player->SetSpeed(MOVE_RUN, 1, true);
1159 player->SetSpeed(MOVE_FLIGHT, 1, true);
1160 return true;
1161 }
@ MOVE_FLIGHT
Definition: Unit.h:384
@ MOVE_RUN
Definition: Unit.h:379
@ LANG_CHAR_NON_MOUNTED
Definition: Language.h:54
@ LANG_YOU_IN_FLIGHT
Definition: Language.h:50
@ SPELL_AURA_MOUNTED
Definition: SpellAuraDefines.h:141
void Dismount()
Definition: Unit.cpp:13518
bool IsMounted() const
Definition: Unit.h:1556
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:14414
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
Definition: Unit.cpp:5045

References Unit::Dismount(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::IsInFlight(), Unit::IsMounted(), LANG_CHAR_NON_MOUNTED, LANG_YOU_IN_FLIGHT, MOVE_FLIGHT, MOVE_RUN, Unit::RemoveAurasByType(), ChatHandler::SendErrorMessage(), Unit::SetSpeed(), and SPELL_AURA_MOUNTED.

Referenced by GetCommands().

◆ HandleFlushArenaPointsCommand()

static bool misc_commandscript::HandleFlushArenaPointsCommand ( ChatHandler )
inlinestatic
2803 {
2804 sArenaTeamMgr->DistributeArenaPoints();
2805 return true;
2806 }
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67

References sArenaTeamMgr.

Referenced by GetCommands().

◆ HandleFreezeCommand()

static bool misc_commandscript::HandleFreezeCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
2809 {
2810 Creature* creatureTarget = handler->getSelectedCreature();
2811
2812 if (!target && !creatureTarget)
2813 {
2814 target = PlayerIdentifier::FromTargetOrSelf(handler);
2815 }
2816
2817 if (!target && !creatureTarget)
2818 {
2820 return false;
2821 }
2822
2823 Player* playerTarget = target->GetConnectedPlayer();
2824 if (playerTarget && !creatureTarget)
2825 {
2826 handler->PSendSysMessage(LANG_COMMAND_FREEZE, target->GetName().c_str());
2827
2828 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_FREEZE))
2829 {
2830 Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, playerTarget, playerTarget);
2831 }
2832
2833 return true;
2834 }
2835 else if (creatureTarget && creatureTarget->IsAlive())
2836 {
2837 handler->PSendSysMessage(LANG_COMMAND_FREEZE, GetLocalizeCreatureName(creatureTarget, handler->GetSessionDbcLocale()).c_str());
2838
2839 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_FREEZE))
2840 {
2841 Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, creatureTarget, creatureTarget);
2842 }
2843
2844 return true;
2845 }
2846
2848 return false;
2849 }
@ LANG_COMMAND_FREEZE
Definition: Language.h:1062
#define sSpellMgr
Definition: SpellMgr.h:825
constexpr auto SPELL_FREEZE
Definition: cs_misc.cpp:56
std::string const GetLocalizeCreatureName(Creature *creature, LocaleConstant locale)
Definition: cs_misc.cpp:58
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:789
Definition: SpellInfo.h:314

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), GetLocalizeCreatureName(), ChatHandler::getSelectedCreature(), ChatHandler::GetSessionDbcLocale(), Unit::IsAlive(), LANG_COMMAND_FREEZE, LANG_SELECT_CHAR_OR_CREATURE, MAX_EFFECT_MASK, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), SPELL_FREEZE, sSpellMgr, and Aura::TryRefreshStackOrCreate().

Referenced by GetCommands().

◆ HandleGetDistanceCommand()

static bool misc_commandscript::HandleGetDistanceCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
1220 {
1221 if (!target)
1222 {
1223 target = PlayerIdentifier::FromTargetOrSelf(handler);
1224 }
1225
1226 WorldObject* object = handler->getSelectedUnit();
1227
1228 if (!object && !target)
1229 {
1230 return false;
1231 }
1232
1233 if (!object && target && target->IsConnected())
1234 {
1235 object = target->GetConnectedPlayer();
1236 }
1237
1238 if (!object)
1239 {
1240 return false;
1241 }
1242
1243 handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(object), handler->GetSession()->GetPlayer()->GetDistance2d(object), handler->GetSession()->GetPlayer()->GetExactDist(object), handler->GetSession()->GetPlayer()->GetExactDist2d(object));
1244 return true;
1245 }
@ LANG_DISTANCE
Definition: Language.h:527
Definition: Object.h:393
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1263
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:166
float GetExactDist(float x, float y, float z) const
Definition: Position.h:178

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), WorldObject::GetDistance(), WorldObject::GetDistance2d(), Position::GetExactDist(), Position::GetExactDist2d(), WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), LANG_DISTANCE, and ChatHandler::PSendSysMessage().

Referenced by GetCommands().

◆ HandleGPSCommand()

static bool misc_commandscript::HandleGPSCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
541 {
542 if (!target)
543 {
544 target = PlayerIdentifier::FromTargetOrSelf(handler);
545 }
546
547 WorldObject* object = handler->getSelectedUnit();
548
549 if (!object && !target)
550 {
551 return false;
552 }
553
554 if (!object && target && target->IsConnected())
555 {
556 object = target->GetConnectedPlayer();
557 }
558
559 if (!object)
560 {
561 return false;
562 }
563
564 Cell cell(Acore::ComputeCellCoord(object->GetPositionX(), object->GetPositionY()));
565
566 uint32 zoneId, areaId;
567 object->GetZoneAndAreaId(zoneId, areaId);
568
569 MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
570 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(zoneId);
571 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
572
573 float zoneX = object->GetPositionX();
574 float zoneY = object->GetPositionY();
575
576 Map2ZoneCoordinates(zoneX, zoneY, zoneId);
577
578 float groundZ = object->GetMapHeight(object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
579 float floorZ = object->GetMapHeight(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
580
581 GridCoord gridCoord = Acore::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
582
583 // 63? WHY?
584 int gridX = 63 - gridCoord.x_coord;
585 int gridY = 63 - gridCoord.y_coord;
586
587 uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
588 uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
590
591 if (haveVMap)
592 {
593 if (object->IsOutdoors())
594 {
595 handler->PSendSysMessage("You are outdoors");
596 }
597 else
598 {
599 handler->PSendSysMessage("You are indoors");
600 }
601 }
602 else
603 {
604 handler->PSendSysMessage("no VMAP available for area info");
605 }
606
608 object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
609 zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
610 areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
611 object->GetPhaseMask(),
612 object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
613 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
614 zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMAP);
615
616 LiquidData const& liquidData = object->GetLiquidData();
617
618 if (liquidData.Status)
619 {
620 handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidData.Level, liquidData.DepthLevel, liquidData.Entry, liquidData.Flags, liquidData.Status);
621 }
622
623 if (object->GetTransport())
624 {
625 handler->PSendSysMessage("Transport offset: %.2f, %.2f, %.2f, %.2f", object->m_movementInfo.transport.pos.GetPositionX(), object->m_movementInfo.transport.pos.GetPositionY(), object->m_movementInfo.transport.pos.GetPositionZ(), object->m_movementInfo.transport.pos.GetOrientation());
626 }
627
628 return true;
629 }
void Map2ZoneCoordinates(float &x, float &y, uint32 zone)
Definition: DBCStores.cpp:744
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define MAX_HEIGHT
Definition: Map.h:164
@ LANG_LIQUID_STATUS
Definition: Language.h:215
@ LANG_MAP_POSITION
Definition: Language.h:133
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:186
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:191
static MMapMgr * createOrGetMMapMgr()
Definition: MMapFactory.cpp:29
dtNavMesh const * GetNavMesh(uint32 mapId)
Definition: MMapMgr.cpp:306
struct MovementInfo::TransportInfo transport
Position pos
Definition: Object.h:285
uint32 GetPhaseMask() const
Definition: Object.h:434
uint32 GetInstanceId() const
Definition: Object.h:431
bool IsOutdoors() const
Definition: Object.cpp:3125
Transport * GetTransport() const
Definition: Object.h:585
MovementInfo m_movementInfo
Definition: Object.h:595
uint32 GetMapId() const
Definition: Position.h:276
Definition: Cell.h:46
Definition: GridDefines.h:86
uint32 x_coord
Definition: GridDefines.h:153
uint32 y_coord
Definition: GridDefines.h:154
Definition: Map.h:171
float Level
Definition: Map.h:176
uint32 Flags
Definition: Map.h:175
uint32 Entry
Definition: Map.h:174
LiquidStatus Status
Definition: Map.h:178
float DepthLevel
Definition: Map.h:177
static bool ExistVMap(uint32 mapid, int gx, int gy)
Definition: Map.cpp:116
static bool ExistMap(uint32 mapid, int gx, int gy)
Definition: Map.cpp:85
Definition: DBCStructure.h:519
char const * area_name[16]
Definition: DBCStructure.h:527
Definition: DBCStructure.h:1323
char const * name[16]
Definition: DBCStructure.h:1329

References AreaTableEntry::area_name, Cell::CellX(), Cell::CellY(), Acore::ComputeCellCoord(), Acore::ComputeGridCoord(), MMAP::MMapFactory::createOrGetMMapMgr(), LiquidData::DepthLevel, LiquidData::Entry, Map::ExistMap(), Map::ExistVMap(), LiquidData::Flags, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), WorldObject::GetInstanceId(), WorldLocation::GetMapId(), MMAP::MMapMgr::GetNavMesh(), Position::GetOrientation(), WorldObject::GetPhaseMask(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), WorldObject::GetTransport(), Cell::GridX(), Cell::GridY(), WorldObject::IsOutdoors(), LANG_LIQUID_STATUS, LANG_MAP_POSITION, LiquidData::Level, WorldObject::m_movementInfo, Map2ZoneCoordinates(), MAX_HEIGHT, MapEntry::name, MovementInfo::TransportInfo::pos, ChatHandler::PSendSysMessage(), sAreaTableStore, sMapStore, LiquidData::Status, MovementInfo::transport, CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by GetCommands().

◆ HandleGroupSummonCommand()

static bool misc_commandscript::HandleGroupSummonCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
963 {
964 if (!target)
965 {
966 target = PlayerIdentifier::FromTargetOrSelf(handler);
967 }
968
969 if (!target || !target->IsConnected())
970 {
971 return false;
972 }
973
974 // check online security
975 if (handler->HasLowerSecurity(target->GetConnectedPlayer()))
976 {
977 return false;
978 }
979
980 auto targetPlayer = target->GetConnectedPlayer();
981
982 Group* group = targetPlayer->GetGroup();
983
984 std::string nameLink = handler->playerLink(target->GetName());
985
986 if (!group)
987 {
988 handler->SendErrorMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
989 return false;
990 }
991
992 Map* gmMap = handler->GetSession()->GetPlayer()->GetMap();
993 bool toInstance = gmMap->Instanceable();
994
995 // we are in instance, and can summon only player in our group with us as lead
996 if (toInstance && (
997 !handler->GetSession()->GetPlayer()->GetGroup() || (group->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
998 (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID())))
999 // the last check is a bit excessive, but let it be, just in case
1000 {
1002 return false;
1003 }
1004
1005 for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
1006 {
1007 Player* player = itr->GetSource();
1008
1009 if (!player || player == handler->GetSession()->GetPlayer() || !player->GetSession())
1010 {
1011 continue;
1012 }
1013
1014 // check online security
1015 if (handler->HasLowerSecurity(player))
1016 {
1017 return false;
1018 }
1019
1020 std::string plNameLink = handler->GetNameLink(player);
1021
1022 if (player->IsBeingTeleported())
1023 {
1024 handler->SendErrorMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
1025 return false;
1026 }
1027
1028 if (toInstance)
1029 {
1030 Map* playerMap = player->GetMap();
1031
1032 if (playerMap->Instanceable() && playerMap->GetInstanceId() != gmMap->GetInstanceId())
1033 {
1034 // cannot summon from instance to instance
1035 handler->SendErrorMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink.c_str());
1036 return false;
1037 }
1038 }
1039
1040 handler->PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), "");
1041 if (handler->needReportToTarget(player))
1042 {
1043 ChatHandler(player->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str());
1044 }
1045
1046 // stop flight if need
1047 if (player->IsInFlight())
1048 {
1049 player->GetMotionMaster()->MovementExpired();
1050 player->CleanupAfterTaxiFlight();
1051 }
1052 // save only in non-flight case
1053 else
1054 {
1055 player->SaveRecallPosition();
1056 }
1057
1058 // before GM
1059 float x, y, z;
1060 handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize());
1061 player->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation(), 0, handler->GetSession()->GetPlayer());
1062 }
1063
1064 return true;
1065 }
@ LANG_SUMMONING
Definition: Language.h:140
@ LANG_NOT_IN_GROUP
Definition: Language.h:149
@ LANG_IS_TELEPORTED
Definition: Language.h:134
@ LANG_CANNOT_SUMMON_TO_INST
Definition: Language.h:135
@ LANG_SUMMONED_BY
Definition: Language.h:141
Definition: Chat.h:38
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:783
bool GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0, WorldObject const *forWho=nullptr, bool force=false) const
Definition: Object.cpp:2687
float GetObjectSize() const
Definition: Object.cpp:2759
bool IsBeingTeleported() const
Definition: Player.h:2054
Definition: Group.h:169
GroupReference * GetFirstMember()
Definition: Group.h:243
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2235
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36
bool Instanceable() const
Definition: Map.h:447
uint32 GetInstanceId() const
Definition: Map.h:419

References Player::CleanupAfterTaxiFlight(), Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), WorldObject::GetClosePoint(), Group::GetFirstMember(), Player::GetGroup(), Object::GetGUID(), Map::GetInstanceId(), Group::GetLeaderGUID(), WorldObject::GetMap(), WorldLocation::GetMapId(), Unit::GetMotionMaster(), ChatHandler::GetNameLink(), WorldObject::GetObjectSize(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Player::GetSession(), ChatHandler::HasLowerSecurity(), Map::Instanceable(), Player::IsBeingTeleported(), Unit::IsInFlight(), LANG_CANNOT_SUMMON_TO_INST, LANG_IS_TELEPORTED, LANG_NOT_IN_GROUP, LANG_SUMMONED_BY, LANG_SUMMONING, MotionMaster::MovementExpired(), ChatHandler::needReportToTarget(), GroupReference::next(), ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), and Player::TeleportTo().

Referenced by GetCommands().

◆ HandleGUIDCommand()

static bool misc_commandscript::HandleGUIDCommand ( ChatHandler handler)
inlinestatic
1164 {
1165 ObjectGuid guid = handler->GetSession()->GetPlayer()->GetTarget();
1166
1167 if (!guid)
1168 {
1170 return false;
1171 }
1172
1173 handler->PSendSysMessage(LANG_OBJECT_GUID, guid.ToString().c_str());
1174 return true;
1175 }
@ LANG_OBJECT_GUID
Definition: Language.h:238
@ LANG_NO_SELECTION
Definition: Language.h:237
Definition: ObjectGuid.h:120
std::string ToString() const
Definition: ObjectGuid.cpp:47

References WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::GetTarget(), LANG_NO_SELECTION, LANG_OBJECT_GUID, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and ObjectGuid::ToString().

Referenced by GetCommands().

◆ HandleHelpCommand()

static bool misc_commandscript::HandleHelpCommand ( ChatHandler handler,
Tail  cmd 
)
inlinestatic
1178 {
1180
1181 if (cmd.empty())
1182 {
1184 }
1185
1186 return true;
1187 }

References Acore::ChatCommands::SendCommandHelpFor().

Referenced by GetCommands().

◆ HandleHideAreaCommand()

static bool misc_commandscript::HandleHideAreaCommand ( ChatHandler handler,
uint32  areaID 
)
inlinestatic
1592 {
1593 Player* playerTarget = handler->getSelectedPlayer();
1594 if (!playerTarget)
1595 {
1597 return false;
1598 }
1599
1600 AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaID);
1601 if (!area)
1602 {
1604 return false;
1605 }
1606
1607 int32 offset = area->exploreFlag / 32;
1608 if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
1609 {
1611 return false;
1612 }
1613
1614 uint32 val = uint32((1 << (area->exploreFlag % 32)));
1615 uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
1616 playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields ^ val)));
1617
1619 return true;
1620 }
@ PLAYER_EXPLORED_ZONES_1
Definition: UpdateFields.h:357
#define PLAYER_EXPLORED_ZONES_SIZE
Definition: Player.h:73
@ LANG_UNEXPLORE_AREA
Definition: Language.h:600
@ LANG_NO_CHAR_SELECTED
Definition: Language.h:148
@ LANG_BAD_VALUE
Definition: Language.h:147
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:101
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650
uint32 exploreFlag
Definition: DBCStructure.h:523

References AreaTableEntry::exploreFlag, ChatHandler::getSelectedPlayer(), Object::GetUInt32Value(), LANG_BAD_VALUE, LANG_NO_CHAR_SELECTED, LANG_UNEXPLORE_AREA, PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE, sAreaTableStore, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), and Object::SetUInt32Value().

Referenced by GetCommands().

◆ HandleKickPlayerCommand()

static bool misc_commandscript::HandleKickPlayerCommand ( ChatHandler handler,
Optional< PlayerIdentifier target,
Optional< std::string_view >  reason 
)
inlinestatic
1324 {
1325 if (!target)
1326 {
1327 target = PlayerIdentifier::FromTargetOrSelf(handler);
1328 }
1329
1330 if (!target || !target->IsConnected())
1331 {
1332 return false;
1333 }
1334
1335 auto targetPlayer = target->GetConnectedPlayer();
1336
1337 if (handler->GetSession() && target->GetGUID() == handler->GetSession()->GetPlayer()->GetGUID())
1338 {
1340 return false;
1341 }
1342
1343 // check online security
1344 if (handler->HasLowerSecurity(targetPlayer))
1345 {
1346 return false;
1347 }
1348
1349 std::string kickReasonStr = handler->GetAcoreString(LANG_NO_REASON);
1350 if (reason && !reason->empty())
1351 {
1352 kickReasonStr = std::string{ *reason };
1353 }
1354
1355 if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
1356 {
1357 sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), target->GetName().c_str(), kickReasonStr.c_str());
1358 }
1359 else
1360 {
1361 handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, target->GetName().c_str());
1362 }
1363
1364 targetPlayer->GetSession()->KickPlayer("HandleKickPlayerCommand");
1365
1366 return true;
1367 }
@ LANG_COMMAND_KICKSELF
Definition: Language.h:326
@ LANG_COMMAND_KICKMESSAGE_WORLD
Definition: Language.h:1298
@ LANG_NO_REASON
Definition: Language.h:790
@ LANG_COMMAND_KICKMESSAGE
Definition: Language.h:327
@ CONFIG_SHOW_KICK_IN_WORLD
Definition: IWorld.h:136
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:184

References CONFIG_SHOW_KICK_IN_WORLD, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), ChatHandler::GetAcoreString(), Object::GetGUID(), WorldSession::GetPlayer(), WorldSession::GetPlayerName(), ChatHandler::GetSession(), ChatHandler::HasLowerSecurity(), LANG_COMMAND_KICKMESSAGE, LANG_COMMAND_KICKMESSAGE_WORLD, LANG_COMMAND_KICKSELF, LANG_NO_REASON, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and sWorld.

Referenced by GetCommands().

◆ HandleLinkGraveCommand()

static bool misc_commandscript::HandleLinkGraveCommand ( ChatHandler handler,
uint32  graveyardId,
Optional< std::string_view >  team 
)
inlinestatic
1433 {
1434 TeamId teamId;
1435
1436 if (!team)
1437 {
1438 teamId = TEAM_NEUTRAL;
1439 }
1440 else if (StringEqualI(team->substr(0, 6), "horde"))
1441 {
1442 teamId = TEAM_HORDE;
1443 }
1444 else if (StringEqualI(team->substr(0, 9), "alliance"))
1445 {
1446 teamId = TEAM_ALLIANCE;
1447 }
1448 else
1449 {
1450 return false;
1451 }
1452
1453 GraveyardStruct const* graveyard = sGraveyard->GetGraveyard(graveyardId);
1454
1455 if (!graveyard)
1456 {
1457 handler->SendErrorMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId);
1458 return false;
1459 }
1460
1461 Player* player = handler->GetSession()->GetPlayer();
1462 uint32 zoneId = player->GetZoneId();
1463
1464 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(zoneId);
1465 if (!areaEntry || areaEntry->zone != 0)
1466 {
1467 handler->SendErrorMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, graveyardId, zoneId);
1468 return false;
1469 }
1470
1471 if (sGraveyard->AddGraveyardLink(graveyardId, zoneId, teamId))
1472 {
1473 handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, graveyardId, zoneId);
1474 }
1475 else
1476 {
1477 handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, graveyardId, zoneId);
1478 }
1479
1480 return true;
1481 }
bool StringEqualI(std::string_view a, std::string_view b)
Definition: Util.cpp:587
#define sGraveyard
Definition: GameGraveyard.h:75
@ LANG_COMMAND_GRAVEYARDALRLINKED
Definition: Language.h:465
@ LANG_COMMAND_GRAVEYARDNOEXIST
Definition: Language.h:464
@ LANG_COMMAND_GRAVEYARDWRONGZONE
Definition: Language.h:467
@ LANG_COMMAND_GRAVEYARDLINKED
Definition: Language.h:466
TeamId
Definition: SharedDefines.h:759
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
Definition: GameGraveyard.h:28
uint32 zone
Definition: DBCStructure.h:522

References WorldSession::GetPlayer(), ChatHandler::GetSession(), WorldObject::GetZoneId(), LANG_COMMAND_GRAVEYARDALRLINKED, LANG_COMMAND_GRAVEYARDLINKED, LANG_COMMAND_GRAVEYARDNOEXIST, LANG_COMMAND_GRAVEYARDWRONGZONE, ChatHandler::PSendSysMessage(), sAreaTableStore, ChatHandler::SendErrorMessage(), sGraveyard, StringEqualI(), TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, and AreaTableEntry::zone.

Referenced by GetCommands().

◆ HandleMailBoxCommand()

static bool misc_commandscript::HandleMailBoxCommand ( ChatHandler handler)
inlinestatic
2957 {
2958 Player* player = handler->GetSession()->GetPlayer();
2959 handler->GetSession()->SendShowMailBox(player->GetGUID());
2960 return true;
2961 }
void SendShowMailBox(ObjectGuid guid)
Definition: NPCHandler.cpp:72

References Object::GetGUID(), WorldSession::GetPlayer(), ChatHandler::GetSession(), and WorldSession::SendShowMailBox().

Referenced by GetCommands().

◆ HandleMaxSkillCommand()

static bool misc_commandscript::HandleMaxSkillCommand ( ChatHandler handler)
inlinestatic
1816 {
1817 Player* SelectedPlayer = handler->getSelectedPlayer();
1818 if (!SelectedPlayer)
1819 {
1821 return false;
1822 }
1823
1824 // each skills that have max skill value dependent from level seted to current level max skill value
1825 SelectedPlayer->UpdateSkillsToMaxSkillsForLevel();
1826 return true;
1827 }
void UpdateSkillsToMaxSkillsForLevel()
Definition: PlayerUpdates.cpp:1089

References ChatHandler::getSelectedPlayer(), LANG_NO_CHAR_SELECTED, ChatHandler::SendErrorMessage(), and Player::UpdateSkillsToMaxSkillsForLevel().

Referenced by GetCommands().

◆ HandleMovegensCommand()

static bool misc_commandscript::HandleMovegensCommand ( ChatHandler handler)
inlinestatic
2585 {
2586 Unit* unit = handler->getSelectedUnit();
2587 if (!unit)
2588 {
2590 return false;
2591 }
2592
2593 handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUID().GetCounter());
2594
2595 MotionMaster* motionMaster = unit->GetMotionMaster();
2596 float x, y, z;
2597 motionMaster->GetDestination(x, y, z);
2598
2599 for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
2600 {
2601 MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(i);
2602 if (!movementGenerator)
2603 {
2604 handler->SendSysMessage("Empty");
2605 continue;
2606 }
2607
2608 switch (movementGenerator->GetMovementGeneratorType())
2609 {
2610 case IDLE_MOTION_TYPE:
2612 break;
2613 case RANDOM_MOTION_TYPE:
2615 break;
2618 break;
2621 break;
2624 break;
2625 case CHASE_MOTION_TYPE:
2626 {
2627 Unit* target = nullptr;
2628 if (unit->GetTypeId() == TYPEID_PLAYER)
2629 {
2630 target = static_cast<ChaseMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
2631 }
2632 else
2633 {
2634 target = static_cast<ChaseMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
2635 }
2636
2637 if (!target)
2638 {
2640 }
2641 else if (target->GetTypeId() == TYPEID_PLAYER)
2642 {
2643 handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter());
2644 }
2645 else
2646 {
2647 handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter());
2648 }
2649 break;
2650 }
2651 case FOLLOW_MOTION_TYPE:
2652 {
2653 Unit* target = nullptr;
2654 if (unit->GetTypeId() == TYPEID_PLAYER)
2655 {
2656 target = static_cast<FollowMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
2657 }
2658 else
2659 {
2660 target = static_cast<FollowMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
2661 }
2662
2663 if (!target)
2664 {
2666 }
2667 else if (target->GetTypeId() == TYPEID_PLAYER)
2668 {
2669 handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter());
2670 }
2671 else
2672 {
2673 handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter());
2674 }
2675 break;
2676 }
2677 case HOME_MOTION_TYPE:
2678 {
2679 if (unit->GetTypeId() == TYPEID_UNIT)
2680 {
2682 }
2683 else
2684 {
2686 }
2687 break;
2688 }
2689 case FLIGHT_MOTION_TYPE:
2691 break;
2692 case POINT_MOTION_TYPE:
2693 {
2694 handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z);
2695 break;
2696 }
2699 break;
2702 break;
2703 case EFFECT_MOTION_TYPE:
2705 break;
2706 default:
2707 handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType());
2708 break;
2709 }
2710 }
2711 return true;
2712 }
std::uint8_t uint8
Definition: Define.h:110
@ LANG_MOVEGENS_FOLLOW_PLAYER
Definition: Language.h:910
@ LANG_MOVEGENS_EFFECT
Definition: Language.h:913
@ LANG_MOVEGENS_UNKNOWN
Definition: Language.h:567
@ LANG_MOVEGENS_CHASE_PLAYER
Definition: Language.h:561
@ LANG_MOVEGENS_IDLE
Definition: Language.h:556
@ LANG_MOVEGENS_CONFUSED
Definition: Language.h:560
@ LANG_MOVEGENS_FOLLOW_CREATURE
Definition: Language.h:911
@ LANG_MOVEGENS_FOLLOW_NULL
Definition: Language.h:912
@ LANG_MOVEGENS_DISTRACT
Definition: Language.h:635
@ LANG_MOVEGENS_CHASE_CREATURE
Definition: Language.h:562
@ LANG_MOVEGENS_RANDOM
Definition: Language.h:557
@ LANG_MOVEGENS_WAYPOINT
Definition: Language.h:558
@ LANG_MOVEGENS_POINT
Definition: Language.h:633
@ LANG_MOVEGENS_ANIMAL_RANDOM
Definition: Language.h:559
@ LANG_MOVEGENS_CHASE_NULL
Definition: Language.h:563
@ LANG_MOVEGENS_FLIGHT
Definition: Language.h:566
@ LANG_MOVEGENS_HOME_CREATURE
Definition: Language.h:564
@ LANG_MOVEGENS_HOME_PLAYER
Definition: Language.h:565
@ LANG_MOVEGENS_LIST
Definition: Language.h:555
@ LANG_MOVEGENS_FEAR
Definition: Language.h:634
@ MAX_MOTION_SLOT
Definition: MotionMaster.h:64
@ DISTRACT_MOTION_TYPE
Definition: MotionMaster.h:48
@ IDLE_MOTION_TYPE
Definition: MotionMaster.h:37
@ CHASE_MOTION_TYPE
Definition: MotionMaster.h:43
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:39
@ FLEEING_MOTION_TYPE
Definition: MotionMaster.h:47
@ CONFUSED_MOTION_TYPE
Definition: MotionMaster.h:42
@ HOME_MOTION_TYPE
Definition: MotionMaster.h:44
@ POINT_MOTION_TYPE
Definition: MotionMaster.h:46
@ FLIGHT_MOTION_TYPE
Definition: MotionMaster.h:45
@ FOLLOW_MOTION_TYPE
Definition: MotionMaster.h:52
@ ANIMAL_RANDOM_MOTION_TYPE
Definition: MotionMaster.h:41
@ RANDOM_MOTION_TYPE
Definition: MotionMaster.h:38
@ EFFECT_MOTION_TYPE
Definition: MotionMaster.h:54
std::string const & GetName() const
Definition: Object.h:446
LowType GetCounter() const
Definition: ObjectGuid.h:147
Definition: MotionMaster.h:110
_Ty GetMotionSlot(int slot) const
Definition: MotionMaster.h:153
bool GetDestination(float &x, float &y, float &z)
Definition: MotionMaster.cpp:908
Definition: MovementGenerator.h:30
virtual MovementGeneratorType GetMovementGeneratorType()=0
Definition: TargetedMovementGenerator.h:39
Definition: TargetedMovementGenerator.h:75

References ANIMAL_RANDOM_MOTION_TYPE, CHASE_MOTION_TYPE, CONFUSED_MOTION_TYPE, DISTRACT_MOTION_TYPE, EFFECT_MOTION_TYPE, FLEEING_MOTION_TYPE, FLIGHT_MOTION_TYPE, FOLLOW_MOTION_TYPE, ObjectGuid::GetCounter(), MotionMaster::GetDestination(), Object::GetGUID(), Unit::GetMotionMaster(), MotionMaster::GetMotionSlot(), MovementGenerator::GetMovementGeneratorType(), WorldObject::GetName(), ChatHandler::getSelectedUnit(), Object::GetTypeId(), HOME_MOTION_TYPE, IDLE_MOTION_TYPE, LANG_MOVEGENS_ANIMAL_RANDOM, LANG_MOVEGENS_CHASE_CREATURE, LANG_MOVEGENS_CHASE_NULL, LANG_MOVEGENS_CHASE_PLAYER, LANG_MOVEGENS_CONFUSED, LANG_MOVEGENS_DISTRACT, LANG_MOVEGENS_EFFECT, LANG_MOVEGENS_FEAR, LANG_MOVEGENS_FLIGHT, LANG_MOVEGENS_FOLLOW_CREATURE, LANG_MOVEGENS_FOLLOW_NULL, LANG_MOVEGENS_FOLLOW_PLAYER, LANG_MOVEGENS_HOME_CREATURE, LANG_MOVEGENS_HOME_PLAYER, LANG_MOVEGENS_IDLE, LANG_MOVEGENS_LIST, LANG_MOVEGENS_POINT, LANG_MOVEGENS_RANDOM, LANG_MOVEGENS_UNKNOWN, LANG_MOVEGENS_WAYPOINT, LANG_SELECT_CHAR_OR_CREATURE, MAX_MOTION_SLOT, POINT_MOTION_TYPE, ChatHandler::PSendSysMessage(), RANDOM_MOTION_TYPE, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), TYPEID_PLAYER, TYPEID_UNIT, and WAYPOINT_MOTION_TYPE.

Referenced by GetCommands().

◆ HandleMuteCommand()

static bool misc_commandscript::HandleMuteCommand ( ChatHandler handler,
Optional< PlayerIdentifier player,
std::string  notSpeakTime,
Tail  muteReason 
)
inlinestatic
2361 {
2362 std::string muteReasonStr{ muteReason };
2363
2364 if (notSpeakTime.empty())
2365 {
2366 return false;
2367 }
2368
2369 if (Acore::StringTo<int32>(notSpeakTime).value_or(0) < 0)
2370 {
2372 return false;
2373 }
2374
2375 if (muteReason.empty())
2376 {
2377 muteReasonStr = handler->GetAcoreString(LANG_NO_REASON);
2378 }
2379
2380 if (!player)
2381 {
2382 player = PlayerIdentifier::FromTarget(handler);
2383 }
2384
2385 if (!player)
2386 {
2388 return false;
2389 }
2390
2391 Player* target = player->GetConnectedPlayer();
2392 uint32 accountId = target ? target->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(player->GetGUID());
2393
2394 // find only player from same account if any
2395 if (!target)
2396 if (WorldSession* session = sWorld->FindSession(accountId))
2397 {
2398 target = session->GetPlayer();
2399 }
2400
2401 // must have strong lesser security level
2402 if (handler->HasLowerSecurity(target, player->GetGUID(), true))
2403 {
2404 return false;
2405 }
2406
2408 int32 muteDuration = TimeStringToSecs(notSpeakTime);
2409 if (muteDuration <= 0)
2410 {
2411 muteDuration = Acore::StringTo<int32>(notSpeakTime).value_or(0);
2412 }
2413
2414 if (muteDuration <= 0)
2415 {
2417 return false;
2418 }
2419
2420 std::string muteBy = "";
2421 if (handler->GetSession())
2422 {
2423 muteBy = handler->GetSession()->GetPlayerName();
2424 }
2425 else
2426 {
2427 muteBy = handler->GetAcoreString(LANG_CONSOLE);
2428 }
2429
2430 if (target)
2431 {
2432 // Target is online, mute will be in effect right away.
2433 int64 muteTime = GameTime::GetGameTime().count() + muteDuration;
2434 target->GetSession()->m_muteTime = muteTime;
2435 stmt->SetData(0, muteTime);
2436 std::string nameLink = handler->playerLink(player->GetName());
2437
2438 if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD))
2439 {
2440 sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), secsToTimeString(muteDuration, true).c_str(), muteReasonStr.c_str());
2441 }
2442
2443 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, secsToTimeString(muteDuration, true).c_str(), muteBy.c_str(), muteReasonStr.c_str());
2444 }
2445 else
2446 {
2447 // Target is offline, mute will be in effect starting from the next login.
2448 stmt->SetData(0, -int32(muteDuration));
2449 }
2450
2451 stmt->SetData(1, muteReasonStr);
2452 stmt->SetData(2, muteBy);
2453 stmt->SetData(3, accountId);
2454 LoginDatabase.Execute(stmt);
2455
2456 stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_MUTE);
2457 stmt->SetData(0, accountId);
2458 stmt->SetData(1, muteDuration / MINUTE);
2459 stmt->SetData(2, muteBy);
2460 stmt->SetData(3, muteReasonStr);
2461 LoginDatabase.Execute(stmt);
2462
2463 std::string nameLink = handler->playerLink(player->GetName());
2464
2465 if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target)
2466 {
2467 sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), secsToTimeString(muteDuration, true).c_str(), muteReasonStr.c_str());
2468 }
2469 else
2470 {
2471 // pussywizard: notify all online GMs
2472 std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
2474 for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
2475 if (itr->second->GetSession()->GetSecurity())
2477 (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : handler->GetAcoreString(LANG_CONSOLE)), nameLink.c_str(), secsToTimeString(muteDuration, true).c_str(), muteReasonStr.c_str());
2478 }
2479
2480 return true;
2481 }
constexpr auto MINUTE
Definition: Common.h:49
std::int64_t int64
Definition: Define.h:103
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition: Util.cpp:73
uint32 TimeStringToSecs(const std::string &timestring)
Definition: Util.cpp:163
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
@ LOGIN_UPD_MUTE_TIME
Definition: LoginDatabase.h:71
@ LOGIN_INS_ACCOUNT_MUTE
Definition: LoginDatabase.h:108
#define sCharacterCache
Definition: CharacterCache.h:83
@ LANG_COMMAND_DISABLE_CHAT_DELAYED
Definition: Language.h:328
@ LANG_YOUR_CHAT_DISABLED
Definition: Language.h:340
@ LANG_COMMAND_MUTEMESSAGE_WORLD
Definition: Language.h:1301
@ LANG_YOU_DISABLE_CHAT
Definition: Language.h:341
@ LANG_CONSOLE
Definition: Language.h:1102
@ CONFIG_SHOW_MUTE_IN_WORLD
Definition: IWorld.h:137
HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:78
Seconds GetGameTime()
Definition: GameTime.cpp:38
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
Definition: ObjectAccessor.h:45
std::unordered_map< ObjectGuid, T * > MapType
Definition: ObjectAccessor.h:51
uint32 GetAccountId() const
Definition: WorldSession.h:363
time_t m_muteTime
Definition: WorldSession.h:496

References CONFIG_SHOW_MUTE_IN_WORLD, Acore::ChatCommands::PlayerIdentifier::FromTarget(), WorldSession::GetAccountId(), ChatHandler::GetAcoreString(), GameTime::GetGameTime(), Object::GetGUID(), WorldSession::GetPlayerName(), ObjectAccessor::GetPlayers(), ChatHandler::GetSession(), Player::GetSession(), ChatHandler::HasLowerSecurity(), LANG_BAD_VALUE, LANG_COMMAND_DISABLE_CHAT_DELAYED, LANG_COMMAND_MUTEMESSAGE_WORLD, LANG_CONSOLE, LANG_NO_REASON, LANG_PLAYER_NOT_FOUND, LANG_YOU_DISABLE_CHAT, LANG_YOUR_CHAT_DISABLED, LOGIN_INS_ACCOUNT_MUTE, LOGIN_UPD_MUTE_TIME, LoginDatabase, WorldSession::m_muteTime, MINUTE, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), sCharacterCache, secsToTimeString(), ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), sWorld, and TimeStringToSecs().

Referenced by GetCommands().

◆ HandleMuteInfoCommand()

static bool misc_commandscript::HandleMuteInfoCommand ( ChatHandler handler,
std::string  accountName 
)
inlinestatic
2544 {
2545 if (!Utf8ToUpperOnlyLatin(accountName))
2546 {
2547 handler->SendErrorMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2548 return false;
2549 }
2550
2551 uint32 accountId = AccountMgr::GetId(accountName);
2552 if (!accountId)
2553 {
2554 handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2555 return false;
2556 }
2557
2558 return HandleMuteInfoHelper(handler, accountId, accountName.c_str());
2559 }
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:527
@ LANG_ACCOUNT_NOT_EXIST
Definition: Language.h:425
uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:200
static bool HandleMuteInfoHelper(ChatHandler *handler, uint32 accountId, char const *accountName)
Definition: cs_misc.cpp:2562

References AccountMgr::GetId(), HandleMuteInfoHelper(), LANG_ACCOUNT_NOT_EXIST, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and Utf8ToUpperOnlyLatin().

Referenced by GetCommands().

◆ HandleMuteInfoHelper()

static bool misc_commandscript::HandleMuteInfoHelper ( ChatHandler handler,
uint32  accountId,
char const *  accountName 
)
inlinestatic
2563 {
2565 stmt->SetData(0, accountId);
2566 PreparedQueryResult result = LoginDatabase.Query(stmt);
2567
2568 if (!result)
2569 {
2570 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_EMPTY, accountName);
2571 return true;
2572 }
2573
2574 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY, accountName);
2575 do
2576 {
2577 Field* fields = result->Fetch();
2578 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, Acore::Time::TimeToHumanReadable(Seconds(fields[0].Get<uint32>())).c_str(), fields[1].Get<uint32>(), fields[2].Get<std::string>().c_str(), fields[3].Get<std::string>().c_str());
2579 } while (result->NextRow());
2580
2581 return true;
2582 }
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:30
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ LOGIN_SEL_ACCOUNT_MUTE_INFO
Definition: LoginDatabase.h:109
@ LANG_COMMAND_MUTEHISTORY_OUTPUT
Definition: Language.h:1128
@ LANG_COMMAND_MUTEHISTORY_EMPTY
Definition: Language.h:1127
@ LANG_COMMAND_MUTEHISTORY
Definition: Language.h:1126
AC_COMMON_API std::string TimeToHumanReadable(Seconds time=0s, std::string_view fmt={})
Definition: Timer.cpp:287
Class used to access individual fields of database query result.
Definition: Field.h:99

References LANG_COMMAND_MUTEHISTORY, LANG_COMMAND_MUTEHISTORY_EMPTY, LANG_COMMAND_MUTEHISTORY_OUTPUT, LOGIN_SEL_ACCOUNT_MUTE_INFO, LoginDatabase, ChatHandler::PSendSysMessage(), PreparedStatementBase::SetData(), and Acore::Time::TimeToHumanReadable().

Referenced by HandleMuteInfoCommand().

◆ HandleNearGraveCommand()

static bool misc_commandscript::HandleNearGraveCommand ( ChatHandler handler,
Optional< std::string_view >  team 
)
inlinestatic
1484 {
1485 TeamId teamId;
1486
1487 if (!team)
1488 {
1489 teamId = TEAM_NEUTRAL;
1490 }
1491 else if (StringEqualI(team->substr(0, 6), "horde"))
1492 {
1493 teamId = TEAM_HORDE;
1494 }
1495 else if (StringEqualI(team->substr(0, 9), "alliance"))
1496 {
1497 teamId = TEAM_ALLIANCE;
1498 }
1499 else
1500 {
1501 return false;
1502 }
1503
1504 Player* player = handler->GetSession()->GetPlayer();
1505 uint32 zone_id = player->GetZoneId();
1506
1507 GraveyardStruct const* graveyard = sGraveyard->GetClosestGraveyard(player, teamId);
1508
1509 if (graveyard)
1510 {
1511 uint32 graveyardId = graveyard->ID;
1512
1513 GraveyardData const* data = sGraveyard->FindGraveyardData(graveyardId, zone_id);
1514 if (!data)
1515 {
1516 handler->SendErrorMessage(LANG_COMMAND_GRAVEYARDERROR, graveyardId);
1517 return false;
1518 }
1519
1520 std::string team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_NOTEAM);
1521
1522 if (data->teamId == TEAM_NEUTRAL)
1523 {
1524 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ANY);
1525 }
1526 else if (data->teamId == TEAM_HORDE)
1527 {
1528 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_HORDE);
1529 }
1530 else if (data->teamId == TEAM_ALLIANCE)
1531 {
1532 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
1533 }
1534
1535 handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, graveyardId, team_name.c_str(), zone_id);
1536 }
1537 else
1538 {
1539 std::string team_name;
1540
1541 if (teamId == TEAM_NEUTRAL)
1542 {
1543 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ANY);
1544 }
1545 else if (teamId == TEAM_HORDE)
1546 {
1547 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_HORDE);
1548 }
1549 else if (teamId == TEAM_ALLIANCE)
1550 {
1551 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
1552 }
1553
1554 handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str());
1555 }
1556
1557 return true;
1558 }
@ LANG_COMMAND_GRAVEYARD_ALLIANCE
Definition: Language.h:472
@ LANG_COMMAND_ZONENOGRAFACTION
Definition: Language.h:476
@ LANG_COMMAND_GRAVEYARDNEAREST
Definition: Language.h:474
@ LANG_COMMAND_GRAVEYARD_NOTEAM
Definition: Language.h:470
@ LANG_COMMAND_GRAVEYARDERROR
Definition: Language.h:469
@ LANG_COMMAND_GRAVEYARD_HORDE
Definition: Language.h:473
@ LANG_COMMAND_GRAVEYARD_ANY
Definition: Language.h:471
uint32 ID
Definition: GameGraveyard.h:29
Definition: GameGraveyard.h:39
TeamId teamId
Definition: GameGraveyard.h:41

References ChatHandler::GetAcoreString(), WorldSession::GetPlayer(), ChatHandler::GetSession(), WorldObject::GetZoneId(), GraveyardStruct::ID, LANG_COMMAND_GRAVEYARD_ALLIANCE, LANG_COMMAND_GRAVEYARD_ANY, LANG_COMMAND_GRAVEYARD_HORDE, LANG_COMMAND_GRAVEYARD_NOTEAM, LANG_COMMAND_GRAVEYARDERROR, LANG_COMMAND_GRAVEYARDNEAREST, LANG_COMMAND_ZONENOGRAFACTION, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), sGraveyard, StringEqualI(), TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, and GraveyardData::teamId.

Referenced by GetCommands().

◆ HandlePInfoCommand()

static bool misc_commandscript::HandlePInfoCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
1874 {
1875 if (!target)
1876 {
1877 target = PlayerIdentifier::FromTargetOrSelf(handler);
1878 }
1879
1880 if (!target)
1881 {
1882 return false;
1883 }
1884
1885 Player* playerTarget = target->GetConnectedPlayer();
1886
1887 CharacterDatabasePreparedStatement* stmt = nullptr;
1888 LoginDatabasePreparedStatement* loginStmt = nullptr;
1889
1890 // Account data print variables
1891 std::string userName = handler->GetAcoreString(LANG_ERROR);
1892 ObjectGuid::LowType lowguid = target->GetGUID().GetCounter();
1893 uint32 accId = 0;
1894 std::string eMail = handler->GetAcoreString(LANG_ERROR);
1895 std::string regMail = handler->GetAcoreString(LANG_ERROR);
1896 uint32 security = 0;
1897 std::string lastIp = handler->GetAcoreString(LANG_ERROR);
1898 uint8 locked = 0;
1899 std::string lastLogin = handler->GetAcoreString(LANG_ERROR);
1900 uint32 failedLogins = 0;
1901 uint32 latency = 0;
1902 std::string OS = handler->GetAcoreString(LANG_UNKNOWN);
1903
1904 // Mute data print variables
1905 int64 muteTime = -1;
1906 std::string muteReason = handler->GetAcoreString(LANG_NO_REASON);
1907 std::string muteBy = handler->GetAcoreString(LANG_UNKNOWN);
1908
1909 // Ban data print variables
1910 int64 banTime = -1;
1911 std::string banType = handler->GetAcoreString(LANG_UNKNOWN);
1912 std::string banReason = handler->GetAcoreString(LANG_NO_REASON);
1913 std::string bannedBy = handler->GetAcoreString(LANG_UNKNOWN);
1914
1915 // Character data print variables
1916 uint8 raceid, classid = 0; //RACE_NONE, CLASS_NONE
1917 std::string raceStr, classStr = handler->GetAcoreString(LANG_UNKNOWN);
1918 uint8 gender = 0;
1919 int8 locale = handler->GetSessionDbcLocale();
1920 uint32 totalPlayerTime = 0;
1921 uint8 level = 0;
1922 std::string alive = handler->GetAcoreString(LANG_ERROR);
1923 uint32 money = 0;
1924 uint32 xp = 0;
1925 uint32 xptotal = 0;
1926
1927 // Position data print
1928 uint32 mapId;
1929 uint32 areaId;
1930 uint32 phase = 0;
1931 char const* areaName = nullptr;
1932 char const* zoneName = nullptr;
1933
1934 // Guild data print variables defined so that they exist, but are not necessarily used
1935 uint32 guildId = 0;
1936 uint8 guildRankId = 0;
1937 std::string guildName;
1938 std::string guildRank;
1939 std::string note;
1940 std::string officeNote;
1941
1942 // get additional information from Player object
1943 if (playerTarget)
1944 {
1945 // check online security
1946 if (handler->HasLowerSecurity(playerTarget))
1947 {
1948 return false;
1949 }
1950
1951 accId = playerTarget->GetSession()->GetAccountId();
1952 money = playerTarget->GetMoney();
1953 totalPlayerTime = playerTarget->GetTotalPlayedTime();
1954 level = playerTarget->GetLevel();
1955 latency = playerTarget->GetSession()->GetLatency();
1956 raceid = playerTarget->getRace();
1957 classid = playerTarget->getClass();
1958 muteTime = playerTarget->GetSession()->m_muteTime;
1959 mapId = playerTarget->GetMapId();
1960 areaId = playerTarget->GetAreaId();
1961 alive = playerTarget->IsAlive() ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO);
1962 gender = playerTarget->getGender();
1963 phase = playerTarget->GetPhaseMask();
1964 }
1965 // get additional information from DB
1966 else
1967 {
1968 // check offline security
1969 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
1970 {
1971 return false;
1972 }
1973
1974 // Query informations from the DB
1975 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
1976 stmt->SetData(0, lowguid);
1977 PreparedQueryResult charInfoResult = CharacterDatabase.Query(stmt);
1978
1979 if (!charInfoResult)
1980 {
1981 return false;
1982 }
1983
1984 Field* fields = charInfoResult->Fetch();
1985 totalPlayerTime = fields[0].Get<uint32>();
1986 level = fields[1].Get<uint8>();
1987 money = fields[2].Get<uint32>();
1988 accId = fields[3].Get<uint32>();
1989 raceid = fields[4].Get<uint8>();
1990 classid = fields[5].Get<uint8>();
1991 mapId = fields[6].Get<uint16>();
1992 areaId = fields[7].Get<uint16>();
1993 gender = fields[8].Get<uint8>();
1994 uint32 health = fields[9].Get<uint32>();
1995 uint32 playerFlags = fields[10].Get<uint32>();
1996
1997 if (!health || playerFlags & PLAYER_FLAGS_GHOST)
1998 {
1999 alive = handler->GetAcoreString(LANG_NO);
2000 }
2001 else
2002 {
2003 alive = handler->GetAcoreString(LANG_YES);
2004 }
2005 }
2006
2007 // Query the prepared statement for login data
2008 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);
2009 loginStmt->SetData(0, int32(realm.Id.Realm));
2010 loginStmt->SetData(1, accId);
2011
2012 PreparedQueryResult accInfoResult = LoginDatabase.Query(loginStmt);
2013 if (accInfoResult)
2014 {
2015 Field* fields = accInfoResult->Fetch();
2016 userName = fields[0].Get<std::string>();
2017 security = fields[1].Get<uint8>();
2018
2019 // Only fetch these fields if commander has sufficient rights)
2020 if (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security))
2021 {
2022 eMail = fields[2].Get<std::string>();
2023 regMail = fields[3].Get<std::string>();
2024 lastIp = fields[4].Get<std::string>();
2025 lastLogin = fields[5].Get<std::string>();
2026
2027 if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(lastIp))
2028 {
2029 lastIp.append(" (");
2030 lastIp.append(location->CountryName);
2031 lastIp.append(")");
2032 }
2033 }
2034 else
2035 {
2036 eMail = handler->GetAcoreString(LANG_UNAUTHORIZED);
2037 regMail = handler->GetAcoreString(LANG_UNAUTHORIZED);
2038 lastIp = handler->GetAcoreString(LANG_UNAUTHORIZED);
2039 lastLogin = handler->GetAcoreString(LANG_UNAUTHORIZED);
2040 }
2041
2042 muteTime = fields[6].Get<uint64>();
2043 muteReason = fields[7].Get<std::string>();
2044 muteBy = fields[8].Get<std::string>();
2045 failedLogins = fields[9].Get<uint32>();
2046 locked = fields[10].Get<uint8>();
2047 OS = fields[11].Get<std::string>();
2048 }
2049
2050 // Creates a chat link to the character. Returns nameLink
2051 std::string nameLink = handler->playerLink(target->GetName());
2052
2053 // Returns banType, banTime, bannedBy, banreason
2054 LoginDatabasePreparedStatement* banQuery = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
2055 banQuery->SetData(0, accId);
2056
2057 PreparedQueryResult accBannedResult = LoginDatabase.Query(banQuery);
2058 if (!accBannedResult)
2059 {
2060 banType = handler->GetAcoreString(LANG_CHARACTER);
2061 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS);
2062 stmt->SetData(0, lowguid);
2063 accBannedResult = CharacterDatabase.Query(stmt);
2064 }
2065
2066 if (accBannedResult)
2067 {
2068 Field* fields = accBannedResult->Fetch();
2069 banTime = int64(fields[1].Get<uint64>() ? 0 : fields[0].Get<uint32>());
2070 bannedBy = fields[2].Get<std::string>();
2071 banReason = fields[3].Get<std::string>();
2072 }
2073
2074 // Can be used to query data from World database
2075 WorldDatabasePreparedStatement* xpQuery = WorldDatabase.GetPreparedStatement(WORLD_SEL_REQ_XP);
2076 xpQuery->SetData(0, level);
2077
2078 PreparedQueryResult xpResult = WorldDatabase.Query(xpQuery);
2079 if (xpResult)
2080 {
2081 Field* fields = xpResult->Fetch();
2082 xptotal = fields[0].Get<uint32>();
2083 }
2084
2085 // Can be used to query data from Characters database
2086 CharacterDatabasePreparedStatement* charXpQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_XP);
2087 charXpQuery->SetData(0, lowguid);
2088
2089 PreparedQueryResult charXpResult = CharacterDatabase.Query(charXpQuery);
2090 if (charXpResult)
2091 {
2092 Field* fields = charXpResult->Fetch();
2093 xp = fields[0].Get<uint32>();
2094 ObjectGuid::LowType gguid = fields[1].Get<uint32>();
2095
2096 if (gguid != 0)
2097 {
2099 guildQuery->SetData(0, lowguid);
2100
2101 PreparedQueryResult guildInfoResult = CharacterDatabase.Query(guildQuery);
2102 if (guildInfoResult)
2103 {
2104 Field* guildInfoFields = guildInfoResult->Fetch();
2105 guildId = guildInfoFields[0].Get<uint32>();
2106 guildName = guildInfoFields[1].Get<std::string>();
2107 guildRank = guildInfoFields[2].Get<std::string>();
2108 note = guildInfoFields[3].Get<std::string>();
2109 officeNote = guildInfoFields[4].Get<std::string>();
2110 }
2111 }
2112 }
2113
2114 // Initiate output
2115 // Output I. LANG_PINFO_PLAYER
2116 handler->PSendSysMessage(LANG_PINFO_PLAYER, playerTarget ? "" : handler->GetAcoreString(LANG_OFFLINE), nameLink.c_str(), target->GetGUID().GetCounter());
2117
2118 // Output II. LANG_PINFO_GM_ACTIVE if character is gamemaster
2119 if (playerTarget && playerTarget->IsGameMaster())
2120 {
2122 }
2123
2124 // Output III. LANG_PINFO_BANNED if ban exists and is applied
2125 if (banTime >= 0)
2126 {
2127 handler->PSendSysMessage(LANG_PINFO_BANNED, banType.c_str(), banReason.c_str(), banTime > 0 ? secsToTimeString(banTime - GameTime::GetGameTime().count(), true).c_str() : handler->GetAcoreString(LANG_PERMANENTLY), bannedBy.c_str());
2128 }
2129
2130 // Output IV. LANG_PINFO_MUTED if mute is applied
2131 if (muteTime > 0)
2132 {
2133 handler->PSendSysMessage(LANG_PINFO_MUTED, muteReason.c_str(), secsToTimeString(muteTime - GameTime::GetGameTime().count(), true).c_str(), muteBy.c_str());
2134 }
2135
2136 // Output V. LANG_PINFO_ACC_ACCOUNT
2137 handler->PSendSysMessage(LANG_PINFO_ACC_ACCOUNT, userName.c_str(), accId, security);
2138
2139 // Output VI. LANG_PINFO_ACC_LASTLOGIN
2140 handler->PSendSysMessage(LANG_PINFO_ACC_LASTLOGIN, lastLogin.c_str(), failedLogins);
2141
2142 // Output VII. LANG_PINFO_ACC_OS
2143 handler->PSendSysMessage(LANG_PINFO_ACC_OS, OS.c_str(), latency);
2144
2145 // Output VIII. LANG_PINFO_ACC_REGMAILS
2146 handler->PSendSysMessage(LANG_PINFO_ACC_REGMAILS, regMail.c_str(), eMail.c_str());
2147
2148 // Output IX. LANG_PINFO_ACC_IP
2149 handler->PSendSysMessage(LANG_PINFO_ACC_IP, lastIp.c_str(), locked ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO));
2150
2151 // Output X. LANG_PINFO_CHR_LEVEL
2152 if (level != sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
2153 {
2154 handler->PSendSysMessage(LANG_PINFO_CHR_LEVEL_LOW, level, xp, xptotal, (xptotal - xp));
2155 }
2156 else
2157 {
2159 }
2160
2161 // Output XI. LANG_PINFO_CHR_RACE
2162 switch (raceid)
2163 {
2164 case RACE_HUMAN:
2165 raceStr = "Human";
2166 break;
2167 case RACE_ORC:
2168 raceStr = "Orc";
2169 break;
2170 case RACE_DWARF:
2171 raceStr = "Dwarf";
2172 break;
2173 case RACE_NIGHTELF:
2174 raceStr = "Night Elf";
2175 break;
2176 case RACE_UNDEAD_PLAYER:
2177 raceStr = "Undead";
2178 break;
2179 case RACE_TAUREN:
2180 raceStr = "Tauren";
2181 break;
2182 case RACE_GNOME:
2183 raceStr = "Gnome";
2184 break;
2185 case RACE_TROLL:
2186 raceStr = "Troll";
2187 break;
2188 case RACE_BLOODELF:
2189 raceStr = "Blood Elf";
2190 break;
2191 case RACE_DRAENEI:
2192 raceStr = "Draenei";
2193 break;
2194 }
2195
2196 switch (classid)
2197 {
2198 case CLASS_WARRIOR:
2199 classStr = "Warrior";
2200 break;
2201 case CLASS_PALADIN:
2202 classStr = "Paladin";
2203 break;
2204 case CLASS_HUNTER:
2205 classStr = "Hunter";
2206 break;
2207 case CLASS_ROGUE:
2208 classStr = "Rogue";
2209 break;
2210 case CLASS_PRIEST:
2211 classStr = "Priest";
2212 break;
2213 case CLASS_DEATH_KNIGHT:
2214 classStr = "Death Knight";
2215 break;
2216 case CLASS_SHAMAN:
2217 classStr = "Shaman";
2218 break;
2219 case CLASS_MAGE:
2220 classStr = "Mage";
2221 break;
2222 case CLASS_WARLOCK:
2223 classStr = "Warlock";
2224 break;
2225 case CLASS_DRUID:
2226 classStr = "Druid";
2227 break;
2228 }
2229
2230 handler->PSendSysMessage(LANG_PINFO_CHR_RACE, (gender == 0 ? handler->GetAcoreString(LANG_CHARACTER_GENDER_MALE) : handler->GetAcoreString(LANG_CHARACTER_GENDER_FEMALE)), raceStr.c_str(), classStr.c_str());
2231
2232 // Output XII. LANG_PINFO_CHR_ALIVE
2233 handler->PSendSysMessage(LANG_PINFO_CHR_ALIVE, alive.c_str());
2234
2235 // Output XIII. LANG_PINFO_CHR_PHASE if player is not in GM mode (GM is in every phase)
2236 if (playerTarget && !playerTarget->IsGameMaster()) // IsInWorld() returns false on loadingscreen, so it's more
2237 {
2238 handler->PSendSysMessage(LANG_PINFO_CHR_PHASE, phase); // precise than just target (safer ?).
2239 }
2240
2241 // However, as we usually just require a target here, we use target instead.
2242 // Output XIV. LANG_PINFO_CHR_MONEY
2243 uint32 gold = money / GOLD;
2244 uint32 silv = (money % GOLD) / SILVER;
2245 uint32 copp = (money % GOLD) % SILVER;
2246 handler->PSendSysMessage(LANG_PINFO_CHR_MONEY, gold, silv, copp);
2247
2248 // Position data
2249 MapEntry const* map = sMapStore.LookupEntry(mapId);
2250 AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId);
2251
2252 if (area)
2253 {
2254 zoneName = area->area_name[locale];
2255
2256 AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->zone);
2257 if (zone)
2258 {
2259 areaName = zoneName;
2260 zoneName = zone->area_name[locale];
2261 }
2262 }
2263
2264 if (!zoneName)
2265 {
2266 zoneName = handler->GetAcoreString(LANG_UNKNOWN);
2267 }
2268
2269 if (areaName)
2270 {
2271 handler->PSendSysMessage(LANG_PINFO_CHR_MAP_WITH_AREA, map->name[locale], zoneName, areaName);
2272 }
2273 else
2274 {
2275 handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->name[locale], zoneName);
2276 }
2277
2278 // Output XVII. - XVIX. if they are not empty
2279 if (!guildName.empty())
2280 {
2281 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName.c_str(), guildId);
2282 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank.c_str(), uint32(guildRankId));
2283
2284 if (!note.empty())
2285 {
2286 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_NOTE, note.c_str());
2287 }
2288
2289 if (!officeNote.empty())
2290 {
2291 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_ONOTE, officeNote.c_str());
2292 }
2293 }
2294
2295 // Output XX. LANG_PINFO_CHR_PLAYEDTIME
2296 handler->PSendSysMessage(LANG_PINFO_CHR_PLAYEDTIME, (secsToTimeString(totalPlayerTime, true)).c_str());
2297
2298 // Mail Data - an own query, because it may or may not be useful.
2299 // SQL: "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?"
2301 mailQuery->SetData(0, lowguid);
2302
2303 PreparedQueryResult mailInfoResult = CharacterDatabase.Query(mailQuery);
2304 if (mailInfoResult)
2305 {
2306 Field* fields = mailInfoResult->Fetch();
2307 uint32 readmail = uint32(fields[0].Get<double>());
2308 uint32 totalmail = uint32(fields[1].Get<uint64>());
2309
2310 // Output XXI. LANG_INFO_CHR_MAILS if at least one mail is given
2311 if (totalmail >= 1)
2312 {
2313 handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, readmail, totalmail);
2314 }
2315 }
2316
2317 return true;
2318 }
AccountTypes
Definition: Common.h:58
std::int8_t int8
Definition: Define.h:106
std::uint64_t uint64
Definition: Define.h:107
std::uint16_t uint16
Definition: Define.h:109
#define sIPLocation
Definition: IPLocation.h:49
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
@ CHAR_SEL_PINFO_XP
Definition: CharacterDatabase.h:336
@ CHAR_SEL_GUILD_MEMBER_EXTENDED
Definition: CharacterDatabase.h:146
@ CHAR_SEL_CHAR_PINFO
Definition: CharacterDatabase.h:335
@ CHAR_SEL_PINFO_MAILS
Definition: CharacterDatabase.h:337
@ CHAR_SEL_PINFO_BANS
Definition: CharacterDatabase.h:338
@ LOGIN_SEL_PINFO
Definition: LoginDatabase.h:87
@ LOGIN_SEL_PINFO_BANS
Definition: LoginDatabase.h:88
@ WORLD_SEL_REQ_XP
Definition: WorldDatabase.h:101
@ PLAYER_FLAGS_GHOST
Definition: Player.h:479
@ LANG_YES
Definition: Language.h:434
@ LANG_CHARACTER_GENDER_FEMALE
Definition: Language.h:795
@ LANG_PINFO_CHR_GUILD_NOTE
Definition: Language.h:785
@ LANG_PINFO_CHR_ALIVE
Definition: Language.h:779
@ LANG_PINFO_ACC_LASTLOGIN
Definition: Language.h:773
@ LANG_CHARACTER
Definition: Language.h:1103
@ LANG_UNKNOWN
Definition: Language.h:77
@ LANG_PINFO_CHR_PHASE
Definition: Language.h:780
@ LANG_ERROR
Definition: Language.h:78
@ LANG_PERMANENTLY
Definition: Language.h:1104
@ LANG_OFFLINE
Definition: Language.h:69
@ LANG_PINFO_CHR_LEVEL_LOW
Definition: Language.h:777
@ LANG_PINFO_CHR_PLAYEDTIME
Definition: Language.h:787
@ LANG_UNAUTHORIZED
Definition: Language.h:791
@ LANG_PINFO_CHR_RACE
Definition: Language.h:778
@ LANG_PINFO_CHR_MAP_WITH_AREA
Definition: Language.h:792
@ LANG_PINFO_PLAYER
Definition: Language.h:768
@ LANG_PINFO_ACC_OS
Definition: Language.h:774
@ LANG_CHARACTER_GENDER_MALE
Definition: Language.h:794
@ LANG_PINFO_CHR_MONEY
Definition: Language.h:781
@ LANG_PINFO_CHR_LEVEL_HIGH
Definition: Language.h:789
@ LANG_NO
Definition: Language.h:435
@ LANG_PINFO_CHR_MAP
Definition: Language.h:782
@ LANG_PINFO_ACC_IP
Definition: Language.h:776
@ LANG_PINFO_BANNED
Definition: Language.h:770
@ LANG_PINFO_CHR_GUILD_RANK
Definition: Language.h:784
@ LANG_PINFO_ACC_ACCOUNT
Definition: Language.h:772
@ LANG_PINFO_ACC_REGMAILS
Definition: Language.h:775
@ LANG_PINFO_GM_ACTIVE
Definition: Language.h:769
@ LANG_PINFO_CHR_MAILS
Definition: Language.h:788
@ LANG_PINFO_CHR_GUILD
Definition: Language.h:783
@ LANG_PINFO_CHR_GUILD_ONOTE
Definition: Language.h:786
@ LANG_PINFO_MUTED
Definition: Language.h:771
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:236
phase
Definition: boss_skadi.cpp:103
@ CLASS_HUNTER
Definition: SharedDefines.h:143
@ CLASS_DRUID
Definition: SharedDefines.h:151
@ CLASS_SHAMAN
Definition: SharedDefines.h:147
@ CLASS_PRIEST
Definition: SharedDefines.h:145
@ CLASS_WARRIOR
Definition: SharedDefines.h:141
@ CLASS_WARLOCK
Definition: SharedDefines.h:149
@ CLASS_MAGE
Definition: SharedDefines.h:148
@ CLASS_DEATH_KNIGHT
Definition: SharedDefines.h:146
@ CLASS_PALADIN
Definition: SharedDefines.h:142
@ CLASS_ROGUE
Definition: SharedDefines.h:144
@ SILVER
Definition: SharedDefines.h:252
@ GOLD
Definition: SharedDefines.h:253
@ RACE_TROLL
Definition: SharedDefines.h:78
@ RACE_UNDEAD_PLAYER
Definition: SharedDefines.h:75
@ RACE_ORC
Definition: SharedDefines.h:72
@ RACE_DRAENEI
Definition: SharedDefines.h:81
@ RACE_NIGHTELF
Definition: SharedDefines.h:74
@ RACE_BLOODELF
Definition: SharedDefines.h:80
@ RACE_DWARF
Definition: SharedDefines.h:73
@ RACE_GNOME
Definition: SharedDefines.h:77
@ RACE_HUMAN
Definition: SharedDefines.h:71
@ RACE_TAUREN
Definition: SharedDefines.h:76
Realm realm
Definition: World.cpp:112
Definition: IPLocation.h:23
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
uint32 GetAreaId() const
Definition: Object.cpp:3108
uint32 LowType
Definition: ObjectGuid.h:124
uint32 GetTotalPlayedTime()
Definition: Player.h:1174
uint32 GetMoney() const
Definition: Player.h:1580
uint8 getGender() const
Definition: Unit.h:1440
uint8 getClass() const
Definition: Unit.h:1438
uint8 getRace(bool original=false) const
Definition: Unit.cpp:21287
uint8 GetLevel() const
Definition: Unit.h:1432
uint32 GetLatency() const
Definition: WorldSession.h:503
uint32 Realm
Definition: Realm.h:42
RealmHandle Id
Definition: Realm.h:68

References AreaTableEntry::area_name, CHAR_SEL_CHAR_PINFO, CHAR_SEL_GUILD_MEMBER_EXTENDED, CHAR_SEL_PINFO_BANS, CHAR_SEL_PINFO_MAILS, CHAR_SEL_PINFO_XP, CharacterDatabase, CLASS_DEATH_KNIGHT, CLASS_DRUID, CLASS_HUNTER, CLASS_MAGE, CLASS_PALADIN, CLASS_PRIEST, CLASS_ROGUE, CLASS_SHAMAN, CLASS_WARLOCK, CLASS_WARRIOR, CONFIG_MAX_PLAYER_LEVEL, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), Field::Get(), WorldSession::GetAccountId(), ChatHandler::GetAcoreString(), WorldObject::GetAreaId(), Unit::getClass(), GameTime::GetGameTime(), Unit::getGender(), WorldSession::GetLatency(), Unit::GetLevel(), WorldLocation::GetMapId(), Player::GetMoney(), WorldObject::GetPhaseMask(), Unit::getRace(), WorldSession::GetSecurity(), ChatHandler::GetSession(), Player::GetSession(), ChatHandler::GetSessionDbcLocale(), Player::GetTotalPlayedTime(), GOLD, ChatHandler::HasLowerSecurity(), Realm::Id, Unit::IsAlive(), Player::IsGameMaster(), LANG_CHARACTER, LANG_CHARACTER_GENDER_FEMALE, LANG_CHARACTER_GENDER_MALE, LANG_ERROR, LANG_NO, LANG_NO_REASON, LANG_OFFLINE, LANG_PERMANENTLY, LANG_PINFO_ACC_ACCOUNT, LANG_PINFO_ACC_IP, LANG_PINFO_ACC_LASTLOGIN, LANG_PINFO_ACC_OS, LANG_PINFO_ACC_REGMAILS, LANG_PINFO_BANNED, LANG_PINFO_CHR_ALIVE, LANG_PINFO_CHR_GUILD, LANG_PINFO_CHR_GUILD_NOTE, LANG_PINFO_CHR_GUILD_ONOTE, LANG_PINFO_CHR_GUILD_RANK, LANG_PINFO_CHR_LEVEL_HIGH, LANG_PINFO_CHR_LEVEL_LOW, LANG_PINFO_CHR_MAILS, LANG_PINFO_CHR_MAP, LANG_PINFO_CHR_MAP_WITH_AREA, LANG_PINFO_CHR_MONEY, LANG_PINFO_CHR_PHASE, LANG_PINFO_CHR_PLAYEDTIME, LANG_PINFO_CHR_RACE, LANG_PINFO_GM_ACTIVE, LANG_PINFO_MUTED, LANG_PINFO_PLAYER, LANG_UNAUTHORIZED, LANG_UNKNOWN, LANG_YES, LOGIN_SEL_PINFO, LOGIN_SEL_PINFO_BANS, LoginDatabase, WorldSession::m_muteTime, MapEntry::name, PLAYER_FLAGS_GHOST, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), RACE_BLOODELF, RACE_DRAENEI, RACE_DWARF, RACE_GNOME, RACE_HUMAN, RACE_NIGHTELF, RACE_ORC, RACE_TAUREN, RACE_TROLL, RACE_UNDEAD_PLAYER, realm, RealmHandle::Realm, sAreaTableStore, secsToTimeString(), PreparedStatementBase::SetData(), SILVER, sIPLocation, sMapStore, sWorld, WORLD_SEL_REQ_XP, WorldDatabase, and AreaTableEntry::zone.

Referenced by GetCommands().

◆ HandlePlayAllCommand()

static bool misc_commandscript::HandlePlayAllCommand ( ChatHandler handler,
uint32  soundId 
)
inlinestatic
2894 {
2895 if (!sSoundEntriesStore.LookupEntry(soundId))
2896 {
2897 handler->SendErrorMessage(LANG_SOUND_NOT_EXIST, soundId);
2898 return false;
2899 }
2900
2901 sWorld->SendGlobalMessage(WorldPackets::Misc::Playsound(soundId).Write());
2902
2904 return true;
2905 }
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
@ LANG_COMMAND_PLAYED_TO_ALL
Definition: Language.h:1071
@ LANG_SOUND_NOT_EXIST
Definition: Language.h:210
Definition: MiscPackets.h:85

References LANG_COMMAND_PLAYED_TO_ALL, LANG_SOUND_NOT_EXIST, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), sSoundEntriesStore, and sWorld.

Referenced by GetCommands().

◆ HandlePossessCommand()

static bool misc_commandscript::HandlePossessCommand ( ChatHandler handler)
inlinestatic
2908 {
2909 Unit* unit = handler->getSelectedUnit();
2910 if (!unit)
2911 {
2912 return false;
2913 }
2914
2915 handler->GetSession()->GetPlayer()->CastSpell(unit, 530, true);
2916 return true;
2917 }

References Unit::CastSpell(), WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), and ChatHandler::GetSession().

Referenced by GetCommands().

◆ HandleRecallCommand()

static bool misc_commandscript::HandleRecallCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
1248 {
1249 if (!target)
1250 {
1251 target = PlayerIdentifier::FromTargetOrSelf(handler);
1252 }
1253
1254 if (!target || !target->IsConnected())
1255 {
1256 return false;
1257 }
1258
1259 auto targetPlayer = target->GetConnectedPlayer();
1260
1261 // check online security
1262 if (handler->HasLowerSecurity(targetPlayer))
1263 {
1264 return false;
1265 }
1266
1267 if (targetPlayer->IsBeingTeleported())
1268 {
1269 handler->SendErrorMessage(LANG_IS_TELEPORTED, handler->playerLink(target->GetName()).c_str());
1270 return false;
1271 }
1272
1273 // stop flight if need
1274 if (targetPlayer->IsInFlight())
1275 {
1276 targetPlayer->GetMotionMaster()->MovementExpired();
1277 targetPlayer->CleanupAfterTaxiFlight();
1278 }
1279
1280 targetPlayer->TeleportTo(targetPlayer->m_recallMap, targetPlayer->m_recallX, targetPlayer->m_recallY, targetPlayer->m_recallZ, targetPlayer->m_recallO);
1281 return true;
1282 }

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), ChatHandler::HasLowerSecurity(), LANG_IS_TELEPORTED, ChatHandler::playerLink(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleRespawnAllCommand()

static bool misc_commandscript::HandleRespawnAllCommand ( ChatHandler handler)
inlinestatic
2345 {
2346 Player* player = handler->GetSession()->GetPlayer();
2347
2349 Cell cell(p);
2350 cell.SetNoCreate();
2351
2352 Acore::RespawnDo u_do;
2353 Acore::WorldObjectWorker<Acore::RespawnDo> worker(player, u_do);
2354 Cell::VisitGridObjects(player, worker, player->GetGridActivationRange());
2355
2356 return true;
2357 }
float GetGridActivationRange() const
Definition: Object.cpp:1623
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
Definition: GridNotifiers.h:257
Definition: GridNotifiers.h:642

References Acore::ComputeCellCoord(), WorldObject::GetGridActivationRange(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), ChatHandler::GetSession(), Cell::SetNoCreate(), and Cell::VisitGridObjects().

Referenced by GetCommands().

◆ HandleRespawnCommand()

static bool misc_commandscript::HandleRespawnCommand ( ChatHandler handler)
inlinestatic
2321 {
2322 Player* player = handler->GetSession()->GetPlayer();
2323
2324 Unit* target = handler->getSelectedUnit();
2325 if (player->GetTarget() && target)
2326 {
2327 if (target->GetTypeId() != TYPEID_UNIT || target->IsPet())
2328 {
2330 return false;
2331 }
2332
2333 if (target->isDead())
2334 {
2335 target->ToCreature()->Respawn(true);
2336 }
2337 return true;
2338 }
2339
2341 return false;
2342 }
void Respawn(bool force=false)
Definition: Creature.cpp:1974
bool IsPet() const
Definition: Unit.h:1425
bool isDead() const
Definition: Unit.h:1824

References WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), Unit::GetTarget(), Object::GetTypeId(), Unit::isDead(), Unit::IsPet(), LANG_SELECT_CREATURE, Creature::Respawn(), ChatHandler::SendErrorMessage(), Object::ToCreature(), and TYPEID_UNIT.

Referenced by GetCommands().

◆ HandleReviveCommand()

static bool misc_commandscript::HandleReviveCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
1111 {
1112 if (!target)
1113 {
1114 target = PlayerIdentifier::FromTargetOrSelf(handler);
1115 }
1116
1117 if (!target)
1118 {
1119 return false;
1120 }
1121
1122 if (target->IsConnected())
1123 {
1124 auto targetPlayer = target->GetConnectedPlayer();
1125
1126 targetPlayer->ResurrectPlayer(!AccountMgr::IsPlayerAccount(targetPlayer->GetSession()->GetSecurity()) ? 1.0f : 0.5f);
1127 targetPlayer->SpawnCorpseBones();
1128 targetPlayer->SaveToDB(false, false);
1129 }
1130 else
1131 {
1132 CharacterDatabaseTransaction trans(nullptr);
1133 Player::OfflineResurrect(target->GetGUID(), trans);
1134 }
1135
1136 return true;
1137 }
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
static void OfflineResurrect(ObjectGuid const guid, CharacterDatabaseTransaction trans)
Definition: Player.cpp:4496

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), AccountMgr::IsPlayerAccount(), and Player::OfflineResurrect().

Referenced by GetCommands().

◆ HandleSaveAllCommand()

static bool misc_commandscript::HandleSaveAllCommand ( ChatHandler handler)
inlinestatic
1316 {
1319 return true;
1320 }
@ LANG_PLAYERS_SAVED
Definition: Language.h:47
void SaveAllPlayers()
Definition: ObjectAccessor.cpp:265

References LANG_PLAYERS_SAVED, ObjectAccessor::SaveAllPlayers(), and ChatHandler::SendSysMessage().

Referenced by GetCommands().

◆ HandleSaveCommand()

static bool misc_commandscript::HandleSaveCommand ( ChatHandler handler)
inlinestatic
1285 {
1286 Player* player = handler->GetSession()->GetPlayer();
1287
1288 // save GM account without delay and output message
1289 if (handler->GetSession()->GetSecurity() >= SEC_GAMEMASTER)
1290 {
1291 if (Player* target = handler->getSelectedPlayer())
1292 {
1293 target->SaveToDB(false, false);
1294 }
1295 else
1296 {
1297 player->SaveToDB(false, false);
1298 }
1299
1301 return true;
1302 }
1303
1304 // save if the player has last been saved over 20 seconds ago
1305 uint32 saveInterval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
1306 if (saveInterval == 0 || (saveInterval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= saveInterval - 20 * IN_MILLISECONDS))
1307 {
1308 player->SaveToDB(false, false);
1309 }
1310
1311 return true;
1312 }
constexpr auto IN_MILLISECONDS
Definition: Common.h:55
@ LANG_PLAYER_SAVED
Definition: Language.h:46
@ CONFIG_INTERVAL_SAVE
Definition: IWorld.h:214
void SaveToDB(bool create, bool logout)
Definition: PlayerStorage.cpp:7073
uint32 GetSaveTimer() const
Definition: Player.h:2317

References CONFIG_INTERVAL_SAVE, WorldSession::GetPlayer(), Player::GetSaveTimer(), WorldSession::GetSecurity(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), IN_MILLISECONDS, LANG_PLAYER_SAVED, Player::SaveToDB(), SEC_GAMEMASTER, ChatHandler::SendSysMessage(), and sWorld.

Referenced by GetCommands().

◆ HandleSetSkillCommand()

static bool misc_commandscript::HandleSetSkillCommand ( ChatHandler handler,
Variant< Hyperlink< skill >, uint32 skillId,
int32  level,
Optional< uint16 maxPureSkill 
)
inlinestatic
1830 {
1831 uint32 skillID = uint32(skillId);
1832
1833 if (skillID <= 0)
1834 {
1835 handler->SendErrorMessage(LANG_INVALID_SKILL_ID, skillID);
1836 return false;
1837 }
1838
1839 Player* target = handler->getSelectedPlayer();
1840 if (!target)
1841 {
1843 return false;
1844 }
1845
1846 SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skillID);
1847 if (!skillLine)
1848 {
1849 handler->SendErrorMessage(LANG_INVALID_SKILL_ID, uint32(skillID));
1850 return false;
1851 }
1852
1853 bool targetHasSkill = target->GetSkillValue(skillID);
1854
1855 // If our target does not yet have the skill they are trying to add to them, the chosen level also becomes
1856 // the max level of the new profession.
1857 uint16 max = maxPureSkill ? *maxPureSkill : targetHasSkill ? target->GetPureMaxSkillValue(skillID) : uint16(level);
1858
1859 if (level <= 0 || level > max || max <= 0)
1860 {
1861 return false;
1862 }
1863
1864 // If the player has the skill, we get the current skill step. If they don't have the skill, we
1865 // add the skill to the player's book with step 1 (which is the first rank, in most cases something
1866 // like 'Apprentice <skill>'.
1867 target->SetSkill(skillID, targetHasSkill ? target->GetSkillStep(skillID) : 1, level, max);
1868 handler->PSendSysMessage(LANG_SET_SKILL, skillID, skillLine->name[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max);
1869 return true;
1870 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ LANG_INVALID_SKILL_ID
Definition: Language.h:508
@ LANG_SET_SKILL
Definition: Language.h:505
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5367
uint16 GetSkillStep(uint16 skill) const
Definition: Player.cpp:5355
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5402
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition: Player.cpp:5244
Definition: DBCStructure.h:1581
char const * name[16]
Definition: DBCStructure.h:1585

References ChatHandler::GetNameLink(), Player::GetPureMaxSkillValue(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSessionDbcLocale(), Player::GetSkillStep(), Player::GetSkillValue(), LANG_INVALID_SKILL_ID, LANG_NO_CHAR_SELECTED, LANG_SET_SKILL, SkillLineEntry::name, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), Player::SetSkill(), and sSkillLineStore.

Referenced by GetCommands().

◆ HandleShowAreaCommand()

static bool misc_commandscript::HandleShowAreaCommand ( ChatHandler handler,
uint32  areaID 
)
inlinestatic
1561 {
1562 Player* playerTarget = handler->getSelectedPlayer();
1563 if (!playerTarget)
1564 {
1566 return false;
1567 }
1568
1569 AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaID);
1570 if (!area)
1571 {
1573 return false;
1574 }
1575
1576 int32 offset = area->exploreFlag / 32;
1577 if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
1578 {
1580 return false;
1581 }
1582
1583 uint32 val = uint32((1 << (area->exploreFlag % 32)));
1584 uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
1585 playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields | val)));
1586
1588 return true;
1589 }
@ LANG_EXPLORE_AREA
Definition: Language.h:599

References AreaTableEntry::exploreFlag, ChatHandler::getSelectedPlayer(), Object::GetUInt32Value(), LANG_BAD_VALUE, LANG_EXPLORE_AREA, LANG_NO_CHAR_SELECTED, PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE, sAreaTableStore, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), and Object::SetUInt32Value().

Referenced by GetCommands().

◆ HandleSkirmishCommand()

static bool misc_commandscript::HandleSkirmishCommand ( ChatHandler handler,
std::vector< std::string_view >  args 
)
inlinestatic
150 {
151 auto tokens = args;
152
153 if (args.empty() || !tokens.size())
154 {
155 handler->PSendSysMessage("Usage: .skirmish [arena] [XvX] [Nick1] [Nick2] ... [NickN]");
156 handler->PSendSysMessage("[arena] can be \"all\" or comma-separated list of possible arenas (NA, BE, RL, DS, RV).");
157 handler->PSendSysMessage("[XvX] can be 1v1, 2v2, 3v3, 5v5. After [XvX] specify enough nicknames for that mode.");
158 handler->SetSentErrorMessage(true);
159 return false;
160 }
161
162 auto tokensItr = tokens.begin();
163
164 std::vector<BattlegroundTypeId> allowedArenas;
165 std::string_view arenasStr = *(tokensItr++);
166
167 auto arenaTokens = Acore::Tokenize(arenasStr, ',', false);
168 for (auto const& arenaName : arenaTokens)
169 {
170 if (arenaName == "all")
171 {
172 if (arenaTokens.size() > 1)
173 {
174 handler->SendErrorMessage("Invalid [arena] specified.");
175 return false;
176 }
177
178 allowedArenas.emplace_back(BATTLEGROUND_NA);
179 allowedArenas.emplace_back(BATTLEGROUND_BE);
180 allowedArenas.emplace_back(BATTLEGROUND_RL);
181 allowedArenas.emplace_back(BATTLEGROUND_DS);
182 allowedArenas.emplace_back(BATTLEGROUND_RV);
183 }
184 else if (arenaName == "NA")
185 {
186 allowedArenas.emplace_back(BATTLEGROUND_NA);
187 }
188 else if (arenaName == "BE")
189 {
190 allowedArenas.emplace_back(BATTLEGROUND_BE);
191 }
192 else if (arenaName == "RL")
193 {
194 allowedArenas.emplace_back(BATTLEGROUND_RL);
195 }
196 else if (arenaName == "DS")
197 {
198 allowedArenas.emplace_back(BATTLEGROUND_DS);
199 }
200 else if (arenaName == "RV")
201 {
202 allowedArenas.emplace_back(BATTLEGROUND_RV);
203 }
204 else
205 {
206 handler->SendErrorMessage("Invalid [arena] specified.");
207 return false;
208 }
209 }
210
211 ASSERT(!allowedArenas.empty());
212 BattlegroundTypeId randomizedArenaBgTypeId = Acore::Containers::SelectRandomContainerElement(allowedArenas);
213
214 uint8 count = 0;
215 if (tokensItr != tokens.end())
216 {
217 std::string_view mode = *(tokensItr++);
218
219 if (mode == "1v1")
220 {
221 count = 2;
222 }
223 else if (mode == "2v2")
224 {
225 count = 4;
226 }
227 else if (mode == "3v3")
228 {
229 count = 6;
230 }
231 else if (mode == "5v5")
232 {
233 count = 10;
234 }
235 }
236
237 if (!count)
238 {
239 handler->SendErrorMessage("Invalid bracket. Can be 1v1, 2v2, 3v3, 5v5");
240 return false;
241 }
242
243 if (tokens.size() != uint16(count + 2))
244 {
245 handler->SendErrorMessage("Invalid number of nicknames for this bracket.");
246 return false;
247 }
248
249 uint8 hcnt = count / 2;
250 uint8 error = 0;
251 std::string last_name;
252 Player* plr = nullptr;
253 std::array<Player*, 10> players = {};
254 uint8 cnt = 0;
255
256 for (; tokensItr != tokens.end(); ++tokensItr)
257 {
258 last_name = std::string(*tokensItr);
259 plr = ObjectAccessor::FindPlayerByName(last_name, false);
260
261 if (!plr)
262 {
263 error = 1;
264 break;
265 }
266
267 if (!plr->IsInWorld() || !plr->FindMap() || plr->IsBeingTeleported())
268 {
269 error = 2;
270 break;
271 }
272
273 if (plr->GetMap()->GetEntry()->Instanceable())
274 {
275 error = 3;
276 break;
277 }
278
279 if (plr->isUsingLfg())
280 {
281 error = 4;
282 break;
283 }
284
285 if (plr->InBattlegroundQueue())
286 {
287 error = 5;
288 break;
289 }
290
291 if (plr->IsInFlight())
292 {
293 error = 10;
294 break;
295 }
296
297 if (!plr->IsAlive())
298 {
299 error = 11;
300 break;
301 }
302
303 const Group* g = plr->GetGroup();
304
305 if (hcnt > 1)
306 {
307 if (!g)
308 {
309 error = 6;
310 break;
311 }
312
313 if (g->isRaidGroup() || g->isBGGroup() || g->isBFGroup() || g->isLFGGroup())
314 {
315 error = 7;
316 break;
317 }
318
319 if (g->GetMembersCount() != hcnt)
320 {
321 error = 8;
322 break;
323 }
324
325 uint8 sti = (cnt < hcnt ? 0 : hcnt);
326 if (sti != cnt && players[sti]->GetGroup() != plr->GetGroup())
327 {
328 error = 9;
329 last_name += " and " + players[sti]->GetName();
330 break;
331 }
332 }
333 else // 1v1
334 {
335 if (g)
336 {
337 error = 12;
338 break;
339 }
340 }
341
342 players[cnt++] = plr;
343 }
344
345 for (uint8 i = 0; i < cnt && !error; ++i)
346 {
347 for (uint8 j = i + 1; j < cnt; ++j)
348 {
349 if (players[i]->GetGUID() == players[j]->GetGUID())
350 {
351 last_name = players[i]->GetName();
352 error = 13;
353 break;
354 }
355 }
356 }
357
358 switch (error)
359 {
360 case 1:
361 handler->PSendSysMessage("Player %s not found.", last_name.c_str());
362 break;
363 case 2:
364 handler->PSendSysMessage("Player %s is being teleported.", last_name.c_str());
365 break;
366 case 3:
367 handler->PSendSysMessage("Player %s is in instance/battleground/arena.", last_name.c_str());
368 break;
369 case 4:
370 handler->PSendSysMessage("Player %s is in LFG system.", last_name.c_str());
371 break;
372 case 5:
373 handler->PSendSysMessage("Player %s is queued for battleground/arena.", last_name.c_str());
374 break;
375 case 6:
376 handler->PSendSysMessage("Player %s is not in group.", last_name.c_str());
377 break;
378 case 7:
379 handler->PSendSysMessage("Player %s is not in normal group.", last_name.c_str());
380 break;
381 case 8:
382 handler->PSendSysMessage("Group of player %s has invalid member count.", last_name.c_str());
383 break;
384 case 9:
385 handler->PSendSysMessage("Players %s are not in the same group.", last_name.c_str());
386 break;
387 case 10:
388 handler->PSendSysMessage("Player %s is in flight.", last_name.c_str());
389 break;
390 case 11:
391 handler->PSendSysMessage("Player %s is dead.", last_name.c_str());
392 break;
393 case 12:
394 handler->PSendSysMessage("Player %s is in a group.", last_name.c_str());
395 break;
396 case 13:
397 handler->PSendSysMessage("Player %s occurs more than once.", last_name.c_str());
398 break;
399 }
400
401 if (error)
402 {
403 handler->SetSentErrorMessage(true);
404 return false;
405 }
406
407 Battleground* bgt = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
408 if (!bgt)
409 {
410 handler->SendErrorMessage("Couldn't create arena map!");
411 return false;
412 }
413
414 Battleground* bg = sBattlegroundMgr->CreateNewBattleground(randomizedArenaBgTypeId, GetBattlegroundBracketById(bgt->GetMapId(), bgt->GetBracketId()), ArenaType(hcnt >= 2 ? hcnt : 2), false);
415 if (!bg)
416 {
417 handler->SendErrorMessage("Couldn't create arena map!");
418 return false;
419 }
420
421 bg->StartBattleground();
422
423 BattlegroundTypeId bgTypeId = bg->GetBgTypeID();
424
425 TeamId teamId1 = Player::TeamIdForRace(players[0]->getRace());
426 TeamId teamId2 = (teamId1 == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE);
427
428 for (uint8 i = 0; i < cnt; ++i)
429 {
430 Player* player = players[i];
431
432 TeamId teamId = (i < hcnt ? teamId1 : teamId2);
433 player->SetEntryPoint();
434
435 uint32 queueSlot = 0;
436 WorldPacket data;
437 sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), teamId);
438 player->GetSession()->SendPacket(&data);
439
440 // Remove from LFG queues
441 sLFGMgr->LeaveAllLfgQueues(player->GetGUID(), false);
442
443 player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId, queueSlot, true, false, teamId);
444 sBattlegroundMgr->SendToBattleground(player, bg->GetInstanceID(), bgTypeId);
445 }
446
447 handler->PSendSysMessage("Success! Players are now being teleported to the arena.");
448 return true;
449 }
#define ASSERT
Definition: Errors.h:68
@ STATUS_IN_PROGRESS
Definition: Battleground.h:197
ArenaType
Definition: Battleground.h:211
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:188
PvPDifficultyEntry const * GetBattlegroundBracketById(uint32 mapid, BattlegroundBracketId id)
Definition: DBCStores.cpp:811
#define sLFGMgr
Definition: LFGMgr.h:641
BattlegroundTypeId
Definition: SharedDefines.h:3479
@ BATTLEGROUND_AA
Definition: SharedDefines.h:3486
@ BATTLEGROUND_BE
Definition: SharedDefines.h:3485
@ BATTLEGROUND_RV
Definition: SharedDefines.h:3491
@ BATTLEGROUND_NA
Definition: SharedDefines.h:3484
@ BATTLEGROUND_DS
Definition: SharedDefines.h:3490
@ BATTLEGROUND_RL
Definition: SharedDefines.h:3488
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition: Tokenize.cpp:20
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:135
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:274
Definition: Battleground.h:298
uint32 GetMapId() const
Definition: Battleground.h:428
uint8 GetArenaType() const
Definition: Battleground.h:340
void StartBattleground()
Definition: Battleground.cpp:1101
uint32 GetInstanceID() const
Definition: Battleground.h:326
uint32 GetStartTime() const
Definition: Battleground.h:329
BattlegroundBracketId GetBracketId() const
Definition: Battleground.h:325
BattlegroundTypeId GetBgTypeID(bool GetRandom=false) const
Definition: Battleground.h:324
void SetSentErrorMessage(bool val)
Definition: Chat.h:135
bool IsInWorld() const
Definition: Object.h:101
Map * FindMap() const
Definition: Object.h:518
static TeamId TeamIdForRace(uint8 race)
Definition: Player.cpp:5745
bool isUsingLfg()
Definition: Player.cpp:12984
bool InBattlegroundQueue(bool ignoreArena=false) const
Definition: Player.cpp:12126
bool isLFGGroup(bool restricted=false) const
Definition: Group.cpp:2204
bool isBGGroup() const
Definition: Group.cpp:2215
uint32 GetMembersCount() const
Definition: Group.h:245
bool isBFGroup() const
Definition: Group.cpp:2220
bool isRaidGroup() const
Definition: Group.cpp:2210
MapEntry const * GetEntry() const
Definition: Map.h:319
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:212
bool Instanceable() const
Definition: DBCStructure.h:1351

References ASSERT, BATTLEGROUND_AA, BATTLEGROUND_BE, BATTLEGROUND_DS, BATTLEGROUND_NA, BATTLEGROUND_RL, BATTLEGROUND_RV, WorldObject::FindMap(), ObjectAccessor::FindPlayerByName(), Battleground::GetArenaType(), GetBattlegroundBracketById(), Battleground::GetBgTypeID(), Battleground::GetBracketId(), Map::GetEntry(), Player::GetGroup(), Object::GetGUID(), Battleground::GetInstanceID(), WorldObject::GetMap(), Battleground::GetMapId(), Group::GetMembersCount(), WorldObject::GetName(), Player::GetSession(), Battleground::GetStartTime(), Player::InBattlegroundQueue(), MapEntry::Instanceable(), Unit::IsAlive(), Player::IsBeingTeleported(), Group::isBFGroup(), Group::isBGGroup(), Unit::IsInFlight(), Object::IsInWorld(), Group::isLFGGroup(), Group::isRaidGroup(), Player::isUsingLfg(), ChatHandler::PSendSysMessage(), sBattlegroundMgr, Acore::Containers::SelectRandomContainerElement(), ChatHandler::SendErrorMessage(), WorldSession::SendPacket(), Player::SetBattlegroundId(), Player::SetEntryPoint(), ChatHandler::SetSentErrorMessage(), sLFGMgr, Battleground::StartBattleground(), STATUS_IN_PROGRESS, TEAM_ALLIANCE, TEAM_HORDE, Player::TeamIdForRace(), and Acore::Tokenize().

Referenced by GetCommands().

◆ HandleStringCommand()

static bool misc_commandscript::HandleStringCommand ( ChatHandler handler,
uint32  id,
Optional< uint8 locale 
)
inlinestatic
2964 {
2965 if (!id)
2966 {
2968 return false;
2969 }
2970
2971 const char* str = sObjectMgr->GetAcoreString(id, locale ? static_cast<LocaleConstant>(*locale) : DEFAULT_LOCALE);
2972
2973 if (!strcmp(str, "<error>"))
2974 {
2976 return true;
2977 }
2978 else
2979 {
2980 handler->SendSysMessage(str);
2981 return true;
2982 }
2983 }
LocaleConstant
Definition: Common.h:67
#define DEFAULT_LOCALE
Definition: Common.h:81
@ LANG_CMD_SYNTAX
Definition: Language.h:42
@ LANG_NO_ACORE_STRING_FOUND
Definition: Language.h:1183

References DEFAULT_LOCALE, LANG_CMD_SYNTAX, LANG_NO_ACORE_STRING_FOUND, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleSummonCommand()

static bool misc_commandscript::HandleSummonCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
841 {
842 if (!target)
843 {
844 target = PlayerIdentifier::FromTarget(handler);
845 }
846
847 if (!target)
848 {
849 return false;
850 }
851
852 Player* _player = handler->GetSession()->GetPlayer();
853 if (target->GetGUID() == _player->GetGUID())
854 {
856 return false;
857 }
858
859 std::string nameLink = handler->playerLink(target->GetName());
860
861 if (target->IsConnected())
862 {
863 auto targetPlayer = target->GetConnectedPlayer();
864
865 // check online security
866 if (handler->HasLowerSecurity(targetPlayer))
867 {
868 return false;
869 }
870
871 if (targetPlayer->IsBeingTeleported())
872 {
873 handler->SendErrorMessage(LANG_IS_TELEPORTED, nameLink.c_str());
874 return false;
875 }
876
877 Map* map = handler->GetSession()->GetPlayer()->GetMap();
878
879 if (map->IsBattlegroundOrArena())
880 {
881 handler->SendErrorMessage("Can't summon to a battleground!");
882 return false;
883 }
884 else if (map->IsDungeon())
885 {
886 // Allow GM to summon players or only other GM accounts inside instances.
887 if (!sWorld->getBoolConfig(CONFIG_INSTANCE_GMSUMMON_PLAYER))
888 {
889 // pussywizard: prevent unbinding normal player's perm bind by just summoning him >_>
890 if (!targetPlayer->GetSession()->GetSecurity())
891 {
892 handler->SendErrorMessage("Only GMs can be summoned to an instance!");
893 return false;
894 }
895 }
896
897 Map* destMap = targetPlayer->GetMap();
898
899 if (destMap->Instanceable() && destMap->GetInstanceId() != map->GetInstanceId())
900 {
901 sInstanceSaveMgr->PlayerUnbindInstance(target->GetGUID(), map->GetInstanceId(), targetPlayer->GetDungeonDifficulty(), true, targetPlayer);
902 }
903
904 // we are in an instance, and can only summon players in our group with us as leader
905 if (!handler->GetSession()->GetPlayer()->GetGroup() || !targetPlayer->GetGroup() ||
906 (targetPlayer->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
907 (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()))
908 // the last check is a bit excessive, but let it be, just in case
909 {
910 handler->SendErrorMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str());
911 return false;
912 }
913 }
914
915 handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), "");
916 if (handler->needReportToTarget(targetPlayer))
917 {
918 ChatHandler(targetPlayer->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str());
919 }
920
921 // stop flight if need
922 if (targetPlayer->IsInFlight())
923 {
924 targetPlayer->GetMotionMaster()->MovementExpired();
925 targetPlayer->CleanupAfterTaxiFlight();
926 }
927 // save only in non-flight case
928 else
929 {
930 targetPlayer->SaveRecallPosition();
931 }
932
933 // before GM
934 float x, y, z;
935 handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, targetPlayer->GetObjectSize());
936 targetPlayer->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, targetPlayer->GetOrientation(), 0, handler->GetSession()->GetPlayer());
937 }
938 else
939 {
940 // check offline security
941 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
942 {
943 return false;
944 }
945
946 handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), handler->GetAcoreString(LANG_OFFLINE));
947
948 // in point where GM stay
950 handler->GetSession()->GetPlayer()->GetPositionX(),
951 handler->GetSession()->GetPlayer()->GetPositionY(),
952 handler->GetSession()->GetPlayer()->GetPositionZ(),
953 handler->GetSession()->GetPlayer()->GetOrientation(),
954 handler->GetSession()->GetPlayer()->GetZoneId(),
955 target->GetGUID());
956 }
957
958 return true;
959 }
@ CONFIG_INSTANCE_GMSUMMON_PLAYER
Definition: IWorld.h:91
static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid)
Definition: PlayerMisc.cpp:84

References CONFIG_INSTANCE_GMSUMMON_PLAYER, Acore::ChatCommands::PlayerIdentifier::FromTarget(), ChatHandler::GetAcoreString(), WorldObject::GetClosePoint(), Player::GetGroup(), Object::GetGUID(), Map::GetInstanceId(), Group::GetLeaderGUID(), WorldObject::GetMap(), WorldLocation::GetMapId(), WorldObject::GetName(), Position::GetOrientation(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::GetSession(), WorldObject::GetZoneId(), ChatHandler::HasLowerSecurity(), Map::Instanceable(), Map::IsBattlegroundOrArena(), Map::IsDungeon(), LANG_CANNOT_SUMMON_TO_INST, LANG_CANT_TELEPORT_SELF, LANG_IS_TELEPORTED, LANG_OFFLINE, LANG_SUMMONED_BY, LANG_SUMMONING, ChatHandler::needReportToTarget(), ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), Player::SavePositionInDB(), ChatHandler::SendErrorMessage(), sInstanceSaveMgr, and sWorld.

Referenced by GetCommands().

◆ HandleUnAuraCommand()

static bool misc_commandscript::HandleUnAuraCommand ( ChatHandler handler,
Variant< SpellInfo const *, std::string_view >  spells 
)
inlinestatic
658 {
659 Unit* target = handler->getSelectedUnit();
660 if (!target)
661 {
663 return false;
664 }
665
666 if (spells.holds_alternative<std::string_view>() && spells.get<std::string_view>() == "all")
667 {
668 target->RemoveAllAuras();
669 return true;
670 }
671
672 if (!spells.holds_alternative<SpellInfo const*>())
673 {
675 return false;
676 }
677
678 auto spell = spells.get<SpellInfo const*>();
679
680 if (!SpellMgr::IsSpellValid(spell))
681 {
682 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
683 return false;
684 }
685
686 target->RemoveAurasDueToSpell(spell->Id);
687
688 return true;
689 }
spells
Definition: boss_krystallus.cpp:26
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4855
void RemoveAllAuras()
Definition: Unit.cpp:5259

References ChatHandler::getSelectedUnit(), SpellMgr::IsSpellValid(), LANG_COMMAND_NOSPELLFOUND, LANG_COMMAND_SPELL_BROKEN, LANG_SELECT_CHAR_OR_CREATURE, Unit::RemoveAllAuras(), Unit::RemoveAurasDueToSpell(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleUnbindSightCommand()

static bool misc_commandscript::HandleUnbindSightCommand ( ChatHandler handler)
inlinestatic
2944 {
2945 Player* player = handler->GetSession()->GetPlayer();
2946
2947 if (player->isPossessing())
2948 {
2949 return false;
2950 }
2951
2952 player->StopCastingBindSight();
2953 return true;
2954 }
void StopCastingBindSight(Aura *except=nullptr)
Definition: Player.cpp:13072
bool isPossessing() const
Definition: Unit.h:1888

References WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::isPossessing(), and Player::StopCastingBindSight().

Referenced by GetCommands().

◆ HandleUnFreezeCommand()

static bool misc_commandscript::HandleUnFreezeCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
2852 {
2853 Creature* creatureTarget = handler->getSelectedCreature();
2854
2855 if (!target && !creatureTarget)
2856 {
2857 target = PlayerIdentifier::FromTargetOrSelf(handler);
2858 }
2859
2860 if (!target && !creatureTarget)
2861 {
2863 return false;
2864 }
2865
2866 Player* playerTarget = target->GetConnectedPlayer();
2867
2868 if (!creatureTarget && playerTarget && playerTarget->HasAura(SPELL_FREEZE))
2869 {
2870 handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName().c_str());
2871 playerTarget->RemoveAurasDueToSpell(SPELL_FREEZE);
2872 return true;
2873 }
2874 else if (creatureTarget && creatureTarget->HasAura(SPELL_FREEZE))
2875 {
2876 handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, GetLocalizeCreatureName(creatureTarget, handler->GetSessionDbcLocale()).c_str());
2877 creatureTarget->RemoveAurasDueToSpell(SPELL_FREEZE);
2878 return true;
2879 }
2880 else if (!creatureTarget && target && !target->IsConnected())
2881 {
2883 stmt->SetData(0, target->GetGUID().GetCounter());
2884 CharacterDatabase.Execute(stmt);
2885 handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName().c_str());
2886 return true;
2887 }
2888
2890 return true;
2891 }
@ CHAR_DEL_CHAR_AURA_FROZEN
Definition: CharacterDatabase.h:353
@ LANG_COMMAND_UNFREEZE
Definition: Language.h:1065
@ LANG_COMMAND_FREEZE_WRONG
Definition: Language.h:1064
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5636

References CHAR_DEL_CHAR_AURA_FROZEN, CharacterDatabase, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), GetLocalizeCreatureName(), ChatHandler::getSelectedCreature(), ChatHandler::GetSessionDbcLocale(), Unit::HasAura(), LANG_COMMAND_FREEZE_WRONG, LANG_COMMAND_UNFREEZE, LANG_SELECT_CHAR_OR_CREATURE, ChatHandler::PSendSysMessage(), Unit::RemoveAurasDueToSpell(), ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), PreparedStatementBase::SetData(), and SPELL_FREEZE.

Referenced by GetCommands().

◆ HandleUnmuteCommand()

static bool misc_commandscript::HandleUnmuteCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
2485 {
2486 if (!target)
2487 {
2488 target = PlayerIdentifier::FromTargetOrSelf(handler);
2489 }
2490
2491 if (!target)
2492 {
2493 return false;
2494 }
2495
2496 Player* playerTarget = target->GetConnectedPlayer();
2497 uint32 accountId = playerTarget ? playerTarget->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(target->GetGUID());
2498
2499 // find only player from same account if any
2500 if (!playerTarget)
2501 {
2502 if (WorldSession* session = sWorld->FindSession(accountId))
2503 {
2504 playerTarget = session->GetPlayer();
2505 }
2506 }
2507
2508 // must have strong lesser security level
2509 if (handler->HasLowerSecurity(playerTarget, target->GetGUID(), true))
2510 {
2511 return false;
2512 }
2513
2514 if (playerTarget)
2515 {
2516 if (playerTarget->CanSpeak())
2517 {
2519 return false;
2520 }
2521
2522 playerTarget->GetSession()->m_muteTime = 0;
2523 }
2524
2526 stmt->SetData(0, 0);
2527 stmt->SetData(1, "");
2528 stmt->SetData(2, "");
2529 stmt->SetData(3, accountId);
2530 LoginDatabase.Execute(stmt);
2531
2532 if (playerTarget)
2533 {
2535 }
2536
2537 handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, handler->playerLink(target->GetName().c_str()));
2538
2539 return true;
2540 }
@ LANG_CHAT_ALREADY_ENABLED
Definition: Language.h:342
@ LANG_YOU_ENABLE_CHAT
Definition: Language.h:344
@ LANG_YOUR_CHAT_ENABLED
Definition: Language.h:343
bool CanSpeak() const
Definition: PlayerMisc.cpp:69

References Player::CanSpeak(), Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), WorldSession::GetAccountId(), Object::GetGUID(), Player::GetSession(), ChatHandler::HasLowerSecurity(), LANG_CHAT_ALREADY_ENABLED, LANG_YOU_ENABLE_CHAT, LANG_YOUR_CHAT_ENABLED, LOGIN_UPD_MUTE_TIME, LoginDatabase, WorldSession::m_muteTime, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), sCharacterCache, ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), and sWorld.

Referenced by GetCommands().

◆ HandleUnPossessCommand()

static bool misc_commandscript::HandleUnPossessCommand ( ChatHandler handler)
inlinestatic
2920 {
2921 Unit* unit = handler->getSelectedUnit();
2922 if (!unit)
2923 {
2924 unit = handler->GetSession()->GetPlayer();
2925 }
2926
2927 unit->RemoveCharmAuras();
2928 return true;
2929 }
void RemoveCharmAuras()
Definition: Unit.cpp:11191

References WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), and Unit::RemoveCharmAuras().

Referenced by GetCommands().

◆ HandleUnstuckCommand()

static bool misc_commandscript::HandleUnstuckCommand ( ChatHandler handler,
Optional< PlayerIdentifier target,
Optional< std::string_view >  location 
)
inlinestatic
1370 {
1371 // No args required for players
1372 if (handler->GetSession() && AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity()))
1373 {
1374 if (Player* player = handler->GetSession()->GetPlayer())
1375 {
1376 player->CastSpell(player, SPELL_STUCK, false);
1377 }
1378
1379 return true;
1380 }
1381
1382 if (!target)
1383 {
1384 target = PlayerIdentifier::FromTargetOrSelf(handler);
1385 }
1386
1387 if (!target || !target->IsConnected())
1388 {
1389 return false;
1390 }
1391
1392 Player* player = target->GetConnectedPlayer();
1393
1394 if (player->IsInFlight() || player->IsInCombat())
1395 {
1396 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(7355);
1397 if (!spellInfo)
1398 {
1399 return false;
1400 }
1401
1402 if (Player* caster = handler->GetSession()->GetPlayer())
1403 {
1405 }
1406
1407 return false;
1408 }
1409
1410 if (location->empty() || *location == "inn")
1411 {
1412 player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->m_homebindO);
1413 return true;
1414 }
1415
1416 if (*location == "graveyard")
1417 {
1418 player->RepopAtGraveyard();
1419 return true;
1420 }
1421
1422 if (*location == "startzone")
1423 {
1424 player->TeleportTo(player->GetStartPosition());
1425 return true;
1426 }
1427
1428 //Not a supported argument
1429 return false;
1430 }
constexpr auto SPELL_STUCK
Definition: cs_misc.cpp:55
@ SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW
Definition: SharedDefines.h:1122
float m_homebindZ
Definition: Player.h:2335
uint32 m_homebindMapId
Definition: Player.h:2331
void RepopAtGraveyard()
Definition: Player.cpp:4834
float m_homebindY
Definition: Player.h:2334
float m_homebindO
Definition: Player.h:2336
WorldLocation GetStartPosition() const
Definition: Player.cpp:11318
float m_homebindX
Definition: Player.h:2333
bool IsInCombat() const
Definition: Unit.h:1702
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition: Spell.cpp:4645

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), WorldSession::GetPlayer(), WorldSession::GetSecurity(), ChatHandler::GetSession(), Player::GetStartPosition(), Unit::IsInCombat(), Unit::IsInFlight(), AccountMgr::IsPlayerAccount(), Player::m_homebindMapId, Player::m_homebindO, Player::m_homebindX, Player::m_homebindY, Player::m_homebindZ, Player::RepopAtGraveyard(), Spell::SendCastResult(), SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW, SPELL_STUCK, sSpellMgr, and Player::TeleportTo().

Referenced by GetCommands().