219 {
220 if (!playerTarget)
221 {
223 }
224
225 if (!playerTarget)
226 {
228 return false;
229 }
230
231 uint32 entry = quest->GetQuestId();
232
233 if (
Player* player = playerTarget->GetConnectedPlayer())
234 {
235
237 {
239 return false;
240 }
241
242
244 {
245 uint32 id = quest->RequiredItemId[x];
246 uint32 count = quest->RequiredItemCount[x];
247 if (!id || !count)
248 {
249 continue;
250 }
251
252 uint32 curItemCount = player->GetItemCount(
id,
true);
253
257 {
258 Item* item = player->StoreNewItem(dest,
id,
true);
259 player->SendNewItem(item, count - curItemCount, true, false);
260 }
261 }
262
263
265 {
266 int32 creature = quest->RequiredNpcOrGo[i];
267 uint32 creatureCount = quest->RequiredNpcOrGoCount[i];
268
269 if (creature > 0)
270 {
272 {
273 for (
uint16 z = 0; z < creatureCount; ++z)
274 {
276 }
277 }
278 }
279 else if (creature < 0)
280 {
281 for (
uint16 z = 0; z < creatureCount; ++z)
282 {
283 player->KillCreditGO(creature);
284 }
285 }
286 }
287
288
290 {
291 if (
uint32 reqPlayers = quest->GetPlayersSlain())
292 {
293 player->KilledPlayerCreditForQuest(reqPlayers, quest);
294 }
295 }
296
297
298 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
299 {
300 uint32 repValue = quest->GetRepObjectiveValue();
301 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
302 if (curRep < repValue)
303 {
305 {
306 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue));
307 }
308 }
309 }
310
311
312 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
313 {
314 uint32 repValue2 = quest->GetRepObjectiveValue2();
315 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
316 if (curRep < repValue2)
317 {
319 {
320 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue2));
321 }
322 }
323 }
324
325
326 int32 ReqOrRewMoney = quest->GetRewOrReqMoney(player->GetLevel());
327 if (ReqOrRewMoney < 0)
328 {
329 player->ModifyMoney(-ReqOrRewMoney);
330 }
331
332 player->CompleteQuest(entry);
333 }
334 else
335 {
338
339 if (!result)
340 {
342 return false;
343 }
344
346
347 typedef std::pair<uint32, uint32> items;
348 std::vector<items> questItems;
349
351 {
352 uint32 id = quest->RequiredItemId[x];
353 uint32 count = quest->RequiredItemCount[x];
354 if (!id || !count)
355 {
356 continue;
357 }
358
359 questItems.emplace_back(id, count);
360 }
361
362 if (!questItems.empty())
363 {
365
366 MailDraft draft(quest->GetTitle(), std::string());
367
368 for (auto const& itr : questItems)
369 {
371 {
373 draft.AddItem(item);
374 }
375 }
376
377 draft.SendMailTo(trans,
MailReceiver(
nullptr, guid), sender);
378 }
379
381
388
390 {
391 stmt->
SetData(index++, quest->RequiredNpcOrGoCount[i]);
392 }
393
395 {
396
398 }
399
401
402 trans->Append(stmt);
403
404
405 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
406 {
407 uint32 repValue = quest->GetRepObjectiveValue();
408
413
414 if (result)
415 {
416 Field* fields = result->Fetch();
418
419 if (curRep < repValue)
420 {
422 {
428 trans->Append(stmt);
429 }
430 }
431 }
432 }
433
434
435 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
436 {
437 uint32 repValue = quest->GetRepObjectiveValue();
438
443
444 if (result)
445 {
446 Field* fields = result->Fetch();
448
449 if (curRep < repValue)
450 {
452 {
458 trans->Append(stmt);
459 }
460 }
461 }
462 }
463
465 }
466
467
469 {
470
473 stmt->
SetData(1, playerTarget->GetGUID().GetCounter());
474
475
477 }
478
481 return true;
482 }
@ 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:1133
@ MAIL_STATIONERY_GM
Definition Mail.h:59
@ MAIL_NORMAL
Definition Mail.h:37
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:758
@ 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:107
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:316
Definition CreatureData.h:186
Definition DBCStructure.h:907