Exemple #1
0
        static bool Prefix(BlueprintAbilityResource __instance, UnitDescriptor unit, ref int __result)
        {
            try
            {
                var self   = __instance;
                var amount = ExtensionMethods.getMaxAmount(self);
                if ((bool)getIncreasedByLevel(amount))
                {
                    var classes = (BlueprintCharacterClass[])getClass(amount);
                    if (classes?.Contains(Helpers.sorcererClass) == true)
                    {
                        var level = unit.Get <UnitPartBloodline>()?.CalcLevel(self);
                        if (level.HasValue)
                        {
                            int num   = (int)getBaseValue(amount) + level.Value * (int)getLevelIncrease(amount);
                            int bonus = 0;
                            EventBus.RaiseEvent(unit.Unit, (IResourceAmountBonusHandler h) => h.CalculateMaxResourceAmount(self, ref bonus));
                            __result = (int)applyMinMax(self, num) + bonus;
                            Log.Write($"BlueprintAbilityResource: modify amount of {self.name}: {__result}");
                            return(false);
                        }
                    }
                }
                else if ((bool)getIncreasedByLevelStartPlusDivStep(amount))
                {
                    var classes = (BlueprintCharacterClass[])getClassDiv(amount);
                    if (classes?.Contains(Helpers.sorcererClass) == true)
                    {
                        var level = unit.Get <UnitPartBloodline>()?.CalcLevel(self);
                        if (level.HasValue)
                        {
                            int num        = (int)getBaseValue(amount);
                            int totalLevel = level.Value;
                            totalLevel += (int)((unit.Progression.CharacterLevel - totalLevel) * (float)getOtherClassesModifier(amount));
                            if ((int)getStartingLevel(amount) <= totalLevel)
                            {
                                num += Math.Max((int)getStartingIncrease(amount) + (int)getPerStepIncrease(amount) * (totalLevel - (int)getStartingLevel(amount)) / (int)getLevelStep(amount), (int)getMinClassLevelIncrease(amount));
                            }

                            int bonus = 0;
                            EventBus.RaiseEvent(unit.Unit, (IResourceAmountBonusHandler h) => h.CalculateMaxResourceAmount(self, ref bonus));
                            __result = (int)applyMinMax(self, num) + bonus;
                            Log.Write($"BlueprintAbilityResource: modify amount of {self.name} (start plus div step): {__result}");
                            return(false);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
            return(true);
        }
Exemple #2
0
 public override bool Check(
     FeatureSelectionState selectionState,
     UnitDescriptor unit,
     LevelUpState state)
 {
     return((unit.Get <UnitPartFullProficiency>()?.hasFullProficiency(category)).GetValueOrDefault() != not);
 }
Exemple #3
0
 static void Postfix(UnitDescriptor owner, Encumbrance encumbrance, ref int __result)
 {
     if (__result < 0 && owner.Get <UnitPartIgnoreEncumbrance>()?.active() == true)
     {
         __result = 0;
     }
 }
Exemple #4
0
        static void Postfix(UnitDescriptor unit, ref bool __result)
        {
            if (__result == false && unit.Body.PrimaryHand.MaybeWeapon != null)
            {
                __result = !unit.Body.PrimaryHand.MaybeWeapon.HoldInTwoHands && Helpers.hasFreeHand(unit.Body.SecondaryHand);
            }
            var use_spell_combat_part = unit.Get <UnitPartCanUseSpellCombat>();

            if (__result == false && use_spell_combat_part != null)
            {
                __result = use_spell_combat_part.canBeUsedOn(unit.Body.PrimaryHand, unit.Body.SecondaryHand, false);
            }
        }
Exemple #5
0
        static void Postfix(UnitDescriptor unit, ref bool __result)
        {
            if (__result == false)
            {//check buckler with unhindering shield
                __result = unit.Body.SecondaryHand.HasItem && Helpers.hasFreeHand(unit.Body.SecondaryHand);
            }
            var use_spell_combat_part = unit.Get <UnitPartCanUseSpellCombat>();

            if (__result == false && use_spell_combat_part != null)
            {
                __result = use_spell_combat_part.canBeUsedOn(unit.Body.PrimaryHand, unit.Body.SecondaryHand, false);
            }
        }
 static void Postfix(BlueprintItemEquipmentUsable __instance, UnitDescriptor unit, ref bool __result)
 {
     if (__result == true)
     {
         return;
     }
     if (__instance.RequireUMDIfCasterHasNoSpellInSpellList)
     {
         var unit_part = unit.Get <UnitPartFamiliarFreeItemUse>();
         if (unit_part == null || !unit_part.isActive())
         {
             return;
         }
         __result = true;
     }
 }
        static public int calculateFakeClassLevel(UnitDescriptor descriptor, BlueprintCharacterClass[] classes, BlueprintArchetype[] archetypes)
        {
            var unit_part_fake_class = descriptor?.Get <UnitPartFakeClassLevel>();

            if (unit_part_fake_class == null)
            {
                return(0);
            }
            int lvl = 0;

            foreach (var c in classes)
            {
                if (archetypes.Any(a => a.GetParentClass() == c))
                {//fake classes should not have archetypes
                    continue;
                }
                lvl += unit_part_fake_class.getFakeClassLevel(c);
            }
            return(lvl);
        }
Exemple #8
0
 private void LevelUp(UnitDescriptor unit, int levels, bool fromFact)
 {
     using (new IgnorePrerequisites())
     {
         ClassLevelLimit component       = unit.Blueprint.GetComponent <ClassLevelLimit>();
         int             classLevelLimit = component == null ? int.MaxValue : component.LevelLimit;
         if (ElementsContext.GetData <DefaultBuildData>() != null)
         {
             classLevelLimit = 0;
         }
         Dictionary <SelectionEntry, HashSet <int> > selectionsHistory = new Dictionary <SelectionEntry, HashSet <int> >();
         HashSet <int> spellHistory = (instance.SelectSpells.Length <= 0) ? null : new HashSet <int>();
         for (int i = 0; i < levels; i++)
         {
             if (unit.Progression.CharacterLevel < classLevelLimit)
             {
                 Main.Log($"A: Adding level {i} unitlevel {unit.Progression.CharacterLevel}");
                 this.AddLevel(unit, selectionsHistory, spellHistory);
             }
             else
             {
                 Main.Log($"B: Adding level {i} unitlevel {unit.Progression.CharacterLevel}");
                 LevelUpPlanUnitHolder levelUpPlanUnitHolder = unit.Get <LevelUpPlanUnitHolder>();
                 if (levelUpPlanUnitHolder != null)
                 {
                     UnitDescriptor    unitDescriptor    = levelUpPlanUnitHolder.RequestPlan();
                     LevelUpController levelUpController = this.AddLevel(unitDescriptor, selectionsHistory, spellHistory);
                     unit.Progression.AddLevelPlan(levelUpController.GetPlan());
                 }
             }
         }
         this.PrepareSpellbook(unit);
         unit.Progression.ReapplyFeaturesOnLevelUp();
         UnitEntityView view = unit.Unit.View;
         if (view != null)
         {
             view.UpdateClassEquipment();
         }
         RestController.ApplyRest(unit);
     }
 }
Exemple #9
0
 public static bool Prefix(BlueprintCharacterClass characterClass, BlueprintCharacterClass[] additionalClasses, UnitDescriptor unit, BlueprintArchetype[] archetypeList, ref int __result)
 {
     try
     {
         if (currentFact == null || characterClass != Helpers.sorcererClass)
         {
             return(true);
         }
         var level = unit.Get <UnitPartBloodline>()?.CalcLevel(currentFact.Blueprint);
         if (level.HasValue)
         {
             Log.Write($"ReplaceCasterLevelOfAbility: modify level of {currentFact.Name}: {level}");
             __result = level.Value;
             return(false);
         }
     }
     catch (Exception e)
     {
         Log.Error(e);
     }
     return(true);
 }
 public static bool isOffHandUnarmedAndCanBeIgnored(BlueprintItemWeapon weapon, UnitDescriptor unit)
 {
     return(weapon.IsUnarmed && !((bool)unit.State.Features.ImprovedUnarmedStrike && (unit.Get <UnitPartUnarmedTwf>()?.active()).GetValueOrDefault()));
 }