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
 
uint16 GetTotalAvailableHooks ()
 

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 HandleAuraStacksCommand (ChatHandler *handler, SpellInfo const *spell, int16 stacks)
 
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, Optional< std::string > percent)
 
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, uint16 totalAvailableHooks=0)
 
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 auraCommandTable =
92 {
93 { "stack", HandleAuraStacksCommand, SEC_GAMEMASTER, Console::No },
94 { "", HandleAuraCommand, SEC_GAMEMASTER, Console::No }
95 };
96
97 static ChatCommandTable commandTable =
98 {
99 { "commentator", HandleCommentatorCommand, SEC_MODERATOR, Console::No },
100 { "dev", HandleDevCommand, SEC_ADMINISTRATOR, Console::No },
101 { "gps", HandleGPSCommand, SEC_MODERATOR, Console::No },
102 { "aura", auraCommandTable },
103 { "unaura", HandleUnAuraCommand, SEC_GAMEMASTER, Console::No },
104 { "appear", HandleAppearCommand, SEC_MODERATOR, Console::No },
105 { "summon", HandleSummonCommand, SEC_GAMEMASTER, Console::No },
106 { "groupsummon", HandleGroupSummonCommand, SEC_GAMEMASTER, Console::No },
107 { "commands", HandleCommandsCommand, SEC_PLAYER, Console::Yes },
108 { "die", HandleDieCommand, SEC_GAMEMASTER, Console::No },
109 { "revive", HandleReviveCommand, SEC_GAMEMASTER, Console::Yes },
110 { "dismount", HandleDismountCommand, SEC_PLAYER, Console::No },
111 { "guid", HandleGUIDCommand, SEC_GAMEMASTER, Console::No },
112 { "help", HandleHelpCommand, SEC_PLAYER, Console::Yes },
113 { "cooldown", HandleCooldownCommand, SEC_GAMEMASTER, Console::No },
114 { "distance", HandleGetDistanceCommand, SEC_ADMINISTRATOR, Console::No },
115 { "recall", HandleRecallCommand, SEC_GAMEMASTER, Console::No },
116 { "save", HandleSaveCommand, SEC_PLAYER, Console::No },
117 { "saveall", HandleSaveAllCommand, SEC_GAMEMASTER, Console::Yes },
118 { "kick", HandleKickPlayerCommand, SEC_GAMEMASTER, Console::Yes },
119 { "unstuck", HandleUnstuckCommand, SEC_GAMEMASTER, Console::Yes },
120 { "linkgrave", HandleLinkGraveCommand, SEC_ADMINISTRATOR, Console::No },
121 { "neargrave", HandleNearGraveCommand, SEC_GAMEMASTER, Console::No },
122 { "showarea", HandleShowAreaCommand, SEC_GAMEMASTER, Console::No },
123 { "hidearea", HandleHideAreaCommand, SEC_ADMINISTRATOR, Console::No },
124 { "additem", HandleAddItemCommand, SEC_GAMEMASTER, Console::Yes },
125 { "additem set", HandleAddItemSetCommand, SEC_GAMEMASTER, Console::No },
126 { "wchange", HandleChangeWeather, SEC_ADMINISTRATOR, Console::No },
127 { "maxskill", HandleMaxSkillCommand, SEC_GAMEMASTER, Console::No },
128 { "setskill", HandleSetSkillCommand, SEC_GAMEMASTER, Console::No },
129 { "pinfo", HandlePInfoCommand, SEC_GAMEMASTER, Console::Yes },
130 { "respawn", HandleRespawnCommand, SEC_GAMEMASTER, Console::No },
131 { "respawn all", HandleRespawnAllCommand, SEC_GAMEMASTER, Console::No },
132 { "mute", HandleMuteCommand, SEC_GAMEMASTER, Console::Yes },
133 { "mutehistory", HandleMuteInfoCommand, SEC_GAMEMASTER, Console::Yes },
134 { "unmute", HandleUnmuteCommand, SEC_GAMEMASTER, Console::Yes },
135 { "movegens", HandleMovegensCommand, SEC_ADMINISTRATOR, Console::No },
136 { "cometome", HandleComeToMeCommand, SEC_ADMINISTRATOR, Console::No },
137 { "damage", HandleDamageCommand, SEC_GAMEMASTER, Console::No },
138 { "combatstop", HandleCombatStopCommand, SEC_GAMEMASTER, Console::Yes },
139 { "flusharenapoints", HandleFlushArenaPointsCommand, SEC_ADMINISTRATOR, Console::Yes },
140 { "freeze", HandleFreezeCommand, SEC_GAMEMASTER, Console::No },
141 { "unfreeze", HandleUnFreezeCommand, SEC_GAMEMASTER, Console::No },
142 { "possess", HandlePossessCommand, SEC_GAMEMASTER, Console::No },
143 { "unpossess", HandleUnPossessCommand, SEC_GAMEMASTER, Console::No },
144 { "bindsight", HandleBindSightCommand, SEC_ADMINISTRATOR, Console::No },
145 { "unbindsight", HandleUnbindSightCommand, SEC_ADMINISTRATOR, Console::No },
146 { "playall", HandlePlayAllCommand, SEC_GAMEMASTER, Console::No },
147 { "skirmish", HandleSkirmishCommand, SEC_ADMINISTRATOR, Console::No },
148 { "mailbox", HandleMailBoxCommand, SEC_MODERATOR, Console::No },
149 { "string", HandleStringCommand, SEC_GAMEMASTER, Console::No }
150 };
151
152 return commandTable;
153 }
@ SEC_PLAYER
Definition: Common.h:57
@ SEC_ADMINISTRATOR
Definition: Common.h:60
@ SEC_GAMEMASTER
Definition: Common.h:59
@ SEC_MODERATOR
Definition: Common.h:58
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleCommentatorCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition: cs_misc.cpp:454
static bool HandleDevCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition: cs_misc.cpp:498
static bool HandleDamageCommand(ChatHandler *handler, uint32 damage, Optional< std::string > percent)
Definition: cs_misc.cpp:2797
static bool HandleSaveCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1328
static bool HandleAuraStacksCommand(ChatHandler *handler, SpellInfo const *spell, int16 stacks)
Definition: cs_misc.cpp:660
static bool HandleLinkGraveCommand(ChatHandler *handler, uint32 graveyardId, Optional< std::string_view > team)
Definition: cs_misc.cpp:1495
static bool HandlePlayAllCommand(ChatHandler *handler, uint32 soundId)
Definition: cs_misc.cpp:2946
static bool HandleAddItemCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, ItemTemplate const *itemTemplate, Optional< int32 > _count)
Definition: cs_misc.cpp:1685
static bool HandleAuraCommand(ChatHandler *handler, SpellInfo const *spell)
Definition: cs_misc.cpp:634
static bool HandleUnstuckCommand(ChatHandler *handler, Optional< PlayerIdentifier > target, Optional< std::string_view > location)
Definition: cs_misc.cpp:1413
static bool HandleRespawnAllCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2407
static bool HandleSkirmishCommand(ChatHandler *handler, std::vector< std::string_view > args)
Definition: cs_misc.cpp:155
static bool HandleUnbindSightCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2996
static bool HandleShowAreaCommand(ChatHandler *handler, uint32 areaID)
Definition: cs_misc.cpp:1623
static bool HandleStringCommand(ChatHandler *handler, uint32 id, Optional< uint8 > locale)
Definition: cs_misc.cpp:3016
static bool HandleChangeWeather(ChatHandler *handler, uint32 type, float grade)
Definition: cs_misc.cpp:1848
static bool HandlePInfoCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1936
static bool HandleSummonCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:888
static bool HandleCooldownCommand(ChatHandler *handler, Optional< SpellInfo const * > spell)
Definition: cs_misc.cpp:1233
static bool HandleReviveCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1158
static bool HandleCommandsCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1115
static bool HandleMailBoxCommand(ChatHandler *handler)
Definition: cs_misc.cpp:3009
static bool HandleDieCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1121
static bool HandleAppearCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:739
static bool HandleHelpCommand(ChatHandler *handler, Tail cmd)
Definition: cs_misc.cpp:1221
static bool HandleRespawnCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2383
static bool HandleNearGraveCommand(ChatHandler *handler, Optional< std::string_view > team)
Definition: cs_misc.cpp:1546
static bool HandleMovegensCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2647
static bool HandleGUIDCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1207
static bool HandleAddItemSetCommand(ChatHandler *handler, Variant< Hyperlink< itemset >, uint32 > itemSetId)
Definition: cs_misc.cpp:1787
static bool HandleSaveAllCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1359
static bool HandleGPSCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:543
static bool HandleKickPlayerCommand(ChatHandler *handler, Optional< PlayerIdentifier > target, Optional< std::string_view > reason)
Definition: cs_misc.cpp:1367
static bool HandleHideAreaCommand(ChatHandler *handler, uint32 areaID)
Definition: cs_misc.cpp:1654
static bool HandleSetSkillCommand(ChatHandler *handler, Variant< Hyperlink< skill >, uint32 > skillId, int32 level, Optional< uint16 > maxPureSkill)
Definition: cs_misc.cpp:1892
static bool HandleUnmuteCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2547
static bool HandleRecallCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1291
static bool HandleBindSightCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2984
static bool HandleComeToMeCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2781
static bool HandleUnPossessCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2972
static bool HandleDismountCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1183
static bool HandleGroupSummonCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1010
static bool HandleCombatStopCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2829
static bool HandleUnAuraCommand(ChatHandler *handler, Variant< SpellInfo const *, std::string_view > spells)
Definition: cs_misc.cpp:705
static bool HandleGetDistanceCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1263
static bool HandleMaxSkillCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1878
static bool HandleFlushArenaPointsCommand(ChatHandler *)
Definition: cs_misc.cpp:2855
static bool HandleFreezeCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2861
static bool HandleMuteInfoCommand(ChatHandler *handler, std::string accountName)
Definition: cs_misc.cpp:2606
static bool HandleUnFreezeCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2904
static bool HandleMuteCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, std::string notSpeakTime, Tail muteReason)
Definition: cs_misc.cpp:2423
static bool HandlePossessCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2960

References HandleAddItemCommand(), HandleAddItemSetCommand(), HandleAppearCommand(), HandleAuraCommand(), HandleAuraStacksCommand(), 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
1686 {
1687 if (!sObjectMgr->GetItemTemplate(itemTemplate->ItemId))
1688 {
1689 handler->SendErrorMessage(LANG_COMMAND_ITEMIDINVALID, itemTemplate->ItemId);
1690 return false;
1691 }
1692
1693 uint32 itemId = itemTemplate->ItemId;
1694 int32 count = 1;
1695
1696 if (_count)
1697 count = *_count;
1698
1699 if (!count)
1700 count = 1;
1701
1702 if (!player)
1703 player = PlayerIdentifier::FromTargetOrSelf(handler);
1704
1705 if (!player)
1706 return false;
1707
1708 Player* playerTarget = player->GetConnectedPlayer();
1709
1710 if (!playerTarget)
1711 return false;
1712
1713 // Subtract
1714 if (count < 0)
1715 {
1716 // Only have scam check on player accounts
1717 if (playerTarget->GetSession()->GetSecurity() == SEC_PLAYER)
1718 {
1719 if (!playerTarget->HasItemCount(itemId, 0))
1720 {
1721 // output that player don't have any items to destroy
1722 handler->SendErrorMessage(LANG_REMOVEITEM_FAILURE, handler->GetNameLink(playerTarget), itemId);
1723 return false;
1724 }
1725
1726 if (!playerTarget->HasItemCount(itemId, -count))
1727 {
1728 // output that player don't have as many items that you want to destroy
1729 handler->SendErrorMessage(LANG_REMOVEITEM_ERROR, handler->GetNameLink(playerTarget), itemId);
1730 return false;
1731 }
1732 }
1733
1734 // output successful amount of destroyed items
1735 playerTarget->DestroyItemCount(itemId, -count, true, false);
1736 handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget));
1737 return true;
1738 }
1739
1740 // Adding items
1741 uint32 noSpaceForCount = 0;
1742
1743 // check space and find places
1744 ItemPosCountVec dest;
1745 InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
1746
1747 if (msg != EQUIP_ERR_OK) // convert to possible store amount
1748 count -= noSpaceForCount;
1749
1750 if (!count || dest.empty()) // can't add any
1751 {
1752 handler->SendErrorMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
1753 return false;
1754 }
1755
1756 Item* item = playerTarget->StoreNewItem(dest, itemId, true);
1757
1758 Player* p = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
1759 // remove binding (let GM give it to another player later)
1760 if (p && p == playerTarget)
1761 {
1762 for (auto const& itemPos : dest)
1763 {
1764 if (Item* item1 = p->GetItemByPos(itemPos.pos))
1765 {
1766 item1->SetBinding(false);
1767 }
1768 }
1769 }
1770
1771 if (p && count && item)
1772 {
1773 p->SendNewItem(item, count, false, true);
1774
1775 if (p != playerTarget)
1776 {
1777 playerTarget->SendNewItem(item, count, true, false);
1778 }
1779 }
1780
1781 if (noSpaceForCount)
1782 handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
1783
1784 return true;
1785 }
std::int32_t int32
Definition: Define.h:103
std::uint32_t uint32
Definition: Define.h:107
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ LANG_ITEM_CANNOT_CREATE
Definition: Language.h:537
@ LANG_REMOVEITEM_FAILURE
Definition: Language.h:1320
@ LANG_REMOVEITEM_ERROR
Definition: Language.h:1321
@ LANG_REMOVEITEM
Definition: Language.h:536
@ LANG_COMMAND_ITEMIDINVALID
Definition: Language.h:467
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:771
InventoryResult
Definition: Item.h:46
@ EQUIP_ERR_OK
Definition: Item.h:47
@ NULL_BAG
Definition: Item.h:40
@ NULL_SLOT
Definition: Item.h:41
virtual std::string GetNameLink() const
Definition: Chat.h:198
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
WorldSession * GetSession()
Definition: Chat.h:242
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:184
Definition: Item.h:220
Definition: Player.h:1064
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition: PlayerStorage.cpp:655
WorldSession * GetSession() const
Definition: Player.h:1981
Item * GetItemByPos(uint16 pos) const
Definition: PlayerStorage.cpp:441
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast=false, bool sendChatMessage=true)
Definition: PlayerStorage.cpp:4750
void DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check=false)
Definition: PlayerStorage.cpp:3121
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0)
Definition: PlayerStorage.cpp:2524
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition: Player.h:1274
AccountTypes GetSecurity() const
Definition: WorldSession.h:359
Player * GetPlayer() const
Definition: WorldSession.h:362

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
1788 {
1789 // prevent generation all items with itemset field value '0'
1790 if (!*itemSetId)
1791 {
1793 return false;
1794 }
1795
1796 Player* player = handler->GetSession()->GetPlayer();
1797 Player* playerTarget = handler->getSelectedPlayer();
1798
1799 if (!playerTarget)
1800 {
1801 playerTarget = player;
1802 }
1803
1804 bool found = false;
1805
1806 for (auto const& [itemid, itemTemplate] : *sObjectMgr->GetItemTemplateStore())
1807 {
1808 if (itemTemplate.ItemSet == uint32(itemSetId))
1809 {
1810 found = true;
1811 ItemPosCountVec dest;
1812 InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemTemplate.ItemId, 1);
1813
1814 if (msg == EQUIP_ERR_OK)
1815 {
1816 Item* item = playerTarget->StoreNewItem(dest, itemTemplate.ItemId, true);
1817
1818 // remove binding (let GM give it to another player later)
1819 if (player == playerTarget)
1820 {
1821 item->SetBinding(false);
1822 }
1823
1824 player->SendNewItem(item, 1, false, true);
1825
1826 if (player != playerTarget)
1827 {
1828 playerTarget->SendNewItem(item, 1, true, false);
1829 }
1830 }
1831 else
1832 {
1833 player->SendEquipError(msg, nullptr, nullptr, itemTemplate.ItemId);
1834 handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemTemplate.ItemId, 1);
1835 }
1836 }
1837 }
1838
1839 if (!found)
1840 {
1842 return false;
1843 }
1844
1845 return true;
1846 }
@ LANG_NO_ITEMS_FROM_ITEMSET_FOUND
Definition: Language.h:542
Player * getSelectedPlayer() const
Definition: Chat.cpp:373
void SetBinding(bool val)
Definition: Item.h:235
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=nullptr, uint32 itemid=0)
Definition: PlayerStorage.cpp:4021

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
740 {
741 if (!target)
742 {
743 target = PlayerIdentifier::FromTarget(handler);
744 }
745
746 if (!target)
747 {
748 return false;
749 }
750
751 Player* _player = handler->GetSession()->GetPlayer();
752 if (target->GetGUID() == _player->GetGUID())
753 {
755 return false;
756 }
757
758 std::string nameLink = handler->playerLink(target->GetName());
759
760 if (target->IsConnected())
761 {
762 auto targetPlayer = target->GetConnectedPlayer();
763
764 // check online security
765 if (handler->HasLowerSecurity(targetPlayer))
766 {
767 return false;
768 }
769
770 Map* map = targetPlayer->GetMap();
771 if (map->IsBattlegroundOrArena())
772 {
773 // only allow if gm mode is on
774 if (!_player->IsGameMaster())
775 {
776 handler->SendErrorMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink);
777 return false;
778 }
779
780 if (!_player->GetMap()->IsBattlegroundOrArena())
781 {
782 _player->SetEntryPoint();
783 }
784
785 _player->SetBattlegroundId(targetPlayer->GetBattlegroundId(), targetPlayer->GetBattlegroundTypeId(), PLAYER_MAX_BATTLEGROUND_QUEUES, false, false, TEAM_NEUTRAL);
786 }
787 else if (map->IsDungeon())
788 {
789 // we have to go to instance, and can go to player only if:
790 // 1) we are in his group (either as leader or as member)
791 // 2) we are not bound to any group and have GM mode on
792 if (_player->GetGroup())
793 {
794 // we are in group, we can go only if we are in the player group
795 if (_player->GetGroup() != targetPlayer->GetGroup())
796 {
798 return false;
799 }
800 }
801 else
802 {
803 // we are not in group, let's verify our GM mode
804 if (!_player->IsGameMaster())
805 {
807 return false;
808 }
809 }
810
811 // if the GM is bound to another instance, he will not be bound to another one
812 InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(_player->GetGUID(), targetPlayer->GetMapId(), targetPlayer->GetDifficulty(map->IsRaid()));
813 if (!bind)
814 {
815 if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetConnectedPlayer()->GetInstanceId()))
816 {
817 sInstanceSaveMgr->PlayerBindToInstance(_player->GetGUID(), save, !save->CanReset(), _player);
818 }
819 }
820
821 if (map->IsRaid())
822 {
823 _player->SetRaidDifficulty(targetPlayer->GetRaidDifficulty());
824 }
825 else
826 {
827 _player->SetDungeonDifficulty(targetPlayer->GetDungeonDifficulty());
828 }
829 }
830
831 handler->PSendSysMessage(LANG_APPEARING_AT, nameLink);
832
833 // stop flight if need
834 if (_player->IsInFlight())
835 {
836 _player->GetMotionMaster()->MovementExpired();
837 _player->CleanupAfterTaxiFlight();
838 }
839 else // save only in non-flight case
840 {
841 _player->SaveRecallPosition();
842 }
843
844 if (_player->TeleportTo(targetPlayer->GetMapId(), targetPlayer->GetPositionX(), targetPlayer->GetPositionY(), targetPlayer->GetPositionZ() + 0.25f, _player->GetOrientation(), TELE_TO_GM_MODE, targetPlayer))
845 {
846 _player->SetPhaseMask(targetPlayer->GetPhaseMask() | 1, false);
847 }
848 }
849 else
850 {
851 // check offline security
852 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
853 {
854 return false;
855 }
856
857 handler->PSendSysMessage(LANG_APPEARING_AT, nameLink);
858
859 // to point where player stay (if loaded)
860 float x, y, z, o;
861 uint32 map;
862 bool in_flight;
863
864 if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, target->GetGUID().GetCounter()))
865 {
866 return false;
867 }
868
869 // stop flight if need
870 if (_player->IsInFlight())
871 {
872 _player->GetMotionMaster()->MovementExpired();
873 _player->CleanupAfterTaxiFlight();
874 }
875 // save only in non-flight case
876 else
877 {
878 _player->SaveRecallPosition();
879 }
880
881 _player->TeleportTo(map, x, y, z, _player->GetOrientation());
882 }
883
884 return true;
885 }
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:176
#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:706
@ TELE_TO_GM_MODE
Definition: Player.h:821
std::string playerLink(std::string const &name) const
Definition: Chat.h:231
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:56
static Optional< PlayerIdentifier > FromTarget(ChatHandler *handler)
Definition: ChatCommandTags.cpp:138
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Map * GetMap() const
Definition: Object.h:531
float GetOrientation() const
Definition: Position.h:119
void SetDungeonDifficulty(Difficulty dungeon_difficulty)
Definition: Player.h:1907
void SetEntryPoint()
Definition: Player.cpp:11291
void SetRaidDifficulty(Difficulty raid_difficulty)
Definition: Player.h:1908
void SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
Definition: Player.cpp:12313
void SaveRecallPosition()
Definition: Player.cpp:5656
Group * GetGroup()
Definition: Player.h:2451
bool IsGameMaster() const
Definition: Player.h:1158
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1331
static bool LoadPositionFromDB(uint32 &mapid, float &x, float &y, float &z, float &o, bool &in_flight, ObjectGuid::LowType guid)
Definition: PlayerStorage.cpp:4875
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10437
MotionMaster * GetMotionMaster()
Definition: Unit.h:1620
bool IsInFlight() const
Definition: Unit.h:1572
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:19050
Definition: InstanceSaveMgr.h:39
Definition: InstanceSaveMgr.h:56
Definition: Map.h:311
bool IsDungeon() const
Definition: Map.h:446
bool IsBattlegroundOrArena() const
Definition: Map.h:454
bool IsRaid() const
Definition: Map.h:448
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:180

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
635 {
636 if (!spell)
637 {
639 return false;
640 }
641
642 if (!SpellMgr::IsSpellValid(spell))
643 {
644 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
645 return false;
646 }
647
648 Unit* target = handler->getSelectedUnit();
649 if (!target)
650 {
652 return false;
653 }
654
655 Aura::TryRefreshStackOrCreate(spell, MAX_EFFECT_MASK, target, target);
656
657 return true;
658 }
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1637
@ LANG_COMMAND_NOSPELLFOUND
Definition: Language.h:477
@ LANG_SELECT_CHAR_OR_CREATURE
Definition: Language.h:31
@ LANG_COMMAND_SPELL_BROKEN
Definition: Language.h:520
Unit * getSelectedUnit() const
Definition: Chat.cpp:385
Definition: Unit.h:630
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:441

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().

◆ HandleAuraStacksCommand()

static bool misc_commandscript::HandleAuraStacksCommand ( ChatHandler handler,
SpellInfo const *  spell,
int16  stacks 
)
inlinestatic
661 {
662 if (!spell)
663 {
665 return false;
666 }
667
668 if (!SpellMgr::IsSpellValid(spell))
669 {
670 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
671 return false;
672 }
673
674 if (!stacks)
675 {
677 return false;
678 }
679
680 Unit* target = handler->getSelectedUnit();
681 if (!target)
682 {
684 return false;
685 }
686
687 Aura* aur = target->GetAura(spell->Id);
688 if (!aur)
689 {
691 return false;
692 }
693
694 if (!spell->StackAmount)
695 {
697 return false;
698 }
699
700 aur->ModStackAmount(stacks);
701
702 return true;
703 }
@ LANG_COMMAND_AURASTACK_CANT_STACK
Definition: Language.h:421
@ LANG_COMMAND_AURASTACK_NO_STACK
Definition: Language.h:420
@ LANG_COMMAND_AURASTACK_NO_AURA
Definition: Language.h:419
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5581
Definition: SpellAuras.h:87
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT, bool periodicReset=false)
Definition: SpellAuras.cpp:1021

References Unit::GetAura(), ChatHandler::getSelectedUnit(), SpellInfo::Id, SpellMgr::IsSpellValid(), LANG_COMMAND_AURASTACK_CANT_STACK, LANG_COMMAND_AURASTACK_NO_AURA, LANG_COMMAND_AURASTACK_NO_STACK, LANG_COMMAND_NOSPELLFOUND, LANG_COMMAND_SPELL_BROKEN, LANG_SELECT_CHAR_OR_CREATURE, Aura::ModStackAmount(), ChatHandler::SendErrorMessage(), and SpellInfo::StackAmount.

Referenced by GetCommands().

◆ HandleBindSightCommand()

static bool misc_commandscript::HandleBindSightCommand ( ChatHandler handler)
inlinestatic
2985 {
2986 Unit* unit = handler->getSelectedUnit();
2987 if (!unit)
2988 {
2989 return false;
2990 }
2991
2992 handler->GetSession()->GetPlayer()->CastSpell(unit, 6277, true);
2993 return true;
2994 }
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:1167

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
1849 {
1850 // Weather is OFF
1851 if (!sWorld->getBoolConfig(CONFIG_WEATHER))
1852 {
1854 return false;
1855 }
1856
1857 Player* player = handler->GetSession()->GetPlayer();
1858 uint32 zoneid = player->GetZoneId();
1859
1860 Weather* weather = WeatherMgr::FindWeather(zoneid);
1861
1862 if (!weather)
1863 {
1864 weather = WeatherMgr::AddWeather(zoneid);
1865 }
1866
1867 if (!weather)
1868 {
1870 return false;
1871 }
1872
1873 weather->SetWeather(WeatherType(type), grade);
1874
1875 return true;
1876 }
WeatherType
Definition: SharedDefines.h:3137
@ LANG_NO_WEATHER
Definition: Language.h:432
@ LANG_WEATHER_DISABLED
Definition: Language.h:433
@ CONFIG_WEATHER
Definition: IWorld.h:94
#define sWorld
Definition: World.h:443
Weather * AddWeather(uint32 zone_id)
Add a Weather object to the list.
Definition: WeatherMgr.cpp:66
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:49
uint32 GetZoneId() const
Definition: Object.cpp:3146
Weather for one zone.
Definition: Weather.h:64

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
2830 {
2831 if (!target)
2832 {
2833 target = PlayerIdentifier::FromTargetOrSelf(handler);
2834 }
2835
2836 if (!target || !target->IsConnected())
2837 {
2839 return false;
2840 }
2841
2842 Player* playerTarget = target->GetConnectedPlayer();
2843
2844 // check online security
2845 if (handler->HasLowerSecurity(playerTarget))
2846 {
2847 return false;
2848 }
2849
2850 playerTarget->CombatStop();
2851 playerTarget->getHostileRefMgr().deleteReferences();
2852 return true;
2853 }
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:539
void deleteReferences(bool removeFromMap=false)
Definition: HostileRefMgr.cpp:125
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10436
HostileRefMgr & getHostileRefMgr()
Definition: Unit.h:907

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
2782 {
2783 Creature* caster = handler->getSelectedCreature();
2784 if (!caster)
2785 {
2787 return false;
2788 }
2789
2790 Player* player = handler->GetSession()->GetPlayer();
2791
2792 caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
2793
2794 return true;
2795 }
@ LANG_SELECT_CREATURE
Definition: Language.h:32
Creature * getSelectedCreature() const
Definition: Chat.cpp:409
Definition: Creature.h:43
float GetPositionZ() const
Definition: Position.h:118
float GetPositionX() const
Definition: Position.h:116
float GetPositionY() const
Definition: Position.h:117
void MovePoint(uint32 id, const Position &pos, bool generatePath=true, bool forceDestination=true)
Definition: MotionMaster.h:213

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
1116 {
1117 SendCommandHelpFor(*handler, "");
1118 return true;
1119 }
AC_GAME_API void SendCommandHelpFor(ChatHandler &handler, std::string_view cmd)
Definition: ChatCommand.cpp:533

References Acore::ChatCommands::SendCommandHelpFor().

Referenced by GetCommands().

◆ HandleCommentatorCommand()

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

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

Referenced by GetCommands().

◆ HandleCooldownCommand()

static bool misc_commandscript::HandleCooldownCommand ( ChatHandler handler,
Optional< SpellInfo const * >  spell 
)
inlinestatic
1234 {
1235 Player* target = handler->getSelectedPlayer();
1236 if (!target)
1237 {
1239 return false;
1240 }
1241
1242 std::string nameLink = handler->GetNameLink(target);
1243
1244 if (!spell)
1245 {
1246 target->RemoveAllSpellCooldown();
1247 handler->PSendSysMessage(LANG_REMOVEALL_COOLDOWN, nameLink);
1248 }
1249 else
1250 {
1251 if (!SpellMgr::IsSpellValid(*spell))
1252 {
1253 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell.value()->Id);
1254 return false;
1255 }
1256
1257 target->RemoveSpellCooldown(spell.value()->Id, true);
1258 handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spell.value()->Id, target == handler->GetSession()->GetPlayer() ? handler->GetAcoreString(LANG_YOU) : nameLink);
1259 }
1260 return true;
1261 }
@ LANG_YOU
Definition: Language.h:76
@ LANG_REMOVE_COOLDOWN
Definition: Language.h:532
@ LANG_REMOVEALL_COOLDOWN
Definition: Language.h:531
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:40
void RemoveAllSpellCooldown()
Definition: Player.cpp:3565
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition: Player.cpp:3514

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,
Optional< std::string >  percent 
)
inlinestatic
2798 {
2799 Unit* target = handler->getSelectedUnit();
2800 if (!target || !handler->GetSession()->GetPlayer()->GetTarget())
2801 {
2803 return false;
2804 }
2805
2806 if (target->IsPlayer())
2807 if (handler->HasLowerSecurity(target->ToPlayer()))
2808 return false;
2809
2810 if (!target->IsAlive() || !damage)
2811 return true;
2812
2813 if (target->IsCreature() && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard
2814 target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth());
2815
2816 if (percent)
2817 if (StringStartsWith("pct", *percent))
2818 if (damage <= 100)
2819 damage = target->CountPctFromMaxHealth(damage);
2820
2821 Unit::DealDamage(handler->GetSession()->GetPlayer(), target, damage, nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false, true);
2822
2823 if (target != handler->GetSession()->GetPlayer())
2825
2826 return true;
2827 }
@ SEC_CONSOLE
Definition: Common.h:61
bool StringStartsWith(std::string_view haystack, std::string_view needle)
Definition: Util.h:401
@ SPELL_SCHOOL_MASK_NORMAL
Definition: SharedDefines.h:297
@ VICTIMSTATE_HIT
Definition: Unit.h:84
@ HITINFO_AFFECTS_VICTIM
Definition: Unit.h:98
@ DIRECT_DAMAGE
Definition: Unit.h:248
void LowerPlayerDamageReq(uint32 unDamage, bool damagedByPlayer=true)
Definition: Creature.cpp:3806
bool IsPlayer() const
Definition: Object.h:197
Player * ToPlayer()
Definition: Object.h:198
bool IsCreature() const
Definition: Object.h:201
Creature * ToCreature()
Definition: Object.h:202
void SendAttackStateUpdate(CalcDamageInfo *damageInfo)
Definition: Unit.cpp:6479
uint32 GetMaxHealth() const
Definition: Unit.h:1030
bool IsAlive() const
Definition: Unit.h:1654
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1042
ObjectGuid GetTarget() const
Definition: Unit.h:818
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:810

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

Referenced by GetCommands().

◆ HandleDevCommand()

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

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

Referenced by GetCommands().

◆ HandleDieCommand()

static bool misc_commandscript::HandleDieCommand ( ChatHandler handler)
inlinestatic
1122 {
1123 Unit* target = handler->getSelectedUnit();
1124
1125 if (!target || !handler->GetSession()->GetPlayer()->GetTarget())
1126 {
1128 return false;
1129 }
1130
1131 if (target->IsPlayer())
1132 {
1133 if (handler->HasLowerSecurity(target->ToPlayer()))
1134 {
1135 return false;
1136 }
1137 }
1138
1139 if (target->IsAlive())
1140 {
1141 if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE))
1142 {
1143 if (target->IsCreature() && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard
1144 {
1145 target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth());
1146 }
1147 Unit::Kill(handler->GetSession()->GetPlayer(), target);
1148 }
1149 else
1150 {
1151 Unit::DealDamage(handler->GetSession()->GetPlayer(), target, target->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false, true);
1152 }
1153 }
1154
1155 return true;
1156 }
@ CONFIG_DIE_COMMAND_MODE
Definition: IWorld.h:107
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:17703
uint32 GetHealth() const
Definition: Unit.h:1029

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

Referenced by GetCommands().

◆ HandleDismountCommand()

static bool misc_commandscript::HandleDismountCommand ( ChatHandler handler)
inlinestatic
1184 {
1185 Player* player = handler->GetSession()->GetPlayer();
1186
1187 // If player is not mounted, so go out :)
1188 if (!player->IsMounted())
1189 {
1191 return false;
1192 }
1193
1194 if (player->IsInFlight())
1195 {
1197 return false;
1198 }
1199
1200 player->Dismount();
1202 player->SetSpeed(MOVE_RUN, 1, true);
1203 player->SetSpeed(MOVE_FLIGHT, 1, true);
1204 return true;
1205 }
@ SPELL_AURA_MOUNTED
Definition: SpellAuraDefines.h:141
@ LANG_CHAR_NON_MOUNTED
Definition: Language.h:54
@ LANG_YOU_IN_FLIGHT
Definition: Language.h:50
@ MOVE_FLIGHT
Definition: UnitDefines.h:334
@ MOVE_RUN
Definition: UnitDefines.h:329
void Dismount()
Definition: Unit.cpp:13524
bool IsMounted() const
Definition: Unit.h:1747
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:14429
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
Definition: Unit.cpp:5110

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
2856 {
2857 sArenaTeamMgr->DistributeArenaPoints();
2858 return true;
2859 }
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67

References sArenaTeamMgr.

Referenced by GetCommands().

◆ HandleFreezeCommand()

static bool misc_commandscript::HandleFreezeCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
2862 {
2863 Creature* creatureTarget = handler->getSelectedCreature();
2864
2865 if (!target && !creatureTarget)
2866 {
2867 target = PlayerIdentifier::FromTargetOrSelf(handler);
2868 }
2869
2870 if (!target && !creatureTarget)
2871 {
2873 return false;
2874 }
2875
2876 Player* playerTarget = target->GetConnectedPlayer();
2877 if (playerTarget && !creatureTarget)
2878 {
2879 handler->PSendSysMessage(LANG_COMMAND_FREEZE, target->GetName());
2880
2881 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_FREEZE))
2882 {
2883 Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, playerTarget, playerTarget);
2884 }
2885
2886 return true;
2887 }
2888 else if (creatureTarget && creatureTarget->IsAlive())
2889 {
2891
2892 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_FREEZE))
2893 {
2894 Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, creatureTarget, creatureTarget);
2895 }
2896
2897 return true;
2898 }
2899
2901 return false;
2902 }
constexpr auto SPELL_FREEZE
Definition: cs_misc.cpp:56
std::string const GetLocalizeCreatureName(Creature *creature, LocaleConstant locale)
Definition: cs_misc.cpp:58
#define sSpellMgr
Definition: SpellMgr.h:825
@ LANG_COMMAND_FREEZE
Definition: Language.h:1046
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:869
Definition: SpellInfo.h:316

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
1264 {
1265 if (!target)
1266 {
1267 target = PlayerIdentifier::FromTargetOrSelf(handler);
1268 }
1269
1270 WorldObject* object = handler->getSelectedUnit();
1271
1272 if (!object && !target)
1273 {
1274 return false;
1275 }
1276
1277 if (!object && target && target->IsConnected())
1278 {
1279 object = target->GetConnectedPlayer();
1280 }
1281
1282 if (!object)
1283 {
1284 return false;
1285 }
1286
1287 handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(object), handler->GetSession()->GetPlayer()->GetDistance2d(object), handler->GetSession()->GetPlayer()->GetExactDist(object), handler->GetSession()->GetPlayer()->GetExactDist2d(object));
1288 return true;
1289 }
@ LANG_DISTANCE
Definition: Language.h:544
Definition: Object.h:405
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:165
float GetExactDist(float x, float y, float z) const
Definition: Position.h:177

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
544 {
545 if (!target)
546 {
547 target = PlayerIdentifier::FromTargetOrSelf(handler);
548 }
549
550 WorldObject* object = handler->getSelectedUnit();
551
552 if (!object && !target)
553 {
554 return false;
555 }
556
557 if (!object && target && target->IsConnected())
558 {
559 object = target->GetConnectedPlayer();
560 }
561
562 if (!object)
563 {
564 return false;
565 }
566
567 Cell cell(Acore::ComputeCellCoord(object->GetPositionX(), object->GetPositionY()));
568
569 uint32 zoneId, areaId;
570 object->GetZoneAndAreaId(zoneId, areaId);
571
572 MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
573 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(zoneId);
574 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
575
576 float zoneX = object->GetPositionX();
577 float zoneY = object->GetPositionY();
578
579 Map2ZoneCoordinates(zoneX, zoneY, zoneId);
580
581 float groundZ = object->GetMapHeight(object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
582 float floorZ = object->GetMapHeight(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
583
584 GridCoord gridCoord = Acore::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
585
586 // 63? WHY?
587 int gridX = 63 - gridCoord.x_coord;
588 int gridY = 63 - gridCoord.y_coord;
589
590 uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
591 uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
593
594 if (haveVMap)
595 {
596 if (object->IsOutdoors())
597 {
598 handler->PSendSysMessage("You are outdoors");
599 }
600 else
601 {
602 handler->PSendSysMessage("You are indoors");
603 }
604 }
605 else
606 {
607 handler->PSendSysMessage("no VMAP available for area info");
608 }
609
611 object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
612 zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
613 areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
614 object->GetPhaseMask(),
615 object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
616 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
617 zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMAP);
618
619 LiquidData const& liquidData = object->GetLiquidData();
620
621 if (liquidData.Status)
622 {
623 handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidData.Level, liquidData.DepthLevel, liquidData.Entry, liquidData.Flags, liquidData.Status);
624 }
625
626 if (object->GetTransport())
627 {
628 handler->PSendSysMessage("Transport offset: {:0.2f}, {:0.2f}, {:0.2f}, {:0.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());
629 }
630
631 return true;
632 }
#define MAX_HEIGHT
Definition: Map.h:162
@ LANG_LIQUID_STATUS
Definition: Language.h:215
@ LANG_MAP_POSITION
Definition: Language.h:133
void Map2ZoneCoordinates(float &x, float &y, uint32 zone)
Definition: DBCStores.cpp:748
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:185
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:190
static MMapMgr * createOrGetMMapMgr()
Definition: MMapFactory.cpp:27
dtNavMesh const * GetNavMesh(uint32 mapId)
Definition: MMapMgr.cpp:306
struct MovementInfo::TransportInfo transport
Position pos
Definition: Object.h:297
uint32 GetPhaseMask() const
Definition: Object.h:446
uint32 GetInstanceId() const
Definition: Object.h:443
bool IsOutdoors() const
Definition: Object.cpp:3171
Transport * GetTransport() const
Definition: Object.h:599
MovementInfo m_movementInfo
Definition: Object.h:609
uint32 GetMapId() const
Definition: Position.h:275
Definition: Cell.h:45
Definition: GridDefines.h:85
uint32 x_coord
Definition: GridDefines.h:152
uint32 y_coord
Definition: GridDefines.h:153
Definition: Map.h:169
float Level
Definition: Map.h:174
uint32 Flags
Definition: Map.h:173
uint32 Entry
Definition: Map.h:172
LiquidStatus Status
Definition: Map.h:176
float DepthLevel
Definition: Map.h:175
static bool ExistVMap(uint32 mapid, int gx, int gy)
Definition: Map.cpp:119
static bool ExistMap(uint32 mapid, int gx, int gy)
Definition: Map.cpp:88
Definition: DBCStructure.h:518
char const * area_name[16]
Definition: DBCStructure.h:526
Definition: DBCStructure.h:1324
char const * name[16]
Definition: DBCStructure.h:1330

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
1011 {
1012 if (!target)
1013 {
1014 target = PlayerIdentifier::FromTargetOrSelf(handler);
1015 }
1016
1017 if (!target || !target->IsConnected())
1018 {
1019 return false;
1020 }
1021
1022 // check online security
1023 if (handler->HasLowerSecurity(target->GetConnectedPlayer()))
1024 {
1025 return false;
1026 }
1027
1028 auto targetPlayer = target->GetConnectedPlayer();
1029
1030 Group* group = targetPlayer->GetGroup();
1031
1032 std::string nameLink = handler->playerLink(target->GetName());
1033
1034 if (!group)
1035 {
1036 handler->SendErrorMessage(LANG_NOT_IN_GROUP, nameLink);
1037 return false;
1038 }
1039
1040 Map* gmMap = handler->GetSession()->GetPlayer()->GetMap();
1041 bool toInstance = gmMap->Instanceable();
1042
1043 // we are in instance, and can summon only player in our group with us as lead
1044 if (toInstance && (
1045 !handler->GetSession()->GetPlayer()->GetGroup() || (group->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
1046 (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID())))
1047 // the last check is a bit excessive, but let it be, just in case
1048 {
1050 return false;
1051 }
1052
1053 for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
1054 {
1055 Player* player = itr->GetSource();
1056
1057 if (!player || player == handler->GetSession()->GetPlayer() || !player->GetSession())
1058 {
1059 continue;
1060 }
1061
1062 // check online security
1063 if (handler->HasLowerSecurity(player))
1064 {
1065 return false;
1066 }
1067
1068 std::string plNameLink = handler->GetNameLink(player);
1069
1070 if (player->IsBeingTeleported())
1071 {
1072 handler->SendErrorMessage(LANG_IS_TELEPORTED, plNameLink);
1073 return false;
1074 }
1075
1076 if (toInstance)
1077 {
1078 Map* playerMap = player->GetMap();
1079
1080 if (playerMap->Instanceable() && playerMap->GetInstanceId() != gmMap->GetInstanceId())
1081 {
1082 // cannot summon from instance to instance
1083 handler->SendErrorMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink);
1084 return false;
1085 }
1086 }
1087
1088 handler->PSendSysMessage(LANG_SUMMONING, plNameLink, "");
1089 if (handler->needReportToTarget(player))
1090 {
1092 }
1093
1094 // stop flight if need
1095 if (player->IsInFlight())
1096 {
1097 player->GetMotionMaster()->MovementExpired();
1098 player->CleanupAfterTaxiFlight();
1099 }
1100 // save only in non-flight case
1101 else
1102 {
1103 player->SaveRecallPosition();
1104 }
1105
1106 // before GM
1107 float x, y, z;
1108 handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize());
1109 player->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation(), 0, handler->GetSession()->GetPlayer());
1110 }
1111
1112 return true;
1113 }
@ 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:37
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:863
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:2699
float GetObjectSize() const
Definition: Object.cpp:2771
bool IsBeingTeleported() const
Definition: Player.h:2073
Definition: Group.h:169
GroupReference * GetFirstMember()
Definition: Group.h:243
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2292
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36
bool Instanceable() const
Definition: Map.h:445
uint32 GetInstanceId() const
Definition: Map.h:417

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
1208 {
1209 ObjectGuid guid = handler->GetSession()->GetPlayer()->GetTarget();
1210
1211 if (!guid)
1212 {
1214 return false;
1215 }
1216
1217 handler->PSendSysMessage(LANG_OBJECT_GUID, guid.ToString());
1218 return true;
1219 }
@ LANG_OBJECT_GUID
Definition: Language.h:238
@ LANG_NO_SELECTION
Definition: Language.h:237
Definition: ObjectGuid.h:118
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
1222 {
1224
1225 if (cmd.empty())
1226 {
1228 }
1229
1230 return true;
1231 }

References Acore::ChatCommands::SendCommandHelpFor().

Referenced by GetCommands().

◆ HandleHideAreaCommand()

static bool misc_commandscript::HandleHideAreaCommand ( ChatHandler handler,
uint32  areaID 
)
inlinestatic
1655 {
1656 Player* playerTarget = handler->getSelectedPlayer();
1657 if (!playerTarget)
1658 {
1660 return false;
1661 }
1662
1663 AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaID);
1664 if (!area)
1665 {
1667 return false;
1668 }
1669
1670 int32 offset = area->exploreFlag / 32;
1671 if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
1672 {
1674 return false;
1675 }
1676
1677 uint32 val = uint32((1 << (area->exploreFlag % 32)));
1678 uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
1679 playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields ^ val)));
1680
1682 return true;
1683 }
@ LANG_UNEXPLORE_AREA
Definition: Language.h:617
@ LANG_NO_CHAR_SELECTED
Definition: Language.h:148
@ LANG_BAD_VALUE
Definition: Language.h:147
#define PLAYER_EXPLORED_ZONES_SIZE
Definition: Player.h:72
@ PLAYER_EXPLORED_ZONES_1
Definition: UpdateFields.h:357
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
void SetUInt32Value(uint16 index, uint32 value)
Definition: Unit.cpp:21317
uint32 exploreFlag
Definition: DBCStructure.h:522

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 Unit::SetUInt32Value().

Referenced by GetCommands().

◆ HandleKickPlayerCommand()

static bool misc_commandscript::HandleKickPlayerCommand ( ChatHandler handler,
Optional< PlayerIdentifier target,
Optional< std::string_view >  reason 
)
inlinestatic
1368 {
1369 if (!target)
1370 {
1371 target = PlayerIdentifier::FromTargetOrSelf(handler);
1372 }
1373
1374 if (!target || !target->IsConnected())
1375 {
1376 return false;
1377 }
1378
1379 auto targetPlayer = target->GetConnectedPlayer();
1380
1381 if (handler->GetSession() && target->GetGUID() == handler->GetSession()->GetPlayer()->GetGUID())
1382 {
1384 return false;
1385 }
1386
1387 // check online security
1388 if (handler->HasLowerSecurity(targetPlayer))
1389 {
1390 return false;
1391 }
1392
1393 std::string kickReasonStr = handler->GetAcoreString(LANG_NO_REASON);
1394 if (reason && !reason->empty())
1395 {
1396 kickReasonStr = std::string{ *reason };
1397 }
1398
1399 if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
1400 {
1401 handler->SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName() : "Server"), target->GetName(), kickReasonStr);
1402 }
1403 else
1404 {
1405 handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, target->GetName());
1406 }
1407
1408 targetPlayer->GetSession()->KickPlayer("HandleKickPlayerCommand");
1409
1410 return true;
1411 }
@ LANG_COMMAND_KICKSELF
Definition: Language.h:326
@ LANG_COMMAND_KICKMESSAGE_WORLD
Definition: Language.h:1285
@ LANG_NO_REASON
Definition: Language.h:807
@ LANG_COMMAND_KICKMESSAGE
Definition: Language.h:327
@ CONFIG_SHOW_KICK_IN_WORLD
Definition: IWorld.h:131
void SendWorldText(std::string_view str)
Definition: Chat.cpp:130
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:186

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(), ChatHandler::SendWorldText(), and sWorld.

Referenced by GetCommands().

◆ HandleLinkGraveCommand()

static bool misc_commandscript::HandleLinkGraveCommand ( ChatHandler handler,
uint32  graveyardId,
Optional< std::string_view >  team 
)
inlinestatic
1496 {
1497 TeamId teamId;
1498
1499 if (!team)
1500 {
1501 teamId = TEAM_NEUTRAL;
1502 }
1503 else if (StringEqualI(team->substr(0, 6), "horde"))
1504 {
1505 teamId = TEAM_HORDE;
1506 }
1507 else if (StringEqualI(team->substr(0, 9), "alliance"))
1508 {
1509 teamId = TEAM_ALLIANCE;
1510 }
1511 else
1512 {
1513 return false;
1514 }
1515
1516 GraveyardStruct const* graveyard = sGraveyard->GetGraveyard(graveyardId);
1517
1518 if (!graveyard)
1519 {
1520 handler->SendErrorMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId);
1521 return false;
1522 }
1523
1524 Player* player = handler->GetSession()->GetPlayer();
1525 uint32 zoneId = player->GetZoneId();
1526
1527 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(zoneId);
1528 if (!areaEntry || areaEntry->zone != 0)
1529 {
1530 handler->SendErrorMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, graveyardId, zoneId);
1531 return false;
1532 }
1533
1534 if (sGraveyard->AddGraveyardLink(graveyardId, zoneId, teamId))
1535 {
1536 handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, graveyardId, zoneId);
1537 }
1538 else
1539 {
1540 handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, graveyardId, zoneId);
1541 }
1542
1543 return true;
1544 }
bool StringEqualI(std::string_view a, std::string_view b)
Definition: Util.cpp:592
TeamId
Definition: SharedDefines.h:759
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
#define sGraveyard
Definition: GameGraveyard.h:74
@ LANG_COMMAND_GRAVEYARDALRLINKED
Definition: Language.h:482
@ LANG_COMMAND_GRAVEYARDNOEXIST
Definition: Language.h:481
@ LANG_COMMAND_GRAVEYARDWRONGZONE
Definition: Language.h:484
@ LANG_COMMAND_GRAVEYARDLINKED
Definition: Language.h:483
Definition: GameGraveyard.h:27
uint32 zone
Definition: DBCStructure.h:521

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
3010 {
3011 Player* player = handler->GetSession()->GetPlayer();
3012 handler->GetSession()->SendShowMailBox(player->GetGUID());
3013 return true;
3014 }
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
1879 {
1880 Player* SelectedPlayer = handler->getSelectedPlayer();
1881 if (!SelectedPlayer)
1882 {
1884 return false;
1885 }
1886
1887 // each skills that have max skill value dependent from level seted to current level max skill value
1888 SelectedPlayer->UpdateSkillsToMaxSkillsForLevel();
1889 return true;
1890 }
void UpdateSkillsToMaxSkillsForLevel()
Definition: PlayerUpdates.cpp:1086

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

Referenced by GetCommands().

◆ HandleMovegensCommand()

static bool misc_commandscript::HandleMovegensCommand ( ChatHandler handler)
inlinestatic
2648 {
2649 Unit* unit = handler->getSelectedUnit();
2650 if (!unit)
2651 {
2653 return false;
2654 }
2655
2656 handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->IsPlayer() ? "Player" : "Creature"), unit->GetGUID().ToString());
2657
2658 MotionMaster* motionMaster = unit->GetMotionMaster();
2659 float x, y, z;
2660 motionMaster->GetDestination(x, y, z);
2661
2662 for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
2663 {
2664 MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(i);
2665 if (!movementGenerator)
2666 {
2667 handler->SendSysMessage("Empty");
2668 continue;
2669 }
2670
2671 switch (movementGenerator->GetMovementGeneratorType())
2672 {
2673 case IDLE_MOTION_TYPE:
2675 break;
2676 case RANDOM_MOTION_TYPE:
2678 break;
2681 break;
2684 break;
2687 break;
2688 case CHASE_MOTION_TYPE:
2689 {
2690 Unit* target = nullptr;
2691 if (unit->IsPlayer())
2692 {
2693 target = static_cast<ChaseMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
2694 }
2695 else
2696 {
2697 target = static_cast<ChaseMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
2698 }
2699
2700 if (!target)
2701 {
2703 }
2704 else if (target->IsPlayer())
2705 {
2706 handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUID().ToString());
2707 }
2708 else
2709 {
2710 handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUID().ToString());
2711 }
2712 break;
2713 }
2714 case FOLLOW_MOTION_TYPE:
2715 {
2716 Unit* target = nullptr;
2717 if (unit->IsPlayer())
2718 {
2719 target = static_cast<FollowMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
2720 }
2721 else
2722 {
2723 target = static_cast<FollowMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
2724 }
2725
2726 if (!target)
2727 {
2729 }
2730 else if (target->IsPlayer())
2731 {
2732 handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUID().ToString());
2733 }
2734 else
2735 {
2736 handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUID().ToString());
2737 }
2738 break;
2739 }
2740 case HOME_MOTION_TYPE:
2741 {
2742 if (unit->IsCreature())
2743 {
2745 }
2746 else
2747 {
2749 }
2750 break;
2751 }
2752 case FLIGHT_MOTION_TYPE:
2754 break;
2755 case POINT_MOTION_TYPE:
2756 {
2757 handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z);
2758 break;
2759 }
2762 break;
2765 break;
2766 case EFFECT_MOTION_TYPE:
2768 break;
2769 default:
2770 handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType());
2771 break;
2772 }
2773 }
2774 return true;
2775 }
std::uint8_t uint8
Definition: Define.h:109
@ LANG_MOVEGENS_FOLLOW_PLAYER
Definition: Language.h:928
@ LANG_MOVEGENS_EFFECT
Definition: Language.h:931
@ LANG_MOVEGENS_UNKNOWN
Definition: Language.h:584
@ LANG_MOVEGENS_CHASE_PLAYER
Definition: Language.h:578
@ LANG_MOVEGENS_IDLE
Definition: Language.h:573
@ LANG_MOVEGENS_CONFUSED
Definition: Language.h:577
@ LANG_MOVEGENS_FOLLOW_CREATURE
Definition: Language.h:929
@ LANG_MOVEGENS_FOLLOW_NULL
Definition: Language.h:930
@ LANG_MOVEGENS_DISTRACT
Definition: Language.h:652
@ LANG_MOVEGENS_CHASE_CREATURE
Definition: Language.h:579
@ LANG_MOVEGENS_RANDOM
Definition: Language.h:574
@ LANG_MOVEGENS_WAYPOINT
Definition: Language.h:575
@ LANG_MOVEGENS_POINT
Definition: Language.h:650
@ LANG_MOVEGENS_ANIMAL_RANDOM
Definition: Language.h:576
@ LANG_MOVEGENS_CHASE_NULL
Definition: Language.h:580
@ LANG_MOVEGENS_FLIGHT
Definition: Language.h:583
@ LANG_MOVEGENS_HOME_CREATURE
Definition: Language.h:581
@ LANG_MOVEGENS_HOME_PLAYER
Definition: Language.h:582
@ LANG_MOVEGENS_LIST
Definition: Language.h:572
@ LANG_MOVEGENS_FEAR
Definition: Language.h:651
@ MAX_MOTION_SLOT
Definition: MotionMaster.h:66
@ DISTRACT_MOTION_TYPE
Definition: MotionMaster.h:50
@ IDLE_MOTION_TYPE
Definition: MotionMaster.h:39
@ CHASE_MOTION_TYPE
Definition: MotionMaster.h:45
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:41
@ FLEEING_MOTION_TYPE
Definition: MotionMaster.h:49
@ CONFUSED_MOTION_TYPE
Definition: MotionMaster.h:44
@ HOME_MOTION_TYPE
Definition: MotionMaster.h:46
@ POINT_MOTION_TYPE
Definition: MotionMaster.h:48
@ FLIGHT_MOTION_TYPE
Definition: MotionMaster.h:47
@ FOLLOW_MOTION_TYPE
Definition: MotionMaster.h:54
@ ANIMAL_RANDOM_MOTION_TYPE
Definition: MotionMaster.h:43
@ RANDOM_MOTION_TYPE
Definition: MotionMaster.h:40
@ EFFECT_MOTION_TYPE
Definition: MotionMaster.h:56
std::string const & GetName() const
Definition: Object.h:458
Definition: MotionMaster.h:112
_Ty GetMotionSlot(int slot) const
Definition: MotionMaster.h:155
bool GetDestination(float &x, float &y, float &z)
Definition: MotionMaster.cpp:962
Definition: MovementGenerator.h:28
virtual MovementGeneratorType GetMovementGeneratorType()=0
Definition: TargetedMovementGenerator.h:39
Definition: TargetedMovementGenerator.h:76

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, MotionMaster::GetDestination(), Object::GetGUID(), Unit::GetMotionMaster(), MotionMaster::GetMotionSlot(), MovementGenerator::GetMovementGeneratorType(), WorldObject::GetName(), ChatHandler::getSelectedUnit(), HOME_MOTION_TYPE, IDLE_MOTION_TYPE, Object::IsCreature(), Object::IsPlayer(), 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(), ObjectGuid::ToString(), and WAYPOINT_MOTION_TYPE.

Referenced by GetCommands().

◆ HandleMuteCommand()

static bool misc_commandscript::HandleMuteCommand ( ChatHandler handler,
Optional< PlayerIdentifier player,
std::string  notSpeakTime,
Tail  muteReason 
)
inlinestatic
2424 {
2425 std::string muteReasonStr{ muteReason };
2426
2427 if (notSpeakTime.empty())
2428 {
2429 return false;
2430 }
2431
2432 if (Acore::StringTo<int32>(notSpeakTime).value_or(0) < 0)
2433 {
2435 return false;
2436 }
2437
2438 if (muteReason.empty())
2439 {
2440 muteReasonStr = handler->GetAcoreString(LANG_NO_REASON);
2441 }
2442
2443 if (!player)
2444 {
2445 player = PlayerIdentifier::FromTarget(handler);
2446 }
2447
2448 if (!player)
2449 {
2451 return false;
2452 }
2453
2454 Player* target = player->GetConnectedPlayer();
2455 uint32 accountId = target ? target->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(player->GetGUID());
2456
2457 // find only player from same account if any
2458 if (!target)
2459 if (WorldSession* session = sWorld->FindSession(accountId))
2460 {
2461 target = session->GetPlayer();
2462 }
2463
2464 // must have strong lesser security level
2465 if (handler->HasLowerSecurity(target, player->GetGUID(), true))
2466 {
2467 return false;
2468 }
2469
2471 int32 muteDuration = TimeStringToSecs(notSpeakTime);
2472 if (muteDuration <= 0)
2473 {
2474 muteDuration = Acore::StringTo<int32>(notSpeakTime).value_or(0);
2475 }
2476
2477 if (muteDuration <= 0)
2478 {
2480 return false;
2481 }
2482
2483 std::string muteBy = "";
2484 if (handler->GetSession())
2485 {
2486 muteBy = handler->GetSession()->GetPlayerName();
2487 }
2488 else
2489 {
2490 muteBy = handler->GetAcoreString(LANG_CONSOLE);
2491 }
2492
2493 if (target)
2494 {
2495 // Target is online, mute will be in effect right away.
2496 int64 muteTime = GameTime::GetGameTime().count() + muteDuration;
2497 target->GetSession()->m_muteTime = muteTime;
2498 stmt->SetData(0, muteTime);
2499 std::string nameLink = handler->playerLink(player->GetName());
2500
2501 if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD))
2502 {
2503 handler->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy, nameLink, secsToTimeString(muteDuration, true), muteReasonStr);
2504 }
2505
2506 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, secsToTimeString(muteDuration, true), muteBy, muteReasonStr);
2507 }
2508 else
2509 {
2510 // Target is offline, mute will be in effect starting from the next login.
2511 stmt->SetData(0, -int32(muteDuration));
2512 }
2513
2514 stmt->SetData(1, muteReasonStr);
2515 stmt->SetData(2, muteBy);
2516 stmt->SetData(3, accountId);
2517 LoginDatabase.Execute(stmt);
2518
2519 stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_MUTE);
2520 stmt->SetData(0, accountId);
2521 stmt->SetData(1, muteDuration / MINUTE);
2522 stmt->SetData(2, muteBy);
2523 stmt->SetData(3, muteReasonStr);
2524 LoginDatabase.Execute(stmt);
2525
2526 std::string nameLink = handler->playerLink(player->GetName());
2527
2528 if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target)
2529 {
2530 handler->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy, nameLink, secsToTimeString(muteDuration, true), muteReasonStr);
2531 }
2532 else
2533 {
2534 // pussywizard: notify all online GMs
2535 std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
2537 for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
2538 if (itr->second->GetSession()->GetSecurity())
2540 (handler->GetSession() ? handler->GetSession()->GetPlayerName() : handler->GetAcoreString(LANG_CONSOLE)), nameLink, secsToTimeString(muteDuration, true), muteReasonStr);
2541 }
2542
2543 return true;
2544 }
constexpr auto MINUTE
Definition: Common.h:47
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition: Util.cpp:73
uint32 TimeStringToSecs(const std::string &timestring)
Definition: Util.cpp:163
std::int64_t int64
Definition: Define.h:102
@ LANG_COMMAND_DISABLE_CHAT_DELAYED
Definition: Language.h:328
@ LANG_YOUR_CHAT_DISABLED
Definition: Language.h:340
@ LANG_COMMAND_MUTEMESSAGE_WORLD
Definition: Language.h:1288
@ LANG_YOU_DISABLE_CHAT
Definition: Language.h:341
@ LANG_CONSOLE
Definition: Language.h:1086
@ CONFIG_SHOW_MUTE_IN_WORLD
Definition: IWorld.h:132
#define sCharacterCache
Definition: CharacterCache.h:83
@ LOGIN_UPD_MUTE_TIME
Definition: LoginDatabase.h:72
@ LOGIN_INS_ACCOUNT_MUTE
Definition: LoginDatabase.h:109
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:75
Seconds GetGameTime()
Definition: GameTime.cpp:38
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77
Definition: ObjectAccessor.h:41
std::unordered_map< ObjectGuid, T * > MapType
Definition: ObjectAccessor.h:47
uint32 GetAccountId() const
Definition: WorldSession.h:361
time_t m_muteTime
Definition: WorldSession.h:494

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(), ChatHandler::SendWorldText(), PreparedStatementBase::SetData(), sWorld, and TimeStringToSecs().

Referenced by GetCommands().

◆ HandleMuteInfoCommand()

static bool misc_commandscript::HandleMuteInfoCommand ( ChatHandler handler,
std::string  accountName 
)
inlinestatic
2607 {
2608 if (!Utf8ToUpperOnlyLatin(accountName))
2609 {
2610 handler->SendErrorMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
2611 return false;
2612 }
2613
2614 uint32 accountId = AccountMgr::GetId(accountName);
2615 if (!accountId)
2616 {
2617 handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
2618 return false;
2619 }
2620
2621 return HandleMuteInfoHelper(handler, accountId, accountName.c_str());
2622 }
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:532
@ LANG_ACCOUNT_NOT_EXIST
Definition: Language.h:442
uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:229
static bool HandleMuteInfoHelper(ChatHandler *handler, uint32 accountId, char const *accountName)
Definition: cs_misc.cpp:2625

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
2626 {
2628 stmt->SetData(0, accountId);
2629 PreparedQueryResult result = LoginDatabase.Query(stmt);
2630
2631 if (!result)
2632 {
2633 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_EMPTY, accountName);
2634 return true;
2635 }
2636
2637 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY, accountName);
2638 do
2639 {
2640 Field* fields = result->Fetch();
2641 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, Acore::Time::TimeToHumanReadable(Seconds(fields[0].Get<uint32>())), fields[1].Get<uint32>(), fields[2].Get<std::string>(), fields[3].Get<std::string>());
2642 } while (result->NextRow());
2643
2644 return true;
2645 }
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:30
@ LANG_COMMAND_MUTEHISTORY_OUTPUT
Definition: Language.h:1112
@ LANG_COMMAND_MUTEHISTORY_EMPTY
Definition: Language.h:1111
@ LANG_COMMAND_MUTEHISTORY
Definition: Language.h:1110
@ LOGIN_SEL_ACCOUNT_MUTE_INFO
Definition: LoginDatabase.h:110
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:45
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:98

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
1547 {
1548 TeamId teamId;
1549
1550 if (!team)
1551 {
1552 teamId = TEAM_NEUTRAL;
1553 }
1554 else if (StringEqualI(team->substr(0, 6), "horde"))
1555 {
1556 teamId = TEAM_HORDE;
1557 }
1558 else if (StringEqualI(team->substr(0, 9), "alliance"))
1559 {
1560 teamId = TEAM_ALLIANCE;
1561 }
1562 else
1563 {
1564 return false;
1565 }
1566
1567 Player* player = handler->GetSession()->GetPlayer();
1568 uint32 zone_id = player->GetZoneId();
1569
1570 GraveyardStruct const* graveyard = sGraveyard->GetClosestGraveyard(player, teamId);
1571
1572 if (graveyard)
1573 {
1574 uint32 graveyardId = graveyard->ID;
1575
1576 GraveyardData const* data = sGraveyard->FindGraveyardData(graveyardId, zone_id);
1577 if (!data)
1578 {
1579 handler->SendErrorMessage(LANG_COMMAND_GRAVEYARDERROR, graveyardId);
1580 return false;
1581 }
1582
1583 std::string team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_NOTEAM);
1584
1585 if (data->teamId == TEAM_NEUTRAL)
1586 {
1587 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ANY);
1588 }
1589 else if (data->teamId == TEAM_HORDE)
1590 {
1591 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_HORDE);
1592 }
1593 else if (data->teamId == TEAM_ALLIANCE)
1594 {
1595 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
1596 }
1597
1598 handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, graveyardId, team_name, zone_id);
1599 }
1600 else
1601 {
1602 std::string team_name;
1603
1604 if (teamId == TEAM_NEUTRAL)
1605 {
1606 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ANY);
1607 }
1608 else if (teamId == TEAM_HORDE)
1609 {
1610 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_HORDE);
1611 }
1612 else if (teamId == TEAM_ALLIANCE)
1613 {
1614 team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
1615 }
1616
1617 handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name);
1618 }
1619
1620 return true;
1621 }
@ LANG_COMMAND_GRAVEYARD_ALLIANCE
Definition: Language.h:489
@ LANG_COMMAND_ZONENOGRAFACTION
Definition: Language.h:493
@ LANG_COMMAND_GRAVEYARDNEAREST
Definition: Language.h:491
@ LANG_COMMAND_GRAVEYARD_NOTEAM
Definition: Language.h:487
@ LANG_COMMAND_GRAVEYARDERROR
Definition: Language.h:486
@ LANG_COMMAND_GRAVEYARD_HORDE
Definition: Language.h:490
@ LANG_COMMAND_GRAVEYARD_ANY
Definition: Language.h:488
uint32 ID
Definition: GameGraveyard.h:28
Definition: GameGraveyard.h:38
TeamId teamId
Definition: GameGraveyard.h:40

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
1937 {
1938 if (!target)
1939 {
1940 target = PlayerIdentifier::FromTargetOrSelf(handler);
1941 }
1942
1943 if (!target)
1944 {
1945 return false;
1946 }
1947
1948 Player* playerTarget = target->GetConnectedPlayer();
1949
1950 CharacterDatabasePreparedStatement* stmt = nullptr;
1951 LoginDatabasePreparedStatement* loginStmt = nullptr;
1952
1953 // Account data print variables
1954 std::string userName = handler->GetAcoreString(LANG_ERROR);
1955 ObjectGuid::LowType lowguid = target->GetGUID().GetCounter();
1956 uint32 accId = 0;
1957 std::string eMail = handler->GetAcoreString(LANG_ERROR);
1958 std::string regMail = handler->GetAcoreString(LANG_ERROR);
1959 uint32 security = 0;
1960 std::string lastIp = handler->GetAcoreString(LANG_ERROR);
1961 uint8 locked = 0;
1962 std::string lastLogin = handler->GetAcoreString(LANG_ERROR);
1963 uint32 failedLogins = 0;
1964 uint32 latency = 0;
1965 std::string OS = handler->GetAcoreString(LANG_UNKNOWN);
1966
1967 // Mute data print variables
1968 int64 muteTime = -1;
1969 std::string muteReason = handler->GetAcoreString(LANG_NO_REASON);
1970 std::string muteBy = handler->GetAcoreString(LANG_UNKNOWN);
1971
1972 // Ban data print variables
1973 int64 banTime = -1;
1974 std::string banType = handler->GetAcoreString(LANG_UNKNOWN);
1975 std::string banReason = handler->GetAcoreString(LANG_NO_REASON);
1976 std::string bannedBy = handler->GetAcoreString(LANG_UNKNOWN);
1977
1978 // Character data print variables
1979 uint8 raceid, classid = 0; //RACE_NONE, CLASS_NONE
1980 std::string raceStr, classStr = handler->GetAcoreString(LANG_UNKNOWN);
1981 uint8 gender = 0;
1982 int8 locale = handler->GetSessionDbcLocale();
1983 uint32 totalPlayerTime = 0;
1984 uint8 level = 0;
1985 std::string alive = handler->GetAcoreString(LANG_ERROR);
1986 uint32 money = 0;
1987 uint32 xp = 0;
1988 uint32 xptotal = 0;
1989
1990 // Position data print
1991 uint32 mapId;
1992 uint32 areaId;
1993 uint32 phase = 0;
1994 char const* areaName = nullptr;
1995 char const* zoneName = nullptr;
1996
1997 // Guild data print variables defined so that they exist, but are not necessarily used
1998 uint32 guildId = 0;
1999 uint8 guildRankId = 0;
2000 std::string guildName;
2001 std::string guildRank;
2002 std::string note;
2003 std::string officeNote;
2004
2005 // get additional information from Player object
2006 if (playerTarget)
2007 {
2008 // check online security
2009 if (handler->HasLowerSecurity(playerTarget))
2010 {
2011 return false;
2012 }
2013
2014 accId = playerTarget->GetSession()->GetAccountId();
2015 money = playerTarget->GetMoney();
2016 totalPlayerTime = playerTarget->GetTotalPlayedTime();
2017 level = playerTarget->GetLevel();
2018 latency = playerTarget->GetSession()->GetLatency();
2019 raceid = playerTarget->getRace();
2020 classid = playerTarget->getClass();
2021 muteTime = playerTarget->GetSession()->m_muteTime;
2022 mapId = playerTarget->GetMapId();
2023 areaId = playerTarget->GetAreaId();
2024 alive = playerTarget->IsAlive() ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO);
2025 gender = playerTarget->getGender();
2026 phase = playerTarget->GetPhaseMask();
2027 }
2028 // get additional information from DB
2029 else
2030 {
2031 // check offline security
2032 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
2033 {
2034 return false;
2035 }
2036
2037 // Query informations from the DB
2038 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
2039 stmt->SetData(0, lowguid);
2040 PreparedQueryResult charInfoResult = CharacterDatabase.Query(stmt);
2041
2042 if (!charInfoResult)
2043 {
2044 return false;
2045 }
2046
2047 Field* fields = charInfoResult->Fetch();
2048 totalPlayerTime = fields[0].Get<uint32>();
2049 level = fields[1].Get<uint8>();
2050 money = fields[2].Get<uint32>();
2051 accId = fields[3].Get<uint32>();
2052 raceid = fields[4].Get<uint8>();
2053 classid = fields[5].Get<uint8>();
2054 mapId = fields[6].Get<uint16>();
2055 areaId = fields[7].Get<uint16>();
2056 gender = fields[8].Get<uint8>();
2057 uint32 health = fields[9].Get<uint32>();
2058 uint32 playerFlags = fields[10].Get<uint32>();
2059
2060 if (!health || playerFlags & PLAYER_FLAGS_GHOST)
2061 {
2062 alive = handler->GetAcoreString(LANG_NO);
2063 }
2064 else
2065 {
2066 alive = handler->GetAcoreString(LANG_YES);
2067 }
2068 }
2069
2070 // Query the prepared statement for login data
2071 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);
2072 loginStmt->SetData(0, int32(realm.Id.Realm));
2073 loginStmt->SetData(1, accId);
2074
2075 PreparedQueryResult accInfoResult = LoginDatabase.Query(loginStmt);
2076 if (accInfoResult)
2077 {
2078 Field* fields = accInfoResult->Fetch();
2079 userName = fields[0].Get<std::string>();
2080 security = fields[1].Get<uint8>();
2081
2082 // Only fetch these fields if commander has sufficient rights)
2083 if (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security))
2084 {
2085 eMail = fields[2].Get<std::string>();
2086 regMail = fields[3].Get<std::string>();
2087 lastIp = fields[4].Get<std::string>();
2088 lastLogin = fields[5].Get<std::string>();
2089
2090 if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(lastIp))
2091 {
2092 lastIp.append(" (");
2093 lastIp.append(location->CountryName);
2094 lastIp.append(")");
2095 }
2096 }
2097 else
2098 {
2099 eMail = handler->GetAcoreString(LANG_UNAUTHORIZED);
2100 regMail = handler->GetAcoreString(LANG_UNAUTHORIZED);
2101 lastIp = handler->GetAcoreString(LANG_UNAUTHORIZED);
2102 lastLogin = handler->GetAcoreString(LANG_UNAUTHORIZED);
2103 }
2104
2105 muteTime = fields[6].Get<uint64>();
2106 muteReason = fields[7].Get<std::string>();
2107 muteBy = fields[8].Get<std::string>();
2108 failedLogins = fields[9].Get<uint32>();
2109 locked = fields[10].Get<uint8>();
2110 OS = fields[11].Get<std::string>();
2111 }
2112
2113 // Creates a chat link to the character. Returns nameLink
2114 std::string nameLink = handler->playerLink(target->GetName());
2115
2116 // Returns banType, banTime, bannedBy, banreason
2117 LoginDatabasePreparedStatement* banQuery = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
2118 banQuery->SetData(0, accId);
2119
2120 PreparedQueryResult accBannedResult = LoginDatabase.Query(banQuery);
2121 if (!accBannedResult)
2122 {
2123 banType = handler->GetAcoreString(LANG_CHARACTER);
2124 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS);
2125 stmt->SetData(0, lowguid);
2126 accBannedResult = CharacterDatabase.Query(stmt);
2127 }
2128
2129 if (accBannedResult)
2130 {
2131 Field* fields = accBannedResult->Fetch();
2132 banTime = int64(fields[1].Get<uint64>() ? 0 : fields[0].Get<uint32>());
2133 bannedBy = fields[2].Get<std::string>();
2134 banReason = fields[3].Get<std::string>();
2135 }
2136
2137 // Can be used to query data from World database
2138 WorldDatabasePreparedStatement* xpQuery = WorldDatabase.GetPreparedStatement(WORLD_SEL_REQ_XP);
2139 xpQuery->SetData(0, level);
2140
2141 PreparedQueryResult xpResult = WorldDatabase.Query(xpQuery);
2142 if (xpResult)
2143 {
2144 Field* fields = xpResult->Fetch();
2145 xptotal = fields[0].Get<uint32>();
2146 }
2147
2148 // Can be used to query data from Characters database
2149 CharacterDatabasePreparedStatement* charXpQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_XP);
2150 charXpQuery->SetData(0, lowguid);
2151
2152 PreparedQueryResult charXpResult = CharacterDatabase.Query(charXpQuery);
2153 if (charXpResult)
2154 {
2155 Field* fields = charXpResult->Fetch();
2156 xp = fields[0].Get<uint32>();
2157 ObjectGuid::LowType gguid = fields[1].Get<uint32>();
2158
2159 if (gguid != 0)
2160 {
2162 guildQuery->SetData(0, lowguid);
2163
2164 PreparedQueryResult guildInfoResult = CharacterDatabase.Query(guildQuery);
2165 if (guildInfoResult)
2166 {
2167 Field* guildInfoFields = guildInfoResult->Fetch();
2168 guildId = guildInfoFields[0].Get<uint32>();
2169 guildName = guildInfoFields[1].Get<std::string>();
2170 guildRank = guildInfoFields[2].Get<std::string>();
2171 note = guildInfoFields[3].Get<std::string>();
2172 officeNote = guildInfoFields[4].Get<std::string>();
2173 }
2174 }
2175 }
2176
2177 // Initiate output
2178 // Output I. LANG_PINFO_PLAYER
2179 handler->PSendSysMessage(LANG_PINFO_PLAYER, playerTarget ? "" : handler->GetAcoreString(LANG_OFFLINE), nameLink, target->GetGUID().ToString());
2180
2181 // Output II. LANG_PINFO_GM_ACTIVE if character is gamemaster
2182 if (playerTarget && playerTarget->IsGameMaster())
2183 {
2185 }
2186
2187 // Output III. LANG_PINFO_BANNED if ban exists and is applied
2188 if (banTime >= 0)
2189 {
2190 handler->PSendSysMessage(LANG_PINFO_BANNED, banType, banReason, banTime > 0 ? secsToTimeString(banTime - GameTime::GetGameTime().count(), true) : handler->GetAcoreString(LANG_PERMANENTLY), bannedBy);
2191 }
2192
2193 // Output IV. LANG_PINFO_MUTED if mute is applied
2194 if (muteTime > 0)
2195 {
2196 handler->PSendSysMessage(LANG_PINFO_MUTED, muteReason, secsToTimeString(muteTime - GameTime::GetGameTime().count(), true), muteBy);
2197 }
2198
2199 // Output V. LANG_PINFO_ACC_ACCOUNT
2200 handler->PSendSysMessage(LANG_PINFO_ACC_ACCOUNT, userName, accId, security);
2201
2202 // Output VI. LANG_PINFO_ACC_LASTLOGIN
2203 handler->PSendSysMessage(LANG_PINFO_ACC_LASTLOGIN, lastLogin, failedLogins);
2204
2205 // Output VII. LANG_PINFO_ACC_OS
2206 handler->PSendSysMessage(LANG_PINFO_ACC_OS, OS, latency);
2207
2208 // Output VIII. LANG_PINFO_ACC_REGMAILS
2209 handler->PSendSysMessage(LANG_PINFO_ACC_REGMAILS, regMail, eMail);
2210
2211 // Output IX. LANG_PINFO_ACC_IP
2212 handler->PSendSysMessage(LANG_PINFO_ACC_IP, lastIp, locked ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO));
2213
2214 // Output X. LANG_PINFO_CHR_LEVEL
2215 if (level != sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
2216 {
2217 handler->PSendSysMessage(LANG_PINFO_CHR_LEVEL_LOW, level, xp, xptotal, (xptotal - xp));
2218 }
2219 else
2220 {
2222 }
2223
2224 // Output XI. LANG_PINFO_CHR_RACE
2225 switch (raceid)
2226 {
2227 case RACE_HUMAN:
2228 raceStr = "Human";
2229 break;
2230 case RACE_ORC:
2231 raceStr = "Orc";
2232 break;
2233 case RACE_DWARF:
2234 raceStr = "Dwarf";
2235 break;
2236 case RACE_NIGHTELF:
2237 raceStr = "Night Elf";
2238 break;
2239 case RACE_UNDEAD_PLAYER:
2240 raceStr = "Undead";
2241 break;
2242 case RACE_TAUREN:
2243 raceStr = "Tauren";
2244 break;
2245 case RACE_GNOME:
2246 raceStr = "Gnome";
2247 break;
2248 case RACE_TROLL:
2249 raceStr = "Troll";
2250 break;
2251 case RACE_BLOODELF:
2252 raceStr = "Blood Elf";
2253 break;
2254 case RACE_DRAENEI:
2255 raceStr = "Draenei";
2256 break;
2257 }
2258
2259 switch (classid)
2260 {
2261 case CLASS_WARRIOR:
2262 classStr = "Warrior";
2263 break;
2264 case CLASS_PALADIN:
2265 classStr = "Paladin";
2266 break;
2267 case CLASS_HUNTER:
2268 classStr = "Hunter";
2269 break;
2270 case CLASS_ROGUE:
2271 classStr = "Rogue";
2272 break;
2273 case CLASS_PRIEST:
2274 classStr = "Priest";
2275 break;
2276 case CLASS_DEATH_KNIGHT:
2277 classStr = "Death Knight";
2278 break;
2279 case CLASS_SHAMAN:
2280 classStr = "Shaman";
2281 break;
2282 case CLASS_MAGE:
2283 classStr = "Mage";
2284 break;
2285 case CLASS_WARLOCK:
2286 classStr = "Warlock";
2287 break;
2288 case CLASS_DRUID:
2289 classStr = "Druid";
2290 break;
2291 }
2292
2293 handler->PSendSysMessage(LANG_PINFO_CHR_RACE, (gender == 0 ? handler->GetAcoreString(LANG_CHARACTER_GENDER_MALE) : handler->GetAcoreString(LANG_CHARACTER_GENDER_FEMALE)), raceStr, classStr);
2294
2295 // Output XII. LANG_PINFO_CHR_ALIVE
2296 handler->PSendSysMessage(LANG_PINFO_CHR_ALIVE, alive);
2297
2298 // Output XIII. LANG_PINFO_CHR_PHASE if player is not in GM mode (GM is in every phase)
2299 if (playerTarget && !playerTarget->IsGameMaster()) // IsInWorld() returns false on loadingscreen, so it's more
2300 {
2301 handler->PSendSysMessage(LANG_PINFO_CHR_PHASE, phase); // precise than just target (safer ?).
2302 }
2303
2304 // However, as we usually just require a target here, we use target instead.
2305 // Output XIV. LANG_PINFO_CHR_MONEY
2306 uint32 gold = money / GOLD;
2307 uint32 silv = (money % GOLD) / SILVER;
2308 uint32 copp = (money % GOLD) % SILVER;
2309 handler->PSendSysMessage(LANG_PINFO_CHR_MONEY, gold, silv, copp);
2310
2311 // Position data
2312 MapEntry const* map = sMapStore.LookupEntry(mapId);
2313 AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId);
2314
2315 if (area)
2316 {
2317 zoneName = area->area_name[locale];
2318
2319 AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->zone);
2320 if (zone)
2321 {
2322 areaName = zoneName;
2323 zoneName = zone->area_name[locale];
2324 }
2325 }
2326
2327 if (!zoneName)
2328 {
2329 zoneName = handler->GetAcoreString(LANG_UNKNOWN);
2330 }
2331
2332 if (areaName)
2333 {
2334 handler->PSendSysMessage(LANG_PINFO_CHR_MAP_WITH_AREA, map->name[locale], zoneName, areaName);
2335 }
2336 else
2337 {
2338 handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->name[locale], zoneName);
2339 }
2340
2341 // Output XVII. - XVIX. if they are not empty
2342 if (!guildName.empty())
2343 {
2344 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName, guildId);
2345 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank, uint32(guildRankId));
2346
2347 if (!note.empty())
2348 {
2350 }
2351
2352 if (!officeNote.empty())
2353 {
2354 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_ONOTE, officeNote);
2355 }
2356 }
2357
2358 // Output XX. LANG_PINFO_CHR_PLAYEDTIME
2359 handler->PSendSysMessage(LANG_PINFO_CHR_PLAYEDTIME, (secsToTimeString(totalPlayerTime, true)));
2360
2361 // Mail Data - an own query, because it may or may not be useful.
2362 // SQL: "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?"
2364 mailQuery->SetData(0, lowguid);
2365
2366 PreparedQueryResult mailInfoResult = CharacterDatabase.Query(mailQuery);
2367 if (mailInfoResult)
2368 {
2369 Field* fields = mailInfoResult->Fetch();
2370 uint32 readmail = uint32(fields[0].Get<double>());
2371 uint32 totalmail = uint32(fields[1].Get<uint64>());
2372
2373 // Output XXI. LANG_INFO_CHR_MAILS if at least one mail is given
2374 if (totalmail >= 1)
2375 {
2376 handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, readmail, totalmail);
2377 }
2378 }
2379
2380 return true;
2381 }
AccountTypes
Definition: Common.h:56
#define sIPLocation
Definition: IPLocation.h:49
std::int8_t int8
Definition: Define.h:105
std::uint64_t uint64
Definition: Define.h:106
std::uint16_t uint16
Definition: Define.h:108
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
@ LANG_YES
Definition: Language.h:451
@ LANG_CHARACTER_GENDER_FEMALE
Definition: Language.h:812
@ LANG_PINFO_CHR_GUILD_NOTE
Definition: Language.h:802
@ LANG_PINFO_CHR_ALIVE
Definition: Language.h:796
@ LANG_PINFO_ACC_LASTLOGIN
Definition: Language.h:790
@ LANG_CHARACTER
Definition: Language.h:1087
@ LANG_UNKNOWN
Definition: Language.h:77
@ LANG_PINFO_CHR_PHASE
Definition: Language.h:797
@ LANG_ERROR
Definition: Language.h:78
@ LANG_PERMANENTLY
Definition: Language.h:1088
@ LANG_OFFLINE
Definition: Language.h:69
@ LANG_PINFO_CHR_LEVEL_LOW
Definition: Language.h:794
@ LANG_PINFO_CHR_PLAYEDTIME
Definition: Language.h:804
@ LANG_UNAUTHORIZED
Definition: Language.h:808
@ LANG_PINFO_CHR_RACE
Definition: Language.h:795
@ LANG_PINFO_CHR_MAP_WITH_AREA
Definition: Language.h:809
@ LANG_PINFO_PLAYER
Definition: Language.h:785
@ LANG_PINFO_ACC_OS
Definition: Language.h:791
@ LANG_CHARACTER_GENDER_MALE
Definition: Language.h:811
@ LANG_PINFO_CHR_MONEY
Definition: Language.h:798
@ LANG_PINFO_CHR_LEVEL_HIGH
Definition: Language.h:806
@ LANG_NO
Definition: Language.h:452
@ LANG_PINFO_CHR_MAP
Definition: Language.h:799
@ LANG_PINFO_ACC_IP
Definition: Language.h:793
@ LANG_PINFO_BANNED
Definition: Language.h:787
@ LANG_PINFO_CHR_GUILD_RANK
Definition: Language.h:801
@ LANG_PINFO_ACC_ACCOUNT
Definition: Language.h:789
@ LANG_PINFO_ACC_REGMAILS
Definition: Language.h:792
@ LANG_PINFO_GM_ACTIVE
Definition: Language.h:786
@ LANG_PINFO_CHR_MAILS
Definition: Language.h:805
@ LANG_PINFO_CHR_GUILD
Definition: Language.h:800
@ LANG_PINFO_CHR_GUILD_ONOTE
Definition: Language.h:803
@ LANG_PINFO_MUTED
Definition: Language.h:788
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:235
@ PLAYER_FLAGS_GHOST
Definition: Player.h:478
@ WORLD_SEL_REQ_XP
Definition: WorldDatabase.h:101
@ 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:88
@ LOGIN_SEL_PINFO_BANS
Definition: LoginDatabase.h:89
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
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:112
uint32 GetAreaId() const
Definition: Object.cpp:3154
uint32 LowType
Definition: ObjectGuid.h:122
uint32 GetTotalPlayedTime()
Definition: Player.h:1186
uint32 GetMoney() const
Definition: Player.h:1599
uint8 getGender() const
Definition: Unit.h:805
uint8 getClass() const
Definition: Unit.h:800
uint8 getRace(bool original=false) const
Definition: Unit.cpp:21007
uint8 GetLevel() const
Definition: Unit.h:1024
uint32 GetLatency() const
Definition: WorldSession.h:502
uint32 Realm
Definition: Realm.h:43
RealmHandle Id
Definition: Realm.h:69

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
2947 {
2948 if (!sSoundEntriesStore.LookupEntry(soundId))
2949 {
2950 handler->SendErrorMessage(LANG_SOUND_NOT_EXIST, soundId);
2951 return false;
2952 }
2953
2954 sWorld->SendGlobalMessage(WorldPackets::Misc::Playsound(soundId).Write());
2955
2957 return true;
2958 }
@ LANG_COMMAND_PLAYED_TO_ALL
Definition: Language.h:1055
@ LANG_SOUND_NOT_EXIST
Definition: Language.h:210
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
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
2961 {
2962 Unit* unit = handler->getSelectedUnit();
2963 if (!unit)
2964 {
2965 return false;
2966 }
2967
2968 handler->GetSession()->GetPlayer()->CastSpell(unit, 530, true);
2969 return true;
2970 }

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
1292 {
1293 if (!target)
1294 {
1295 target = PlayerIdentifier::FromTargetOrSelf(handler);
1296 }
1297
1298 if (!target || !target->IsConnected())
1299 {
1300 return false;
1301 }
1302
1303 auto targetPlayer = target->GetConnectedPlayer();
1304
1305 // check online security
1306 if (handler->HasLowerSecurity(targetPlayer))
1307 {
1308 return false;
1309 }
1310
1311 if (targetPlayer->IsBeingTeleported())
1312 {
1313 handler->SendErrorMessage(LANG_IS_TELEPORTED, handler->playerLink(target->GetName()));
1314 return false;
1315 }
1316
1317 // stop flight if need
1318 if (targetPlayer->IsInFlight())
1319 {
1320 targetPlayer->GetMotionMaster()->MovementExpired();
1321 targetPlayer->CleanupAfterTaxiFlight();
1322 }
1323
1324 targetPlayer->TeleportTo(targetPlayer->m_recallMap, targetPlayer->m_recallX, targetPlayer->m_recallY, targetPlayer->m_recallZ, targetPlayer->m_recallO);
1325 return true;
1326 }

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
2408 {
2409 Player* player = handler->GetSession()->GetPlayer();
2410
2412 Cell cell(p);
2413 cell.SetNoCreate();
2414
2415 Acore::RespawnDo u_do;
2416 Acore::WorldObjectWorker<Acore::RespawnDo> worker(player, u_do);
2417 Cell::VisitGridObjects(player, worker, player->GetGridActivationRange());
2418
2419 return true;
2420 }
float GetGridActivationRange() const
Definition: Object.cpp:1623
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:178
Definition: GridNotifiers.h:260
Definition: GridNotifiers.h:645

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
2384 {
2385 Player* player = handler->GetSession()->GetPlayer();
2386
2387 Unit* target = handler->getSelectedUnit();
2388 if (player->GetTarget() && target)
2389 {
2390 if (!target->IsCreature() || target->IsPet())
2391 {
2393 return false;
2394 }
2395
2396 if (target->isDead())
2397 {
2398 target->ToCreature()->Respawn(true);
2399 }
2400 return true;
2401 }
2402
2404 return false;
2405 }
void Respawn(bool force=false)
Definition: Creature.cpp:2035
bool IsPet() const
Definition: Unit.h:754
bool isDead() const
Definition: Unit.h:1656

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

Referenced by GetCommands().

◆ HandleReviveCommand()

static bool misc_commandscript::HandleReviveCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
1159 {
1160 if (!target)
1161 target = PlayerIdentifier::FromTargetOrSelf(handler);
1162
1163 if (!target)
1164 return false;
1165
1166 if (target->IsConnected())
1167 {
1168 auto targetPlayer = target->GetConnectedPlayer();
1169 targetPlayer->RemoveAurasDueToSpell(27827); // Spirit of Redemption
1170 targetPlayer->ResurrectPlayer(!AccountMgr::IsPlayerAccount(targetPlayer->GetSession()->GetSecurity()) ? 1.0f : 0.5f);
1171 targetPlayer->SpawnCorpseBones();
1172 targetPlayer->SaveToDB(false, false);
1173 }
1174 else
1175 {
1176 CharacterDatabaseTransaction trans(nullptr);
1177 Player::OfflineResurrect(target->GetGUID(), trans);
1178 }
1179
1180 return true;
1181 }
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
static void OfflineResurrect(ObjectGuid const guid, CharacterDatabaseTransaction trans)
Definition: Player.cpp:4579

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

Referenced by GetCommands().

◆ HandleSaveAllCommand()

static bool misc_commandscript::HandleSaveAllCommand ( ChatHandler handler)
inlinestatic
1360 {
1363 return true;
1364 }
@ LANG_PLAYERS_SAVED
Definition: Language.h:47
void SaveAllPlayers()
Definition: ObjectAccessor.cpp:262

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

Referenced by GetCommands().

◆ HandleSaveCommand()

static bool misc_commandscript::HandleSaveCommand ( ChatHandler handler)
inlinestatic
1329 {
1330 Player* player = handler->GetSession()->GetPlayer();
1331
1332 // save GM account without delay and output message
1333 if (handler->GetSession()->GetSecurity() >= SEC_GAMEMASTER)
1334 {
1335 if (Player* target = handler->getSelectedPlayer())
1336 {
1337 target->SaveToDB(false, false);
1338 }
1339 else
1340 {
1341 player->SaveToDB(false, false);
1342 }
1343
1345 return true;
1346 }
1347
1348 // save if the player has last been saved over 20 seconds ago
1349 uint32 saveInterval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
1350 if (saveInterval == 0 || (saveInterval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= saveInterval - 20 * IN_MILLISECONDS))
1351 {
1352 player->SaveToDB(false, false);
1353 }
1354
1355 return true;
1356 }
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
@ LANG_PLAYER_SAVED
Definition: Language.h:46
@ CONFIG_INTERVAL_SAVE
Definition: IWorld.h:213
void SaveToDB(bool create, bool logout)
Definition: PlayerStorage.cpp:7049
uint32 GetSaveTimer() const
Definition: Player.h:2338

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
1893 {
1894 uint32 skillID = uint32(skillId);
1895
1896 if (skillID <= 0)
1897 {
1898 handler->SendErrorMessage(LANG_INVALID_SKILL_ID, skillID);
1899 return false;
1900 }
1901
1902 Player* target = handler->getSelectedPlayer();
1903 if (!target)
1904 {
1906 return false;
1907 }
1908
1909 SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skillID);
1910 if (!skillLine)
1911 {
1912 handler->SendErrorMessage(LANG_INVALID_SKILL_ID, uint32(skillID));
1913 return false;
1914 }
1915
1916 bool targetHasSkill = target->GetSkillValue(skillID);
1917
1918 // If our target does not yet have the skill they are trying to add to them, the chosen level also becomes
1919 // the max level of the new profession.
1920 uint16 max = maxPureSkill ? *maxPureSkill : targetHasSkill ? target->GetPureMaxSkillValue(skillID) : uint16(level);
1921
1922 if (level <= 0 || level > max || max <= 0)
1923 {
1924 return false;
1925 }
1926
1927 // If the player has the skill, we get the current skill step. If they don't have the skill, we
1928 // add the skill to the player's book with step 1 (which is the first rank, in most cases something
1929 // like 'Apprentice <skill>'.
1930 target->SetSkill(skillID, targetHasSkill ? target->GetSkillStep(skillID) : 1, level, max);
1931 handler->PSendSysMessage(LANG_SET_SKILL, skillID, skillLine->name[handler->GetSessionDbcLocale()], handler->GetNameLink(target), level, max);
1932 return true;
1933 }
@ LANG_INVALID_SKILL_ID
Definition: Language.h:525
@ LANG_SET_SKILL
Definition: Language.h:522
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5446
uint16 GetSkillStep(uint16 skill) const
Definition: Player.cpp:5434
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5481
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition: Player.cpp:5325
Definition: DBCStructure.h:1582
char const * name[16]
Definition: DBCStructure.h:1586

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
1624 {
1625 Player* playerTarget = handler->getSelectedPlayer();
1626 if (!playerTarget)
1627 {
1629 return false;
1630 }
1631
1632 AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaID);
1633 if (!area)
1634 {
1636 return false;
1637 }
1638
1639 int32 offset = area->exploreFlag / 32;
1640 if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
1641 {
1643 return false;
1644 }
1645
1646 uint32 val = uint32((1 << (area->exploreFlag % 32)));
1647 uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
1648 playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields | val)));
1649
1651 return true;
1652 }
@ LANG_EXPLORE_AREA
Definition: Language.h:616

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 Unit::SetUInt32Value().

Referenced by GetCommands().

◆ HandleSkirmishCommand()

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

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
3017 {
3018 if (!id)
3019 {
3021 return false;
3022 }
3023
3024 const char* str = sObjectMgr->GetAcoreString(id, locale ? static_cast<LocaleConstant>(*locale) : DEFAULT_LOCALE);
3025
3026 if (!strcmp(str, "<error>"))
3027 {
3029 return true;
3030 }
3031 else
3032 {
3033 handler->SendSysMessage(str);
3034 return true;
3035 }
3036 }
LocaleConstant
Definition: Common.h:65
#define DEFAULT_LOCALE
Definition: Common.h:79
@ LANG_CMD_SYNTAX
Definition: Language.h:42
@ LANG_NO_ACORE_STRING_FOUND
Definition: Language.h:1169

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
889 {
890 if (!target)
891 {
892 target = PlayerIdentifier::FromTarget(handler);
893 }
894
895 if (!target)
896 {
897 return false;
898 }
899
900 Player* _player = handler->GetSession()->GetPlayer();
901 if (target->GetGUID() == _player->GetGUID())
902 {
904 return false;
905 }
906
907 std::string nameLink = handler->playerLink(target->GetName());
908
909 if (target->IsConnected())
910 {
911 auto targetPlayer = target->GetConnectedPlayer();
912
913 // check online security
914 if (handler->HasLowerSecurity(targetPlayer))
915 {
916 return false;
917 }
918
919 if (targetPlayer->IsBeingTeleported())
920 {
921 handler->SendErrorMessage(LANG_IS_TELEPORTED, nameLink);
922 return false;
923 }
924
925 Map* map = handler->GetSession()->GetPlayer()->GetMap();
926
927 if (map->IsBattlegroundOrArena())
928 {
929 handler->SendErrorMessage("Can't summon to a battleground!");
930 return false;
931 }
932 else if (map->IsDungeon())
933 {
934 // Allow GM to summon players or only other GM accounts inside instances.
935 if (!sWorld->getBoolConfig(CONFIG_INSTANCE_GMSUMMON_PLAYER))
936 {
937 // pussywizard: prevent unbinding normal player's perm bind by just summoning him >_>
938 if (!targetPlayer->GetSession()->GetSecurity())
939 {
940 handler->SendErrorMessage("Only GMs can be summoned to an instance!");
941 return false;
942 }
943 }
944
945 Map* destMap = targetPlayer->GetMap();
946
947 if (destMap->Instanceable() && destMap->GetInstanceId() != map->GetInstanceId())
948 {
949 sInstanceSaveMgr->PlayerUnbindInstance(target->GetGUID(), map->GetInstanceId(), targetPlayer->GetDungeonDifficulty(), true, targetPlayer);
950 }
951
952 // we are in an instance, and can only summon players in our group with us as leader
953 if (!handler->GetSession()->GetPlayer()->GetGroup() || !targetPlayer->GetGroup() ||
954 (targetPlayer->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
955 (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()))
956 // the last check is a bit excessive, but let it be, just in case
957 {
959 return false;
960 }
961 }
962
963 handler->PSendSysMessage(LANG_SUMMONING, nameLink, "");
964 if (handler->needReportToTarget(targetPlayer))
965 {
966 ChatHandler(targetPlayer->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()));
967 }
968
969 // stop flight if need
970 if (targetPlayer->IsInFlight())
971 {
972 targetPlayer->GetMotionMaster()->MovementExpired();
973 targetPlayer->CleanupAfterTaxiFlight();
974 }
975 // save only in non-flight case
976 else
977 {
978 targetPlayer->SaveRecallPosition();
979 }
980
981 // before GM
982 float x, y, z;
983 handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, targetPlayer->GetObjectSize());
984 targetPlayer->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, targetPlayer->GetOrientation(), 0, handler->GetSession()->GetPlayer());
985 }
986 else
987 {
988 // check offline security
989 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
990 {
991 return false;
992 }
993
994 handler->PSendSysMessage(LANG_SUMMONING, nameLink, handler->GetAcoreString(LANG_OFFLINE));
995
996 // in point where GM stay
998 handler->GetSession()->GetPlayer()->GetPositionX(),
999 handler->GetSession()->GetPlayer()->GetPositionY(),
1000 handler->GetSession()->GetPlayer()->GetPositionZ(),
1001 handler->GetSession()->GetPlayer()->GetOrientation(),
1002 handler->GetSession()->GetPlayer()->GetZoneId(),
1003 target->GetGUID());
1004 }
1005
1006 return true;
1007 }
@ CONFIG_INSTANCE_GMSUMMON_PLAYER
Definition: IWorld.h:86
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
706 {
707 Unit* target = handler->getSelectedUnit();
708 if (!target)
709 {
711 return false;
712 }
713
714 if (spells.holds_alternative<std::string_view>() && spells.get<std::string_view>() == "all")
715 {
716 target->RemoveAllAuras();
717 return true;
718 }
719
720 if (!spells.holds_alternative<SpellInfo const*>())
721 {
723 return false;
724 }
725
726 auto spell = spells.get<SpellInfo const*>();
727
728 if (!SpellMgr::IsSpellValid(spell))
729 {
730 handler->SendErrorMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
731 return false;
732 }
733
734 target->RemoveAurasDueToSpell(spell->Id);
735
736 return true;
737 }
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:4909
void RemoveAllAuras()
Definition: Unit.cpp:5319

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
2997 {
2998 Player* player = handler->GetSession()->GetPlayer();
2999
3000 if (player->isPossessing())
3001 {
3002 return false;
3003 }
3004
3005 player->StopCastingBindSight();
3006 return true;
3007 }
void StopCastingBindSight(Aura *except=nullptr)
Definition: Player.cpp:13166
bool isPossessing() const
Definition: Unit.h:1238

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
2905 {
2906 Creature* creatureTarget = handler->getSelectedCreature();
2907
2908 if (!target && !creatureTarget)
2909 {
2910 target = PlayerIdentifier::FromTargetOrSelf(handler);
2911 }
2912
2913 if (!target && !creatureTarget)
2914 {
2916 return false;
2917 }
2918
2919 Player* playerTarget = target->GetConnectedPlayer();
2920
2921 if (!creatureTarget && playerTarget && playerTarget->HasAura(SPELL_FREEZE))
2922 {
2923 handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName());
2924 playerTarget->RemoveAurasDueToSpell(SPELL_FREEZE);
2925 return true;
2926 }
2927 else if (creatureTarget && creatureTarget->HasAura(SPELL_FREEZE))
2928 {
2930 creatureTarget->RemoveAurasDueToSpell(SPELL_FREEZE);
2931 return true;
2932 }
2933 else if (!creatureTarget && target && !target->IsConnected())
2934 {
2936 stmt->SetData(0, target->GetGUID().GetCounter());
2937 CharacterDatabase.Execute(stmt);
2938 handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName());
2939 return true;
2940 }
2941
2943 return true;
2944 }
@ LANG_COMMAND_UNFREEZE
Definition: Language.h:1049
@ LANG_COMMAND_FREEZE_WRONG
Definition: Language.h:1048
@ CHAR_DEL_CHAR_AURA_FROZEN
Definition: CharacterDatabase.h:353
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5698

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
2548 {
2549 if (!target)
2550 {
2551 target = PlayerIdentifier::FromTargetOrSelf(handler);
2552 }
2553
2554 if (!target)
2555 {
2556 return false;
2557 }
2558
2559 Player* playerTarget = target->GetConnectedPlayer();
2560 uint32 accountId = playerTarget ? playerTarget->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(target->GetGUID());
2561
2562 // find only player from same account if any
2563 if (!playerTarget)
2564 {
2565 if (WorldSession* session = sWorld->FindSession(accountId))
2566 {
2567 playerTarget = session->GetPlayer();
2568 }
2569 }
2570
2571 // must have strong lesser security level
2572 if (handler->HasLowerSecurity(playerTarget, target->GetGUID(), true))
2573 {
2574 return false;
2575 }
2576
2577 if (playerTarget)
2578 {
2579 if (playerTarget->CanSpeak())
2580 {
2582 return false;
2583 }
2584
2585 playerTarget->GetSession()->m_muteTime = 0;
2586 }
2587
2589 stmt->SetData(0, 0);
2590 stmt->SetData(1, "");
2591 stmt->SetData(2, "");
2592 stmt->SetData(3, accountId);
2593 LoginDatabase.Execute(stmt);
2594
2595 if (playerTarget)
2596 {
2598 }
2599
2600 handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, handler->playerLink(target->GetName()));
2601
2602 return true;
2603 }
@ 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
2973 {
2974 Unit* unit = handler->getSelectedUnit();
2975 if (!unit)
2976 {
2977 unit = handler->GetSession()->GetPlayer();
2978 }
2979
2980 unit->RemoveCharmAuras();
2981 return true;
2982 }
void RemoveCharmAuras()
Definition: Unit.cpp:11197

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
1414 {
1415 // No args required for players
1416 if (handler->GetSession() && AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity()))
1417 {
1418 if (Player* player = handler->GetSession()->GetPlayer())
1419 {
1420 player->CastSpell(player, SPELL_STUCK, false);
1421 }
1422
1423 return true;
1424 }
1425
1426 if (!target)
1427 {
1428 target = PlayerIdentifier::FromTargetOrSelf(handler);
1429 }
1430
1431 if (!target || !target->IsConnected())
1432 {
1433 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
1434 return false;
1435
1437 stmt->SetData(0, target->GetGUID().GetCounter());
1438
1439 PreparedQueryResult result = CharacterDatabase.Query(stmt);
1440
1441 if (result)
1442 {
1443 Field* fieldsDB = result->Fetch();
1444 WorldLocation loc(fieldsDB[0].Get<uint16>(), fieldsDB[2].Get<float>(), fieldsDB[3].Get<float>(), fieldsDB[4].Get<float>(), 0.0f);
1445 uint32 zoneId = fieldsDB[1].Get<uint16>();
1446
1447 Player::SavePositionInDB(loc, zoneId, target->GetGUID(), nullptr);
1448
1449 handler->PSendSysMessage(LANG_SUMMONING, target->GetName(), handler->GetAcoreString(LANG_OFFLINE));
1450 }
1451
1452 return true;
1453 }
1454
1455 Player* player = target->GetConnectedPlayer();
1456
1457 if (player->IsInFlight() || player->IsInCombat())
1458 {
1459 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(7355);
1460 if (!spellInfo)
1461 {
1462 return false;
1463 }
1464
1465 if (Player* caster = handler->GetSession()->GetPlayer())
1466 {
1468 }
1469
1470 return false;
1471 }
1472
1473 if (location->empty() || *location == "inn")
1474 {
1475 player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
1476 return true;
1477 }
1478
1479 if (*location == "graveyard")
1480 {
1481 player->RepopAtGraveyard();
1482 return true;
1483 }
1484
1485 if (*location == "startzone")
1486 {
1487 player->TeleportTo(player->GetStartPosition());
1488 return true;
1489 }
1490
1491 //Not a supported argument
1492 return false;
1493 }
constexpr auto SPELL_STUCK
Definition: cs_misc.cpp:55
@ SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW
Definition: SharedDefines.h:1122
@ CHAR_SEL_CHARACTER_HOMEBIND
Definition: CharacterDatabase.h:87
Definition: Position.h:250
float m_homebindZ
Definition: Player.h:2356
uint32 m_homebindMapId
Definition: Player.h:2352
void RepopAtGraveyard()
Definition: Player.cpp:4915
float m_homebindY
Definition: Player.h:2355
WorldLocation GetStartPosition() const
Definition: Player.cpp:11410
float m_homebindX
Definition: Player.h:2354
bool IsInCombat() const
Definition: Unit.h:884
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition: Spell.cpp:4674

References CHAR_SEL_CHARACTER_HOMEBIND, CharacterDatabase, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), Field::Get(), ChatHandler::GetAcoreString(), Position::GetOrientation(), WorldSession::GetPlayer(), WorldSession::GetSecurity(), ChatHandler::GetSession(), Player::GetStartPosition(), ChatHandler::HasLowerSecurity(), Unit::IsInCombat(), Unit::IsInFlight(), AccountMgr::IsPlayerAccount(), LANG_OFFLINE, LANG_SUMMONING, Player::m_homebindMapId, Player::m_homebindX, Player::m_homebindY, Player::m_homebindZ, ChatHandler::PSendSysMessage(), Player::RepopAtGraveyard(), Player::SavePositionInDB(), Spell::SendCastResult(), PreparedStatementBase::SetData(), SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW, SPELL_STUCK, sSpellMgr, and Player::TeleportTo().

Referenced by GetCommands().