Scripts/Commands: Fix .quest complete to properly work with PvP kill quests. Closes #16321.
This commit is contained in:
1 parent
b355c67994
commit
8bb732b951
3 files changed
+35
-20
No files matched your search
@@ -16379,10 +16379,8 @@ void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid /*= ObjectGuid::E
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -16398,27 +16396,38 @@ void Player::KilledPlayerCredit()
|
||||
{
|
||||
if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_PLAYER_KILL))
|
||||
{
|
||||
uint32 reqkill = qInfo->GetPlayersSlain();
|
||||
uint16 curkill = q_status.PlayerCount;
|
||||
|
||||
if (curkill < reqkill)
|
||||
{
|
||||
q_status.PlayerCount = curkill + addkillcount;
|
||||
|
||||
m_QuestStatusSave[questid] = QUEST_DEFAULT_SAVE_TYPE;
|
||||
|
||||
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<uint16>(reqKill - curKill, count);
|
||||
questStatus.PlayerCount = curKill + count;
|
||||
|
||||
m_QuestStatusSave[quest->GetQuestId()] = QUEST_DEFAULT_SAVE_TYPE;
|
||||
|
||||
SendQuestUpdateAddPlayer(quest, curKill, count);
|
||||
}
|
||||
|
||||
if (CanCompleteQuest(questId))
|
||||
CompleteQuest(questId);
|
||||
}
|
||||
|
||||
void Player::KillCreditGO(uint32 entry, ObjectGuid guid)
|
||||
{
|
||||
uint16 addCastCount = 1;
|
||||
|
||||
@@ -1384,7 +1384,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
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);
|
||||
|
||||
@@ -230,6 +230,11 @@ public:
|
||||
player->KillCreditGO(creature);
|
||||
}
|
||||
|
||||
// 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())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user