From: Liza Carvelli Date: Thu, 19 Jun 2025 17:27:17 +0000 (+0200) Subject: Extend combat step to enable triggering by using an item on the ground X-Git-Tag: v5.18~3 X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;h=8795c5e32aa6b38faa3f9a99e0eefcba40ade519;p=Questionable.git Extend combat step to enable triggering by using an item on the ground --- diff --git a/Questionable/Controller/Steps/Interactions/Combat.cs b/Questionable/Controller/Steps/Interactions/Combat.cs index e63058a8..bb700f62 100644 --- a/Questionable/Controller/Steps/Interactions/Combat.cs +++ b/Questionable/Controller/Steps/Interactions/Combat.cs @@ -42,15 +42,31 @@ internal static class Combat break; case EEnemySpawnType.AfterItemUse: - ArgumentNullException.ThrowIfNull(step.DataId); ArgumentNullException.ThrowIfNull(step.ItemId); if (step.GroundTarget == true) - yield return new UseItem.UseOnGround(quest.Id, step.DataId.Value, step.ItemId.Value, + { + if (step.DataId != null) + yield return new UseItem.UseOnGround(quest.Id, step.DataId.Value, step.ItemId.Value, + step.CompletionQuestVariablesFlags, true); + else + { + ArgumentNullException.ThrowIfNull(step.Position); + yield return new UseItem.UseOnPosition(quest.Id, step.Position.Value, step.ItemId.Value, + step.CompletionQuestVariablesFlags, true); + } + } + else if (step.DataId != null) + { + yield return new UseItem.UseOnObject(quest.Id, step.DataId.Value, step.ItemId.Value, step.CompletionQuestVariablesFlags, true); + } else - yield return new UseItem.UseOnObject(quest.Id, step.DataId.Value, step.ItemId.Value, + { + yield return new UseItem.UseOnSelf(quest.Id, step.ItemId.Value, step.CompletionQuestVariablesFlags, true); + } + yield return new WaitAtEnd.WaitDelay(TimeSpan.FromSeconds(1)); yield return CreateTask(quest, sequence, step); break; diff --git a/Questionable/Controller/Steps/Interactions/UseItem.cs b/Questionable/Controller/Steps/Interactions/UseItem.cs index 25799a76..ce9cfd45 100644 --- a/Questionable/Controller/Steps/Interactions/UseItem.cs +++ b/Questionable/Controller/Steps/Interactions/UseItem.cs @@ -234,11 +234,9 @@ internal static class UseItem ElementId? QuestId, Vector3 Position, uint ItemId, - IList CompletionQuestVariablesFlags) - : IUseItemBase + IList CompletionQuestVariablesFlags, + bool StartingCombat = false) : IUseItemBase { - public bool StartingCombat => false; - public override string ToString() => $"UseItem({ItemId} on ground at {Position.ToString("G", CultureInfo.InvariantCulture)})"; } @@ -276,9 +274,9 @@ internal static class UseItem internal sealed record UseOnSelf( ElementId? QuestId, uint ItemId, - IList CompletionQuestVariablesFlags) : IUseItemBase + IList CompletionQuestVariablesFlags, + bool StartingCombat = false) : IUseItemBase { - public bool StartingCombat => false; public override string ToString() => $"UseItem({ItemId})"; }