mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Scenarios: Fix bad criteria evaluation in scenarios (#27881)
* Adjust Scenario criteria evaluation process so that entire criteria trees are not completed when a single child tree is completed.
This commit is contained in:
@@ -175,38 +175,41 @@ bool Scenario::CanUpdateCriteriaTree(Criteria const * /*criteria*/, CriteriaTree
|
||||
|
||||
bool Scenario::CanCompleteCriteriaTree(CriteriaTree const* tree)
|
||||
{
|
||||
ScenarioStepEntry const* step = tree->ScenarioStep;
|
||||
if (!step)
|
||||
ScenarioStepEntry const* step = ASSERT_NOTNULL(tree->ScenarioStep);
|
||||
ScenarioStepState const state = GetStepState(step);
|
||||
if (state == SCENARIO_STEP_DONE)
|
||||
return false;
|
||||
|
||||
if (step->ScenarioID != _data->Entry->ID)
|
||||
ScenarioStepEntry const* currentStep = GetStep();
|
||||
if (!currentStep)
|
||||
return false;
|
||||
|
||||
if (step->IsBonusObjective())
|
||||
return !IsComplete();
|
||||
if (!step->IsBonusObjective())
|
||||
if (step != currentStep)
|
||||
return false;
|
||||
|
||||
if (step != GetStep())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return CriteriaHandler::CanCompleteCriteriaTree(tree);
|
||||
}
|
||||
|
||||
void Scenario::CompletedCriteriaTree(CriteriaTree const* tree, Player* /*referencePlayer*/)
|
||||
{
|
||||
ScenarioStepEntry const* step = tree->ScenarioStep;
|
||||
if (!step)
|
||||
return;
|
||||
|
||||
if (!step->IsBonusObjective() && step != GetStep())
|
||||
return;
|
||||
|
||||
if (GetStepState(step) == SCENARIO_STEP_DONE)
|
||||
ScenarioStepEntry const* step = ASSERT_NOTNULL(tree->ScenarioStep);
|
||||
if (!IsCompletedStep(step))
|
||||
return;
|
||||
|
||||
SetStepState(step, SCENARIO_STEP_DONE);
|
||||
CompleteStep(step);
|
||||
}
|
||||
|
||||
bool Scenario::IsCompletedStep(ScenarioStepEntry const* step)
|
||||
{
|
||||
CriteriaTree const* tree = sCriteriaMgr->GetCriteriaTree(step->Criteriatreeid);
|
||||
if (!tree)
|
||||
return false;
|
||||
|
||||
return IsCompletedCriteriaTree(tree);
|
||||
}
|
||||
|
||||
void Scenario::SendPacket(WorldPacket const* data) const
|
||||
{
|
||||
for (ObjectGuid guid : _players)
|
||||
|
||||
@@ -64,6 +64,7 @@ class TC_GAME_API Scenario : public CriteriaHandler
|
||||
virtual void Update(uint32 /*diff*/) { }
|
||||
|
||||
bool IsComplete();
|
||||
bool IsCompletedStep(ScenarioStepEntry const* step);
|
||||
void SetStepState(ScenarioStepEntry const* step, ScenarioStepState state) { _stepStates[step] = state; }
|
||||
ScenarioEntry const* GetEntry() const;
|
||||
ScenarioStepState GetStepState(ScenarioStepEntry const* step);
|
||||
|
||||
Reference in New Issue
Block a user