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.
99 {
102
103 if (playerName)
104 {
106 {
109 return false;
110 }
111
113 if (guid)
114 {
116 }
117 else
118 {
119 if (time)
120 {
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 {
158 return false;
159 }
160
162
163 if (target)
164 {
167 {
168 handler->
PSendSysMessage(
"Player %s already has a longer %s Deserter active.", handler->
playerLink(*playerName), isInstance ?
"Instance" :
"Battleground");
169 return true;
170 }
171
172 aura = target->
AddAura(deserterSpell, target);
173 if (!aura)
174 {
177 return false;
178 }
180 }
181 else
182 {
183 int32 remainTime = 0;
185 {
186 Field* fields = result->Fetch();
187 remainTime = fields[0].
Get<
int32>();
188
190 {
191 handler->
PSendSysMessage(
"Player %s already has a longer %s Deserter active.", handler->
playerLink(*playerName), isInstance ?
"Instance" :
"Battleground");
192 return true;
193 }
195 }
196
202 stmt->
SetData(index++, deserterSpell);
212 stmt->
SetData(index++, isInstance ? 1800000 : 900000);
216 }
217
219 return true;
220 }
constexpr auto IN_MILLISECONDS
Definition: Common.h:62
std::int32_t int32
Definition: Define.h:104
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition: Util.cpp:74
uint32 TimeStringToSecs(const std::string ×tring)
Definition: Util.cpp:164
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
@ CHAR_INS_AURA
Definition: CharacterDatabase.h:196
#define sCharacterCache
Definition: CharacterCache.h:83
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:264
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:522
@ LANG_BAD_VALUE
Definition: Language.h:147
@ LFG_SPELL_DUNGEON_DESERTER
Definition: cs_deserter.cpp:35
@ BG_SPELL_DESERTER
Definition: cs_deserter.cpp:36
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:276
Definition: PreparedStatement.h:158
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
std::string playerLink(std::string const &name) const
Definition: Chat.h:111
WorldSession * GetSession()
Definition: Chat.h:122
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
Player * getSelectedPlayerOrSelf() const
Definition: Chat.cpp:345
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
std::string const & GetName() const
Definition: Object.h:446
Definition: ObjectGuid.h:120
LowType GetCounter() const
Definition: ObjectGuid.h:147
Definition: Player.h:1046
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5499
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:19031
Definition: SpellAuras.h:87
int32 GetDuration() const
Definition: SpellAuras.h:133
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:882