public void OnEventAboutToTrigger(RuleHealDamage evt)
        {
            float val = (float)this.ModifierPercents.Calculate(this.Fact.MaybeContext) / 100.0f;

            if (evt.Modifier.HasValue)
            {
                evt.Modifier = new float?(evt.Modifier.Value * val);
            }
            else
            {
                evt.Modifier = new float?(val);
            }
        }
Esempio n. 2
0
        public void OnEventAboutToTrigger(RuleHealDamage evt)
        {
            if (inRuleHealDamage)
            {
                return;
            }
            inRuleHealDamage = true; // prevent reentrancy

            var context = Helpers.GetMechanicsContext();
            int rolls   = evt.HealFormula.Rolls;

            if (context != null && currentHealDice != null)
            {
                // For some reason, dice are not passed in to the RuleHealDamage,
                // so we need to capure them in places like ContextActionHealTarget,
                // and then compute the number of rolls here.
                var healDice         = currentHealDice;
                var sharedValueCount = Enum.GetValues(typeof(AbilitySharedValue)).Length;
                for (int i = 0; i <= sharedValueCount; i++) // guard against a loop.
                {
                    rolls += healDice.DiceCountValue.Calculate(context);
                    Log.Write($"{GetType().Name}: rolls {rolls} ({healDice.DiceCountValue})");
                    // See if the shared value came from a dice roll
                    if (!healDice.BonusValue.IsValueShared)
                    {
                        break;
                    }
                    var calcShared = context.AssociatedBlueprint.GetComponents <ContextCalculateSharedValue>()
                                     .FirstOrDefault(c => c.ValueType == healDice.BonusValue.ValueShared);
                    if (calcShared == null)
                    {
                        break;
                    }
                    healDice = calcShared.Value;
                }
            }

            var bonus = rolls * 2; // +2 per dice

            Log.Append($"{GetType().Name}: heal bonus {bonus}, dice {evt.HealFormula}, total bonus {evt.Bonus + bonus}");
            Log.Write($"  context: {context}, currentHealDice: {currentHealDice}");
            Rulebook.CurrentContext.Trigger(new RuleHealDamage(evt.Initiator, evt.Target, evt.HealFormula, evt.Bonus + bonus));

            // Disable the original heal roll, so we don't get double healing
            evt.Modifier     = 0;
            inRuleHealDamage = false;
        }
Esempio n. 3
0
            static public bool Prefix(RuleHealDamage __instance, RulebookEventContext context)
            {
                if (__instance.Target == null)
                {
                    return(true);
                }

                var context2 = __instance.Reason.Context;

                if (context2?.AssociatedBlueprint != null && context2.AssociatedBlueprint is BlueprintBuff)
                {//do not apply shadow twice
                    return(true);
                }
                context2 = ShadowSpells.extractMainContext(context2, __instance.Initiator);
                if (context2 == null)
                {
                    return(true);
                }

                if (!__instance.Target.Ensure <UnitPartDisbelief>().attemptedDisbelief(context2))
                {
                    if (__instance.Target.Descriptor.State.HasCondition(UnitCondition.TrueSeeing))
                    {
                        __instance.Target.Ensure <UnitPartDisbelief>().register(context2, true);
                    }
                    else
                    {
                        __instance.Target.Ensure <UnitPartDisbelief>().register(context2, ShadowSpells.makeDisbeliefSave(context2, __instance.Target));
                    }
                }

                if (__instance.Target.Ensure <UnitPartDisbelief>().disbelieved(context2))
                {
                    int illusion_reality = ShadowSpells.getSpellReality(context2);

                    if (illusion_reality > 0)
                    {
                        __instance.Modifier = new float?((__instance.Modifier.HasValue ? __instance.Modifier.GetValueOrDefault() : 1f) * 0.01f * illusion_reality);
                        Common.AddBattleLogMessage(__instance.Target.CharacterName + " reduces healing from "
                                                   + context2.SourceAbility.Name + " to " + illusion_reality.ToString() + "% due to disbelief");
                    }
                }
                return(true);
            }
Esempio n. 4
0
 public void OnEventDidTrigger(RuleHealDamage evt)
 {
 }
Esempio n. 5
0
 public RuleHealDamageWithOverflow(RuleHealDamage rule)
     : base(rule.Initiator, rule.Target, rule.HealFormula, rule.Bonus)
 {
 }