示例#1
0
 static void Postfix(AbilityData __instance, ref bool __result)
 {
     if (Mod.Enabled && FixSpellstrikeWithMetamagicReach && !__result)
     {
         if (__instance.Blueprint.GetComponent <AbilityDeliverTouch>() != null &&
             __instance.HasMetamagic(Metamagic.Reach))
         {
             __result = true;
         }
     }
 }
        static bool Prefix(AbilityData __instance, TargetWrapper target, ref bool __result)
        {
            foreach (IAbilityTargetChecker targetChecker in __instance.Blueprint.TargetCheckers)
            {
                if (!targetChecker.CanTarget(__instance.Caster.Unit, target))
                {
                    __result = false;
                    return(false);
                }
            }

            if ((__instance.Caster.Buffs.HasFact(SharedSpells.can_only_target_self_buff) && Common.isPersonalSpell(__instance) ||
                 __instance.HasMetamagic((Metamagic)MetamagicFeats.MetamagicExtender.ImprovedSpellSharing)) &&
                target.Unit != __instance.Caster.Unit)
            {
                __result = false;
                return(false);
            }


            if (!__instance.Blueprint.CanTargetSelf && target.Unit == __instance.Caster.Unit)
            {
                __result = false;
                return(false);
            }

            if (__instance.TargetAnchor == AbilityTargetAnchor.Unit && __instance.Blueprint.Range == AbilityRange.Personal && !__instance.AlchemistInfusion)
            {//if spell was orginally personal - check validity of sharing it with target
                __result = SharedSpells.isValidShareSpellTarget(target.Unit, __instance.Caster);
                return(false);
            }

            switch (__instance.TargetAnchor)
            {
            case AbilityTargetAnchor.Owner:
                if (target.IsUnit)
                {
                    __result = target.Unit == __instance.Caster.Unit;
                }
                break;

            case AbilityTargetAnchor.Unit:
                __result = target.IsUnit && (__instance.Blueprint.CanTargetFriends || target.Unit.IsPlayerFaction || __instance.Caster.Unit.CanAttack(target.Unit));
                break;

            case AbilityTargetAnchor.Point:
                __result = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(false);
        }
示例#3
0
            static void Postfix(UnitPartMagus __instance, AbilityData spell, ref bool __result)
            {
                if (__result == true)
                {
                    return;
                }

                if (spell.Blueprint.GetComponent <AbilityDeliverTouch>() != null &&
                    (spell.HasMetamagic(Metamagic.Reach) || ((spell.Blueprint.AvailableMetamagic & Metamagic.Reach) != 0) && __instance.Owner.HasFact(reach_spellstrike))
                    )
                {
                    __result = __instance.IsSpellFromMagusSpellList(spell);
                }
            }
        public override bool canUseOnAbility(AbilityData ability, CommandType actual_action_type)
        {
            if (ability == null)
            {
                return(false);
            }

            if (ability.Spellbook == null)
            {
                return(false);
            }

            if (actual_action_type != action_type)
            {
                return(false);
            }

            if (actual_action_type == CommandType.Standard)
            {
                bool need_full_round = !ability.HasMetamagic(Metamagic.Quicken) &&
                                       (
                    (ability.Spellbook.Blueprint.Spontaneous && ability.MetamagicData != null && ability.MetamagicData.NotEmpty) ||
                    (ability.Blueprint.IsFullRoundAction)
                                       );
                if (is_full_round != need_full_round)
                {
                    return(false);
                }
            }

            if (ability.SpellLevel > max_spell_level.Calculate(this.Fact.MaybeContext))
            {
                return(false);
            }

            if (ability.Spellbook.Blueprint.IsArcane != is_arcane)
            {
                return(false);
            }
            return(true);
        }