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

Public Member Functions

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

Static Public Member Functions

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

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ misc_commandscript()

misc_commandscript::misc_commandscript ( )
inline
85: CommandScript("misc_commandscript") { }
Definition: ScriptMgr.h:850

Member Function Documentation

◆ GetCommands()

ChatCommandTable misc_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

88 {
89 static ChatCommandTable commandTable =
90 {
91 { "dev", HandleDevCommand, SEC_ADMINISTRATOR, Console::No },
92 { "gps", HandleGPSCommand, SEC_MODERATOR, Console::No },
93 { "aura", HandleAuraCommand, SEC_GAMEMASTER, Console::No },
94 { "unaura", HandleUnAuraCommand, SEC_GAMEMASTER, Console::No },
95 { "appear", HandleAppearCommand, SEC_MODERATOR, Console::No },
96 { "summon", HandleSummonCommand, SEC_GAMEMASTER, Console::No },
97 { "groupsummon", HandleGroupSummonCommand, SEC_GAMEMASTER, Console::No },
98 { "commands", HandleCommandsCommand, SEC_PLAYER, Console::Yes },
99 { "die", HandleDieCommand, SEC_GAMEMASTER, Console::No },
100 { "revive", HandleReviveCommand, SEC_GAMEMASTER, Console::Yes },
101 { "dismount", HandleDismountCommand, SEC_PLAYER, Console::No },
102 { "guid", HandleGUIDCommand, SEC_GAMEMASTER, Console::No },
103 { "help", HandleHelpCommand, SEC_PLAYER, Console::Yes },
104 { "cooldown", HandleCooldownCommand, SEC_GAMEMASTER, Console::No },
105 { "distance", HandleGetDistanceCommand, SEC_ADMINISTRATOR, Console::No },
106 { "recall", HandleRecallCommand, SEC_GAMEMASTER, Console::No },
107 { "save", HandleSaveCommand, SEC_PLAYER, Console::No },
108 { "saveall", HandleSaveAllCommand, SEC_GAMEMASTER, Console::Yes },
109 { "kick", HandleKickPlayerCommand, SEC_GAMEMASTER, Console::Yes },
110 { "unstuck", HandleUnstuckCommand, SEC_GAMEMASTER, Console::Yes },
111 { "linkgrave", HandleLinkGraveCommand, SEC_ADMINISTRATOR, Console::No },
112 { "neargrave", HandleNearGraveCommand, SEC_GAMEMASTER, Console::No },
113 { "showarea", HandleShowAreaCommand, SEC_GAMEMASTER, Console::No },
114 { "hidearea", HandleHideAreaCommand, SEC_ADMINISTRATOR, Console::No },
115 { "additem", HandleAddItemCommand, SEC_GAMEMASTER, Console::No },
116 { "additem set", HandleAddItemSetCommand, SEC_GAMEMASTER, Console::No },
117 { "wchange", HandleChangeWeather, SEC_ADMINISTRATOR, Console::No },
118 { "maxskill", HandleMaxSkillCommand, SEC_GAMEMASTER, Console::No },
119 { "setskill", HandleSetSkillCommand, SEC_GAMEMASTER, Console::No },
120 { "pinfo", HandlePInfoCommand, SEC_GAMEMASTER, Console::Yes },
121 { "respawn", HandleRespawnCommand, SEC_GAMEMASTER, Console::No },
122 { "respawn all", HandleRespawnAllCommand, SEC_GAMEMASTER, Console::No },
123 { "mute", HandleMuteCommand, SEC_GAMEMASTER, Console::Yes },
124 { "mutehistory", HandleMuteInfoCommand, SEC_GAMEMASTER, Console::Yes },
125 { "unmute", HandleUnmuteCommand, SEC_GAMEMASTER, Console::Yes },
126 { "movegens", HandleMovegensCommand, SEC_ADMINISTRATOR, Console::No },
127 { "cometome", HandleComeToMeCommand, SEC_ADMINISTRATOR, Console::No },
128 { "damage", HandleDamageCommand, SEC_GAMEMASTER, Console::No },
129 { "combatstop", HandleCombatStopCommand, SEC_GAMEMASTER, Console::Yes },
130 { "flusharenapoints", HandleFlushArenaPointsCommand, SEC_ADMINISTRATOR, Console::No },
131 { "freeze", HandleFreezeCommand, SEC_GAMEMASTER, Console::No },
132 { "unfreeze", HandleUnFreezeCommand, SEC_GAMEMASTER, Console::No },
133 { "possess", HandlePossessCommand, SEC_GAMEMASTER, Console::No },
134 { "unpossess", HandleUnPossessCommand, SEC_GAMEMASTER, Console::No },
135 { "bindsight", HandleBindSightCommand, SEC_ADMINISTRATOR, Console::No },
136 { "unbindsight", HandleUnbindSightCommand, SEC_ADMINISTRATOR, Console::No },
137 { "playall", HandlePlayAllCommand, SEC_GAMEMASTER, Console::No },
138 { "skirmish", HandleSkirmishCommand, SEC_ADMINISTRATOR, Console::No },
139 { "mailbox", HandleMailBoxCommand, SEC_MODERATOR, Console::No },
140 { "string", HandleStringCommand, SEC_GAMEMASTER, Console::No }
141 };
142
143 return commandTable;
144 }
@ SEC_PLAYER
Definition: Common.h:66
@ SEC_ADMINISTRATOR
Definition: Common.h:69
@ SEC_GAMEMASTER
Definition: Common.h:68
@ SEC_MODERATOR
Definition: Common.h:67
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:50
static bool HandleDevCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition: cs_misc.cpp:454
static bool HandleDamageCommand(ChatHandler *handler, uint32 damage)
Definition: cs_misc.cpp:2758
static bool HandleSaveCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1273
static bool HandleLinkGraveCommand(ChatHandler *handler, uint32 graveyardId, Optional< std::string_view > team)
Definition: cs_misc.cpp:1422
static bool HandlePlayAllCommand(ChatHandler *handler, uint32 soundId)
Definition: cs_misc.cpp:2922
static bool HandleAuraCommand(ChatHandler *handler, SpellInfo const *spell)
Definition: cs_misc.cpp:594
static bool HandleUnstuckCommand(ChatHandler *handler, Optional< PlayerIdentifier > target, Optional< std::string_view > location)
Definition: cs_misc.cpp:1359
static bool HandleRespawnAllCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2361
static bool HandleSkirmishCommand(ChatHandler *handler, std::vector< std::string_view > args)
Definition: cs_misc.cpp:146
static bool HandleUnbindSightCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2973
static bool HandleShowAreaCommand(ChatHandler *handler, uint32 areaID)
Definition: cs_misc.cpp:1553
static bool HandleStringCommand(ChatHandler *handler, uint32 id, Optional< uint8 > locale)
Definition: cs_misc.cpp:2993
static bool HandleChangeWeather(ChatHandler *handler, uint32 type, float grade)
Definition: cs_misc.cpp:1794
static bool HandlePInfoCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1888
static bool HandleSummonCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:813
static bool HandleCooldownCommand(ChatHandler *handler, Optional< SpellInfo const * > spell)
Definition: cs_misc.cpp:1175
static bool HandleReviveCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1093
static bool HandleCommandsCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1049
static bool HandleMailBoxCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2986
static bool HandleDieCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1055
static bool HandleAppearCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:660
static bool HandleHelpCommand(ChatHandler *handler, Tail cmd)
Definition: cs_misc.cpp:1163
static bool HandleRespawnCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2335
static bool HandleNearGraveCommand(ChatHandler *handler, Optional< std::string_view > team)
Definition: cs_misc.cpp:1475
static bool HandleMovegensCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2606
static bool HandleGUIDCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1148
static bool HandleAddItemSetCommand(ChatHandler *handler, Variant< Hyperlink< itemset >, uint32 > itemSetId)
Definition: cs_misc.cpp:1731
static bool HandleSaveAllCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1304
static bool HandleGPSCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:503
static bool HandleKickPlayerCommand(ChatHandler *handler, Optional< PlayerIdentifier > target, Optional< std::string_view > reason)
Definition: cs_misc.cpp:1312
static bool HandleHideAreaCommand(ChatHandler *handler, uint32 areaID)
Definition: cs_misc.cpp:1587
static bool HandleSetSkillCommand(ChatHandler *handler, Variant< Hyperlink< skill >, uint32 > skillId, int32 level, Optional< uint16 > maxPureSkill)
Definition: cs_misc.cpp:1841
static bool HandleUnmuteCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2504
static bool HandleRecallCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1235
static bool HandleBindSightCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2961
static bool HandleComeToMeCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2741
static bool HandleUnPossessCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2949
static bool HandleDismountCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1122
static bool HandleGroupSummonCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:940
static bool HandleCombatStopCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2801
static bool HandleUnAuraCommand(ChatHandler *handler, Variant< SpellInfo const *, std::string_view > spells)
Definition: cs_misc.cpp:623
static bool HandleGetDistanceCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:1207
static bool HandleMaxSkillCommand(ChatHandler *handler)
Definition: cs_misc.cpp:1826
static bool HandleFlushArenaPointsCommand(ChatHandler *)
Definition: cs_misc.cpp:2828
static bool HandleFreezeCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2834
static bool HandleMuteInfoCommand(ChatHandler *handler, std::string accountName)
Definition: cs_misc.cpp:2564
static bool HandleUnFreezeCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_misc.cpp:2879
static bool HandleAddItemCommand(ChatHandler *handler, ItemTemplate const *itemTemplate, Optional< int32 > _count)
Definition: cs_misc.cpp:1621
static bool HandleMuteCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, std::string notSpeakTime, Tail muteReason)
Definition: cs_misc.cpp:2377
static bool HandlePossessCommand(ChatHandler *handler)
Definition: cs_misc.cpp:2937

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

References Player::CanStoreNewItem(), Player::DestroyItemCount(), EQUIP_ERR_OK, Player::GetItemByPos(), ChatHandler::GetNameLink(), WorldSession::GetPlayer(), WorldSession::GetSecurity(), ChatHandler::getSelectedPlayer(), 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, Player::SendNewItem(), Item::SetBinding(), ChatHandler::SetSentErrorMessage(), sObjectMgr, and Player::StoreNewItem().

Referenced by GetCommands().

◆ HandleAddItemSetCommand()

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

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(), Player::SendNewItem(), Item::SetBinding(), ChatHandler::SetSentErrorMessage(), sObjectMgr, and Player::StoreNewItem().

Referenced by GetCommands().

◆ HandleAppearCommand()

static bool misc_commandscript::HandleAppearCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
661 {
662 if (!target)
663 {
664 target = PlayerIdentifier::FromTarget(handler);
665 }
666
667 if (!target)
668 {
669 return false;
670 }
671
672 Player* _player = handler->GetSession()->GetPlayer();
673 if (target->GetGUID() == _player->GetGUID())
674 {
676 handler->SetSentErrorMessage(true);
677 return false;
678 }
679
680 std::string nameLink = handler->playerLink(target->GetName());
681
682 if (target->IsConnected())
683 {
684 auto targetPlayer = target->GetConnectedPlayer();
685
686 // check online security
687 if (handler->HasLowerSecurity(targetPlayer))
688 {
689 return false;
690 }
691
692 Map* map = targetPlayer->GetMap();
693 if (map->IsBattlegroundOrArena())
694 {
695 // only allow if gm mode is on
696 if (!_player->IsGameMaster())
697 {
698 handler->PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str());
699 handler->SetSentErrorMessage(true);
700 return false;
701 }
702
703 if (!_player->GetMap()->IsBattlegroundOrArena())
704 {
705 _player->SetEntryPoint();
706 }
707
708 _player->SetBattlegroundId(targetPlayer->GetBattlegroundId(), targetPlayer->GetBattlegroundTypeId(), PLAYER_MAX_BATTLEGROUND_QUEUES, false, false, TEAM_NEUTRAL);
709 }
710 else if (map->IsDungeon())
711 {
712 // we have to go to instance, and can go to player only if:
713 // 1) we are in his group (either as leader or as member)
714 // 2) we are not bound to any group and have GM mode on
715 if (_player->GetGroup())
716 {
717 // we are in group, we can go only if we are in the player group
718 if (_player->GetGroup() != targetPlayer->GetGroup())
719 {
720 handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY, nameLink.c_str());
721 handler->SetSentErrorMessage(true);
722 return false;
723 }
724 }
725 else
726 {
727 // we are not in group, let's verify our GM mode
728 if (!_player->IsGameMaster())
729 {
730 handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM, nameLink.c_str());
731 handler->SetSentErrorMessage(true);
732 return false;
733 }
734 }
735
736 // if the GM is bound to another instance, he will not be bound to another one
737 InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(_player->GetGUID(), targetPlayer->GetMapId(), targetPlayer->GetDifficulty(map->IsRaid()));
738 if (!bind)
739 {
740 if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetConnectedPlayer()->GetInstanceId()))
741 {
742 sInstanceSaveMgr->PlayerBindToInstance(_player->GetGUID(), save, !save->CanReset(), _player);
743 }
744 }
745
746 if (map->IsRaid())
747 {
748 _player->SetRaidDifficulty(targetPlayer->GetRaidDifficulty());
749 }
750 else
751 {
752 _player->SetDungeonDifficulty(targetPlayer->GetDungeonDifficulty());
753 }
754 }
755
756 handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
757
758 // stop flight if need
759 if (_player->IsInFlight())
760 {
761 _player->GetMotionMaster()->MovementExpired();
762 _player->CleanupAfterTaxiFlight();
763 }
764 else // save only in non-flight case
765 {
766 _player->SaveRecallPosition();
767 }
768
769 if (_player->TeleportTo(targetPlayer->GetMapId(), targetPlayer->GetPositionX(), targetPlayer->GetPositionY(), targetPlayer->GetPositionZ() + 0.25f, _player->GetOrientation(), TELE_TO_GM_MODE, targetPlayer))
770 {
771 _player->SetPhaseMask(targetPlayer->GetPhaseMask() | 1, false);
772 }
773 }
774 else
775 {
776 // check offline security
777 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
778 {
779 return false;
780 }
781
782 handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
783
784 // to point where player stay (if loaded)
785 float x, y, z, o;
786 uint32 map;
787 bool in_flight;
788
789 if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, target->GetGUID().GetCounter()))
790 {
791 return false;
792 }
793
794 // stop flight if need
795 if (_player->IsInFlight())
796 {
797 _player->GetMotionMaster()->MovementExpired();
798 _player->CleanupAfterTaxiFlight();
799 }
800 // save only in non-flight case
801 else
802 {
803 _player->SaveRecallPosition();
804 }
805
806 _player->TeleportTo(map, x, y, z, _player->GetOrientation());
807 }
808
809 return true;
810 }
@ TELE_TO_GM_MODE
Definition: Player.h:814
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
@ LANG_CANNOT_GO_TO_INST_PARTY
Definition: Language.h:136
@ LANG_CANT_TELEPORT_SELF
Definition: Language.h:211
@ LANG_APPEARING_AT
Definition: Language.h:145
@ LANG_CANNOT_GO_TO_INST_GM
Definition: Language.h:137
@ LANG_CANNOT_GO_TO_BG_GM
Definition: Language.h:686
@ TEAM_NEUTRAL
Definition: SharedDefines.h:734
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:148
std::string playerLink(std::string const &name) const
Definition: Chat.h:111
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:53
static Optional< PlayerIdentifier > FromTarget(ChatHandler *handler)
Definition: ChatCommandTags.cpp:138
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
Map * GetMap() const
Definition: Object.h:517
float GetOrientation() const
Definition: Position.h:120
void SetDungeonDifficulty(Difficulty dungeon_difficulty)
Definition: Player.h:1874
void SetEntryPoint()
Definition: Player.cpp:11179
void SetRaidDifficulty(Difficulty raid_difficulty)
Definition: Player.h:1875
void SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
Definition: Player.cpp:12207
void SaveRecallPosition()
Definition: Player.cpp:5564
Group * GetGroup()
Definition: Player.h:2418
bool IsGameMaster() const
Definition: Player.h:1136
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1311
static bool LoadPositionFromDB(uint32 &mapid, float &x, float &y, float &z, float &o, bool &in_flight, ObjectGuid::LowType guid)
Definition: PlayerStorage.cpp:4901
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10325
MotionMaster * GetMotionMaster()
Definition: Unit.h:2262
bool IsInFlight() const
Definition: Unit.h:1676
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:19217
Definition: InstanceSaveMgr.h:39
Definition: InstanceSaveMgr.h:56
Definition: Map.h:312
bool IsDungeon() const
Definition: Map.h:447
bool IsBattlegroundOrArena() const
Definition: Map.h:455
bool IsRaid() const
Definition: Map.h:449
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178

References Player::CleanupAfterTaxiFlight(), Acore::ChatCommands::PlayerIdentifier::FromTarget(), Player::GetGroup(), Object::GetGUID(), WorldObject::GetMap(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), ChatHandler::HasLowerSecurity(), Map::IsBattlegroundOrArena(), Map::IsDungeon(), Player::IsGameMaster(), Unit::IsInFlight(), Map::IsRaid(), LANG_APPEARING_AT, LANG_CANNOT_GO_TO_BG_GM, LANG_CANNOT_GO_TO_INST_GM, LANG_CANNOT_GO_TO_INST_PARTY, LANG_CANT_TELEPORT_SELF, Player::LoadPositionFromDB(), MotionMaster::MovementExpired(), PLAYER_MAX_BATTLEGROUND_QUEUES, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), Player::SaveRecallPosition(), ChatHandler::SendSysMessage(), Player::SetBattlegroundId(), Player::SetDungeonDifficulty(), Player::SetEntryPoint(), Unit::SetPhaseMask(), Player::SetRaidDifficulty(), ChatHandler::SetSentErrorMessage(), 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
595 {
596 if (!spell)
597 {
599 handler->SetSentErrorMessage(true);
600 return false;
601 }
602
603 if (!SpellMgr::IsSpellValid(spell))
604 {
605 handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
606 handler->SetSentErrorMessage(true);
607 return false;
608 }
609
610 Unit* target = handler->getSelectedUnit();
611 if (!target)
612 {
614 handler->SetSentErrorMessage(true);
615 return false;
616 }
617
618 Aura::TryRefreshStackOrCreate(spell, MAX_EFFECT_MASK, target, target);
619
620 return true;
621 }
@ LANG_COMMAND_NOSPELLFOUND
Definition: Language.h:460
@ LANG_SELECT_CHAR_OR_CREATURE
Definition: Language.h:31
@ LANG_COMMAND_SPELL_BROKEN
Definition: Language.h:503
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1611
Unit * getSelectedUnit() const
Definition: Chat.cpp:313
Definition: Unit.h:1290
static Aura * TryRefreshStackOrCreate(SpellInfo const *spellproto, uint8 tryEffMask, WorldObject *owner, Unit *caster, int32 *baseAmount=nullptr, Item *castItem=nullptr, ObjectGuid casterGUID=ObjectGuid::Empty, bool *refresh=nullptr, bool periodicReset=false)
Definition: SpellAuras.cpp:326
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition: SpellMgr.cpp:442

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

Referenced by GetCommands().

◆ HandleBindSightCommand()

static bool misc_commandscript::HandleBindSightCommand ( ChatHandler handler)
inlinestatic
2962 {
2963 Unit* unit = handler->getSelectedUnit();
2964 if (!unit)
2965 {
2966 return false;
2967 }
2968
2969 handler->GetSession()->GetPlayer()->CastSpell(unit, 6277, true);
2970 return true;
2971 }
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169

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

Referenced by GetCommands().

◆ HandleChangeWeather()

static bool misc_commandscript::HandleChangeWeather ( ChatHandler handler,
uint32  type,
float  grade 
)
inlinestatic
1795 {
1796 // Weather is OFF
1797 if (!sWorld->getBoolConfig(CONFIG_WEATHER))
1798 {
1800 handler->SetSentErrorMessage(true);
1801 return false;
1802 }
1803
1804 Player* player = handler->GetSession()->GetPlayer();
1805 uint32 zoneid = player->GetZoneId();
1806
1807 Weather* weather = WeatherMgr::FindWeather(zoneid);
1808
1809 if (!weather)
1810 {
1811 weather = WeatherMgr::AddWeather(zoneid);
1812 }
1813
1814 if (!weather)
1815 {
1817 handler->SetSentErrorMessage(true);
1818 return false;
1819 }
1820
1821 weather->SetWeather(WeatherType(type), grade);
1822
1823 return true;
1824 }
@ LANG_NO_WEATHER
Definition: Language.h:415
@ LANG_WEATHER_DISABLED
Definition: Language.h:416
@ CONFIG_WEATHER
Definition: IWorld.h:98
WeatherType
Definition: SharedDefines.h:3109
#define sWorld
Definition: World.h:451
Weather * AddWeather(uint32 zone_id)
Add a Weather object to the list.
Definition: WeatherMgr.cpp:68
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:51
uint32 GetZoneId() const
Definition: Object.cpp:3075
Weather for one zone.
Definition: Weather.h:65

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

Referenced by GetCommands().

◆ HandleCombatStopCommand()

static bool misc_commandscript::HandleCombatStopCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
2802 {
2803 if (!target)
2804 {
2805 target = PlayerIdentifier::FromTargetOrSelf(handler);
2806 }
2807
2808 if (!target || !target->IsConnected())
2809 {
2811 handler->SetSentErrorMessage(true);
2812 return false;
2813 }
2814
2815 Player* playerTarget = target->GetConnectedPlayer();
2816
2817 // check online security
2818 if (handler->HasLowerSecurity(playerTarget))
2819 {
2820 return false;
2821 }
2822
2823 playerTarget->CombatStop();
2824 playerTarget->getHostileRefMgr().deleteReferences();
2825 return true;
2826 }
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:522
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:189
void deleteReferences(bool removeFromMap=false)
Definition: HostileRefMgr.cpp:125
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10401
HostileRefMgr & getHostileRefMgr()
Definition: Unit.h:2149

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

Referenced by GetCommands().

◆ HandleComeToMeCommand()

static bool misc_commandscript::HandleComeToMeCommand ( ChatHandler handler)
inlinestatic
2742 {
2743 Creature* caster = handler->getSelectedCreature();
2744 if (!caster)
2745 {
2747 handler->SetSentErrorMessage(true);
2748 return false;
2749 }
2750
2751 Player* player = handler->GetSession()->GetPlayer();
2752
2753 caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
2754
2755 return true;
2756 }
@ LANG_SELECT_CREATURE
Definition: Language.h:32
Creature * getSelectedCreature() const
Definition: Chat.cpp:337
Definition: Creature.h:46
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
void MovePoint(uint32 id, const Position &pos, bool generatePath=true, bool forceDestination=true)
Definition: MotionMaster.h:210

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

Referenced by GetCommands().

◆ HandleCommandsCommand()

static bool misc_commandscript::HandleCommandsCommand ( ChatHandler handler)
inlinestatic
1050 {
1051 SendCommandHelpFor(*handler, "");
1052 return true;
1053 }
AC_GAME_API void SendCommandHelpFor(ChatHandler &handler, std::string_view cmd)
Definition: ChatCommand.cpp:536

References Acore::ChatCommands::SendCommandHelpFor().

Referenced by GetCommands().

◆ HandleCooldownCommand()

static bool misc_commandscript::HandleCooldownCommand ( ChatHandler handler,
Optional< SpellInfo const * >  spell 
)
inlinestatic
1176 {
1177 Player* target = handler->getSelectedPlayer();
1178 if (!target)
1179 {
1181 handler->SetSentErrorMessage(true);
1182 return false;
1183 }
1184
1185 std::string nameLink = handler->GetNameLink(target);
1186
1187 if (!spell)
1188 {
1189 target->RemoveAllSpellCooldown();
1190 handler->PSendSysMessage(LANG_REMOVEALL_COOLDOWN, nameLink.c_str());
1191 }
1192 else
1193 {
1194 if (!SpellMgr::IsSpellValid(*spell))
1195 {
1196 handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell.value()->Id);
1197 handler->SetSentErrorMessage(true);
1198 return false;
1199 }
1200
1201 target->RemoveSpellCooldown(spell.value()->Id, true);
1202 handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spell.value()->Id, target == handler->GetSession()->GetPlayer() ? handler->GetAcoreString(LANG_YOU) : nameLink.c_str());
1203 }
1204 return true;
1205 }
@ LANG_YOU
Definition: Language.h:76
@ LANG_REMOVE_COOLDOWN
Definition: Language.h:515
@ LANG_REMOVEALL_COOLDOWN
Definition: Language.h:514
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:42
void RemoveAllSpellCooldown()
Definition: Player.cpp:3513
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition: Player.cpp:3462

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(), ChatHandler::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleDamageCommand()

static bool misc_commandscript::HandleDamageCommand ( ChatHandler handler,
uint32  damage 
)
inlinestatic
2759 {
2760 Unit* target = handler->getSelectedUnit();
2761 if (!target || !handler->GetSession()->GetPlayer()->GetTarget())
2762 {
2764 handler->SetSentErrorMessage(true);
2765 return false;
2766 }
2767
2768 if (target->GetTypeId() == TYPEID_PLAYER)
2769 {
2770 if (handler->HasLowerSecurity(target->ToPlayer()))
2771 {
2772 return false;
2773 }
2774 }
2775
2776 if (!target->IsAlive())
2777 {
2778 return true;
2779 }
2780
2781 if (!damage)
2782 {
2783 return true;
2784 }
2785
2786 if (target->GetTypeId() == TYPEID_UNIT && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard
2787 {
2788 target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth());
2789 }
2790
2791 Unit::DealDamage(handler->GetSession()->GetPlayer(), target, damage, nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false, true);
2792
2793 if (target != handler->GetSession()->GetPlayer())
2794 {
2796 }
2797
2798 return true;
2799 }
@ SEC_CONSOLE
Definition: Common.h:70
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ VICTIMSTATE_HIT
Definition: Unit.h:167
@ HITINFO_AFFECTS_VICTIM
Definition: Unit.h:181
@ DIRECT_DAMAGE
Definition: Unit.h:435
@ SPELL_SCHOOL_MASK_NORMAL
Definition: SharedDefines.h:269
void LowerPlayerDamageReq(uint32 unDamage, bool damagedByPlayer=true)
Definition: Creature.cpp:3689
Player * ToPlayer()
Definition: Object.h:195
TypeID GetTypeId() const
Definition: Object.h:121
Creature * ToCreature()
Definition: Object.h:197
void SendAttackStateUpdate(CalcDamageInfo *damageInfo)
Definition: Unit.cpp:6391
uint32 GetMaxHealth() const
Definition: Unit.h:1441
bool IsAlive() const
Definition: Unit.h:1808
ObjectGuid GetTarget() const
Definition: Unit.h:2433
static uint32 DealDamage(Unit *attacker, Unit *victim, uint32 damage, CleanDamage const *cleanDamage=nullptr, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=nullptr, bool durabilityLoss=true, bool allowGM=false, Spell const *spell=nullptr)
Definition: Unit.cpp:815

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

Referenced by GetCommands().

◆ HandleDevCommand()

static bool misc_commandscript::HandleDevCommand ( ChatHandler handler,
Optional< bool >  enableArg 
)
inlinestatic
455 {
456 WorldSession* session = handler->GetSession();
457
458 if (!session)
459 {
460 return false;
461 }
462
463 auto SetDevMod = [&](bool enable)
464 {
465 session->SendNotification(enable ? LANG_DEV_ON : LANG_DEV_OFF);
466 session->GetPlayer()->SetDeveloper(enable);
467 sScriptMgr->OnHandleDevCommand(handler->GetSession()->GetPlayer(), enable);
468 };
469
470 if (WorldSession* session = handler->GetSession())
471 {
472 if (!enableArg)
473 {
474 if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->IsDeveloper())
475 {
476 SetDevMod(true);
477 }
478 else
479 {
480 SetDevMod(false);
481 }
482
483 return true;
484 }
485
486 if (*enableArg)
487 {
488 SetDevMod(true);
489 return true;
490 }
491 else
492 {
493 SetDevMod(false);
494 return true;
495 }
496 }
497
499 handler->SetSentErrorMessage(true);
500 return false;
501 }
@ LANG_DEV_ON
Definition: Language.h:899
@ LANG_DEV_OFF
Definition: Language.h:900
@ LANG_USE_BOL
Definition: Language.h:303
#define sScriptMgr
Definition: ScriptMgr.h:2702
bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:276
void SetDeveloper(bool on)
Definition: Player.h:1133
bool IsDeveloper() const
Definition: Player.h:1132
Player session in the World.
Definition: WorldSession.h:330
void SendNotification(const char *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:787

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

Referenced by GetCommands().

◆ HandleDieCommand()

static bool misc_commandscript::HandleDieCommand ( ChatHandler handler)
inlinestatic
1056 {
1057 Unit* target = handler->getSelectedUnit();
1058
1059 if (!target || !handler->GetSession()->GetPlayer()->GetTarget())
1060 {
1062 handler->SetSentErrorMessage(true);
1063 return false;
1064 }
1065
1066 if (target->GetTypeId() == TYPEID_PLAYER)
1067 {
1068 if (handler->HasLowerSecurity(target->ToPlayer()))
1069 {
1070 return false;
1071 }
1072 }
1073
1074 if (target->IsAlive())
1075 {
1076 if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE))
1077 {
1078 if (target->GetTypeId() == TYPEID_UNIT && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard
1079 {
1080 target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth());
1081 }
1082 Unit::Kill(handler->GetSession()->GetPlayer(), target);
1083 }
1084 else
1085 {
1086 Unit::DealDamage(handler->GetSession()->GetPlayer(), target, target->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false, true);
1087 }
1088 }
1089
1090 return true;
1091 }
@ CONFIG_DIE_COMMAND_MODE
Definition: IWorld.h:111
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:17862
uint32 GetHealth() const
Definition: Unit.h:1440

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

Referenced by GetCommands().

◆ HandleDismountCommand()

static bool misc_commandscript::HandleDismountCommand ( ChatHandler handler)
inlinestatic
1123 {
1124 Player* player = handler->GetSession()->GetPlayer();
1125
1126 // If player is not mounted, so go out :)
1127 if (!player->IsMounted())
1128 {
1130 handler->SetSentErrorMessage(true);
1131 return false;
1132 }
1133
1134 if (player->IsInFlight())
1135 {
1137 handler->SetSentErrorMessage(true);
1138 return false;
1139 }
1140
1141 player->Dismount();
1143 player->SetSpeed(MOVE_RUN, 1, true);
1144 player->SetSpeed(MOVE_FLIGHT, 1, true);
1145 return true;
1146 }
@ MOVE_FLIGHT
Definition: Unit.h:384
@ MOVE_RUN
Definition: Unit.h:379
@ LANG_CHAR_NON_MOUNTED
Definition: Language.h:54
@ LANG_YOU_IN_FLIGHT
Definition: Language.h:50
@ SPELL_AURA_MOUNTED
Definition: SpellAuraDefines.h:141
void Dismount()
Definition: Unit.cpp:13435
bool IsMounted() const
Definition: Unit.h:1542
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:14323
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
Definition: Unit.cpp:5025

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), Unit::SetSpeed(), and SPELL_AURA_MOUNTED.

Referenced by GetCommands().

◆ HandleFlushArenaPointsCommand()

static bool misc_commandscript::HandleFlushArenaPointsCommand ( ChatHandler )
inlinestatic
2829 {
2830 sArenaTeamMgr->DistributeArenaPoints();
2831 return true;
2832 }
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67

References sArenaTeamMgr.

Referenced by GetCommands().

◆ HandleFreezeCommand()

static bool misc_commandscript::HandleFreezeCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
2835 {
2836 Creature* creatureTarget = handler->getSelectedCreature();
2837
2838 if (!target && !creatureTarget)
2839 {
2840 target = PlayerIdentifier::FromTargetOrSelf(handler);
2841 }
2842
2843 if (!target && !creatureTarget)
2844 {
2846 handler->SetSentErrorMessage(true);
2847 return false;
2848 }
2849
2850 Player* playerTarget = target->GetConnectedPlayer();
2851 if (playerTarget && !creatureTarget)
2852 {
2853 handler->PSendSysMessage(LANG_COMMAND_FREEZE, target->GetName().c_str());
2854
2855 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_FREEZE))
2856 {
2857 Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, playerTarget, playerTarget);
2858 }
2859
2860 return true;
2861 }
2862 else if (creatureTarget && creatureTarget->IsAlive())
2863 {
2864 handler->PSendSysMessage(LANG_COMMAND_FREEZE, GetLocalizeCreatureName(creatureTarget, handler->GetSessionDbcLocale()).c_str());
2865
2866 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_FREEZE))
2867 {
2868 Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, creatureTarget, creatureTarget);
2869 }
2870
2871 return true;
2872 }
2873
2875 handler->SetSentErrorMessage(true);
2876 return false;
2877 }
@ LANG_COMMAND_FREEZE
Definition: Language.h:1053
#define sSpellMgr
Definition: SpellMgr.h:818
constexpr auto SPELL_FREEZE
Definition: cs_misc.cpp:54
std::string const GetLocalizeCreatureName(Creature *creature, LocaleConstant locale)
Definition: cs_misc.cpp:56
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:782
Definition: SpellInfo.h:314

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

Referenced by GetCommands().

◆ HandleGetDistanceCommand()

static bool misc_commandscript::HandleGetDistanceCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
1208 {
1209 if (!target)
1210 {
1211 target = PlayerIdentifier::FromTargetOrSelf(handler);
1212 }
1213
1214 WorldObject* object = handler->getSelectedUnit();
1215
1216 if (!object && !target)
1217 {
1218 return false;
1219 }
1220
1221 if (!object && target && target->IsConnected())
1222 {
1223 object = target->GetConnectedPlayer();
1224 }
1225
1226 if (!object)
1227 {
1228 return false;
1229 }
1230
1231 handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(object), handler->GetSession()->GetPlayer()->GetDistance2d(object), handler->GetSession()->GetPlayer()->GetExactDist(object), handler->GetSession()->GetPlayer()->GetExactDist2d(object));
1232 return true;
1233 }
@ LANG_DISTANCE
Definition: Language.h:527
Definition: Object.h:393
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1263
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:166
float GetExactDist(float x, float y, float z) const
Definition: Position.h:178

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

Referenced by GetCommands().

◆ HandleGPSCommand()

static bool misc_commandscript::HandleGPSCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
504 {
505 if (!target)
506 {
507 target = PlayerIdentifier::FromTargetOrSelf(handler);
508 }
509
510 WorldObject* object = handler->getSelectedUnit();
511
512 if (!object && !target)
513 {
514 return false;
515 }
516
517 if (!object && target && target->IsConnected())
518 {
519 object = target->GetConnectedPlayer();
520 }
521
522 if (!object)
523 {
524 return false;
525 }
526
527 Cell cell(Acore::ComputeCellCoord(object->GetPositionX(), object->GetPositionY()));
528
529 uint32 zoneId, areaId;
530 object->GetZoneAndAreaId(zoneId, areaId);
531
532 MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
533 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(zoneId);
534 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
535
536 float zoneX = object->GetPositionX();
537 float zoneY = object->GetPositionY();
538
539 Map2ZoneCoordinates(zoneX, zoneY, zoneId);
540
541 float groundZ = object->GetMapHeight(object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
542 float floorZ = object->GetMapHeight(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
543
544 GridCoord gridCoord = Acore::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
545
546 // 63? WHY?
547 int gridX = 63 - gridCoord.x_coord;
548 int gridY = 63 - gridCoord.y_coord;
549
550 uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
551 uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
553
554 if (haveVMap)
555 {
556 if (object->IsOutdoors())
557 {
558 handler->PSendSysMessage("You are outdoors");
559 }
560 else
561 {
562 handler->PSendSysMessage("You are indoors");
563 }
564 }
565 else
566 {
567 handler->PSendSysMessage("no VMAP available for area info");
568 }
569
571 object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
572 zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
573 areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
574 object->GetPhaseMask(),
575 object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
576 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
577 zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMAP);
578
579 LiquidData const& liquidData = object->GetLiquidData();
580
581 if (liquidData.Status)
582 {
583 handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidData.Level, liquidData.DepthLevel, liquidData.Entry, liquidData.Flags, liquidData.Status);
584 }
585
586 if (object->GetTransport())
587 {
588 handler->PSendSysMessage("Transport offset: %.2f, %.2f, %.2f, %.2f", object->m_movementInfo.transport.pos.GetPositionX(), object->m_movementInfo.transport.pos.GetPositionY(), object->m_movementInfo.transport.pos.GetPositionZ(), object->m_movementInfo.transport.pos.GetOrientation());
589 }
590
591 return true;
592 }
void Map2ZoneCoordinates(float &x, float &y, uint32 zone)
Definition: DBCStores.cpp:741
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define MAX_HEIGHT
Definition: Map.h:163
@ LANG_LIQUID_STATUS
Definition: Language.h:215
@ LANG_MAP_POSITION
Definition: Language.h:133
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:186
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:191
static MMapMgr * createOrGetMMapMgr()
Definition: MMapFactory.cpp:29
dtNavMesh const * GetNavMesh(uint32 mapId)
Definition: MMapMgr.cpp:306
struct MovementInfo::TransportInfo transport
Position pos
Definition: Object.h:285
uint32 GetPhaseMask() const
Definition: Object.h:434
uint32 GetInstanceId() const
Definition: Object.h:431
bool IsOutdoors() const
Definition: Object.cpp:3100
Transport * GetTransport() const
Definition: Object.h:585
MovementInfo m_movementInfo
Definition: Object.h:595
uint32 GetMapId() const
Definition: Position.h:276
Definition: Cell.h:46
Definition: GridDefines.h:86
uint32 x_coord
Definition: GridDefines.h:153
uint32 y_coord
Definition: GridDefines.h:154
Definition: Map.h:170
float Level
Definition: Map.h:175
uint32 Flags
Definition: Map.h:174
uint32 Entry
Definition: Map.h:173
LiquidStatus Status
Definition: Map.h:177
float DepthLevel
Definition: Map.h:176
static bool ExistVMap(uint32 mapid, int gx, int gy)
Definition: Map.cpp:118
static bool ExistMap(uint32 mapid, int gx, int gy)
Definition: Map.cpp:87
Definition: DBCStructure.h:519
char const * area_name[16]
Definition: DBCStructure.h:527
Definition: DBCStructure.h:1308
char const * name[16]
Definition: DBCStructure.h:1314

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
941 {
942 if (!target)
943 {
944 target = PlayerIdentifier::FromTargetOrSelf(handler);
945 }
946
947 if (!target || !target->IsConnected())
948 {
949 return false;
950 }
951
952 // check online security
953 if (handler->HasLowerSecurity(target->GetConnectedPlayer()))
954 {
955 return false;
956 }
957
958 auto targetPlayer = target->GetConnectedPlayer();
959
960 Group* group = targetPlayer->GetGroup();
961
962 std::string nameLink = handler->playerLink(target->GetName());
963
964 if (!group)
965 {
966 handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
967 handler->SetSentErrorMessage(true);
968 return false;
969 }
970
971 Map* gmMap = handler->GetSession()->GetPlayer()->GetMap();
972 bool toInstance = gmMap->Instanceable();
973
974 // we are in instance, and can summon only player in our group with us as lead
975 if (toInstance && (
976 !handler->GetSession()->GetPlayer()->GetGroup() || (group->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
977 (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID())))
978 // the last check is a bit excessive, but let it be, just in case
979 {
981 handler->SetSentErrorMessage(true);
982 return false;
983 }
984
985 for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
986 {
987 Player* player = itr->GetSource();
988
989 if (!player || player == handler->GetSession()->GetPlayer() || !player->GetSession())
990 {
991 continue;
992 }
993
994 // check online security
995 if (handler->HasLowerSecurity(player))
996 {
997 return false;
998 }
999
1000 std::string plNameLink = handler->GetNameLink(player);
1001
1002 if (player->IsBeingTeleported())
1003 {
1004 handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
1005 handler->SetSentErrorMessage(true);
1006 return false;
1007 }
1008
1009 if (toInstance)
1010 {
1011 Map* playerMap = player->GetMap();
1012
1013 if (playerMap->Instanceable() && playerMap->GetInstanceId() != gmMap->GetInstanceId())
1014 {
1015 // cannot summon from instance to instance
1016 handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink.c_str());
1017 handler->SetSentErrorMessage(true);
1018 return false;
1019 }
1020 }
1021
1022 handler->PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), "");
1023 if (handler->needReportToTarget(player))
1024 {
1025 ChatHandler(player->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str());
1026 }
1027
1028 // stop flight if need
1029 if (player->IsInFlight())
1030 {
1031 player->GetMotionMaster()->MovementExpired();
1032 player->CleanupAfterTaxiFlight();
1033 }
1034 // save only in non-flight case
1035 else
1036 {
1037 player->SaveRecallPosition();
1038 }
1039
1040 // before GM
1041 float x, y, z;
1042 handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize());
1043 player->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation(), 0, handler->GetSession()->GetPlayer());
1044 }
1045
1046 return true;
1047 }
@ LANG_SUMMONING
Definition: Language.h:140
@ LANG_NOT_IN_GROUP
Definition: Language.h:149
@ LANG_IS_TELEPORTED
Definition: Language.h:134
@ LANG_CANNOT_SUMMON_TO_INST
Definition: Language.h:135
@ LANG_SUMMONED_BY
Definition: Language.h:141
Definition: Chat.h:38
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:776
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:2662
float GetObjectSize() const
Definition: Object.cpp:2734
bool IsBeingTeleported() const
Definition: Player.h:2041
Definition: Group.h:168
GroupReference * GetFirstMember()
Definition: Group.h:242
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2235
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36
bool Instanceable() const
Definition: Map.h:446
uint32 GetInstanceId() const
Definition: Map.h:418

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and Player::TeleportTo().

Referenced by GetCommands().

◆ HandleGUIDCommand()

static bool misc_commandscript::HandleGUIDCommand ( ChatHandler handler)
inlinestatic
1149 {
1150 ObjectGuid guid = handler->GetSession()->GetPlayer()->GetTarget();
1151
1152 if (!guid)
1153 {
1155 handler->SetSentErrorMessage(true);
1156 return false;
1157 }
1158
1159 handler->PSendSysMessage(LANG_OBJECT_GUID, guid.ToString().c_str());
1160 return true;
1161 }
@ LANG_OBJECT_GUID
Definition: Language.h:238
@ LANG_NO_SELECTION
Definition: Language.h:237
Definition: ObjectGuid.h:120
std::string ToString() const
Definition: ObjectGuid.cpp:47

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

Referenced by GetCommands().

◆ HandleHelpCommand()

static bool misc_commandscript::HandleHelpCommand ( ChatHandler handler,
Tail  cmd 
)
inlinestatic
1164 {
1166
1167 if (cmd.empty())
1168 {
1170 }
1171
1172 return true;
1173 }

References Acore::ChatCommands::SendCommandHelpFor().

Referenced by GetCommands().

◆ HandleHideAreaCommand()

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

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

Referenced by GetCommands().

◆ HandleKickPlayerCommand()

static bool misc_commandscript::HandleKickPlayerCommand ( ChatHandler handler,
Optional< PlayerIdentifier target,
Optional< std::string_view >  reason 
)
inlinestatic
1313 {
1314 if (!target)
1315 {
1316 target = PlayerIdentifier::FromTargetOrSelf(handler);
1317 }
1318
1319 if (!target || !target->IsConnected())
1320 {
1321 return false;
1322 }
1323
1324 auto targetPlayer = target->GetConnectedPlayer();
1325
1326 if (handler->GetSession() && target->GetGUID() == handler->GetSession()->GetPlayer()->GetGUID())
1327 {
1329 handler->SetSentErrorMessage(true);
1330 return false;
1331 }
1332
1333 // check online security
1334 if (handler->HasLowerSecurity(targetPlayer))
1335 {
1336 return false;
1337 }
1338
1339 std::string kickReasonStr = handler->GetAcoreString(LANG_NO_REASON);
1340 if (reason && !reason->empty())
1341 {
1342 kickReasonStr = std::string{ *reason };
1343 }
1344
1345 if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
1346 {
1347 sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), target->GetName().c_str(), kickReasonStr.c_str());
1348 }
1349 else
1350 {
1351 handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, target->GetName().c_str());
1352 }
1353
1354 targetPlayer->GetSession()->KickPlayer("HandleKickPlayerCommand");
1355
1356 return true;
1357 }
@ LANG_COMMAND_KICKSELF
Definition: Language.h:326
@ LANG_COMMAND_KICKMESSAGE_WORLD
Definition: Language.h:1289
@ LANG_NO_REASON
Definition: Language.h:781
@ LANG_COMMAND_KICKMESSAGE
Definition: Language.h:327
@ CONFIG_SHOW_KICK_IN_WORLD
Definition: IWorld.h:135
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:179

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

Referenced by GetCommands().

◆ HandleLinkGraveCommand()

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

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

Referenced by GetCommands().

◆ HandleMailBoxCommand()

static bool misc_commandscript::HandleMailBoxCommand ( ChatHandler handler)
inlinestatic
2987 {
2988 Player* player = handler->GetSession()->GetPlayer();
2989 handler->GetSession()->SendShowMailBox(player->GetGUID());
2990 return true;
2991 }
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
1827 {
1828 Player* SelectedPlayer = handler->getSelectedPlayer();
1829 if (!SelectedPlayer)
1830 {
1832 handler->SetSentErrorMessage(true);
1833 return false;
1834 }
1835
1836 // each skills that have max skill value dependent from level seted to current level max skill value
1837 SelectedPlayer->UpdateSkillsToMaxSkillsForLevel();
1838 return true;
1839 }
void UpdateSkillsToMaxSkillsForLevel()
Definition: PlayerUpdates.cpp:1086

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

Referenced by GetCommands().

◆ HandleMovegensCommand()

static bool misc_commandscript::HandleMovegensCommand ( ChatHandler handler)
inlinestatic
2607 {
2608 Unit* unit = handler->getSelectedUnit();
2609 if (!unit)
2610 {
2612 handler->SetSentErrorMessage(true);
2613 return false;
2614 }
2615
2616 handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUID().GetCounter());
2617
2618 MotionMaster* motionMaster = unit->GetMotionMaster();
2619 float x, y, z;
2620 motionMaster->GetDestination(x, y, z);
2621
2622 for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
2623 {
2624 MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(i);
2625 if (!movementGenerator)
2626 {
2627 handler->SendSysMessage("Empty");
2628 continue;
2629 }
2630
2631 switch (movementGenerator->GetMovementGeneratorType())
2632 {
2633 case IDLE_MOTION_TYPE:
2635 break;
2636 case RANDOM_MOTION_TYPE:
2638 break;
2641 break;
2644 break;
2647 break;
2648 case CHASE_MOTION_TYPE:
2649 {
2650 Unit* target = nullptr;
2651 if (unit->GetTypeId() == TYPEID_PLAYER)
2652 {
2653 target = static_cast<ChaseMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
2654 }
2655 else
2656 {
2657 target = static_cast<ChaseMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
2658 }
2659
2660 if (!target)
2661 {
2663 }
2664 else if (target->GetTypeId() == TYPEID_PLAYER)
2665 {
2666 handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter());
2667 }
2668 else
2669 {
2670 handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter());
2671 }
2672 break;
2673 }
2674 case FOLLOW_MOTION_TYPE:
2675 {
2676 Unit* target = nullptr;
2677 if (unit->GetTypeId() == TYPEID_PLAYER)
2678 {
2679 target = static_cast<FollowMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
2680 }
2681 else
2682 {
2683 target = static_cast<FollowMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
2684 }
2685
2686 if (!target)
2687 {
2689 }
2690 else if (target->GetTypeId() == TYPEID_PLAYER)
2691 {
2692 handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter());
2693 }
2694 else
2695 {
2696 handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter());
2697 }
2698 break;
2699 }
2700 case HOME_MOTION_TYPE:
2701 {
2702 if (unit->GetTypeId() == TYPEID_UNIT)
2703 {
2705 }
2706 else
2707 {
2709 }
2710 break;
2711 }
2712 case FLIGHT_MOTION_TYPE:
2714 break;
2715 case POINT_MOTION_TYPE:
2716 {
2717 handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z);
2718 break;
2719 }
2722 break;
2725 break;
2726 case EFFECT_MOTION_TYPE:
2728 break;
2729 default:
2730 handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType());
2731 break;
2732 }
2733 }
2734 return true;
2735 }
std::uint8_t uint8
Definition: Define.h:110
@ LANG_MOVEGENS_FOLLOW_PLAYER
Definition: Language.h:901
@ LANG_MOVEGENS_EFFECT
Definition: Language.h:904
@ LANG_MOVEGENS_UNKNOWN
Definition: Language.h:567
@ LANG_MOVEGENS_CHASE_PLAYER
Definition: Language.h:561
@ LANG_MOVEGENS_IDLE
Definition: Language.h:556
@ LANG_MOVEGENS_CONFUSED
Definition: Language.h:560
@ LANG_MOVEGENS_FOLLOW_CREATURE
Definition: Language.h:902
@ LANG_MOVEGENS_FOLLOW_NULL
Definition: Language.h:903
@ LANG_MOVEGENS_DISTRACT
Definition: Language.h:635
@ LANG_MOVEGENS_CHASE_CREATURE
Definition: Language.h:562
@ LANG_MOVEGENS_RANDOM
Definition: Language.h:557
@ LANG_MOVEGENS_WAYPOINT
Definition: Language.h:558
@ LANG_MOVEGENS_POINT
Definition: Language.h:633
@ LANG_MOVEGENS_ANIMAL_RANDOM
Definition: Language.h:559
@ LANG_MOVEGENS_CHASE_NULL
Definition: Language.h:563
@ LANG_MOVEGENS_FLIGHT
Definition: Language.h:566
@ LANG_MOVEGENS_HOME_CREATURE
Definition: Language.h:564
@ LANG_MOVEGENS_HOME_PLAYER
Definition: Language.h:565
@ LANG_MOVEGENS_LIST
Definition: Language.h:555
@ LANG_MOVEGENS_FEAR
Definition: Language.h:634
@ MAX_MOTION_SLOT
Definition: MotionMaster.h:64
@ DISTRACT_MOTION_TYPE
Definition: MotionMaster.h:48
@ IDLE_MOTION_TYPE
Definition: MotionMaster.h:37
@ CHASE_MOTION_TYPE
Definition: MotionMaster.h:43
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:39
@ FLEEING_MOTION_TYPE
Definition: MotionMaster.h:47
@ CONFUSED_MOTION_TYPE
Definition: MotionMaster.h:42
@ HOME_MOTION_TYPE
Definition: MotionMaster.h:44
@ POINT_MOTION_TYPE
Definition: MotionMaster.h:46
@ FLIGHT_MOTION_TYPE
Definition: MotionMaster.h:45
@ FOLLOW_MOTION_TYPE
Definition: MotionMaster.h:52
@ ANIMAL_RANDOM_MOTION_TYPE
Definition: MotionMaster.h:41
@ RANDOM_MOTION_TYPE
Definition: MotionMaster.h:38
@ EFFECT_MOTION_TYPE
Definition: MotionMaster.h:54
std::string const & GetName() const
Definition: Object.h:446
LowType GetCounter() const
Definition: ObjectGuid.h:147
Definition: MotionMaster.h:110
_Ty GetMotionSlot(int slot) const
Definition: MotionMaster.h:153
bool GetDestination(float &x, float &y, float &z)
Definition: MotionMaster.cpp:866
Definition: MovementGenerator.h:30
virtual MovementGeneratorType GetMovementGeneratorType()=0
Definition: TargetedMovementGenerator.h:39
Definition: TargetedMovementGenerator.h:75

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

Referenced by GetCommands().

◆ HandleMuteCommand()

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

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

Referenced by GetCommands().

◆ HandleMuteInfoCommand()

static bool misc_commandscript::HandleMuteInfoCommand ( ChatHandler handler,
std::string  accountName 
)
inlinestatic
2565 {
2566 if (!Utf8ToUpperOnlyLatin(accountName))
2567 {
2568 handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2569 handler->SetSentErrorMessage(true);
2570 return false;
2571 }
2572
2573 uint32 accountId = AccountMgr::GetId(accountName);
2574 if (!accountId)
2575 {
2576 handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2577 return false;
2578 }
2579
2580 return HandleMuteInfoHelper(handler, accountId, accountName.c_str());
2581 }
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:528
@ LANG_ACCOUNT_NOT_EXIST
Definition: Language.h:425
uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:200
static bool HandleMuteInfoHelper(ChatHandler *handler, uint32 accountId, char const *accountName)
Definition: cs_misc.cpp:2584

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

Referenced by GetCommands().

◆ HandleMuteInfoHelper()

static bool misc_commandscript::HandleMuteInfoHelper ( ChatHandler handler,
uint32  accountId,
char const *  accountName 
)
inlinestatic
2585 {
2587 stmt->SetData(0, accountId);
2588 PreparedQueryResult result = LoginDatabase.Query(stmt);
2589
2590 if (!result)
2591 {
2592 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_EMPTY, accountName);
2593 return true;
2594 }
2595
2596 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY, accountName);
2597 do
2598 {
2599 Field* fields = result->Fetch();
2600 handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, Acore::Time::TimeToHumanReadable(Seconds(fields[0].Get<uint32>())).c_str(), fields[1].Get<uint32>(), fields[2].Get<std::string>().c_str(), fields[3].Get<std::string>().c_str());
2601 } while (result->NextRow());
2602
2603 return true;
2604 }
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:30
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ LOGIN_SEL_ACCOUNT_MUTE_INFO
Definition: LoginDatabase.h:109
@ LANG_COMMAND_MUTEHISTORY_OUTPUT
Definition: Language.h:1119
@ LANG_COMMAND_MUTEHISTORY_EMPTY
Definition: Language.h:1118
@ LANG_COMMAND_MUTEHISTORY
Definition: Language.h:1117
AC_COMMON_API std::string TimeToHumanReadable(Seconds time=0s, std::string_view fmt={})
Definition: Timer.cpp:287
Class used to access individual fields of database query result.
Definition: Field.h:99

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

Referenced by HandleMuteInfoCommand().

◆ HandleNearGraveCommand()

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

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

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

Referenced by GetCommands().

◆ HandlePlayAllCommand()

static bool misc_commandscript::HandlePlayAllCommand ( ChatHandler handler,
uint32  soundId 
)
inlinestatic
2923 {
2924 if (!sSoundEntriesStore.LookupEntry(soundId))
2925 {
2926 handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
2927 handler->SetSentErrorMessage(true);
2928 return false;
2929 }
2930
2931 sWorld->SendGlobalMessage(WorldPackets::Misc::Playsound(soundId).Write());
2932
2934 return true;
2935 }
DBCStorage< SoundEntriesEntry > sSoundEntriesStore(SoundEntriesfmt)
@ LANG_COMMAND_PLAYED_TO_ALL
Definition: Language.h:1062
@ LANG_SOUND_NOT_EXIST
Definition: Language.h:210
Definition: MiscPackets.h:83

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

Referenced by GetCommands().

◆ HandlePossessCommand()

static bool misc_commandscript::HandlePossessCommand ( ChatHandler handler)
inlinestatic
2938 {
2939 Unit* unit = handler->getSelectedUnit();
2940 if (!unit)
2941 {
2942 return false;
2943 }
2944
2945 handler->GetSession()->GetPlayer()->CastSpell(unit, 530, true);
2946 return true;
2947 }

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
1236 {
1237 if (!target)
1238 {
1239 target = PlayerIdentifier::FromTargetOrSelf(handler);
1240 }
1241
1242 if (!target || !target->IsConnected())
1243 {
1244 return false;
1245 }
1246
1247 auto targetPlayer = target->GetConnectedPlayer();
1248
1249 // check online security
1250 if (handler->HasLowerSecurity(targetPlayer))
1251 {
1252 return false;
1253 }
1254
1255 if (targetPlayer->IsBeingTeleported())
1256 {
1257 handler->PSendSysMessage(LANG_IS_TELEPORTED, handler->playerLink(target->GetName()).c_str());
1258 handler->SetSentErrorMessage(true);
1259 return false;
1260 }
1261
1262 // stop flight if need
1263 if (targetPlayer->IsInFlight())
1264 {
1265 targetPlayer->GetMotionMaster()->MovementExpired();
1266 targetPlayer->CleanupAfterTaxiFlight();
1267 }
1268
1269 targetPlayer->TeleportTo(targetPlayer->m_recallMap, targetPlayer->m_recallX, targetPlayer->m_recallY, targetPlayer->m_recallZ, targetPlayer->m_recallO);
1270 return true;
1271 }

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

Referenced by GetCommands().

◆ HandleRespawnAllCommand()

static bool misc_commandscript::HandleRespawnAllCommand ( ChatHandler handler)
inlinestatic
2362 {
2363 Player* player = handler->GetSession()->GetPlayer();
2364
2366 Cell cell(p);
2367 cell.SetNoCreate();
2368
2369 Acore::RespawnDo u_do;
2370 Acore::WorldObjectWorker<Acore::RespawnDo> worker(player, u_do);
2371 Cell::VisitGridObjects(player, worker, player->GetGridActivationRange());
2372
2373 return true;
2374 }
float GetGridActivationRange() const
Definition: Object.cpp:1623
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
Definition: GridNotifiers.h:257
Definition: GridNotifiers.h:642

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

Referenced by GetCommands().

◆ HandleRespawnCommand()

static bool misc_commandscript::HandleRespawnCommand ( ChatHandler handler)
inlinestatic
2336 {
2337 Player* player = handler->GetSession()->GetPlayer();
2338
2339 Unit* target = handler->getSelectedUnit();
2340 if (player->GetTarget() && target)
2341 {
2342 if (target->GetTypeId() != TYPEID_UNIT || target->IsPet())
2343 {
2345 handler->SetSentErrorMessage(true);
2346 return false;
2347 }
2348
2349 if (target->isDead())
2350 {
2351 target->ToCreature()->Respawn();
2352 }
2353 return true;
2354 }
2355
2357 handler->SetSentErrorMessage(true);
2358 return false;
2359 }
void Respawn(bool force=false)
Definition: Creature.cpp:2005
bool IsPet() const
Definition: Unit.h:1413
bool isDead() const
Definition: Unit.h:1810

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

Referenced by GetCommands().

◆ HandleReviveCommand()

static bool misc_commandscript::HandleReviveCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
1094 {
1095 if (!target)
1096 {
1097 target = PlayerIdentifier::FromTargetOrSelf(handler);
1098 }
1099
1100 if (!target)
1101 {
1102 return false;
1103 }
1104
1105 if (target->IsConnected())
1106 {
1107 auto targetPlayer = target->GetConnectedPlayer();
1108
1109 targetPlayer->ResurrectPlayer(!AccountMgr::IsPlayerAccount(targetPlayer->GetSession()->GetSecurity()) ? 1.0f : 0.5f);
1110 targetPlayer->SpawnCorpseBones();
1111 targetPlayer->SaveToDB(false, false);
1112 }
1113 else
1114 {
1115 CharacterDatabaseTransaction trans(nullptr);
1116 Player::OfflineResurrect(target->GetGUID(), trans);
1117 }
1118
1119 return true;
1120 }
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
static void OfflineResurrect(ObjectGuid const guid, CharacterDatabaseTransaction trans)
Definition: Player.cpp:4483

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

Referenced by GetCommands().

◆ HandleSaveAllCommand()

static bool misc_commandscript::HandleSaveAllCommand ( ChatHandler handler)
inlinestatic
1305 {
1308 return true;
1309 }
@ LANG_PLAYERS_SAVED
Definition: Language.h:47
void SaveAllPlayers()
Definition: ObjectAccessor.cpp:267

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

Referenced by GetCommands().

◆ HandleSaveCommand()

static bool misc_commandscript::HandleSaveCommand ( ChatHandler handler)
inlinestatic
1274 {
1275 Player* player = handler->GetSession()->GetPlayer();
1276
1277 // save GM account without delay and output message
1278 if (handler->GetSession()->GetSecurity() >= SEC_GAMEMASTER)
1279 {
1280 if (Player* target = handler->getSelectedPlayer())
1281 {
1282 target->SaveToDB(false, false);
1283 }
1284 else
1285 {
1286 player->SaveToDB(false, false);
1287 }
1288
1290 return true;
1291 }
1292
1293 // save if the player has last been saved over 20 seconds ago
1294 uint32 saveInterval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
1295 if (saveInterval == 0 || (saveInterval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= saveInterval - 20 * IN_MILLISECONDS))
1296 {
1297 player->SaveToDB(false, false);
1298 }
1299
1300 return true;
1301 }
constexpr auto IN_MILLISECONDS
Definition: Common.h:62
@ LANG_PLAYER_SAVED
Definition: Language.h:46
@ CONFIG_INTERVAL_SAVE
Definition: IWorld.h:212
void SaveToDB(bool create, bool logout)
Definition: PlayerStorage.cpp:7067
uint32 GetSaveTimer() const
Definition: Player.h:2304

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
1842 {
1843 uint32 skillID = uint32(skillId);
1844
1845 if (skillID <= 0)
1846 {
1847 handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skillID);
1848 handler->SetSentErrorMessage(true);
1849 return false;
1850 }
1851
1852 Player* target = handler->getSelectedPlayer();
1853 if (!target)
1854 {
1856 handler->SetSentErrorMessage(true);
1857 return false;
1858 }
1859
1860 SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skillID);
1861 if (!skillLine)
1862 {
1863 handler->PSendSysMessage(LANG_INVALID_SKILL_ID, uint32(skillID));
1864 handler->SetSentErrorMessage(true);
1865 return false;
1866 }
1867
1868 bool targetHasSkill = target->GetSkillValue(skillID);
1869
1870 // If our target does not yet have the skill they are trying to add to them, the chosen level also becomes
1871 // the max level of the new profession.
1872 uint16 max = maxPureSkill ? *maxPureSkill : targetHasSkill ? target->GetPureMaxSkillValue(skillID) : uint16(level);
1873
1874 if (level <= 0 || level > max || max <= 0)
1875 {
1876 return false;
1877 }
1878
1879 // If the player has the skill, we get the current skill step. If they don't have the skill, we
1880 // add the skill to the player's book with step 1 (which is the first rank, in most cases something
1881 // like 'Apprentice <skill>'.
1882 target->SetSkill(skillID, targetHasSkill ? target->GetSkillStep(skillID) : 1, level, max);
1883 handler->PSendSysMessage(LANG_SET_SKILL, skillID, skillLine->name[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max);
1884 return true;
1885 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ LANG_INVALID_SKILL_ID
Definition: Language.h:508
@ LANG_SET_SKILL
Definition: Language.h:505
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5354
uint16 GetSkillStep(uint16 skill) const
Definition: Player.cpp:5342
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5389
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition: Player.cpp:5231
Definition: DBCStructure.h:1556
char const * name[16]
Definition: DBCStructure.h:1560

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), Player::SetSkill(), and sSkillLineStore.

Referenced by GetCommands().

◆ HandleShowAreaCommand()

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

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

Referenced by GetCommands().

◆ HandleSkirmishCommand()

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

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(), 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
2994 {
2995 if (!id)
2996 {
2998 return false;
2999 }
3000
3001 const char* str = sObjectMgr->GetAcoreString(id, locale ? static_cast<LocaleConstant>(*locale) : DEFAULT_LOCALE);
3002
3003 if (!strcmp(str, "<error>"))
3004 {
3006 return true;
3007 }
3008 else
3009 {
3010 handler->SendSysMessage(str);
3011 return true;
3012 }
3013 }
LocaleConstant
Definition: Common.h:74
#define DEFAULT_LOCALE
Definition: Common.h:88
@ LANG_CMD_SYNTAX
Definition: Language.h:42
@ LANG_NO_ACORE_STRING_FOUND
Definition: Language.h:1174

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
814 {
815 if (!target)
816 {
817 target = PlayerIdentifier::FromTarget(handler);
818 }
819
820 if (!target)
821 {
822 return false;
823 }
824
825 Player* _player = handler->GetSession()->GetPlayer();
826 if (target->GetGUID() == _player->GetGUID())
827 {
829 handler->SetSentErrorMessage(true);
830 return false;
831 }
832
833 std::string nameLink = handler->playerLink(target->GetName());
834
835 if (target->IsConnected())
836 {
837 auto targetPlayer = target->GetConnectedPlayer();
838
839 // check online security
840 if (handler->HasLowerSecurity(targetPlayer))
841 {
842 return false;
843 }
844
845 if (targetPlayer->IsBeingTeleported())
846 {
847 handler->PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str());
848 handler->SetSentErrorMessage(true);
849 return false;
850 }
851
852 Map* map = handler->GetSession()->GetPlayer()->GetMap();
853
854 if (map->IsBattlegroundOrArena())
855 {
856 handler->PSendSysMessage("Can't summon to a battleground!");
857 handler->SetSentErrorMessage(true);
858 return false;
859 }
860 else if (map->IsDungeon())
861 {
862 // Allow GM to summon players or only other GM accounts inside instances.
863 if (!sWorld->getBoolConfig(CONFIG_INSTANCE_GMSUMMON_PLAYER))
864 {
865 // pussywizard: prevent unbinding normal player's perm bind by just summoning him >_>
866 if (!targetPlayer->GetSession()->GetSecurity())
867 {
868 handler->PSendSysMessage("Only GMs can be summoned to an instance!");
869 handler->SetSentErrorMessage(true);
870 return false;
871 }
872 }
873
874 Map* destMap = targetPlayer->GetMap();
875
876 if (destMap->Instanceable() && destMap->GetInstanceId() != map->GetInstanceId())
877 {
878 sInstanceSaveMgr->PlayerUnbindInstance(target->GetGUID(), map->GetInstanceId(), targetPlayer->GetDungeonDifficulty(), true, targetPlayer);
879 }
880
881 // we are in an instance, and can only summon players in our group with us as leader
882 if (!handler->GetSession()->GetPlayer()->GetGroup() || !targetPlayer->GetGroup() ||
883 (targetPlayer->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
884 (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()))
885 // the last check is a bit excessive, but let it be, just in case
886 {
887 handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str());
888 handler->SetSentErrorMessage(true);
889 return false;
890 }
891 }
892
893 handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), "");
894 if (handler->needReportToTarget(targetPlayer))
895 {
896 ChatHandler(targetPlayer->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str());
897 }
898
899 // stop flight if need
900 if (targetPlayer->IsInFlight())
901 {
902 targetPlayer->GetMotionMaster()->MovementExpired();
903 targetPlayer->CleanupAfterTaxiFlight();
904 }
905 // save only in non-flight case
906 else
907 {
908 targetPlayer->SaveRecallPosition();
909 }
910
911 // before GM
912 float x, y, z;
913 handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, targetPlayer->GetObjectSize());
914 targetPlayer->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, targetPlayer->GetOrientation(), 0, handler->GetSession()->GetPlayer());
915 }
916 else
917 {
918 // check offline security
919 if (handler->HasLowerSecurity(nullptr, target->GetGUID()))
920 {
921 return false;
922 }
923
924 handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), handler->GetAcoreString(LANG_OFFLINE));
925
926 // in point where GM stay
928 handler->GetSession()->GetPlayer()->GetPositionX(),
929 handler->GetSession()->GetPlayer()->GetPositionY(),
930 handler->GetSession()->GetPlayer()->GetPositionZ(),
931 handler->GetSession()->GetPlayer()->GetOrientation(),
932 handler->GetSession()->GetPlayer()->GetZoneId(),
933 target->GetGUID());
934 }
935
936 return true;
937 }
@ CONFIG_INSTANCE_GMSUMMON_PLAYER
Definition: IWorld.h:90
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::SetSentErrorMessage(), sInstanceSaveMgr, and sWorld.

Referenced by GetCommands().

◆ HandleUnAuraCommand()

static bool misc_commandscript::HandleUnAuraCommand ( ChatHandler handler,
Variant< SpellInfo const *, std::string_view >  spells 
)
inlinestatic
624 {
625 Unit* target = handler->getSelectedUnit();
626 if (!target)
627 {
629 handler->SetSentErrorMessage(true);
630 return false;
631 }
632
633 if (spells.holds_alternative<std::string_view>() && spells.get<std::string_view>() == "all")
634 {
635 target->RemoveAllAuras();
636 return true;
637 }
638
639 if (!spells.holds_alternative<SpellInfo const*>())
640 {
642 handler->SetSentErrorMessage(true);
643 return false;
644 }
645
646 auto spell = spells.get<SpellInfo const*>();
647
648 if (!SpellMgr::IsSpellValid(spell))
649 {
650 handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
651 handler->SetSentErrorMessage(true);
652 return false;
653 }
654
655 target->RemoveAurasDueToSpell(spell->Id);
656
657 return true;
658 }
spells
Definition: boss_krystallus.cpp:25
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4835
void RemoveAllAuras()
Definition: Unit.cpp:5239

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

Referenced by GetCommands().

◆ HandleUnbindSightCommand()

static bool misc_commandscript::HandleUnbindSightCommand ( ChatHandler handler)
inlinestatic
2974 {
2975 Player* player = handler->GetSession()->GetPlayer();
2976
2977 if (player->isPossessing())
2978 {
2979 return false;
2980 }
2981
2982 player->StopCastingBindSight();
2983 return true;
2984 }
void StopCastingBindSight(Aura *except=nullptr)
Definition: Player.cpp:13049
bool isPossessing() const
Definition: Unit.h:1874

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
2880 {
2881 Creature* creatureTarget = handler->getSelectedCreature();
2882
2883 if (!target && !creatureTarget)
2884 {
2885 target = PlayerIdentifier::FromTargetOrSelf(handler);
2886 }
2887
2888 if (!target && !creatureTarget)
2889 {
2891 handler->SetSentErrorMessage(true);
2892 return false;
2893 }
2894
2895 Player* playerTarget = target->GetConnectedPlayer();
2896
2897 if (!creatureTarget && playerTarget && playerTarget->HasAura(SPELL_FREEZE))
2898 {
2899 handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName().c_str());
2900 playerTarget->RemoveAurasDueToSpell(SPELL_FREEZE);
2901 return true;
2902 }
2903 else if (creatureTarget && creatureTarget->HasAura(SPELL_FREEZE))
2904 {
2905 handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, GetLocalizeCreatureName(creatureTarget, handler->GetSessionDbcLocale()).c_str());
2906 creatureTarget->RemoveAurasDueToSpell(SPELL_FREEZE);
2907 return true;
2908 }
2909 else if (!creatureTarget && target && !target->IsConnected())
2910 {
2912 stmt->SetData(0, target->GetGUID().GetCounter());
2913 CharacterDatabase.Execute(stmt);
2914 handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName().c_str());
2915 return true;
2916 }
2917
2919 return true;
2920 }
@ CHAR_DEL_CHAR_AURA_FROZEN
Definition: CharacterDatabase.h:353
@ LANG_COMMAND_UNFREEZE
Definition: Language.h:1056
@ LANG_COMMAND_FREEZE_WRONG
Definition: Language.h:1055
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5610

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::SendSysMessage(), PreparedStatementBase::SetData(), ChatHandler::SetSentErrorMessage(), and SPELL_FREEZE.

Referenced by GetCommands().

◆ HandleUnmuteCommand()

static bool misc_commandscript::HandleUnmuteCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
2505 {
2506 if (!target)
2507 {
2508 target = PlayerIdentifier::FromTargetOrSelf(handler);
2509 }
2510
2511 if (!target)
2512 {
2513 return false;
2514 }
2515
2516 Player* playerTarget = target->GetConnectedPlayer();
2517 uint32 accountId = playerTarget ? playerTarget->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(target->GetGUID());
2518
2519 // find only player from same account if any
2520 if (!playerTarget)
2521 {
2522 if (WorldSession* session = sWorld->FindSession(accountId))
2523 {
2524 playerTarget = session->GetPlayer();
2525 }
2526 }
2527
2528 // must have strong lesser security level
2529 if (handler->HasLowerSecurity(playerTarget, target->GetGUID(), true))
2530 {
2531 return false;
2532 }
2533
2534 if (playerTarget)
2535 {
2536 if (playerTarget->CanSpeak())
2537 {
2539 handler->SetSentErrorMessage(true);
2540 return false;
2541 }
2542
2543 playerTarget->GetSession()->m_muteTime = 0;
2544 }
2545
2547 stmt->SetData(0, 0);
2548 stmt->SetData(1, "");
2549 stmt->SetData(2, "");
2550 stmt->SetData(3, accountId);
2551 LoginDatabase.Execute(stmt);
2552
2553 if (playerTarget)
2554 {
2556 }
2557
2558 handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, handler->playerLink(target->GetName().c_str()));
2559
2560 return true;
2561 }
@ 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::SendSysMessage(), PreparedStatementBase::SetData(), ChatHandler::SetSentErrorMessage(), and sWorld.

Referenced by GetCommands().

◆ HandleUnPossessCommand()

static bool misc_commandscript::HandleUnPossessCommand ( ChatHandler handler)
inlinestatic
2950 {
2951 Unit* unit = handler->getSelectedUnit();
2952 if (!unit)
2953 {
2954 unit = handler->GetSession()->GetPlayer();
2955 }
2956
2957 unit->RemoveCharmAuras();
2958 return true;
2959 }
void RemoveCharmAuras()
Definition: Unit.cpp:11152

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
1360 {
1361 // No args required for players
1362 if (handler->GetSession() && AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity()))
1363 {
1364 if (Player* player = handler->GetSession()->GetPlayer())
1365 {
1366 player->CastSpell(player, SPELL_STUCK, false);
1367 }
1368
1369 return true;
1370 }
1371
1372 if (!target)
1373 {
1374 target = PlayerIdentifier::FromTargetOrSelf(handler);
1375 }
1376
1377 if (!target || !target->IsConnected())
1378 {
1379 return false;
1380 }
1381
1382 Player* player = target->GetConnectedPlayer();
1383
1384 if (player->IsInFlight() || player->IsInCombat())
1385 {
1386 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(7355);
1387 if (!spellInfo)
1388 {
1389 return false;
1390 }
1391
1392 if (Player* caster = handler->GetSession()->GetPlayer())
1393 {
1395 }
1396
1397 return false;
1398 }
1399
1400 if (location->empty() || *location == "inn")
1401 {
1402 player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->m_homebindO);
1403 return true;
1404 }
1405
1406 if (*location == "graveyard")
1407 {
1408 player->RepopAtGraveyard();
1409 return true;
1410 }
1411
1412 if (*location == "startzone")
1413 {
1414 player->TeleportTo(player->GetStartPosition());
1415 return true;
1416 }
1417
1418 //Not a supported argument
1419 return false;
1420 }
constexpr auto SPELL_STUCK
Definition: cs_misc.cpp:53
@ SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW
Definition: SharedDefines.h:1094
float m_homebindZ
Definition: Player.h:2322
uint32 m_homebindMapId
Definition: Player.h:2318
void RepopAtGraveyard()
Definition: Player.cpp:4821
float m_homebindY
Definition: Player.h:2321
float m_homebindO
Definition: Player.h:2323
WorldLocation GetStartPosition() const
Definition: Player.cpp:11297
float m_homebindX
Definition: Player.h:2320
bool IsInCombat() const
Definition: Unit.h:1688
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition: Spell.cpp:4631

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

Referenced by GetCommands().