diff --git a/QuestPaths/quest-v1.json b/QuestPaths/quest-v1.json index c7ebd5fa..69b6c854 100644 --- a/QuestPaths/quest-v1.json +++ b/QuestPaths/quest-v1.json @@ -584,6 +584,7 @@ "AutoOnEnterArea", "AfterInteraction", "AfterItemUse", + "AfterAction", "OverworldEnemies" ] }, diff --git a/Questionable.Model/Questing/Converter/EnemySpawnTypeConverter.cs b/Questionable.Model/Questing/Converter/EnemySpawnTypeConverter.cs index e97faa4f..d37c5b7c 100644 --- a/Questionable.Model/Questing/Converter/EnemySpawnTypeConverter.cs +++ b/Questionable.Model/Questing/Converter/EnemySpawnTypeConverter.cs @@ -9,6 +9,7 @@ public sealed class EnemySpawnTypeConverter() : EnumConverter(V { { EEnemySpawnType.AfterInteraction, "AfterInteraction" }, { EEnemySpawnType.AfterItemUse, "AfterItemUse" }, + { EEnemySpawnType.AfterAction, "AfterAction" }, { EEnemySpawnType.AutoOnEnterArea, "AutoOnEnterArea" }, { EEnemySpawnType.OverworldEnemies, "OverworldEnemies" }, }; diff --git a/Questionable.Model/Questing/EEnemySpawnType.cs b/Questionable.Model/Questing/EEnemySpawnType.cs index 3c42b9f4..f119ea08 100644 --- a/Questionable.Model/Questing/EEnemySpawnType.cs +++ b/Questionable.Model/Questing/EEnemySpawnType.cs @@ -9,6 +9,7 @@ public enum EEnemySpawnType None = 0, AfterInteraction, AfterItemUse, + AfterAction, AutoOnEnterArea, OverworldEnemies, } diff --git a/Questionable/Controller/Steps/Interactions/Action.cs b/Questionable/Controller/Steps/Interactions/Action.cs index a91983b3..6d4da220 100644 --- a/Questionable/Controller/Steps/Interactions/Action.cs +++ b/Questionable/Controller/Steps/Interactions/Action.cs @@ -24,13 +24,18 @@ internal static class Action ArgumentNullException.ThrowIfNull(step.Action); - var task = new UseOnObject(step.DataId, step.Action.Value, gameFunctions, - loggerFactory.CreateLogger()); + var task = OnObject(step.DataId, step.Action.Value); if (step.Action.Value.RequiresMount()) return [task]; else return [mountFactory.Unmount(), task]; } + + public ITask OnObject(uint? dataId, EAction action) + { + return new UseOnObject(dataId, action, gameFunctions, + loggerFactory.CreateLogger()); + } } private sealed class UseOnObject( diff --git a/Questionable/Controller/Steps/Interactions/Combat.cs b/Questionable/Controller/Steps/Interactions/Combat.cs index 39909c56..6657da33 100644 --- a/Questionable/Controller/Steps/Interactions/Combat.cs +++ b/Questionable/Controller/Steps/Interactions/Combat.cs @@ -18,6 +18,7 @@ internal static class Combat Interact.Factory interactFactory, Mount.Factory mountFactory, UseItem.Factory useItemFactory, + Action.Factory actionFactory, QuestFunctions questFunctions) : ITaskFactory { public IEnumerable CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step) @@ -58,6 +59,19 @@ internal static class Combat break; } + case EEnemySpawnType.AfterAction: + { + ArgumentNullException.ThrowIfNull(step.DataId); + ArgumentNullException.ThrowIfNull(step.Action); + + if (!step.Action.Value.RequiresMount()) + yield return mountFactory.Unmount(); + yield return actionFactory.OnObject(step.DataId.Value, step.Action.Value); + yield return new WaitAtEnd.WaitDelay(TimeSpan.FromSeconds(1)); + yield return CreateTask(quest, sequence, step); + break; + } ; + case EEnemySpawnType.AutoOnEnterArea: if (step.CombatDelaySecondsAtStart == null) yield return new WaitAtEnd.WaitDelay(TimeSpan.FromSeconds(1));