225 {
226 if (!playerTarget)
227 {
229 }
230
231 if (!playerTarget)
232 {
234 return false;
235 }
236
237 uint32 entry = quest->GetQuestId();
238
239 if (
Player* player = playerTarget->GetConnectedPlayer())
240 {
241
243 {
245 return false;
246 }
247
248
250 {
251 uint32 id = quest->RequiredItemId[x];
252 uint32 count = quest->RequiredItemCount[x];
253 if (!id || !count)
254 {
255 continue;
256 }
257
258 uint32 curItemCount = player->GetItemCount(
id,
true);
259
263 {
264 Item* item = player->StoreNewItem(dest,
id,
true);
265 player->SendNewItem(item, count - curItemCount, true, false);
266 }
267 }
268
269
271 {
272 int32 creature = quest->RequiredNpcOrGo[i];
273 uint32 creatureCount = quest->RequiredNpcOrGoCount[i];
274
275 if (creature > 0)
276 {
278 {
279 for (
uint16 z = 0; z < creatureCount; ++z)
280 {
282 }
283 }
284 }
285 else if (creature < 0)
286 {
287 for (
uint16 z = 0; z < creatureCount; ++z)
288 {
289 player->KillCreditGO(creature);
290 }
291 }
292 }
293
294
296 {
297 if (
uint32 reqPlayers = quest->GetPlayersSlain())
298 {
299 player->KilledPlayerCreditForQuest(reqPlayers, quest);
300 }
301 }
302
303
304 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
305 {
306 uint32 repValue = quest->GetRepObjectiveValue();
307 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
308 if (curRep < repValue)
309 {
311 {
312 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue));
313 }
314 }
315 }
316
317
318 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
319 {
320 uint32 repValue2 = quest->GetRepObjectiveValue2();
321 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
322 if (curRep < repValue2)
323 {
325 {
326 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue2));
327 }
328 }
329 }
330
331
332 int32 ReqOrRewMoney = quest->GetRewOrReqMoney(player->GetLevel());
333 if (ReqOrRewMoney < 0)
334 {
335 player->ModifyMoney(-ReqOrRewMoney);
336 }
337
338 player->CompleteQuest(entry);
339 }
340 else
341 {
344
345 if (!result)
346 {
348 return false;
349 }
350
352
353 typedef std::pair<uint32, uint32> items;
354 std::vector<items> questItems;
355
357 {
358 uint32 id = quest->RequiredItemId[x];
359 uint32 count = quest->RequiredItemCount[x];
360 if (!id || !count)
361 {
362 continue;
363 }
364
365 questItems.emplace_back(id, count);
366 }
367
368 if (!questItems.empty())
369 {
371
372 MailDraft draft(quest->GetTitle(), std::string());
373
374 for (auto const& itr : questItems)
375 {
377 {
379 draft.AddItem(item);
380 }
381 }
382
383 draft.SendMailTo(trans,
MailReceiver(
nullptr, guid), sender);
384 }
385
387
394
396 {
397 stmt->
SetData(index++, quest->RequiredNpcOrGoCount[i]);
398 }
399
401 {
402
404 }
405
407
408 trans->Append(stmt);
409
410
411 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
412 {
413 uint32 repValue = quest->GetRepObjectiveValue();
414
419
420 if (result)
421 {
422 Field* fields = result->Fetch();
424
425 if (curRep < repValue)
426 {
428 {
434 trans->Append(stmt);
435 }
436 }
437 }
438 }
439
440
441 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
442 {
443 uint32 repValue = quest->GetRepObjectiveValue();
444
449
450 if (result)
451 {
452 Field* fields = result->Fetch();
454
455 if (curRep < repValue)
456 {
458 {
464 trans->Append(stmt);
465 }
466 }
467 }
468 }
469
471 }
472
473
475 {
476
479 stmt->
SetData(1, playerTarget->GetGUID().GetCounter());
480
481
483 }
484
487 return true;
488 }
std::int32_t int32
Definition: Define.h:103
std::uint16_t uint16
Definition: Define.h:108
@ QUEST_FLAGS_EXPLORATION
Definition: QuestDef.h:134
@ QUEST_STATUS_NONE
Definition: QuestDef.h:100
@ QUEST_SPECIAL_FLAGS_PLAYER_KILL
Definition: QuestDef.h:179
@ LANG_COMMAND_QUEST_COMPLETE
Definition: Language.h:508
@ LANG_COMMAND_QUEST_NOTFOUND
Definition: Language.h:504
@ LANG_COMMAND_QUEST_NOT_FOUND_IN_LOG
Definition: Language.h:1122
@ CONFIG_QUEST_ENABLE_QUEST_TRACKER
Definition: IWorld.h:147
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:771
@ EQUIP_ERR_OK
Definition: Item.h:47
@ NULL_BAG
Definition: Item.h:40
@ NULL_SLOT
Definition: Item.h:41
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
@ MAIL_STATIONERY_GM
Definition: Mail.h:59
@ MAIL_NORMAL
Definition: Mail.h:37
@ CHAR_SEL_CHAR_REP_BY_FACTION
Definition: CharacterDatabase.h:399
@ CHAR_UPD_QUEST_TRACK_GM_COMPLETE
Definition: CharacterDatabase.h:502
@ CHAR_UPD_CHAR_REP_FACTION_CHANGE
Definition: CharacterDatabase.h:401
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:45
#define sWorld
Definition: World.h:443
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
Definition: CreatureData.h:186
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
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
LowType GetCounter() const
Definition: ObjectGuid.h:145
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
Definition: DBCStructure.h:906