mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-09 00:08:01 +00:00
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:
@@ -1444,6 +1444,7 @@ public:
|
|||||||
void ReputationChanged2(FactionEntry const* factionEntry);
|
void ReputationChanged2(FactionEntry const* factionEntry);
|
||||||
[[nodiscard]] bool HasQuestForItem(uint32 itemId, uint32 excludeQuestId = 0, bool turnIn = false, bool* showInLoot = nullptr) const;
|
[[nodiscard]] bool HasQuestForItem(uint32 itemId, uint32 excludeQuestId = 0, bool turnIn = false, bool* showInLoot = nullptr) const;
|
||||||
[[nodiscard]] bool HasQuestForGO(int32 GOId) const;
|
[[nodiscard]] bool HasQuestForGO(int32 GOId) const;
|
||||||
|
[[nodiscard]] bool HasQuest(uint32 questId) const;
|
||||||
void UpdateForQuestWorldObjects();
|
void UpdateForQuestWorldObjects();
|
||||||
[[nodiscard]] bool CanShareQuest(uint32 quest_id) const;
|
[[nodiscard]] bool CanShareQuest(uint32 quest_id) const;
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
void Player::SendPreparedQuest(ObjectGuid guid)
|
||||||
{
|
{
|
||||||
QuestMenu& questMenu = PlayerTalkClass->GetQuestMenu();
|
QuestMenu& questMenu = PlayerTalkClass->GetQuestMenu();
|
||||||
|
|||||||
@@ -1813,8 +1813,7 @@ void Player::UpdateForQuestWorldObjects()
|
|||||||
|
|
||||||
UpdateData udata;
|
UpdateData udata;
|
||||||
WorldPacket packet;
|
WorldPacket packet;
|
||||||
for (GuidUnorderedSet::iterator itr = m_clientGUIDs.begin();
|
for (GuidUnorderedSet::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr)
|
||||||
itr != m_clientGUIDs.end(); ++itr)
|
|
||||||
{
|
{
|
||||||
if ((*itr).IsGameObject())
|
if ((*itr).IsGameObject())
|
||||||
{
|
{
|
||||||
@@ -1823,8 +1822,7 @@ void Player::UpdateForQuestWorldObjects()
|
|||||||
}
|
}
|
||||||
else if ((*itr).IsCreatureOrVehicle())
|
else if ((*itr).IsCreatureOrVehicle())
|
||||||
{
|
{
|
||||||
Creature* obj =
|
Creature* obj = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
|
||||||
ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1832,23 +1830,15 @@ void Player::UpdateForQuestWorldObjects()
|
|||||||
if (!obj->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
|
if (!obj->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SpellClickInfoMapBounds clickPair =
|
SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());
|
||||||
sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());
|
for (SpellClickInfoContainer::const_iterator _itr = clickPair.first; _itr != clickPair.second; ++_itr)
|
||||||
for (SpellClickInfoContainer::const_iterator _itr = clickPair.first;
|
|
||||||
_itr != clickPair.second; ++_itr)
|
|
||||||
{
|
{
|
||||||
//! This code doesn't look right, but it was logically converted
|
//! This code doesn't look right, but it was logically converted to condition system to do the exact
|
||||||
//! to condition system to do the exact same thing it did
|
//! same thing it did before. It definitely needs to be overlooked for intended functionality.
|
||||||
//! before. It definitely needs to be overlooked for intended
|
ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), _itr->second.spellId);
|
||||||
//! functionality.
|
|
||||||
ConditionList conds =
|
|
||||||
sConditionMgr->GetConditionsForSpellClickEvent(
|
|
||||||
obj->GetEntry(), _itr->second.spellId);
|
|
||||||
bool buildUpdateBlock = false;
|
bool buildUpdateBlock = false;
|
||||||
for (ConditionList::const_iterator jtr = conds.begin();
|
for (ConditionList::const_iterator jtr = conds.begin(); jtr != conds.end() && !buildUpdateBlock; ++jtr)
|
||||||
jtr != conds.end() && !buildUpdateBlock; ++jtr)
|
if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED || (*jtr)->ConditionType == CONDITION_QUESTTAKEN)
|
||||||
if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED ||
|
|
||||||
(*jtr)->ConditionType == CONDITION_QUESTTAKEN)
|
|
||||||
buildUpdateBlock = true;
|
buildUpdateBlock = true;
|
||||||
|
|
||||||
if (buildUpdateBlock)
|
if (buildUpdateBlock)
|
||||||
|
|||||||
@@ -114,6 +114,11 @@ public:
|
|||||||
uint32 currentQuest;
|
uint32 currentQuest;
|
||||||
|
|
||||||
void Reset() override
|
void Reset() override
|
||||||
|
{
|
||||||
|
ResetData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetData()
|
||||||
{
|
{
|
||||||
events.Reset();
|
events.Reset();
|
||||||
summons.DespawnAll();
|
summons.DespawnAll();
|
||||||
@@ -135,27 +140,27 @@ public:
|
|||||||
switch(currentQuest)
|
switch(currentQuest)
|
||||||
{
|
{
|
||||||
case QUEST_BFV_FALLEN_HEROES:
|
case QUEST_BFV_FALLEN_HEROES:
|
||||||
me->SummonCreature(NPC_ELDRETH, 8245.5f, 3522.7f, 627.67f, 3.11f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_ELDRETH, 8245.5f, 3522.7f, 627.67f, 3.11f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
me->SummonCreature(NPC_GENESS, 8217.45f, 3546.0f, 628.20f, 4.41f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_GENESS, 8217.45f, 3546.0f, 628.20f, 4.41f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
me->SummonCreature(NPC_JHADRAS, 8179.99f, 3523.72f, 628.1f, 5.95f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_JHADRAS, 8179.99f, 3523.72f, 628.1f, 5.95f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
me->SummonCreature(NPC_MASUD, 8184.97f, 3491.2f, 625.33f, 0.6f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_MASUD, 8184.97f, 3491.2f, 625.33f, 0.6f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
me->SummonCreature(NPC_RITH, 8213.5f, 3478.5f, 626.79f, 1.56f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_RITH, 8213.5f, 3478.5f, 626.79f, 1.56f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
me->SummonCreature(NPC_TALLA, 8238.30f, 3485.5f, 628.5f, 2.157f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_TALLA, 8238.30f, 3485.5f, 628.5f, 2.157f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
break;
|
break;
|
||||||
case QUEST_BFV_DARK_MASTER:
|
case QUEST_BFV_DARK_MASTER:
|
||||||
me->SummonCreature(NPC_DARK_MASTER, 8184.97f, 3491.2f, 625.33f, 0.6f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_DARK_MASTER, 8184.97f, 3491.2f, 625.33f, 0.6f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
break;
|
break;
|
||||||
case QUEST_BFV_SIGRID:
|
case QUEST_BFV_SIGRID:
|
||||||
me->SummonCreature(NPC_SIGRID, 8238.30f, 3485.5f, 628.5f, 2.157f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_SIGRID, 8238.30f, 3485.5f, 628.5f, 2.157f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
break;
|
break;
|
||||||
case QUEST_BFV_CARNAGE:
|
case QUEST_BFV_CARNAGE:
|
||||||
me->SummonCreature(NPC_CARNAGE, 8179.99f, 3523.72f, 628.1f, 5.95f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_CARNAGE, 8179.99f, 3523.72f, 628.1f, 5.95f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
break;
|
break;
|
||||||
case QUEST_BFV_THANE:
|
case QUEST_BFV_THANE:
|
||||||
me->SummonCreature(NPC_THANE, 8217.45f, 3546.0f, 628.20f, 4.41f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_THANE, 8217.45f, 3546.0f, 628.20f, 4.41f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
break;
|
break;
|
||||||
case QUEST_BFV_FINAL:
|
case QUEST_BFV_FINAL:
|
||||||
me->SummonCreature(NPC_PRINCE, 8245.5f, 3522.7f, 627.67f, 3.11f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
me->SummonCreature(NPC_PRINCE, 8245.5f, 3522.7f, 627.67f, 3.11f, TEMPSUMMON_MANUAL_DESPAWN, 30000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,7 +207,6 @@ public:
|
|||||||
me->MonsterYell("The unthinkable has happened... $N has slain Prince Sandoval!", LANG_UNIVERSAL, ObjectAccessor::GetPlayer(*me, playerGUID));
|
me->MonsterYell("The unthinkable has happened... $N has slain Prince Sandoval!", LANG_UNIVERSAL, ObjectAccessor::GetPlayer(*me, playerGUID));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
player->GroupEventHappens(quest, player);
|
player->GroupEventHappens(quest, player);
|
||||||
}
|
}
|
||||||
playerGUID2 = playerGUID;
|
playerGUID2 = playerGUID;
|
||||||
@@ -210,6 +214,18 @@ public:
|
|||||||
if (quest == QUEST_BFV_FINAL)
|
if (quest == QUEST_BFV_FINAL)
|
||||||
events.ScheduleEvent(EVENT_VALHALAS_THIRD, 7000);
|
events.ScheduleEvent(EVENT_VALHALAS_THIRD, 7000);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint32 quest = currentQuest;
|
||||||
|
if (Player* player = ObjectAccessor::GetPlayer(*me, playerGUID))
|
||||||
|
{
|
||||||
|
if (!player->HasQuest(quest))
|
||||||
|
{
|
||||||
|
ResetData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateAI(uint32 diff) override
|
void UpdateAI(uint32 diff) override
|
||||||
@@ -310,8 +326,11 @@ public:
|
|||||||
|
|
||||||
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override
|
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override
|
||||||
{
|
{
|
||||||
|
npc_battle_at_valhalasAI* vAI = CAST_AI(npc_battle_at_valhalas::npc_battle_at_valhalasAI, creature->AI());
|
||||||
|
vAI->ResetData();
|
||||||
|
|
||||||
creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
|
creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
|
||||||
if (npc_battle_at_valhalasAI* vAI = CAST_AI(npc_battle_at_valhalas::npc_battle_at_valhalasAI, creature->AI()))
|
if (vAI)
|
||||||
vAI->StartBattle(player->GetGUID(), quest->GetQuestId());
|
vAI->StartBattle(player->GetGUID(), quest->GetQuestId());
|
||||||
|
|
||||||
switch (quest->GetQuestId())
|
switch (quest->GetQuestId())
|
||||||
|
|||||||
Reference in New Issue
Block a user