Exemplo n.º 1
0
            public void OnEventAboutToTrigger(RuleApplyMetamagic evt)
            {
                var spell = this.Param?.Blueprint as BlueprintAbility;

                if (spell == null)
                {
                    return;
                }

                bool same_spells = SpellDuplicates.isDuplicateOrParent(spell, evt.Spell);

                if (!same_spells)
                {
                    return;
                }
                var spellbook = evt.Spellbook;

                if (spellbook == null || spellbook.GetSpellLevel(spell) > max_spell_level)
                {
                    return;
                }
                if (evt.AppliedMetamagics.Count == 0)
                {
                    return;
                }
                int reduction = evt.AppliedMetamagics.Max(m => m == Metamagic.Heighten ? 0 : m.DefaultCost());

                evt.ReduceCost(reduction);
            }
Exemplo n.º 2
0
        static BlueprintProgression createCurseProgression(BlueprintProgression oracle_curse)
        {
            var features = new BlueprintFeature[] { oracle_curse.LevelEntries[0].Features[0] as BlueprintFeature, //1 -> 5
                                                    oracle_curse.LevelEntries[1].Features[0] as BlueprintFeature, //5 -> 10,
                                                    oracle_curse.LevelEntries[2].Features[0] as BlueprintFeature, //10 -> 20
            };

            var curse = Helpers.CreateProgression("PactWizard" + oracle_curse.name,
                                                  oracle_curse.Name,
                                                  oracle_curse.Description,
                                                  "",
                                                  features[0].Icon,
                                                  FeatureGroup.None);
            List <BlueprintAbility> curse_spells = new List <BlueprintAbility>();

            for (int i = 0; i < features.Length; i++)
            {
                features[i] = library.CopyAndAdd(features[i], "PactWizard" + features[i].name, "");
                foreach (var af in features[i].GetComponents <AddFeatureOnClassLevel>())
                {
                    features[i].ReplaceComponent(af, af.CreateCopy(c => { c.Class = archetype.GetParentClass(); c.Level = c.Level * 2; }));
                }

                foreach (var aks in features[i].GetComponents <AddKnownSpell>())
                {
                    features[i].ReplaceComponent(aks, aks.CreateCopy(c =>
                    {
                        c.CharacterClass = archetype.GetParentClass();
                        if (archetype.GetParentClass().Spellbook.SpellList.Contains(c.Spell) &&
                            archetype.GetParentClass().Spellbook.SpellList.GetLevel(c.Spell) != c.SpellLevel)
                        {
                            c.Spell = SpellDuplicates.addDuplicateSpell(c.Spell, "PactWizard" + c.Spell.name, "");
                        }
                        curse_spells.Add(c.Spell);
                    }
                                                                     )
                                                 );
                }
            }

            if (!curse_spells.Empty())
            {
                var feature2 = Helpers.CreateFeature(oracle_curse.name + "CurseMetamagicFeature",
                                                     "",
                                                     "",
                                                     "",
                                                     null,
                                                     FeatureGroup.None,
                                                     Helpers.Create <NewMechanics.MetamagicMechanics.ReduceMetamagicCostForSpecifiedSpells>(r => { r.reduction = 1; r.spells = curse_spells.ToArray(); })
                                                     );
                feature2.HideInCharacterSheetAndLevelUp = true;
                patron_metamagic.AddComponent(Common.createAddFeatureIfHasFact(curse, feature2));
            }

            curse.LevelEntries = new LevelEntry[] { Helpers.LevelEntry(5, features[0]), Helpers.LevelEntry(10, features[1]), Helpers.LevelEntry(20, features[2]) };
            curse.UIGroups     = Helpers.CreateUIGroups(features);
            curse.Classes      = new BlueprintCharacterClass[] { archetype.GetParentClass() };
            return(curse);
        }
Exemplo n.º 3
0
            public override void OnEventAboutToTrigger(RuleApplyMetamagic evt)
            {
                var spellbook = evt.Spellbook;

                if (spellbook == null || !SpellDuplicates.containsDuplicateOrParent(spells, evt.Spell))
                {
                    return;
                }
                if (evt.AppliedMetamagics.Count == 0)
                {
                    return;
                }

                evt.ReduceCost(reduction);
            }
Exemplo n.º 4
0
        private bool hasSpell(UnitDescriptor unit, BlueprintAbility spell)
        {
            var duplicates = SpellDuplicates.getDuplicates(spell);

            foreach (var sb in unit.Spellbooks)
            {
                foreach (var d in duplicates)
                {
                    if (sb.CanSpend(d))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
            public bool canUseOnAbility(AbilityData ability)
            {
                //Main.logger.Log("Checking Spell and Ability");
                var spell = this.Param?.Blueprint as BlueprintAbility;

                if (spell == null || ability?.Blueprint == null)
                {
                    return(false);
                }

                // Main.logger.Log("Checking spellbook");
                if (!spell.IsSpell)
                {
                    return(false);
                }

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

                // Main.logger.Log("Checking correct spell");
                var allowed = ability.Blueprint.Parent == null?SpellDuplicates.isDuplicate(ability.Blueprint, spell) : SpellDuplicates.isDuplicate(ability.Blueprint.Parent, spell);

                if (!allowed)
                {
                    return(false);
                }

                //Main.logger.Log("Checking metamagic");
                int metamagic_count = Helpers.PopulationCount((int)(ability.MetamagicData.MetamagicMask & ~((Metamagic)MetamagicFeats.MetamagicExtender.FreeMetamagic)));

                if (metamagic_count > max_metamagics)
                {
                    var arcanist_part = this.Owner.Get <UnitPartArcanistPreparedMetamagic>();
                    if (arcanist_part != null && ability.Spellbook.Blueprint == arcanist_part.spellbook)
                    {
                        return(arcanist_part.noCastingTimeIncreaseForMetamagic(ability.Blueprint, ability.MetamagicData.MetamagicMask & ~(Metamagic)MetamagicFeats.MetamagicExtender.FreeMetamagic, max_metamagics));
                    }
                    return(false);
                }

                return(true);
            }
Exemplo n.º 6
0
            public bool canUseOnAbility(AbilityData ability)
            {
                var spell = this.Param?.Blueprint as BlueprintAbility;

                if (spell == null || ability?.Blueprint == null)
                {
                    return(false);
                }

                if (!spell.IsSpell)
                {
                    return(false);
                }

                int metamagic_count = Helpers.PopulationCount((int)(ability.MetamagicData.MetamagicMask & ~((Metamagic)MetamagicFeats.MetamagicExtender.BloodIntensity)));

                if (metamagic_count > max_metamagics)
                {
                    return(false);
                }
                return(ability.Blueprint.Parent == null?SpellDuplicates.isDuplicate(ability.Blueprint, spell) : SpellDuplicates.isDuplicate(ability.Blueprint.Parent, spell));
            }
Exemplo n.º 7
0
            public void OnEventAboutToTrigger(RuleApplyMetamagic evt)
            {
                var spell = this.Param?.Blueprint as BlueprintAbility;

                if (spell == null)
                {
                    return;
                }

                var spellbook = evt.Spellbook;

                if (spellbook == null || !SpellDuplicates.isDuplicateOrParent(spell, evt.Spell))
                {
                    return;
                }
                if (evt.AppliedMetamagics.Count == 0)
                {
                    return;
                }

                evt.ReduceCost(reduction);
            }