示例#1
0
        public void OnEventAboutToTrigger(RuleCalculateAbilityParams evt)
        {
            UnitDescriptor unit = evt.AbilityData != null ? evt.AbilityData.Caster : null;

            if (unit != null && evt.Spell != null && evt.Spellbook != null && evt.Spell.Type == AbilityType.Spell)
            {
                if (metamagic == Metamagic.Heighten && HeightenTarget > evt.SpellLevel)
                {
                    int metamagicCost = MetamagicHelper.DefaultCost(metamagic);
                    if (metamagic == Metamagic.Heighten)
                    {
                        metamagicCost += (HeightenTarget - evt.SpellLevel);
                    }
                    if (unit.Resources.GetResourceAmount(ArcaneReservoir.resource) < metamagicCost)
                    {
                        if (this.ShallRemove)
                        {
                            base.Buff.Remove();
                        }
                    }
                    unit.Resources.Spend(ArcaneReservoir.resource, metamagicCost);

                    evt.AddMetamagic(this.metamagic);
                    if (this.metamagic == Metamagic.Heighten)
                    {
                        MetamagicData md = metamagicData_Getter(evt) as MetamagicData;
                        md.HeightenLevel = (HeightenTarget - evt.SpellLevel >= md.HeightenLevel ? HeightenTarget - evt.SpellLevel : md.HeightenLevel);
                    }
                    if (this.ShallRemove)
                    {
                        base.Buff.Remove();
                    }
                }
            }
        }
示例#2
0
            public override void OnEventAboutToTrigger(RuleCalculateAbilityParams evt)
            {
                cost_to_pay = 0;
                if (!CanBeUsedOn(evt.Spell, evt.AbilityData))
                {
                    return;
                }

                cost_to_pay = 2 * (evt.Spellbook.GetSpellLevel(evt.Spell) + MetamagicHelper.DefaultCost(Metamagic));
                evt.AddMetamagic(this.Metamagic);
            }
        public BlueprintFeature createMetamagicMaster(BlueprintCharacterClass caster_class)
        {
            var feature = Helpers.CreateFeature(prefix + "MetamagicMasterFeature",
                                                "Metamagic Master",
                                                "As a free action while casting a spell, you can expend 1 or more points of mental focus to apply a metamagic feat you know to that spell without increasing the spell’s casting time or the spell level of the spell slot it occupies. The number of points of mental focus you must expend to use this power is equal to the increase in spell levels the metamagic feat would normally require (minimum 1).",
                                                "",
                                                LoadIcons.Image2Sprite.Create(@"AbilityIcons/ArcaneExploit.png"),
                                                FeatureGroup.None
                                                );

            BlueprintFeature[] metamagics = library.GetAllBlueprints().OfType <BlueprintFeature>().Where(b => b.Groups.Contains(FeatureGroup.WizardFeat) && (b.GetComponent <AddMetamagicFeat>() != null) && b.AssetGuid != "2f5d1e705c7967546b72ad8218ccf99c").ToArray();
            foreach (var m in metamagics)
            {
                var metamagic = m.GetComponent <Kingmaker.UnitLogic.FactLogic.AddMetamagicFeat>().Metamagic;
                var cost      = MetamagicHelper.DefaultCost(metamagic);
                var buff      = Helpers.CreateBuff(prefix + m.name + "MetamagicMasterBuff",
                                                   "Metamagic Master: " + m.Name,
                                                   feature.Description + "\n" + m.Name + ": " + m.Description,
                                                   "",
                                                   m.Icon,
                                                   null,
                                                   Helpers.Create <NewMechanics.MetamagicMechanics.MetamagicOnSpellDescriptor>(ms =>
                {
                    ms.spell_descriptor = SpellDescriptor.None;
                    ms.specific_class   = caster_class;
                    ms.resource         = resource;
                    ms.Metamagic        = metamagic;
                    ms.amount           = cost;
                }
                                                                                                                               )
                                                   );

                var toggle = Common.buffToToggle(buff, CommandType.Free, true,
                                                 resource.CreateActivatableResourceLogic(ActivatableAbilityResourceLogic.ResourceSpendType.Never),
                                                 Helpers.Create <ResourceMechanics.RestrictionHasEnoughResource>(r => { r.resource = resource; r.amount = cost; })
                                                 );

                toggle.Group = ActivatableAbilityGroupExtension.MetamagicMaster.ToActivatableAbilityGroup();
                addFocusInvestmentCheck(toggle, SpellSchool.Divination, SpellSchool.Evocation, SpellSchool.Necromancy);

                var feature1 = Common.ActivatableAbilityToFeature(toggle);

                feature.AddComponent(Helpers.Create <NewMechanics.AddFeatureIfHasFactsFromList>(a => { a.Feature = feature1; a.CheckedFacts = new Kingmaker.Blueprints.Facts.BlueprintUnitFact[] { m }; }));
                m.AddComponent(Helpers.Create <NewMechanics.AddFeatureIfHasFactsFromList>(a => { a.Feature = feature1; a.CheckedFacts = new Kingmaker.Blueprints.Facts.BlueprintUnitFact[] { feature }; }));
            }

            return(feature);
        }
示例#4
0
            public override bool CanBeUsedOn(BlueprintAbility ability, [CanBeNull] AbilityData data)
            {
                bool is_metamagic_not_available = ability == null || data?.Spellbook == null || ability.Type != AbilityType.Spell ||
                                                  ((ability.AvailableMetamagic & Metamagic) == 0);

                if (is_metamagic_not_available)
                {
                    return(false);
                }

                int cost = 2 * (data.SpellLevel + MetamagicHelper.DefaultCost(Metamagic));

                if (this.resource == null || this.Owner.Resources.GetResourceAmount((BlueprintScriptableObject)this.resource) < cost)
                {
                    return(false);
                }

                return(true);
            }