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.
100 {
103
104 if (playerName)
105 {
107 {
109 return false;
110 }
111
113 if (guid)
114 {
116 }
117 else
118 {
119 if (time)
120 {
122 return false;
123 }
124
125 time = playerName;
126 playerName = "";
127 }
128 }
129
130 if (!playerName || playerName->empty())
131 {
133 {
134 return false;
135 }
136
137 playerName = target->
GetName();
139 }
140
141 if (!time)
142 {
143 time = isInstance ? "30m" : "15m";
144 }
145
147
148 if (duration == 0)
149 {
150 duration = Acore::StringTo<int32>(*time).value_or(0);
151 }
152
153 if (duration == 0)
154 {
156 return false;
157 }
158
160
161 if (target)
162 {
165 {
166 handler->
PSendSysMessage(
"Player {} already has a longer {} Deserter active.", handler->
playerLink(*playerName), isInstance ?
"Instance" :
"Battleground");
167 return true;
168 }
169
170 aura = target->
AddAura(deserterSpell, target);
171 if (!aura)
172 {
174 return false;
175 }
177 }
178 else
179 {
180 int32 remainTime = 0;
182 {
183 Field* fields = result->Fetch();
184 remainTime = fields[0].
Get<
int32>();
185
187 {
188 handler->
PSendSysMessage(
"Player {} already has a longer {} Deserter active.", handler->
playerLink(*playerName), isInstance ?
"Instance" :
"Battleground");
189 return true;
190 }
192 }
193
199 stmt->
SetData(index++, deserterSpell);
209 stmt->
SetData(index++, isInstance ? 1800000 : 900000);
213 }
214
215 if (isInstance)
216 {
218 if (
Group* group =
sGroupMgr->GetGroupByGUID(groupId.GetCounter()))
219 if (group->isLFGGroup())
221 }
224
225 handler->
PSendSysMessage(
"{} of {} Deserter has been added to player {}.",
secsToTimeString(duration), isInstance ?
"Instance" :
"Battleground", handler->playerLink(*playerName));
226 return true;
227 }
#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:545
@ LANG_BAD_VALUE
Definition Language.h:148
bool normalizePlayerName(std::string &name)
Definition ObjectMgr.cpp:208
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:211
WorldSession * GetSession()
Definition Chat.h:242
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
Player * getSelectedPlayerOrSelf() const
Definition Chat.cpp:418
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:301
Definition ObjectGuid.h:118
LowType GetCounter() const
Definition ObjectGuid.h:145
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition Player.cpp:2330
void LeaveBattleground(Battleground *bg=nullptr)
Definition Player.cpp:11287
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:5711
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:19125
Map * GetMap() const
Definition Object.h:620
std::string const & GetName() const
Definition Object.h:524
@ LFG_SPELL_DUNGEON_DESERTER
Definition cs_deserter.cpp:36
@ BG_SPELL_DESERTER
Definition cs_deserter.cpp:37
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition ObjectAccessor.cpp:271