示例#1
0
        static void Postfix(UnitDescriptor __instance)
        {
            var action = library.Get <BlueprintAbility>(CombatManeuverData.combatManeuverActionIds[CombatManeuver.Disarm]);

            if (action != null && __instance.HasFact(action))
            {
                __instance.RemoveFact(action);
            }

            var disarmToggle = library.Get <BlueprintActivatableAbility>(DisarmToggleAbility.Data.Guid);

            if (disarmToggle != null && !__instance.HasFact(disarmToggle))
            {
                __instance.AddFact(disarmToggle);
            }
        }
示例#2
0
        static void Postfix(UnitDescriptor __instance)
        {
            foreach (var maneuver in new CombatManeuver[] { CombatManeuver.BullRush, CombatManeuver.DirtyTrickBlind, CombatManeuver.DirtyTrickEntangle, CombatManeuver.DirtyTrickSickened })
            {
                var action = library.Get <BlueprintAbility>(CombatManeuverData.combatManeuverActionIds[maneuver]);
                if (action != null && __instance.HasFact(action))
                {
                    __instance.RemoveFact(action);
                }
            }
            var groupAction = library.Get <BlueprintAbility>(CombatManeuversStandardAbility.Data.Guid);

            if (groupAction != null && !__instance.HasFact(groupAction))
            {
                __instance.AddFact(groupAction);
            }
        }
示例#3
0
        static public bool Prefix(UnitUseAbility __instance, UnitCommand.CommandType commandType, ref AbilityData spell, TargetWrapper target)
        {
            //base ctor

            /*this.Type = commandType;
             * this.Target = target;
             * this.Cutscene = (ElementsContext.GetData<CutsceneParametersContext.ContextData>() != null);*/

            //modify spell
            if (spell == null)
            {
                return(true);
            }
            if (spell.Spellbook == null)
            {
                return(true);
            }
            if (spell.Spellbook.Blueprint.CharacterClass != ArcanistClass.arcanist)
            {
                return(true);
            }
            UnitDescriptor unit          = spell.Caster;
            bool           hadMetamagic  = spell.MetamagicData != null;
            bool           hadMetamixing = unit.Buffs.HasFact(Metamixing.buff);

            //An arcanist can't combine prepared metamagic and spontaneous metamagic, if she doesn't have
            //the Metamixing exploit.
            if (hadMetamagic && !hadMetamixing)
            {
                return(true);
            }
            //UnityModManager.Logger.Log($"spell {spell.Name} has metamagic {(spell.MetamagicData!=null?spell.MetamagicData.MetamagicMask:0)}");
            MetamagicBuilder builder = new MetamagicBuilder(spell.Spellbook, spell);
            Dictionary <Metamagic, Feature> meta_feat = new Dictionary <Metamagic, Feature>();

            foreach (var ft in builder.SpellMetamagicFeatures)
            {
                AddMetamagicFeat comp = ft.Get <AddMetamagicFeat>();
                if (comp == null)
                {
                    continue;
                }
                Metamagic metaId = comp.Metamagic;
                meta_feat[metaId] = ft;
            }
            bool flag = false;

            foreach (var kv in SponMetamagic.buffDict)
            {
                Metamagic metaId        = (Metamagic)(kv.Key.first);
                int       HeightenLevel = kv.Key.second;
                if (!meta_feat.ContainsKey(metaId))
                {
                    continue;
                }
                BlueprintBuff buff = kv.Value;
                if (!unit.HasFact(buff))
                {
                    continue;
                }

                //If the arcanist has the Metamixing exploit, she can add ONE
                //metamagic feat to a prepared spell, without using extra time to cast.
                //(regardless if the spell had metamagic feats when prepared)
                if (metaId == Metamagic.Heighten)
                {
                    int originalLevel = spell.Spellbook.GetSpellLevel(spell.Blueprint);
                    if (HeightenLevel <= originalLevel)
                    {
                        continue;
                    }
                    builder.AddHeightenMetamagic(meta_feat[metaId], HeightenLevel - originalLevel);
                    unit.RemoveFact(buff);
                    flag = true;
                    if (hadMetamixing)
                    {
                        unit.Resources.Spend(ArcaneReservoir.resource, 1);
                        break;
                    }
                }
                else
                {
                    builder.AddMetamagic(meta_feat[metaId]);
                    unit.RemoveFact(buff);
                    flag = true;
                    if (hadMetamixing)
                    {
                        unit.Resources.Spend(ArcaneReservoir.resource, 1);
                        break;
                    }
                }
            }
            if (flag && !hadMetamixing)
            {
                unit.AddBuff(SponMetamagic.flagBuff, unit.Unit);
            }
            //fix ConvertedFrom. this is used in checking if a subspell is existed in memorized spells.
            //if spell is a subspell, spell.IsAvailableInSpellbook will use its m_ConvertedFrom(which is its master spell)
            //to get the return value.
            var newSpell = builder.ResultAbilityData;

            newSpell.ConvertedFrom = spell.ConvertedFrom;
            spell = newSpell;
            //UnityModManager.Logger.Log($"new spell {spell.Name} has metamagic {(spell.MetamagicData != null ? spell.MetamagicData.MetamagicMask : 0)}");
            return(true);
        }