示例#1
0
        public override IEnumerator <AbilityDeliveryTarget> Deliver(AbilityExecutionContext context, TargetWrapper target)
        {
            UnitEntityData caster = context.MaybeCaster;

            if (caster == null)
            {
                UberDebug.LogError("Caster is missing", Array.Empty <object>());
                yield break;
            }

            RulebookEventContext rulebookContext      = context.RulebookContext;
            RuleAttackWithWeapon attackWithWeapon     = (rulebookContext != null) ? rulebookContext.AllEvents.LastOfType <RuleAttackWithWeapon>() : null;
            RuleAttackWithWeapon ruleAttackWithWeapon = attackWithWeapon;
            RuleAttackRoll       attackRoll           = (ruleAttackWithWeapon != null) ? ruleAttackWithWeapon.AttackRoll : null;

            attackRoll = (attackRoll ?? context.TriggerRule <RuleAttackRoll>(new RuleAttackRoll(caster, target.Unit, caster.GetFirstWeapon(), 0)));
            if (attackWithWeapon == null)
            {
                attackRoll.ConsumeMirrorImageIfNecessary();
            }
            yield return(new AbilityDeliveryTarget(target)
            {
                AttackRoll = attackRoll
            });

            yield break;
        }
 internal static bool Prefix(AbilityExecutionContext context, TargetWrapper target)
 {
     try {
         return(!target.IsUnit || context.TriggerRule(new RuleSpellTargetCheck(context, target.Unit)).CanTargetUnit);
     }
     catch (Exception e) {
         Log.Error(e);
     }
     return(true);
 }
示例#3
0
        internal static bool Prefix(AbilityExecutionContext context, TargetWrapper target)
        {
            if (!target.IsUnit)
            {
                return(true);
            }
            if (context?.Params == null || context.MaybeCaster == null)
            {
                return(true);
            }

            if (!(target.Unit.Get <UnitPartSaveAgainstHarmlessSpells>()?.active()).GetValueOrDefault())
            {
                return(true);
            }

            if (target.Unit == context.MaybeCaster || !target.Unit.IsAlly(context.MaybeCaster))
            {
                return(true);
            }

            if (context.AbilityBlueprint?.GetComponent <HarmlessSpell>() == null || !context.AbilityBlueprint.IsSpell)
            {
                return(true);
            }

            RuleSavingThrow ruleSavingThrow = new RuleSavingThrow(target.Unit, context.AbilityBlueprint.GetComponent <HarmlessSpell>().save_type, context.Params.DC);

            ruleSavingThrow.Reason = (RuleReason)((MechanicsContext)context);
            if (context.TriggerRule <RuleSavingThrow>(ruleSavingThrow).IsPassed)
            {
                return(false);
            }

            return(true);
        }
示例#4
0
        public override IEnumerator <AbilityDeliveryTarget> Deliver(AbilityExecutionContext context, TargetWrapper target)
        {
            UnitEntityData caster = context.MaybeCaster;
            bool           flag   = caster == null;

            if (flag)
            {
                UberDebug.LogError(this, "Caster is missing", Array.Empty <object>());
                yield break;
            }
            WeaponSlot threatHand = caster.GetThreatHand();
            bool       flag2      = threatHand == null;

            if (flag2)
            {
                UberDebug.LogError("Caster can't attack", Array.Empty <object>());
                yield break;
            }
            UnitEntityData targetUnit = target.Unit;
            bool           flag3      = targetUnit == null;

            if (flag3)
            {
                UberDebug.LogError("Can't be applied to point", Array.Empty <object>());
                yield break;
            }
            int attackPenalty = 0;

            AbilityEffectCoupDeGrace.EventHandlers handlers = new AbilityEffectCoupDeGrace.EventHandlers();
            handlers.Add(new AbilityEffectCoupDeGrace.Coup(caster));
            RuleAttackWithWeapon rule = new RuleAttackWithWeapon(caster, targetUnit, threatHand.Weapon, attackPenalty)
            {
                AutoHit = true,
                AutoCriticalConfirmation = true,
                AutoCriticalThreat       = true
            };

            using (handlers.Activate())
            {
                context.TriggerRule <RuleAttackWithWeapon>(rule);
            }
            AbilityEffectCoupDeGrace.EventHandlers eventHandlers = null;
            yield return(new AbilityDeliveryTarget(target));

            RuleSavingThrow rule3 = new RuleSavingThrow(targetUnit, SavingThrowType.Fortitude, AbilityEffectCoupDeGrace.m_coupDamage + 10);

            context.TriggerRule <RuleSavingThrow>(rule3);
            bool flag6 = !rule3.IsPassed;

            if (flag6)
            {
                targetUnit.Descriptor.State.MarkedForDeath = true;
            }
            using (context.GetDataScope(target))
            {
                this.Actions.Run();
            }
            ElementsContextData elementsContextData = null;

            rule3 = null;
            yield break;
        }