TrinityCore
Loading...
Searching...
No Matches
cs_cheat.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* ScriptData
19Name: cheat_commandscript
20%Complete: 100
21Comment: All cheat related commands
22Category: commandscripts
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "Chat.h"
27#include "ChatCommand.h"
28#include "DB2Stores.h"
29#include "Language.h"
30#include "Player.h"
31#include "RBAC.h"
32#include "WorldSession.h"
33
34using namespace Trinity::ChatCommands;
35
37{
38public:
39 cheat_commandscript() : CommandScript("cheat_commandscript") { }
40
41 std::span<ChatCommandBuilder const> GetCommands() const override
42 {
43 static ChatCommandTable cheatCommandTable =
44 {
53
54 };
55
56 static ChatCommandTable commandTable =
57 {
58 { "cheat", cheatCommandTable },
59 };
60 return commandTable;
61 }
62
63 static bool HandleGodModeCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
64 {
65 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_GOD);
66 if (enableArg)
67 enable = *enableArg;
68
69 if (enable)
70 {
72 handler->SendSysMessage("Godmode is ON. You won't take damage.");
73 }
74 else
75 {
77 handler->SendSysMessage("Godmode is OFF. You can take damage.");
78 }
79
80 return true;
81 }
82
83 static bool HandleCasttimeCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
84 {
85 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_CASTTIME);
86 if (enableArg)
87 enable = *enableArg;
88
89 if (enable)
90 {
92 handler->SendSysMessage("CastTime Cheat is ON. Your spells won't have a casttime.");
93 }
94 else
95 {
97 handler->SendSysMessage("CastTime Cheat is OFF. Your spells will have a casttime.");
98 }
99
100 return true;
101 }
102
104 {
105 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_COOLDOWN);
106 if (enableArg)
107 enable = *enableArg;
108
109 if (enable)
110 {
112 handler->SendSysMessage("Cooldown Cheat is ON. You are not on the global cooldown.");
113 }
114 else
115 {
117 handler->SendSysMessage("Cooldown Cheat is OFF. You are on the global cooldown.");
118 }
119
120 return true;
121 }
122
123 static bool HandlePowerCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
124 {
125 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_POWER);
126 if (enableArg)
127 enable = *enableArg;
128
129 if (enable)
130 {
131 Player* player = handler->GetSession()->GetPlayer();
132 // Set max power to all powers
133 for (Powers power : player->GetPowerTypes())
134 player->SetFullPower(power);
136 handler->SendSysMessage("Power Cheat is ON. You don't need mana/rage/energy to use spells.");
137 }
138 else
139 {
141 handler->SendSysMessage("Power Cheat is OFF. You need mana/rage/energy to use spells.");
142 }
143
144 return true;
145 }
146
148 {
149 Player* player = handler->GetSession()->GetPlayer();
150
151 char const* enabled = "ON";
152 char const* disabled = "OFF";
153
155 handler->PSendSysMessage(LANG_COMMAND_CHEAT_GOD, player->GetCommandStatus(CHEAT_GOD) ? enabled : disabled);
156 handler->PSendSysMessage(LANG_COMMAND_CHEAT_CD, player->GetCommandStatus(CHEAT_COOLDOWN) ? enabled : disabled);
157 handler->PSendSysMessage(LANG_COMMAND_CHEAT_CT, player->GetCommandStatus(CHEAT_CASTTIME) ? enabled : disabled);
158 handler->PSendSysMessage(LANG_COMMAND_CHEAT_POWER, player->GetCommandStatus(CHEAT_POWER) ? enabled : disabled);
159 handler->PSendSysMessage(LANG_COMMAND_CHEAT_WW, player->GetCommandStatus(CHEAT_WATERWALK) ? enabled : disabled);
160 handler->PSendSysMessage(LANG_COMMAND_CHEAT_TAXINODES, player->isTaxiCheater() ? enabled : disabled);
161 return true;
162 }
163
165 {
166 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_WATERWALK);
167 if (enableArg)
168 enable = *enableArg;
169
170 if (enable)
171 {
173 handler->GetSession()->GetPlayer()->SetWaterWalking(true); // ON
174 handler->SendSysMessage("Waterwalking is ON. You can walk on water.");
175 }
176 else
177 {
179 handler->GetSession()->GetPlayer()->SetWaterWalking(false); // OFF
180 handler->SendSysMessage("Waterwalking is OFF. You can't walk on water.");
181 }
182
183 return true;
184 }
185
186 static bool HandleTaxiCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
187 {
188 Player* chr = handler->getSelectedPlayer();
189
190 if (!chr)
191 chr = handler->GetSession()->GetPlayer();
192 else if (handler->HasLowerSecurity(chr, ObjectGuid::Empty)) // check online security
193 return false;
194
195 bool enable = !chr->isTaxiCheater();
196 if (enableArg)
197 enable = *enableArg;
198
199 if (enable)
200 {
201 chr->SetTaxiCheater(true);
202 handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str());
203 if (handler->needReportToTarget(chr))
205 }
206 else
207 {
208 chr->SetTaxiCheater(false);
209 handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str());
210 if (handler->needReportToTarget(chr))
212 }
213
214 return true;
215 }
216
217 static bool HandleExploreCheatCommand(ChatHandler* handler, bool reveal)
218 {
219 Player* chr = handler->getSelectedPlayer();
220 if (!chr)
221 {
223 handler->SetSentErrorMessage(true);
224 return false;
225 }
226
227 if (reveal)
228 {
229 handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(chr).c_str());
230 if (handler->needReportToTarget(chr))
232 }
233 else
234 {
235 handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(chr).c_str());
236 if (handler->needReportToTarget(chr))
238 }
239
240 for (uint16 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
241 {
242 if (reveal)
243 handler->GetSession()->GetPlayer()->AddExploredZones(i, 0xFFFFFFFFFFFFFFFF);
244 else
245 handler->GetSession()->GetPlayer()->RemoveExploredZones(i, 0xFFFFFFFFFFFFFFFF);
246 }
247
248 return true;
249 }
250};
251
constexpr size_t PLAYER_EXPLORED_ZONES_SIZE
Definition DBCEnums.h:160
uint16_t uint16
Definition Define.h:155
@ LANG_YOU_SET_EXPLORE_NOTHING
Definition Language.h:632
@ LANG_YOURS_TAXIS_REMOVED
Definition Language.h:172
@ LANG_COMMAND_CHEAT_CT
Definition Language.h:414
@ LANG_YOURS_TAXIS_ADDED
Definition Language.h:171
@ LANG_COMMAND_CHEAT_WW
Definition Language.h:417
@ LANG_COMMAND_CHEAT_POWER
Definition Language.h:416
@ LANG_COMMAND_CHEAT_GOD
Definition Language.h:413
@ LANG_YOU_REMOVE_TAXIS
Definition Language.h:170
@ LANG_COMMAND_CHEAT_CD
Definition Language.h:415
@ LANG_YOURS_EXPLORE_SET_ALL
Definition Language.h:633
@ LANG_NO_CHAR_SELECTED
Definition Language.h:150
@ LANG_YOU_SET_EXPLORE_ALL
Definition Language.h:631
@ LANG_YOURS_EXPLORE_SET_NOTHING
Definition Language.h:634
@ LANG_YOU_GIVE_TAXIS
Definition Language.h:169
@ LANG_COMMAND_CHEAT_STATUS
Definition Language.h:412
@ LANG_COMMAND_CHEAT_TAXINODES
Definition Language.h:419
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
@ CHEAT_COOLDOWN
Definition Player.h:1062
@ CHEAT_POWER
Definition Player.h:1063
@ CHEAT_GOD
Definition Player.h:1060
@ CHEAT_WATERWALK
Definition Player.h:1064
@ CHEAT_CASTTIME
Definition Player.h:1061
Role Based Access Control related classes definition.
Powers
Player * getSelectedPlayer()
Definition Chat.cpp:204
WorldSession * GetSession()
Definition Chat.h:42
virtual std::string GetNameLink() const
Definition Chat.cpp:56
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition Chat.cpp:61
void SetSentErrorMessage(bool val)
Definition Chat.h:127
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:62
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:111
virtual bool needReportToTarget(Player *chr) const
Definition Chat.cpp:587
static ObjectGuid const Empty
Definition ObjectGuid.h:314
bool GetCommandStatus(uint32 command) const
Definition Player.h:1323
WorldSession * GetSession() const
Definition Player.h:2256
void SetCommandStatusOn(uint32 command)
Definition Player.h:1324
void AddExploredZones(uint32 pos, uint64 mask)
Definition Player.cpp:6289
void SetCommandStatusOff(uint32 command)
Definition Player.h:1325
ClassPowerTypes GetPowerTypes() const override
void RemoveExploredZones(uint32 pos, uint64 mask)
Definition Player.cpp:6298
void SetTaxiCheater(bool on)
Definition Player.h:1300
bool isTaxiCheater() const
Definition Player.h:1299
void SetFullPower(Powers power)
Definition Unit.h:837
bool SetWaterWalking(bool enable)
Definition Unit.cpp:13581
Player * GetPlayer() const
static bool HandleCasttimeCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:83
static bool HandleExploreCheatCommand(ChatHandler *handler, bool reveal)
Definition cs_cheat.cpp:217
std::span< ChatCommandBuilder const > GetCommands() const override
Definition cs_cheat.cpp:41
static bool HandleWaterWalkCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:164
static bool HandleCoolDownCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:103
static bool HandleTaxiCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:186
static bool HandleGodModeCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:63
static bool HandleCheatStatusCommand(ChatHandler *handler)
Definition cs_cheat.cpp:147
static bool HandlePowerCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:123
void AddSC_cheat_commandscript()
Definition cs_cheat.cpp:252
ChatCommandBuilder const [] ChatCommandTable
Definition ChatCommand.h:49
@ RBAC_PERM_COMMAND_CHEAT_POWER
Definition RBAC.h:212
@ RBAC_PERM_COMMAND_CHEAT_TAXI
Definition RBAC.h:214
@ RBAC_PERM_COMMAND_CHEAT_GOD
Definition RBAC.h:211
@ RBAC_PERM_COMMAND_CHEAT_COOLDOWN
Definition RBAC.h:209
@ RBAC_PERM_COMMAND_CHEAT_CASTTIME
Definition RBAC.h:208
@ RBAC_PERM_COMMAND_CHEAT_WATERWALK
Definition RBAC.h:215
@ RBAC_PERM_COMMAND_CHEAT_STATUS
Definition RBAC.h:213
@ RBAC_PERM_COMMAND_CHEAT_EXPLORE
Definition RBAC.h:210