222 {
223 if (!playerTarget)
224 {
226 }
227
228 if (!playerTarget)
229 {
231 return false;
232 }
233
234 uint32 entry = quest->GetQuestId();
235
236 if (
Player* player = playerTarget->GetConnectedPlayer())
237 {
238
240 {
242 return false;
243 }
244
245
247 {
248 uint32 id = quest->RequiredItemId[x];
249 uint32 count = quest->RequiredItemCount[x];
250 if (!id || !count)
251 {
252 continue;
253 }
254
255 uint32 curItemCount = player->GetItemCount(
id,
true);
256
260 {
261 Item* item = player->StoreNewItem(dest,
id,
true);
262 player->SendNewItem(item, count - curItemCount, true, false);
263 }
264 }
265
266
268 {
269 int32 creature = quest->RequiredNpcOrGo[i];
270 uint32 creatureCount = quest->RequiredNpcOrGoCount[i];
271
272 if (creature > 0)
273 {
275 {
276 for (
uint16 z = 0; z < creatureCount; ++z)
277 {
279 }
280 }
281 }
282 else if (creature < 0)
283 {
284 for (
uint16 z = 0; z < creatureCount; ++z)
285 {
286 player->KillCreditGO(creature);
287 }
288 }
289 }
290
291
293 {
294 if (
uint32 reqPlayers = quest->GetPlayersSlain())
295 {
296 player->KilledPlayerCreditForQuest(reqPlayers, quest);
297 }
298 }
299
300
301 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
302 {
303 uint32 repValue = quest->GetRepObjectiveValue();
304 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
305 if (curRep < repValue)
306 {
308 {
309 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue));
310 }
311 }
312 }
313
314
315 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
316 {
317 uint32 repValue2 = quest->GetRepObjectiveValue2();
318 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
319 if (curRep < repValue2)
320 {
322 {
323 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue2));
324 }
325 }
326 }
327
328
329 int32 ReqOrRewMoney = quest->GetRewOrReqMoney(player->GetLevel());
330 if (ReqOrRewMoney < 0)
331 {
332 player->ModifyMoney(-ReqOrRewMoney);
333 }
334
335 player->CompleteQuest(entry);
336 }
337 else
338 {
341
342 if (!result)
343 {
345 return false;
346 }
347
349
350 typedef std::pair<uint32, uint32> items;
351 std::vector<items> questItems;
352
354 {
355 uint32 id = quest->RequiredItemId[x];
356 uint32 count = quest->RequiredItemCount[x];
357 if (!id || !count)
358 {
359 continue;
360 }
361
362 questItems.emplace_back(id, count);
363 }
364
365 if (!questItems.empty())
366 {
368
369 MailDraft draft(quest->GetTitle(), std::string());
370
371 for (auto const& itr : questItems)
372 {
374 {
376 draft.AddItem(item);
377 }
378 }
379
380 draft.SendMailTo(trans,
MailReceiver(
nullptr, guid), sender);
381 }
382
384
391
393 {
394 stmt->
SetData(index++, quest->RequiredNpcOrGoCount[i]);
395 }
396
398 {
399
401 }
402
404
405 trans->Append(stmt);
406
407
408 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
409 {
410 uint32 repValue = quest->GetRepObjectiveValue();
411
416
417 if (result)
418 {
419 Field* fields = result->Fetch();
421
422 if (curRep < repValue)
423 {
425 {
431 trans->Append(stmt);
432 }
433 }
434 }
435 }
436
437
438 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
439 {
440 uint32 repValue = quest->GetRepObjectiveValue();
441
446
447 if (result)
448 {
449 Field* fields = result->Fetch();
451
452 if (curRep < repValue)
453 {
455 {
461 trans->Append(stmt);
462 }
463 }
464 }
465 }
466
468 }
469
470
472 {
473
476 stmt->
SetData(1, playerTarget->GetGUID().GetCounter());
477
478
480 }
481
484 return true;
485 }
@ CHAR_SEL_CHAR_REP_BY_FACTION
Definition CharacterDatabase.h:403
@ CHAR_UPD_QUEST_TRACK_GM_COMPLETE
Definition CharacterDatabase.h:508
@ CHAR_UPD_CHAR_REP_FACTION_CHANGE
Definition CharacterDatabase.h:405
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:517
@ LANG_COMMAND_QUEST_NOTFOUND
Definition Language.h:513
@ LANG_COMMAND_QUEST_NOT_FOUND_IN_LOG
Definition Language.h:1137
@ MAIL_STATIONERY_GM
Definition Mail.h:59
@ MAIL_NORMAL
Definition Mail.h:37
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:757
@ 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:114
#define sWorld
Definition World.h:317
Definition CreatureData.h:187
Definition DBCStructure.h:907