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 @@ +