diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index adb9fc9f4..b87c4c058 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1473,7 +1473,8 @@ public: void ItemRemovedQuestCheck(uint32 entry, uint32 count); void KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid); void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); - void KilledPlayerCredit(); + void KilledPlayerCredit(uint16 count = 1); + void KilledPlayerCreditForQuest(uint16 count, Quest const* quest); void KillCreditGO(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); void TalkedToCreature(uint32 entry, ObjectGuid guid); void MoneyChanged(uint32 value); diff --git a/src/server/game/Entities/Player/PlayerQuest.cpp b/src/server/game/Entities/Player/PlayerQuest.cpp index 2d817f3c6..ead2efd4d 100644 --- a/src/server/game/Entities/Player/PlayerQuest.cpp +++ b/src/server/game/Entities/Player/PlayerQuest.cpp @@ -1961,19 +1961,22 @@ void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid) } } -void Player::KilledPlayerCredit() +void Player::KilledPlayerCredit(uint16 count) { - uint16 addkillcount = 1; - for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); if (!questid) + { continue; + } Quest const* qInfo = sObjectMgr->GetQuestTemplate(questid); if (!qInfo) + { continue; + } + // just if !ingroup || !noraidgroup || raidgroup QuestStatusData& q_status = m_QuestStatus[questid]; if (q_status.Status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid(GetMap()->GetDifficulty()))) @@ -1981,27 +1984,44 @@ void Player::KilledPlayerCredit() // Xinef: PvP Killing quest require player to be in same zone as quest zone (only 2 quests so no doubt, can be extended to conditions in cata ;s) if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_PLAYER_KILL) && (qInfo->GetZoneOrSort() >= 0 && GetZoneId() == uint32(qInfo->GetZoneOrSort()))) { - uint32 reqkill = qInfo->GetPlayersSlain(); - uint16 curkill = q_status.PlayerCount; - - if (curkill < reqkill) - { - q_status.PlayerCount = curkill + addkillcount; - - m_QuestStatusSave[questid] = true; - - SendQuestUpdateAddPlayer(qInfo, curkill, addkillcount); - } - - if (CanCompleteQuest(questid)) - CompleteQuest(questid); - - break; + KilledPlayerCreditForQuest(count, qInfo); + break; // there is only one quest per zone } } } } +void Player::KilledPlayerCreditForQuest(uint16 count, Quest const* quest) +{ + uint32 const questId = quest->GetQuestId(); + + auto it = m_QuestStatus.find(questId); + if (it == m_QuestStatus.end()) + { + return; + } + + QuestStatusData& questStatus = it->second; + + uint16 curKill = questStatus.PlayerCount; + uint32 reqKill = quest->GetPlayersSlain(); + + if (curKill < reqKill) + { + count = std::min(reqKill - curKill, count); + questStatus.PlayerCount = curKill + count; + + m_QuestStatusSave[quest->GetQuestId()] = true; + + SendQuestUpdateAddPlayer(quest, curKill, count); + } + + if (CanCompleteQuest(questId)) + { + CompleteQuest(questId); + } +} + void Player::KillCreditGO(uint32 entry, ObjectGuid guid) { uint16 addCastCount = 1; diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 7f2173058..6cb46ed49 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -298,6 +298,15 @@ public: } } + // player kills + if (quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_PLAYER_KILL)) + { + if (uint32 reqPlayers = quest->GetPlayersSlain()) + { + player->KilledPlayerCreditForQuest(reqPlayers, quest); + } + } + // If the quest requires reputation to complete if (uint32 repFaction = quest->GetRepObjectiveFaction()) {