Beispiel #1
0
        static internal void updateItemsForChannelDerivative(BlueprintAbility original_ability, BlueprintAbility derived_ability)
        {
            var config = derived_ability.GetComponent <ContextRankConfig>();

            ContextRankProgression progression = Helpers.GetField <ContextRankProgression>(config, "m_Progression");
            int step        = Helpers.GetField <int>(config, "m_StepLevel");
            int level_scale = (progression == ContextRankProgression.OnePlusDivStep || progression == ContextRankProgression.DivStep || progression == ContextRankProgression.StartPlusDivStep)
                                    ? step : 2;

            //phylacteries bonuses
            BlueprintEquipmentEnchantment[] enchants = new BlueprintEquipmentEnchantment[] { library.Get <Kingmaker.Blueprints.Items.Ecnchantments.BlueprintEquipmentEnchantment>("60f06749fa4729c49bc3eb2eb7e3b316"),
                                                                                             library.Get <Kingmaker.Blueprints.Items.Ecnchantments.BlueprintEquipmentEnchantment>("f5d0bf8c1b4574848acb8d1fbb544807"),
                                                                                             library.Get <Kingmaker.Blueprints.Items.Ecnchantments.BlueprintEquipmentEnchantment>("cb4a39044b59f5e47ad5bc08ff9d6669"),
                                                                                             library.Get <Kingmaker.Blueprints.Items.Ecnchantments.BlueprintEquipmentEnchantment>("e988cf802d403d941b2ed8b6016de68f"), };

            foreach (var e in enchants)
            {
                var boni = e.GetComponents <AddCasterLevelEquipment>().ToArray();
                foreach (var b in boni)
                {
                    if (b.Spell == original_ability)
                    {
                        var b2 = b.CreateCopy();
                        b2.Spell = derived_ability;
                        b2.Bonus = boni[0].Bonus / 2 * level_scale;
                        e.AddComponent(b2);
                    }
                }
            }


            BlueprintBuff[] buffs = new BlueprintBuff[] { library.Get <BlueprintBuff>("b5ebb94df76531c4ca4f13bfd91efd4e") };// camp dish buff

            foreach (var buff in buffs)
            {
                var boni = buff.GetComponents <AddCasterLevelForAbility>().ToArray();
                foreach (var b in boni)
                {
                    if (b.Spell == original_ability)
                    {
                        var b2 = b.CreateCopy();
                        b2.Spell = derived_ability;
                        b2.Bonus = boni[0].Bonus / 2 * level_scale;
                        buff.AddComponent(b2);
                    }
                }
            }
        }
Beispiel #2
0
        static void updateItemsForQuick(BlueprintAbility original_ability, BlueprintAbility quicken_ability)
        {
            //phylacteries bonuses
            BlueprintEquipmentEnchantment[] enchants = new BlueprintEquipmentEnchantment[] { library.Get <Kingmaker.Blueprints.Items.Ecnchantments.BlueprintEquipmentEnchantment>("60f06749fa4729c49bc3eb2eb7e3b316"),
                                                                                             library.Get <Kingmaker.Blueprints.Items.Ecnchantments.BlueprintEquipmentEnchantment>("f5d0bf8c1b4574848acb8d1fbb544807"),
                                                                                             library.Get <Kingmaker.Blueprints.Items.Ecnchantments.BlueprintEquipmentEnchantment>("cb4a39044b59f5e47ad5bc08ff9d6669"),
                                                                                             library.Get <Kingmaker.Blueprints.Items.Ecnchantments.BlueprintEquipmentEnchantment>("e988cf802d403d941b2ed8b6016de68f"), };

            foreach (var e in enchants)
            {
                var boni = e.GetComponents <AddCasterLevelEquipment>().ToArray();
                foreach (var b in boni)
                {
                    if (b.Spell == original_ability)
                    {
                        var b2 = b.CreateCopy();
                        b2.Spell = quicken_ability;
                        e.AddComponent(b2);
                    }
                }
            }
        }
        public static void PatchItem <T>(FileInfo file, BlueprintScriptableObject blueprintScriptableObject, string guid)
        {
            Common.ModLoggerDebug($"{guid} -> {blueprintScriptableObject} ({blueprintScriptableObject.GetType()})");

            T   jsonItem  = DeserialiseItem <T>(file);
            var blueprint = Convert.ChangeType(blueprintScriptableObject, blueprintScriptableObject.GetType());

            foreach (PropertyInfo property in jsonItem.GetType().GetProperties())
            {
                if (property.Name == "m_BaseDamage" && Traverse.Create(jsonItem).Property("m_BaseDamage").GetValue() != null)
                {
                    ModifiedDiceFormula dice        = (ModifiedDiceFormula)property.GetValue(jsonItem);
                    DiceFormula         diceFormula = new DiceFormula((int)dice.m_Rolls, (DiceType)dice.m_Dice);
                    Traverse.Create(blueprint).Field("m_BaseDamage").SetValue(diceFormula);

                    Common.ModLoggerDebug($"{blueprint} m_BaseDamage set to {diceFormula}.");
                }
                else if (property.Name == "m_DamageDice" && Traverse.Create(jsonItem).Property("m_DamageDice").GetValue() != null)
                {
                    ModifiedDiceFormula dice        = (ModifiedDiceFormula)property.GetValue(jsonItem);
                    DiceFormula         diceFormula = new DiceFormula((int)dice.m_Rolls, (DiceType)dice.m_Dice);
                    Traverse.Create(blueprint).Field("m_DamageDice").SetValue(diceFormula);

                    Common.ModLoggerDebug($"{blueprint} m_DamageDice set to {diceFormula}.");
                }
                else if (property.Name == "m_Enchantments" && Traverse.Create(jsonItem).Property("m_Enchantments").GetValue() != null)
                {
                    if (typeof(T) == typeof(EnchantableEquipment))
                    {
                        string[] enchantmentsGUIDS = (string[])Traverse.Create(jsonItem).Property("m_Enchantments").GetValue();
                        BlueprintEquipmentEnchantment[] enchantmentsBlueprints = new BlueprintEquipmentEnchantment[enchantmentsGUIDS.Length];
                        for (int i = 0; i < enchantmentsGUIDS.Length; i++)
                        {
                            string enchantmentGUID = CleanEnchantment(enchantmentsGUIDS[i]);
                            enchantmentsBlueprints[i] = (BlueprintEquipmentEnchantment)Utilities.GetBlueprintByGuid <BlueprintEquipmentEnchantment>(enchantmentGUID);
                        }

                        Traverse.Create(blueprint).Field("m_Enchantments").SetValue(enchantmentsBlueprints);

                        Common.ModLoggerDebug($"{blueprint} m_Enchantments set to {enchantmentsBlueprints}.");
                    }
                    else if (typeof(T) == typeof(ModifiedWeapon))
                    {
                        string[] enchantmentsGUIDS = (string[])Traverse.Create(jsonItem).Property("m_Enchantments").GetValue();
                        BlueprintWeaponEnchantment[] enchantmentsBlueprints = new BlueprintWeaponEnchantment[enchantmentsGUIDS.Length];
                        for (int i = 0; i < enchantmentsGUIDS.Length; i++)
                        {
                            string enchantmentGUID = CleanEnchantment(enchantmentsGUIDS[i]);
                            enchantmentsBlueprints[i] = (BlueprintWeaponEnchantment)Utilities.GetBlueprintByGuid <BlueprintWeaponEnchantment>(enchantmentGUID);
                        }
                        Traverse.Create(blueprint).Field("m_Enchantments").SetValue(enchantmentsBlueprints);

                        Common.ModLoggerDebug($"{blueprint} m_Enchantments set to {enchantmentsBlueprints}.");
                    }
                }
                else
                {
                    SetBlueprintField(blueprint, jsonItem, property.Name);
                }
            }
        }