From c81639bf56f04c0956bfa16815edce8eb7700b5b Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 24 Jun 2022 21:43:24 -0400 Subject: [PATCH] Core/Conditions: Added CONDITION_SCENE_IN_PROGRESS, useful for cases where you need phase things when a scene is in progress. Port From (https://github.com/TrinityCore/TrinityCore/commit/bd401af0912eca2c938b6dd93fdb7689b9146c89) --- Source/Framework/Constants/ConditionConst.cs | 1 + Source/Game/Conditions/Condition.cs | 9 +++++++++ Source/Game/Conditions/ConditionManager.cs | 12 +++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Source/Framework/Constants/ConditionConst.cs b/Source/Framework/Constants/ConditionConst.cs index 2083e97ec..b196492ff 100644 --- a/Source/Framework/Constants/ConditionConst.cs +++ b/Source/Framework/Constants/ConditionConst.cs @@ -74,6 +74,7 @@ namespace Framework.Constants TypeMask = 52, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask BattlePetCount = 53, // SpecieId count ComparisonType true if player has `count` of battle pet species ScenarioStep = 54, // ScenarioStepId 0 0 true if player is at scenario with current step equal to ScenarioStepID + SceneInProgress = 55, // SceneScriptPackageId 0 0 true if player is playing a scene with ScriptPackageId equal to given value Max } diff --git a/Source/Game/Conditions/Condition.cs b/Source/Game/Conditions/Condition.cs index e4f155de0..bcb265dd2 100644 --- a/Source/Game/Conditions/Condition.cs +++ b/Source/Game/Conditions/Condition.cs @@ -411,6 +411,12 @@ namespace Game.Conditions } break; } + case ConditionTypes.SceneInProgress: + { + if (player != null) + condMeets = player.GetSceneMgr().GetActiveSceneCount(ConditionValue1) > 0; + break; + } default: condMeets = false; break; @@ -527,6 +533,9 @@ namespace Game.Conditions case ConditionTypes.ScenarioStep: mask |= GridMapTypeMask.All; break; + case ConditionTypes.SceneInProgress: + mask |= GridMapTypeMask.Player; + break; default: Cypher.Assert(false, "Condition.GetSearcherTypeMaskForCondition - missing condition handling!"); break; diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index 0eb573378..1091982bf 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -1767,6 +1767,15 @@ namespace Game } break; } + case ConditionTypes.SceneInProgress: + { + if (!CliDB.SceneScriptPackageStorage.ContainsKey(cond.ConditionValue1)) + { + Log.outError(LogFilter.Sql, $"{cond.ToString(true)} has non existing SceneScriptPackageId in value1 ({cond.ConditionValue1}), skipped."); + return false; + } + break; + } default: Log.outError(LogFilter.Sql, $"{cond.ToString()} Invalid ConditionType in `condition` table, ignoring."); return false; @@ -2986,7 +2995,8 @@ namespace Game new ConditionTypeInfo("Object Entry or Guid", true, true, true), new ConditionTypeInfo("Object TypeMask", true, false, false), new ConditionTypeInfo("BattlePet Species Learned", true, true, true), - new ConditionTypeInfo("On Scenario Step", true, false, false) + new ConditionTypeInfo("On Scenario Step", true, false, false), + new ConditionTypeInfo("Scene In Progress", true, false, false) }; public struct ConditionTypeInfo