Exemplo n.º 1
0
        public void ruleSavingThrowTriggered(RuleSavingThrow evt)
        {
            var context = evt.Reason?.Context;

            if (context == null)
            {
                return;
            }

            var caster = context.MaybeCaster;

            if (caster == null)
            {
                return;
            }

            if (caster != this.Owner.Unit)
            {
                return;
            }

            if (context?.SourceAbility.GetComponent <DisbeliefSpell>() == null)
            {
                context = ShadowSpells.extractMainContext(context, caster);
                if (context == null)
                {
                    return;
                }

                if (!ShadowSpells.is_making_disbelief_save)
                {
                    return;
                }
            }


            if (context.SpellSchool == school &&
                (save_type == SavingThrowType.Unknown || evt.Type == save_type) &&
                (context?.SourceAbility.GetComponent <DisbeliefSpell>() != null || !evt.Initiator.Ensure <UnitPartDisbelief>().attemptedDisbelief(context))
                )
            {
                var cl_check = RulebookEvent.Dice.D(new DiceFormula(1, DiceType.D20)) + evt.Reason.Context.Params.CasterLevel;
                if (cl_check > evt.DifficultyClass)
                {
                    Common.AddBattleLogMessage("Changing spell DC for " + evt.Initiator.CharacterName + $" form {evt.DifficultyClass} to {cl_check} due to {this.Fact.Name}");
                    Helpers.SetField(evt, "DifficultyClass", cl_check);
                }
            }
        }
Exemplo n.º 2
0
        static public MechanicsContext extractMainContext(MechanicsContext context, UnitEntityData context_caster)
        {
            var main_context = context?.SourceAbilityContext;

            var caster = context_caster ?? main_context?.MaybeCaster;

            var summoned_context = ShadowSpells.getShadowBuff(caster?.Descriptor)?.MaybeContext?.SourceAbilityContext;

            if (summoned_context != null)
            {
                return(summoned_context);
            }
            var parent_context = caster?.Get <UnitPartUseShadowContext>()?.maybeGetShadowContext(main_context);

            return(parent_context ?? main_context);
        }
Exemplo n.º 3
0
        public override void OnEventAboutToTrigger(RuleSavingThrow evt)
        {
            var context = evt.Reason?.Context;

            if (context == null)
            {
                return;
            }

            var caster = context.MaybeCaster;

            if (caster == null)
            {
                return;
            }

            if (context?.SourceAbility.GetComponent <DisbeliefSpell>() == null)
            {
                context = ShadowSpells.extractMainContext(context, caster);
                if (context == null)
                {
                    return;
                }

                if (!ShadowSpells.is_making_disbelief_save)
                {
                    return;
                }
            }


            if (context.SpellSchool == school &&
                (save_type == SavingThrowType.Unknown || evt.Type == save_type) &&
                (context?.SourceAbility.GetComponent <DisbeliefSpell>() != null || !evt.Initiator.Ensure <UnitPartDisbelief>().attemptedDisbelief(context))
                )
            {
                int bonus = this.value.Calculate(this.Fact.MaybeContext);
                evt.AddTemporaryModifier(evt.Initiator.Stats.SaveWill.AddModifier(bonus, (GameLogicComponent)this, descriptor));
                evt.AddTemporaryModifier(evt.Initiator.Stats.SaveReflex.AddModifier(bonus, (GameLogicComponent)this, descriptor));
                evt.AddTemporaryModifier(evt.Initiator.Stats.SaveFortitude.AddModifier(bonus, (GameLogicComponent)this, descriptor));
            }
        }
Exemplo n.º 4
0
 private MechanicsContext getContext(MechanicsContext context)
 {
     return(ShadowSpells.extractMainContext(context, this.Owner.Unit));
 }