TrinityCore
Loading...
Searching...
No Matches
cs_deserter.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
25#include "ScriptMgr.h"
26#include "Chat.h"
27#include "Language.h"
28#include "Player.h"
29#include "RBAC.h"
30#include "SpellAuras.h"
31
32using namespace Trinity::ChatCommands;
33
39
41{
42public:
43 deserter_commandscript() : CommandScript("deserter_commandscript") { }
44
50 {
51 static ChatCommandTable deserterInstanceCommandTable =
52 {
55 };
56 static ChatCommandTable deserterBGCommandTable =
57 {
60 };
61
62 static ChatCommandTable deserterCommandTable =
63 {
64 { "instance", deserterInstanceCommandTable },
65 { "bg", deserterBGCommandTable },
66 };
67 static ChatCommandTable commandTable =
68 {
69 { "deserter", deserterCommandTable },
70 };
71 return commandTable;
72 }
73
94 static bool HandleDeserterAdd(ChatHandler* handler, uint32 time, bool isInstance)
95 {
96 Player* player = handler->getSelectedPlayer();
97 if (!player)
98 {
100 handler->SetSentErrorMessage(true);
101 return false;
102 }
103
104 if (!time)
105 {
107 handler->SetSentErrorMessage(true);
108 return false;
109 }
110
111 Aura* aura = player->AddAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER, player);
112
113 if (!aura)
114 {
116 handler->SetSentErrorMessage(true);
117 return false;
118 }
119 aura->SetDuration(time * IN_MILLISECONDS);
120
121 return true;
122 }
123
143 static bool HandleDeserterRemove(ChatHandler* handler, bool isInstance)
144 {
145 Player* player = handler->getSelectedPlayer();
146 if (!player)
147 {
149 handler->SetSentErrorMessage(true);
150 return false;
151 }
152
154
155 return true;
156 }
157
159 static bool HandleDeserterInstanceAdd(ChatHandler* handler, uint32 time)
160 {
161 return HandleDeserterAdd(handler, time, true);
162 }
163
165 static bool HandleDeserterBGAdd(ChatHandler* handler, uint32 time)
166 {
167 return HandleDeserterAdd(handler, time, false);
168 }
169
172 {
173 return HandleDeserterRemove(handler, true);
174 }
175
178 {
179 return HandleDeserterRemove(handler, false);
180 }
181};
182
@ IN_MILLISECONDS
Definition Common.h:35
uint32_t uint32
Definition Define.h:133
@ LANG_NO_CHAR_SELECTED
Definition Language.h:150
@ LANG_BAD_VALUE
Definition Language.h:149
Spells
Definition PlayerAI.cpp:32
Role Based Access Control related classes definition.
void SetDuration(int32 duration, bool withMods=false)
Player * getSelectedPlayer()
Definition Chat.cpp:302
void SetSentErrorMessage(bool val)
Definition Chat.h:134
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:101
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3638
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:11964
static bool HandleDeserterInstanceRemove(ChatHandler *handler)
ChatCommandTable GetCommands() const override
Returns the command structure for the system.
static bool HandleDeserterAdd(ChatHandler *handler, uint32 time, bool isInstance)
Applies the Deserter Debuff to a player.
static bool HandleDeserterRemove(ChatHandler *handler, bool isInstance)
Removes the Deserter Debuff from a player.
static bool HandleDeserterBGRemove(ChatHandler *handler)
static bool HandleDeserterBGAdd(ChatHandler *handler, uint32 time)
static bool HandleDeserterInstanceAdd(ChatHandler *handler, uint32 time)
void AddSC_deserter_commandscript()
@ LFG_SPELL_DUNGEON_DESERTER
@ BG_SPELL_DESERTER
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:50
@ RBAC_PERM_COMMAND_DESERTER_BG_REMOVE
Definition RBAC.h:219
@ RBAC_PERM_COMMAND_DESERTER_INSTANCE_REMOVE
Definition RBAC.h:222
@ RBAC_PERM_COMMAND_DESERTER_INSTANCE_ADD
Definition RBAC.h:221
@ RBAC_PERM_COMMAND_DESERTER_BG_ADD
Definition RBAC.h:218