218 {
219 if (!playerTarget)
220 {
222 }
223
224 if (!playerTarget)
225 {
227 return false;
228 }
229
230 uint32 entry = quest->GetQuestId();
231
232 if (
Player* player = playerTarget->GetConnectedPlayer())
233 {
234
236 {
238 return false;
239 }
240
241
243 {
244 uint32 id = quest->RequiredItemId[x];
245 uint32 count = quest->RequiredItemCount[x];
246 if (!id || !count)
247 {
248 continue;
249 }
250
251 uint32 curItemCount = player->GetItemCount(
id,
true);
252
256 {
257 Item* item = player->StoreNewItem(dest,
id,
true);
258 player->SendNewItem(item, count - curItemCount, true, false);
259 }
260 }
261
262
264 {
265 int32 creature = quest->RequiredNpcOrGo[i];
266 uint32 creatureCount = quest->RequiredNpcOrGoCount[i];
267
268 if (creature > 0)
269 {
271 {
272 for (
uint16 z = 0; z < creatureCount; ++z)
273 {
275 }
276 }
277 }
278 else if (creature < 0)
279 {
280 for (
uint16 z = 0; z < creatureCount; ++z)
281 {
282 player->KillCreditGO(creature);
283 }
284 }
285 }
286
287
289 {
290 if (
uint32 reqPlayers = quest->GetPlayersSlain())
291 {
292 player->KilledPlayerCreditForQuest(reqPlayers, quest);
293 }
294 }
295
296
297 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
298 {
299 uint32 repValue = quest->GetRepObjectiveValue();
300 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
301 if (curRep < repValue)
302 {
304 {
305 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue));
306 }
307 }
308 }
309
310
311 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
312 {
313 uint32 repValue2 = quest->GetRepObjectiveValue2();
314 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
315 if (curRep < repValue2)
316 {
318 {
319 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue2));
320 }
321 }
322 }
323
324
325 int32 ReqOrRewMoney = quest->GetRewOrReqMoney(player->GetLevel());
326 if (ReqOrRewMoney < 0)
327 {
328 player->ModifyMoney(-ReqOrRewMoney);
329 }
330
331 player->CompleteQuest(entry);
332 }
333 else
334 {
337
338 if (!result)
339 {
341 return false;
342 }
343
345
346 typedef std::pair<uint32, uint32> items;
347 std::vector<items> questItems;
348
350 {
351 uint32 id = quest->RequiredItemId[x];
352 uint32 count = quest->RequiredItemCount[x];
353 if (!id || !count)
354 {
355 continue;
356 }
357
358 questItems.emplace_back(id, count);
359 }
360
361 if (!questItems.empty())
362 {
364
365 MailDraft draft(quest->GetTitle(), std::string());
366
367 for (auto const& itr : questItems)
368 {
370 {
372 draft.AddItem(item);
373 }
374 }
375
376 draft.SendMailTo(trans,
MailReceiver(
nullptr, guid), sender);
377 }
378
380
387
389 {
390 stmt->
SetData(index++, quest->RequiredNpcOrGoCount[i]);
391 }
392
394 {
395
397 }
398
400
401 trans->Append(stmt);
402
403
404 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
405 {
406 uint32 repValue = quest->GetRepObjectiveValue();
407
412
413 if (result)
414 {
415 Field* fields = result->Fetch();
417
418 if (curRep < repValue)
419 {
421 {
427 trans->Append(stmt);
428 }
429 }
430 }
431 }
432
433
434 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
435 {
436 uint32 repValue = quest->GetRepObjectiveValue();
437
442
443 if (result)
444 {
445 Field* fields = result->Fetch();
447
448 if (curRep < repValue)
449 {
451 {
457 trans->Append(stmt);
458 }
459 }
460 }
461 }
462
464 }
465
466
468 {
469
472 stmt->
SetData(1, playerTarget->GetGUID().GetCounter());
473
474
476 }
477
480 return true;
481 }
@ CHAR_SEL_CHAR_REP_BY_FACTION
Definition CharacterDatabase.h:401
@ CHAR_UPD_QUEST_TRACK_GM_COMPLETE
Definition CharacterDatabase.h:504
@ CHAR_UPD_CHAR_REP_FACTION_CHANGE
Definition CharacterDatabase.h:403
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition DatabaseEnvFwd.h:69
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
std::int32_t int32
Definition Define.h:103
std::uint16_t uint16
Definition Define.h:108
@ EQUIP_ERR_OK
Definition Item.h:47
@ NULL_BAG
Definition Item.h:40
@ NULL_SLOT
Definition Item.h:41
@ LANG_COMMAND_QUEST_COMPLETE
Definition Language.h:514
@ LANG_COMMAND_QUEST_NOTFOUND
Definition Language.h:510
@ LANG_COMMAND_QUEST_NOT_FOUND_IN_LOG
Definition Language.h:1130
@ MAIL_STATIONERY_GM
Definition Mail.h:59
@ MAIL_NORMAL
Definition Mail.h:37
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:778
@ QUEST_FLAGS_EXPLORATION
Definition QuestDef.h:134
@ QUEST_STATUS_NONE
Definition QuestDef.h:100
@ QUEST_SPECIAL_FLAGS_PLAYER_KILL
Definition QuestDef.h:179
@ CONFIG_QUEST_ENABLE_QUEST_TRACKER
Definition WorldConfig.h:105
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
static Item * CreateItem(uint32 item, uint32 count, Player const *player=nullptr, bool clone=false, uint32 randomPropertyId=0)
Definition Item.cpp:1087
virtual void SaveToDB(CharacterDatabaseTransaction trans)
Definition Item.cpp:336
LowType GetCounter() const
Definition ObjectGuid.h:145
static ObjectGuid const Empty
Definition ObjectGuid.h:120
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
#define sWorld
Definition World.h:320
Definition CreatureData.h:186
Definition DBCStructure.h:907