mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Quests: Dont immediately update object visibility at PhaseShift and wait for the AI Hooks to be called in Player::RewardQuest (#28516)
This commit is contained in:
@@ -15051,15 +15051,70 @@ void Player::RewardQuest(Quest const* quest, LootItemType rewardType, uint32 rew
|
||||
UpdatePvPState();
|
||||
}
|
||||
|
||||
SendQuestUpdate(quest_id);
|
||||
|
||||
SendQuestGiverStatusMultiple();
|
||||
|
||||
bool conditionChanged = SendQuestUpdate(quest_id, false);
|
||||
|
||||
//lets remove flag for delayed teleports
|
||||
SetCanDelayTeleport(false);
|
||||
|
||||
bool canHaveNextQuest = !quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE) ? !questGiver->IsPlayer() : true;
|
||||
if (canHaveNextQuest)
|
||||
{
|
||||
switch (questGiver->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
{
|
||||
//For AutoSubmition was added plr case there as it almost same exclute AI script cases.
|
||||
// Send next quest
|
||||
if (Quest const* nextQuest = GetNextQuest(questGiver->GetGUID(), quest))
|
||||
{
|
||||
// Only send the quest to the player if the conditions are met
|
||||
if (CanTakeQuest(nextQuest, false))
|
||||
{
|
||||
if (nextQuest->IsAutoAccept() && CanAddQuest(nextQuest, true))
|
||||
AddQuestAndCheckCompletion(nextQuest, questGiver);
|
||||
|
||||
PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, questGiver->GetGUID(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerTalkClass->ClearMenus();
|
||||
if (Creature* creatureQGiver = questGiver->ToCreature())
|
||||
creatureQGiver->AI()->OnQuestReward(this, quest, rewardType, rewardId);
|
||||
break;
|
||||
}
|
||||
case TYPEID_GAMEOBJECT:
|
||||
{
|
||||
GameObject* questGiverGob = questGiver->ToGameObject();
|
||||
// Send next quest
|
||||
if (Quest const* nextQuest = GetNextQuest(questGiverGob->GetGUID(), quest))
|
||||
{
|
||||
// Only send the quest to the player if the conditions are met
|
||||
if (CanTakeQuest(nextQuest, false))
|
||||
{
|
||||
if (nextQuest->IsAutoAccept() && CanAddQuest(nextQuest, true))
|
||||
AddQuestAndCheckCompletion(nextQuest, questGiver);
|
||||
|
||||
PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, questGiverGob->GetGUID(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerTalkClass->ClearMenus();
|
||||
questGiverGob->AI()->OnQuestReward(this, quest, rewardType, rewardId);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sScriptMgr->OnQuestStatusChange(this, quest_id);
|
||||
sScriptMgr->OnQuestStatusChange(this, quest, oldStatus, QUEST_STATUS_REWARDED);
|
||||
|
||||
if (conditionChanged)
|
||||
UpdateObjectVisibility();
|
||||
}
|
||||
|
||||
void Player::SetRewardedQuest(uint32 quest_id)
|
||||
@@ -15750,7 +15805,7 @@ void Player::RemoveRewardedQuest(uint32 questId, bool update /*= true*/)
|
||||
SendQuestUpdate(questId);
|
||||
}
|
||||
|
||||
void Player::SendQuestUpdate(uint32 questId)
|
||||
bool Player::SendQuestUpdate(uint32 questId, bool updateVisiblity /*= true*/)
|
||||
{
|
||||
SpellAreaForQuestMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestMapBounds(questId);
|
||||
|
||||
@@ -15799,7 +15854,7 @@ void Player::SendQuestUpdate(uint32 questId)
|
||||
}
|
||||
|
||||
UpdateVisibleGameobjectsOrSpellClicks();
|
||||
PhasingHandler::OnConditionChange(this);
|
||||
return PhasingHandler::OnConditionChange(this, updateVisiblity);
|
||||
}
|
||||
|
||||
QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
|
||||
|
||||
@@ -1607,7 +1607,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
void SetQuestStatus(uint32 questId, QuestStatus status, bool update = true);
|
||||
void RemoveActiveQuest(uint32 questId, bool update = true);
|
||||
void RemoveRewardedQuest(uint32 questId, bool update = true);
|
||||
void SendQuestUpdate(uint32 questId);
|
||||
bool SendQuestUpdate(uint32 questId, bool updateVisiblity = true);
|
||||
QuestGiverStatus GetQuestDialogStatus(Object* questGiver);
|
||||
|
||||
void SetDailyQuestStatus(uint32 quest_id);
|
||||
|
||||
@@ -386,54 +386,6 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::Quest
|
||||
bg->HandleQuestComplete(packet.QuestID, _player);
|
||||
|
||||
_player->RewardQuest(quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID, object);
|
||||
|
||||
switch (object->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
{
|
||||
//For AutoSubmition was added plr case there as it almost same exclute AI script cases.
|
||||
// Send next quest
|
||||
if (Quest const* nextQuest = _player->GetNextQuest(packet.QuestGiverGUID, quest))
|
||||
{
|
||||
// Only send the quest to the player if the conditions are met
|
||||
if (_player->CanTakeQuest(nextQuest, false))
|
||||
{
|
||||
if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true))
|
||||
_player->AddQuestAndCheckCompletion(nextQuest, object);
|
||||
|
||||
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, packet.QuestGiverGUID, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
_player->PlayerTalkClass->ClearMenus();
|
||||
if (Creature* creatureQGiver = object->ToCreature())
|
||||
creatureQGiver->AI()->OnQuestReward(_player, quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID);
|
||||
break;
|
||||
}
|
||||
case TYPEID_GAMEOBJECT:
|
||||
{
|
||||
GameObject* questGiver = object->ToGameObject();
|
||||
// Send next quest
|
||||
if (Quest const* nextQuest = _player->GetNextQuest(packet.QuestGiverGUID, quest))
|
||||
{
|
||||
// Only send the quest to the player if the conditions are met
|
||||
if (_player->CanTakeQuest(nextQuest, false))
|
||||
{
|
||||
if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true))
|
||||
_player->AddQuestAndCheckCompletion(nextQuest, object);
|
||||
|
||||
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, packet.QuestGiverGUID, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
_player->PlayerTalkClass->ClearMenus();
|
||||
questGiver->AI()->OnQuestReward(_player, quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -366,7 +366,7 @@ void PhasingHandler::OnAreaChange(WorldObject* object)
|
||||
UpdateVisibilityIfNeeded(object, true, changed);
|
||||
}
|
||||
|
||||
void PhasingHandler::OnConditionChange(WorldObject* object)
|
||||
bool PhasingHandler::OnConditionChange(WorldObject* object, bool updateVisibility /*= true*/)
|
||||
{
|
||||
PhaseShift& phaseShift = object->GetPhaseShift();
|
||||
PhaseShift& suppressedPhaseShift = object->GetSuppressedPhaseShift();
|
||||
@@ -478,7 +478,8 @@ void PhasingHandler::OnConditionChange(WorldObject* object)
|
||||
unit->RemoveNotOwnSingleTargetAuras(true);
|
||||
}
|
||||
|
||||
UpdateVisibilityIfNeeded(object, true, changed);
|
||||
UpdateVisibilityIfNeeded(object, updateVisibility, changed);
|
||||
return changed;
|
||||
}
|
||||
|
||||
void PhasingHandler::SendToPlayer(Player const* player, PhaseShift const& phaseShift)
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
static void OnMapChange(WorldObject* object);
|
||||
static void OnAreaChange(WorldObject* object);
|
||||
static void OnConditionChange(WorldObject* object);
|
||||
static bool OnConditionChange(WorldObject* object, bool updateVisibility = true);
|
||||
|
||||
static void SendToPlayer(Player const* player, PhaseShift const& phaseShift);
|
||||
static void SendToPlayer(Player const* player);
|
||||
|
||||
Reference in New Issue
Block a user