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.
101 {
104
105 if (playerName)
106 {
108 {
110 return false;
111 }
112
114 if (guid)
115 {
117 }
118 else
119 {
120 if (time)
121 {
123 return false;
124 }
125
126 time = playerName;
127 playerName = "";
128 }
129 }
130
131 if (!playerName || playerName->empty())
132 {
134 {
135 return false;
136 }
137
138 playerName = target->
GetName();
140 }
141
142 if (!time)
143 {
144 time = isInstance ? "30m" : "15m";
145 }
146
148
149 if (duration == 0)
150 {
151 duration = Acore::StringTo<int32>(*time).value_or(0);
152 }
153
154 if (duration == 0)
155 {
157 return false;
158 }
159
161
162 if (target)
163 {
166 {
167 handler->
PSendSysMessage(
"Player {} already has a longer {} Deserter active.", handler->
playerLink(*playerName), isInstance ?
"Instance" :
"Battleground");
168 return true;
169 }
170
171 aura = target->
AddAura(deserterSpell, target);
172 if (!aura)
173 {
175 return false;
176 }
178 }
179 else
180 {
181 int32 remainTime = 0;
183 {
184 Field* fields = result->Fetch();
185 remainTime = fields[0].
Get<
int32>();
186
188 {
189 handler->
PSendSysMessage(
"Player {} already has a longer {} Deserter active.", handler->
playerLink(*playerName), isInstance ?
"Instance" :
"Battleground");
190 return true;
191 }
193 }
194
200 stmt->
SetData(index++, deserterSpell);
210 stmt->
SetData(index++, isInstance ? 1800000 : 900000);
214 }
215
216 if (isInstance)
217 {
219 if (
Group* group =
sGroupMgr->GetGroupByGUID(groupId.GetCounter()))
220 if (group->isLFGGroup())
222 }
225
226 handler->
PSendSysMessage(
"{} of {} Deserter has been added to player {}.",
secsToTimeString(duration), isInstance ?
"Instance" :
"Battleground", handler->playerLink(*playerName));
227 return true;
228 }
#define sCharacterCache
Definition CharacterCache.h:83
@ CHAR_INS_AURA
Definition CharacterDatabase.h:196
constexpr auto IN_MILLISECONDS
Definition Common.h:53
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::int32_t int32
Definition Define.h:103
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
#define sGroupMgr
Definition GroupMgr.h:51
@ LANG_PLAYER_NOT_FOUND
Definition Language.h:548
@ LANG_BAD_VALUE
Definition Language.h:151
bool normalizePlayerName(std::string &name)
Definition ObjectMgr.cpp:209
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition Util.cpp:73
uint32 TimeStringToSecs(const std::string ×tring)
Definition Util.cpp:163
Definition SpellAuras.h:87
int32 GetDuration() const
Definition SpellAuras.h:133
void SetDuration(int32 duration, bool withMods=false)
Definition SpellAuras.cpp:810
std::string playerLink(std::string const &name) const
Definition Chat.h:231
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
WorldSession * GetSession()
Definition Chat.h:242
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
Player * getSelectedPlayerOrSelf() const
Definition Chat.cpp:426
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
bool IsBattleground() const
Definition Map.h:303
Definition ObjectGuid.h:118
LowType GetCounter() const
Definition ObjectGuid.h:145
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition Player.cpp:2328
void LeaveBattleground(Battleground *bg=nullptr)
Definition Player.cpp:11269
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5859
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:15117
Map * GetMap() const
Definition Object.h:625
std::string const & GetName() const
Definition Object.h:528
@ LFG_SPELL_DUNGEON_DESERTER
Definition cs_deserter.cpp:37
@ BG_SPELL_DESERTER
Definition cs_deserter.cpp:38
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition ObjectAccessor.cpp:271