From ad060c69d20b3902130151942d740dc56da7a0e8 Mon Sep 17 00:00:00 2001 From: Sean Petrie Date: Sun, 1 Oct 2023 20:09:07 -0500 Subject: [PATCH] Release prep --- Repository.json | 2 +- .../AbilitySpecific/AdamantineMindTrigger.cs | 38 +++++++++++++++++++ .../TabletopTweaks-Core.csproj | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 TabletopTweaks-Core/NewComponents/AbilitySpecific/AdamantineMindTrigger.cs diff --git a/Repository.json b/Repository.json index 9232d78b..7240b687 100644 --- a/Repository.json +++ b/Repository.json @@ -2,7 +2,7 @@ "Releases": [ { "Id": "TabletopTweaks-Core", - "Version": "0.6.7" + "Version": "0.6.8" } ] } diff --git a/TabletopTweaks-Core/NewComponents/AbilitySpecific/AdamantineMindTrigger.cs b/TabletopTweaks-Core/NewComponents/AbilitySpecific/AdamantineMindTrigger.cs new file mode 100644 index 00000000..d00970e1 --- /dev/null +++ b/TabletopTweaks-Core/NewComponents/AbilitySpecific/AdamantineMindTrigger.cs @@ -0,0 +1,38 @@ +using Kingmaker.ElementsSystem; +using Kingmaker.EntitySystem.Stats; +using Kingmaker.PubSubSystem; +using Kingmaker.RuleSystem.Rules; +using Kingmaker.UnitLogic.Mechanics.Components; +using Kingmaker.UnitLogic.Mechanics; +using Kingmaker.UnitLogic; +using Kingmaker.Blueprints.Classes.Spells; +using Kingmaker.Blueprints.JsonSystem; + +namespace TabletopTweaks.Core.NewComponents.AbilitySpecific { + [TypeId("4e0c887660ff412fa3fe63524e475e90")] + public class AdamantineMindTrigger : UnitFactComponentDelegate, IInitiatorRulebookHandler, IRulebookHandler, ISubscriber, IInitiatorRulebookSubscriber { + public void OnEventAboutToTrigger(RuleSavingThrow evt) { + } + + public void OnEventDidTrigger(RuleSavingThrow evt) { + if (this.CheckConditions(evt) && base.Fact.MaybeContext != null) { + MechanicsContext maybeContext = base.Fact.MaybeContext; + using ((maybeContext != null) ? maybeContext.GetDataScope(base.Owner) : null) { + IFactContextOwner factContextOwner = base.Fact as IFactContextOwner; + if (factContextOwner != null) { + var NewSave = base.Context.TriggerRule(new RuleSavingThrow(evt.Reason.Context.MaybeCaster, SavingThrowType.Will, evt.DifficultyClass)); + if (!NewSave.IsPassed) { + factContextOwner.RunActionInContext(this.Action, evt.Reason.Context.MaybeCaster); + } + } + } + } + } + private bool CheckConditions(RuleSavingThrow evt) { + return evt.IsPassed && evt.Reason?.Context.MaybeCaster != null && (evt.Reason?.Context.SpellDescriptor & this.Descriptor) != SpellDescriptor.None; + } + + public SpellDescriptorWrapper Descriptor = SpellDescriptor.MindAffecting; + public ActionList Action; + } +} diff --git a/TabletopTweaks-Core/TabletopTweaks-Core.csproj b/TabletopTweaks-Core/TabletopTweaks-Core.csproj index 82c4e49c..f325bf37 100644 --- a/TabletopTweaks-Core/TabletopTweaks-Core.csproj +++ b/TabletopTweaks-Core/TabletopTweaks-Core.csproj @@ -166,6 +166,7 @@ +