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 "Language.h"
28#include "Player.h"
29#include "RBAC.h"
30#include "WorldSession.h"
31
32using namespace Trinity::ChatCommands;
33
35{
36public:
37 cheat_commandscript() : CommandScript("cheat_commandscript") { }
38
40 {
41 static ChatCommandTable cheatCommandTable =
42 {
51
52 };
53
54 static ChatCommandTable commandTable =
55 {
56 { "cheat", cheatCommandTable },
57 };
58 return commandTable;
59 }
60
61 static bool HandleGodModeCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
62 {
63 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_GOD);
64 if (enableArg)
65 enable = *enableArg;
66
67 if (enable)
68 {
70 handler->SendSysMessage("Godmode is ON. You won't take damage.");
71 }
72 else
73 {
75 handler->SendSysMessage("Godmode is OFF. You can take damage.");
76 }
77
78 return true;
79 }
80
81 static bool HandleCasttimeCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
82 {
83 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_CASTTIME);
84 if (enableArg)
85 enable = *enableArg;
86
87 if (enable)
88 {
90 handler->SendSysMessage("CastTime Cheat is ON. Your spells won't have a casttime.");
91 }
92 else
93 {
95 handler->SendSysMessage("CastTime Cheat is OFF. Your spells will have a casttime.");
96 }
97
98 return true;
99 }
100
102 {
103 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_COOLDOWN);
104 if (enableArg)
105 enable = *enableArg;
106
107 if (enable)
108 {
110 handler->SendSysMessage("Cooldown Cheat is ON. You are not on the global cooldown.");
111 }
112 else
113 {
115 handler->SendSysMessage("Cooldown Cheat is OFF. You are on the global cooldown.");
116 }
117
118 return true;
119 }
120
121 static bool HandlePowerCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
122 {
123 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_POWER);
124 if (enableArg)
125 enable = *enableArg;
126
127 if (enable)
128 {
130 handler->SendSysMessage("Power Cheat is ON. You don't need mana/rage/energy to use spells.");
131 }
132 else
133 {
135 handler->SendSysMessage("Power Cheat is OFF. You need mana/rage/energy to use spells.");
136 }
137
138 return true;
139 }
140
142 {
143 Player* player = handler->GetSession()->GetPlayer();
144
145 char const* enabled = "ON";
146 char const* disabled = "OFF";
147
149 handler->PSendSysMessage(LANG_COMMAND_CHEAT_GOD, player->GetCommandStatus(CHEAT_GOD) ? enabled : disabled);
150 handler->PSendSysMessage(LANG_COMMAND_CHEAT_CD, player->GetCommandStatus(CHEAT_COOLDOWN) ? enabled : disabled);
151 handler->PSendSysMessage(LANG_COMMAND_CHEAT_CT, player->GetCommandStatus(CHEAT_CASTTIME) ? enabled : disabled);
152 handler->PSendSysMessage(LANG_COMMAND_CHEAT_POWER, player->GetCommandStatus(CHEAT_POWER) ? enabled : disabled);
153 handler->PSendSysMessage(LANG_COMMAND_CHEAT_WW, player->GetCommandStatus(CHEAT_WATERWALK) ? enabled : disabled);
154 handler->PSendSysMessage(LANG_COMMAND_CHEAT_TAXINODES, player->isTaxiCheater() ? enabled : disabled);
155
156 return true;
157 }
158
160 {
161 bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_WATERWALK);
162 if (enableArg)
163 enable = *enableArg;
164
165 if (enable)
166 {
168 handler->GetSession()->GetPlayer()->SetWaterWalking(true); // ON
169 handler->SendSysMessage("Waterwalking is ON. You can walk on water.");
170 }
171 else
172 {
174 handler->GetSession()->GetPlayer()->SetWaterWalking(false); // OFF
175 handler->SendSysMessage("Waterwalking is OFF. You can't walk on water.");
176 }
177
178 return true;
179 }
180
181 static bool HandleTaxiCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
182 {
183 Player* chr = handler->getSelectedPlayer();
184
185 if (!chr)
186 chr = handler->GetSession()->GetPlayer();
187 else if (handler->HasLowerSecurity(chr, ObjectGuid::Empty)) // check online security
188 return false;
189
190 bool enable = !chr->isTaxiCheater();
191 if (enableArg)
192 enable = *enableArg;
193
194 if (enable)
195 {
196 chr->SetTaxiCheater(true);
197 handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str());
198 if (handler->needReportToTarget(chr))
200 }
201 else
202 {
203 chr->SetTaxiCheater(false);
204 handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str());
205 if (handler->needReportToTarget(chr))
207 }
208
209 return true;
210 }
211
212 static bool HandleExploreCheatCommand(ChatHandler* handler, bool reveal)
213 {
214 Player* chr = handler->getSelectedPlayer();
215 if (!chr)
216 {
218 handler->SetSentErrorMessage(true);
219 return false;
220 }
221
222 if (reveal)
223 {
224 handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(chr).c_str());
225 if (handler->needReportToTarget(chr))
227 }
228 else
229 {
230 handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(chr).c_str());
231 if (handler->needReportToTarget(chr))
233 }
234
235 for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
236 {
237 if (reveal)
238 handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0xFFFFFFFF);
239 else
241 }
242
243 return true;
244 }
245};
246
uint8_t uint8
Definition Define.h:135
@ 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:839
@ CHEAT_POWER
Definition Player.h:840
@ CHEAT_GOD
Definition Player.h:837
@ CHEAT_WATERWALK
Definition Player.h:841
@ CHEAT_CASTTIME
Definition Player.h:838
#define PLAYER_EXPLORED_ZONES_SIZE
Definition Player.h:117
Role Based Access Control related classes definition.
@ PLAYER_EXPLORED_ZONES_1
Player * getSelectedPlayer()
Definition Chat.cpp:302
WorldSession * GetSession()
Definition Chat.h:46
virtual std::string GetNameLink() const
Definition Chat.cpp:46
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition Chat.cpp:51
void SetSentErrorMessage(bool val)
Definition Chat.h:134
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:69
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:101
virtual bool needReportToTarget(Player *chr) const
Definition Chat.cpp:686
static ObjectGuid const Empty
Definition ObjectGuid.h:140
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:760
bool GetCommandStatus(uint32 command) const
Definition Player.h:1028
WorldSession * GetSession() const
Definition Player.h:1719
void SetCommandStatusOn(uint32 command)
Definition Player.h:1029
void SetCommandStatusOff(uint32 command)
Definition Player.h:1030
void SetTaxiCheater(bool on)
Definition Player.h:1005
bool isTaxiCheater() const
Definition Player.h:1004
bool SetWaterWalking(bool enable)
Definition Unit.cpp:13423
Player * GetPlayer() const
static bool HandleCasttimeCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:81
static bool HandleExploreCheatCommand(ChatHandler *handler, bool reveal)
Definition cs_cheat.cpp:212
ChatCommandTable GetCommands() const override
Definition cs_cheat.cpp:39
static bool HandleWaterWalkCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:159
static bool HandleCoolDownCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:101
static bool HandleTaxiCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:181
static bool HandleGodModeCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:61
static bool HandleCheatStatusCommand(ChatHandler *handler)
Definition cs_cheat.cpp:141
static bool HandlePowerCheatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_cheat.cpp:121
void AddSC_cheat_commandscript()
Definition cs_cheat.cpp:247
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:50
@ 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