Пример #1
0
        public static string GetDescription(this SimpleBlueprint bp)
        // borrowed shamelessly and enhanced from Bag of Tricks https://www.nexusmods.com/pathfinderkingmaker/mods/26, which is under the MIT License
        {
            try {
                // avoid exceptions on known broken items
                var guid = bp.AssetGuid;
                if (guid == "b60252a8ae028ba498340199f48ead67" || guid == "fb379e61500421143b52c739823b4082")
                {
                    return(null);
                }
                var associatedBlueprint = bp as IUIDataProvider;
                return(associatedBlueprint?.Description.StripHTML());

                // Why did BoT do this instead of the above which is what MechanicsContext.SelectUIData() does for description
#if false
                var description = bp.Des
                                  UnitReference mainChar = Game.Instance.Player.MainCharacter;
                if (mainChar == null)
                {
                    return("");
                }
                MechanicsContext context = new MechanicsContext((UnitEntityData)null, mainChar.Value.Descriptor, bp, (MechanicsContext)null, (TargetWrapper)null);
                return(context?.SelectUIData(UIDataType.Description)?.Description ?? "");
#endif
            }
            catch (Exception e) {
                Console.Write($"{e}");
#if DEBUG
                return("ERROR".red().bold() + $": caught exception {e}");
#else
                return("");
#endif
            }
        }
Пример #2
0
        public virtual IEnumerable <CalculatedResourceCost> GetResourceCost(Bundle _bundle)
        {
            var calculatedResources = new List <CalculatedResourceCost>();

            SimpleBlueprint craftingBp = CraftingMethods.Values[0];

            for (int i = 0; i < craftingBp.Resources.Count; i++)
            {
                calculatedResources.Add(new CalculatedResourceCost
                {
                    Type = craftingBp.Resources.Keys[i],
                    // (resource value * how many) / by how many are produced.
                    Amount = (craftingBp.Resources.Values[i] * (int)_bundle.BundledInformation[SimpleBlueprint.BUNDLED_AMOUNT_KEY]) / craftingBp.Yield
                });
            }

            return(calculatedResources);
        }
Пример #3
0
 public static void Postfix(ref int __result, RuleDealDamage __instance, int damage)
 {
     if (settings.toggleNoFriendlyFireForAOE)
     {
         SimpleBlueprint blueprint = __instance.Reason.Context?.AssociatedBlueprint;
         if (!(blueprint is BlueprintBuff))
         {
             var blueprintAbility = __instance.Reason.Context?.SourceAbility;
             if (blueprintAbility != null &&
                 __instance.Initiator.Descriptor.IsPartyOrPet() &&
                 __instance.Target.Descriptor.IsPartyOrPet() &&
                 ((blueprintAbility.EffectOnAlly == AbilityEffectOnUnit.Harmful) || (blueprintAbility.EffectOnEnemy == AbilityEffectOnUnit.Harmful)))
             {
                 __result = 0;
             }
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Generates a random shield armour enchantment with a given equivalent bonus.
        /// </summary>
        /// <param name="bonus">+x bonus to generate a random enchantment for. Value from 1-5.</param>
        /// <returns>A random shield armor enchantment. Null if the method fails.</returns>
        public static BlueprintArmorEnchantment GetRandomShieldEnchantment(int bonus)
        {
            Random rand = new Random();
            int    dieResult;
            string enchantGUID = null;

            switch (bonus)
            {
            case 1:
                dieResult = rand.Next(5);
                if (dieResult == 1)
                {
                    enchantGUID = balanced;
                }
                else if (dieResult == 2)
                {
                    enchantGUID = poisonResistant;
                }
                else if (dieResult == 3)
                {
                    enchantGUID = arrowCatching;
                }
                else
                {
                    enchantGUID = fortLight;
                }
                break;

            case 2:
                dieResult = rand.Next(2);
                if (dieResult == 1)
                {
                    enchantGUID = spellRes13;
                }
                else
                {
                    enchantGUID = arrowDeflecting;
                }
                break;

            case 3:
                dieResult = rand.Next(3);
                if (dieResult == 1)
                {
                    enchantGUID = spellRes15;
                }
                else
                {
                    enchantGUID = fortMed;
                }
                break;

            case 4:
                dieResult = rand.Next(3);
                if (dieResult == 1)
                {
                    enchantGUID = resistEnergy[rand.Next(resistEnergy.Length + 1) - 1];
                }
                else
                {
                    enchantGUID = spellRes17;
                }
                break;

            case 5:
                dieResult = rand.Next(5);
                if (dieResult == 1)
                {
                    enchantGUID = resistEnergyImp[rand.Next(resistEnergy.Length + 1) - 1];
                }
                else if (dieResult == 2)
                {
                    enchantGUID = resistEnergyGreat[rand.Next(resistEnergy.Length + 1) - 1];
                }
                else if (dieResult == 3)
                {
                    enchantGUID = spellRes19;
                }
                else
                {
                    enchantGUID = fortHeavy;
                }
                break;

            default:
                return(null);
            }

            SimpleBlueprint holder = ResourcesLibrary.TryGetBlueprint(new BlueprintGuid(System.Guid.Parse(enchantGUID)));

            return(holder as BlueprintArmorEnchantment);
        }
Пример #5
0
        /// <summary>
        /// Generates a random ranged weapon enchantment with a given equivalent bonus.
        ///
        /// If Elemental Burst enchantments are chosen, they need the base
        /// Elemental damage enchantment on the item, too (e.g. Flaming Burst requires
        /// Flaming).
        ///
        /// Certain bonus values only have one possiblility to be generated.
        /// </summary>
        /// <param name="bonus">+x bonus to generate a random enchantment for. Value 1-4.</param>
        /// <returns>A random ranged weapon enchantment. Null if the method fails.</returns>
        public static BlueprintWeaponEnchantment GetRandomRangedWeaponEnchantment(int bonus)
        {
            Random rand = new Random();
            int    dieResult;
            string enchantGUID = null;

            switch (bonus)
            {
            case 1:
                dieResult = rand.Next(101);
                if (1 <= dieResult && dieResult <= 9)
                {
                    enchantGUID = bane[rand.Next(bane.Length + 1) - 1];
                }
                else if (10 <= dieResult && dieResult <= 18)
                {
                    enchantGUID = corrosive;
                }
                else if (19 <= dieResult && dieResult <= 23)
                {
                    enchantGUID = cruel;
                }
                else if (24 <= dieResult && dieResult <= 36)
                {
                    enchantGUID = flaming;
                }
                else if (37 <= dieResult && dieResult <= 48)
                {
                    enchantGUID = frost;
                }
                else if (49 <= dieResult && dieResult <= 54)
                {
                    enchantGUID = ghosttouch;
                }
                else if (55 <= dieResult && dieResult <= 69)
                {
                    enchantGUID = heartseeker;
                }
                else if (70 <= dieResult && dieResult <= 85)
                {
                    enchantGUID = shock;
                }
                else
                {
                    enchantGUID = thundering;
                }
                break;

            case 2:
                dieResult = rand.Next(11);
                switch (dieResult)
                {
                case 1:
                    enchantGUID = anarchic;
                    break;

                case 2:
                    enchantGUID = axiomatic;
                    break;

                case 3:
                    enchantGUID = corrosiveBurst;
                    break;

                case 4:
                    enchantGUID = flamingBurst;
                    break;

                case 5:
                    enchantGUID = icyBurst;
                    break;

                case 6:
                    enchantGUID = shockingBurst;
                    break;

                case 7:
                    enchantGUID = thunderingBurst;
                    break;

                case 8:
                    enchantGUID = holy;
                    break;

                case 9:
                    enchantGUID = unholy;
                    break;

                case 10:
                    enchantGUID = igniting;
                    break;
                }
                break;

            case 3:
                enchantGUID = speed;
                break;

            case 4:
                dieResult = rand.Next(12);
                if (dieResult <= 2)
                {
                    enchantGUID = brilliantEnergy;
                }
                else
                {
                    enchantGUID = secondChance;
                }
                break;

            default:
                return(null);
            }

            SimpleBlueprint holder = ResourcesLibrary.TryGetBlueprint(new BlueprintGuid(System.Guid.Parse(enchantGUID)));

            return(holder as BlueprintWeaponEnchantment);
        }
Пример #6
0
        /// <summary>
        /// Generates a random melee weapon enchantment with a given equivalent bonus.
        ///
        /// If Elemental Burst enchantments are chosen, they need the base
        /// Elemental damage enchantment on the item, too (e.g. Flaming Burst requires
        /// Flaming).
        ///
        /// Certain bonus values only have one possiblility to be generated.
        /// </summary>
        /// <param name="bonus">+x bonus to generate a random enchantment for. Value from 1-5.</param>
        /// <returns>A random melee weapon enchantment. Null if the method fails.</returns>
        public static BlueprintWeaponEnchantment GetRandomMeleeWeaponEnchantment(int bonus)
        {
            Random rand = new Random();
            int    dieResult;
            string enchantGUID = null;

            switch (bonus)
            {
            case 1:
                dieResult = rand.Next(101);
                if (1 <= dieResult && dieResult <= 9)
                {
                    enchantGUID = bane[rand.Next(bane.Length + 1) - 1];
                }
                else if (10 <= dieResult && dieResult <= 18)
                {
                    enchantGUID = corrosive;
                }
                else if (19 <= dieResult && dieResult <= 23)
                {
                    enchantGUID = cruel;
                }
                else if (24 <= dieResult && dieResult <= 32)
                {
                    enchantGUID = flaming;
                }
                else if (33 <= dieResult && dieResult <= 41)
                {
                    enchantGUID = frost;
                }
                else if (42 <= dieResult && dieResult <= 45)
                {
                    enchantGUID = furious;
                }
                else if (46 <= dieResult && dieResult <= 51)
                {
                    enchantGUID = ghosttouch;
                }
                else if (52 <= dieResult && dieResult <= 56)
                {
                    enchantGUID = heartseeker;
                }
                else if (57 <= dieResult && dieResult <= 77)
                {
                    enchantGUID = keen;
                }
                else if (78 <= dieResult && dieResult <= 85)
                {
                    enchantGUID = shock;
                }
                else if (86 <= dieResult && dieResult <= 94)
                {
                    enchantGUID = thundering;
                }
                else
                {
                    enchantGUID = vicious;
                }
                break;

            case 2:
                dieResult = rand.Next(101) / 9;     // integer division here gives us pretty accurate results
                switch (dieResult)
                {
                case 0:
                    enchantGUID = anarchic;
                    break;

                case 1:
                    enchantGUID = axiomatic;
                    break;

                case 2:
                    enchantGUID = corrosiveBurst;
                    break;

                case 3:
                    enchantGUID = flamingBurst;
                    break;

                case 4:
                    enchantGUID = holy;
                    break;

                case 5:
                    enchantGUID = unholy;
                    break;

                case 6:
                    enchantGUID = icyBurst;
                    break;

                case 7:
                    enchantGUID = igniting;
                    break;

                case 8:
                    enchantGUID = disruption;
                    break;

                case 9:
                    enchantGUID = shockingBurst;
                    break;

                case 10:
                    enchantGUID = thunderingBurst;
                    break;

                case 11:
                    enchantGUID = furyborn;
                    break;
                }
                break;

            case 3:
                dieResult = rand.Next(4) - 1;
                if (dieResult == 0)
                {
                    enchantGUID = nullifying;
                }
                else
                {
                    enchantGUID = speed;
                }
                break;

            case 4:
                enchantGUID = brilliantEnergy;
                break;

            case 5:
                enchantGUID = vorpal;
                break;

            default:
                return(null);
            }

            SimpleBlueprint holder = ResourcesLibrary.TryGetBlueprint(new BlueprintGuid(System.Guid.Parse(enchantGUID)));

            return(holder as BlueprintWeaponEnchantment);
        }
Пример #7
0
 public static IEnumerable <BlueprintAction> ActionsForBlueprint(SimpleBlueprint bp) => ActionsForType(bp.GetType());
Пример #8
0
 public static IEnumerable <BlueprintAction> GetActions(this SimpleBlueprint bp) => BlueprintAction.ActionsForBlueprint(bp);
Пример #9
0
 public static void BlueprintActionButton(this BlueprintAction action, UnitEntityData unit, SimpleBlueprint bp, Action buttonAction, float width)
 {
     if (action != null && action.canPerform(bp, unit))
     {
         UI.ActionButton(action.name, buttonAction, width == 0 ? UI.AutoWidth() : UI.Width(width));
     }
     else
     {
         UI.Space(width + 3);
     }
 }