221 {
222 if (!playerTarget)
223 {
225 }
226
227 if (!playerTarget)
228 {
230 return false;
231 }
232
233 uint32 entry = quest->GetQuestId();
234
235 if (
Player* player = playerTarget->GetConnectedPlayer())
236 {
237
239 {
241 return false;
242 }
243
244
246 {
247 uint32 id = quest->RequiredItemId[x];
248 uint32 count = quest->RequiredItemCount[x];
249 if (!id || !count)
250 {
251 continue;
252 }
253
254 uint32 curItemCount = player->GetItemCount(
id,
true);
255
259 {
260 Item* item = player->StoreNewItem(dest,
id,
true);
261 player->SendNewItem(item, count - curItemCount, true, false);
262 }
263 }
264
265
267 {
268 int32 creature = quest->RequiredNpcOrGo[i];
269 uint32 creatureCount = quest->RequiredNpcOrGoCount[i];
270
271 if (creature > 0)
272 {
274 {
275 for (
uint16 z = 0; z < creatureCount; ++z)
276 {
278 }
279 }
280 }
281 else if (creature < 0)
282 {
283 for (
uint16 z = 0; z < creatureCount; ++z)
284 {
285 player->KillCreditGO(creature);
286 }
287 }
288 }
289
290
292 {
293 if (
uint32 reqPlayers = quest->GetPlayersSlain())
294 {
295 player->KilledPlayerCreditForQuest(reqPlayers, quest);
296 }
297 }
298
299
300 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
301 {
302 uint32 repValue = quest->GetRepObjectiveValue();
303 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
304 if (curRep < repValue)
305 {
307 {
308 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue));
309 }
310 }
311 }
312
313
314 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
315 {
316 uint32 repValue2 = quest->GetRepObjectiveValue2();
317 uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
318 if (curRep < repValue2)
319 {
321 {
322 player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue2));
323 }
324 }
325 }
326
327
328 int32 ReqOrRewMoney = quest->GetRewOrReqMoney(player->GetLevel());
329 if (ReqOrRewMoney < 0)
330 {
331 player->ModifyMoney(-ReqOrRewMoney);
332 }
333
334 player->CompleteQuest(entry);
335 }
336 else
337 {
340
341 if (!result)
342 {
344 return false;
345 }
346
348
349 typedef std::pair<uint32, uint32> items;
350 std::vector<items> questItems;
351
353 {
354 uint32 id = quest->RequiredItemId[x];
355 uint32 count = quest->RequiredItemCount[x];
356 if (!id || !count)
357 {
358 continue;
359 }
360
361 questItems.emplace_back(id, count);
362 }
363
364 if (!questItems.empty())
365 {
367
368 MailDraft draft(quest->GetTitle(), std::string());
369
370 for (auto const& itr : questItems)
371 {
373 {
375 draft.AddItem(item);
376 }
377 }
378
379 draft.SendMailTo(trans,
MailReceiver(
nullptr, guid), sender);
380 }
381
383
390
392 {
393 stmt->
SetData(index++, quest->RequiredNpcOrGoCount[i]);
394 }
395
397 {
398
400 }
401
403
404 trans->Append(stmt);
405
406
407 if (
uint32 repFaction = quest->GetRepObjectiveFaction())
408 {
409 uint32 repValue = quest->GetRepObjectiveValue();
410
415
416 if (result)
417 {
418 Field* fields = result->Fetch();
420
421 if (curRep < repValue)
422 {
424 {
430 trans->Append(stmt);
431 }
432 }
433 }
434 }
435
436
437 if (
uint32 repFaction = quest->GetRepObjectiveFaction2())
438 {
439 uint32 repValue = quest->GetRepObjectiveValue();
440
445
446 if (result)
447 {
448 Field* fields = result->Fetch();
450
451 if (curRep < repValue)
452 {
454 {
460 trans->Append(stmt);
461 }
462 }
463 }
464 }
465
467 }
468
469
471 {
472
475 stmt->
SetData(1, playerTarget->GetGUID().GetCounter());
476
477
479 }
480
483 return true;
484 }
@ CHAR_SEL_CHAR_REP_BY_FACTION
Definition CharacterDatabase.h:401
@ CHAR_UPD_QUEST_TRACK_GM_COMPLETE
Definition CharacterDatabase.h:506
@ 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:1134
@ 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:109
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:316
Definition CreatureData.h:187
Definition DBCStructure.h:907