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

                if (spell == null)
                {
                    return;
                }

                bool same_spells = evt.Spell.Parent == null?SpellDuplicates.isDuplicate(evt.Spell, spell) : SpellDuplicates.isDuplicate(evt.Spell.Parent, 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);
            }
            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.º 3
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.º 4
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.isDuplicate(spell, evt.Spell))
                {
                    return;
                }
                if (evt.AppliedMetamagics.Count == 0)
                {
                    return;
                }

                evt.ReduceCost(reduction);
            }