Applies the Deserter Debuff to a player.
This function applies a Deserter Debuff of the given type (Instance or BG) to the selected player, with the provided duration in seconds.
.deserter instance add 1h30m (using player target or self)
-or-
.deserter bg add 1h30m (using player target or self)
-or-
.deserter bg add Tester 1h30m (using player of name 'Tester')
99 {
102
103 if (playerName)
104 {
106 {
108 return false;
109 }
110
112 if (guid)
113 {
115 }
116 else
117 {
118 if (time)
119 {
121 return false;
122 }
123
124 time = playerName;
125 playerName = "";
126 }
127 }
128
129 if (!playerName || playerName->empty())
130 {
132 {
133 return false;
134 }
135
136 playerName = target->
GetName();
138 }
139
140 if (!time)
141 {
142 time = isInstance ? "30m" : "15m";
143 }
144
146
147 if (duration == 0)
148 {
149 duration = Acore::StringTo<int32>(*time).value_or(0);
150 }
151
152 if (duration == 0)
153 {
155 return false;
156 }
157
159
160 if (target)
161 {
164 {
165 handler->
PSendSysMessage(
"Player {} already has a longer {} Deserter active.", handler->
playerLink(*playerName), isInstance ?
"Instance" :
"Battleground");
166 return true;
167 }
168
169 aura = target->
AddAura(deserterSpell, target);
170 if (!aura)
171 {
173 return false;
174 }
176 }
177 else
178 {
179 int32 remainTime = 0;
181 {
182 Field* fields = result->Fetch();
183 remainTime = fields[0].
Get<
int32>();
184
186 {
187 handler->
PSendSysMessage(
"Player {} already has a longer {} Deserter active.", handler->
playerLink(*playerName), isInstance ?
"Instance" :
"Battleground");
188 return true;
189 }
191 }
192
198 stmt->
SetData(index++, deserterSpell);
208 stmt->
SetData(index++, isInstance ? 1800000 : 900000);
212 }
213
215 return true;
216 }
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition: Util.cpp:73
uint32 TimeStringToSecs(const std::string ×tring)
Definition: Util.cpp:163
std::int32_t int32
Definition: Define.h:103
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
@ LFG_SPELL_DUNGEON_DESERTER
Definition: cs_deserter.cpp:35
@ BG_SPELL_DESERTER
Definition: cs_deserter.cpp:36
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:208
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:539
@ LANG_BAD_VALUE
Definition: Language.h:147
#define sCharacterCache
Definition: CharacterCache.h:83
@ CHAR_INS_AURA
Definition: CharacterDatabase.h:196
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:27
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:271
Definition: PreparedStatement.h:157
Class used to access individual fields of database query result.
Definition: Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:112
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77
std::string playerLink(std::string const &name) const
Definition: Chat.h:231
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
WorldSession * GetSession()
Definition: Chat.h:242
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
Player * getSelectedPlayerOrSelf() const
Definition: Chat.cpp:417
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
std::string const & GetName() const
Definition: Object.h:458
Definition: ObjectGuid.h:118
LowType GetCounter() const
Definition: ObjectGuid.h:145
Definition: Player.h:1064
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5581
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:18864
Definition: SpellAuras.h:87
int32 GetDuration() const
Definition: SpellAuras.h:133
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:868