fix(Core/Script): 'Battle at Valhalas' quests done automatically (#7036)

* fix(Core/Script): 'Battle at Valhalas' quests done automatically

Battle at Valhalas series of quests, get to automatically complete

Closes #6753

* Refactoring

* Refactoring

* Refactoring PlayerUpdates.cpp

Co-authored-by: IntelligentQuantum <IntelligentQuantum@ProtonMail.Com>

* Refactoring PlayerQuest.cpp

Co-authored-by: IntelligentQuantum <IntelligentQuantum@ProtonMail.Com>

* Update src/server/scripts/Northrend/zone_icecrown.cpp

Co-authored-by: IntelligentQuantum <IntelligentQuantum@ProtonMail.Com>
This commit is contained in:
Artem
2021-09-25 17:59:49 +03:00
committed by GitHub
parent 4bf98a17de
commit 87a4e493a3
4 changed files with 56 additions and 32 deletions

View File

@@ -1444,6 +1444,7 @@ public:
void ReputationChanged2(FactionEntry const* factionEntry);
[[nodiscard]] bool HasQuestForItem(uint32 itemId, uint32 excludeQuestId = 0, bool turnIn = false, bool* showInLoot = nullptr) const;
[[nodiscard]] bool HasQuestForGO(int32 GOId) const;
[[nodiscard]] bool HasQuest(uint32 questId) const;
void UpdateForQuestWorldObjects();
[[nodiscard]] bool CanShareQuest(uint32 quest_id) const;

View File

@@ -84,6 +84,20 @@ void Player::PrepareQuestMenu(ObjectGuid guid)
}
}
bool Player::HasQuest(uint32 questId) const
{
for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i)
{
uint32 questid = GetQuestSlotQuestId(i);
if (questid == questId)
{
return true;
}
}
return false;
}
void Player::SendPreparedQuest(ObjectGuid guid)
{
QuestMenu& questMenu = PlayerTalkClass->GetQuestMenu();

View File

@@ -1813,8 +1813,7 @@ void Player::UpdateForQuestWorldObjects()
UpdateData udata;
WorldPacket packet;
for (GuidUnorderedSet::iterator itr = m_clientGUIDs.begin();
itr != m_clientGUIDs.end(); ++itr)
for (GuidUnorderedSet::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr)
{
if ((*itr).IsGameObject())
{
@@ -1823,8 +1822,7 @@ void Player::UpdateForQuestWorldObjects()
}
else if ((*itr).IsCreatureOrVehicle())
{
Creature* obj =
ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
Creature* obj = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
if (!obj)
continue;
@@ -1832,23 +1830,15 @@ void Player::UpdateForQuestWorldObjects()
if (!obj->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
continue;
SpellClickInfoMapBounds clickPair =
sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());
for (SpellClickInfoContainer::const_iterator _itr = clickPair.first;
_itr != clickPair.second; ++_itr)
SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());
for (SpellClickInfoContainer::const_iterator _itr = clickPair.first; _itr != clickPair.second; ++_itr)
{
//! This code doesn't look right, but it was logically converted
//! to condition system to do the exact same thing it did
//! before. It definitely needs to be overlooked for intended
//! functionality.
ConditionList conds =
sConditionMgr->GetConditionsForSpellClickEvent(
obj->GetEntry(), _itr->second.spellId);
//! This code doesn't look right, but it was logically converted to condition system to do the exact
//! same thing it did before. It definitely needs to be overlooked for intended functionality.
ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), _itr->second.spellId);
bool buildUpdateBlock = false;
for (ConditionList::const_iterator jtr = conds.begin();
jtr != conds.end() && !buildUpdateBlock; ++jtr)
if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED ||
(*jtr)->ConditionType == CONDITION_QUESTTAKEN)
for (ConditionList::const_iterator jtr = conds.begin(); jtr != conds.end() && !buildUpdateBlock; ++jtr)
if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED || (*jtr)->ConditionType == CONDITION_QUESTTAKEN)
buildUpdateBlock = true;
if (buildUpdateBlock)