Esempio n. 1
0
        public static void GetEnchantmentFromItem_Post(Item base_item, Item item, ref BaseEnchantment __result)
        {
            try
            {
                if (!mod.Config.EnchantableScythes)
                {
                    return;
                }

                if (base_item is MeleeWeapon weapon && weapon.isScythe(-1))
                {
                    // actual enchantments
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 74))
                    {
                        var enchantmentRandom = new Random((int)(Game1.stats.getStat("timesEnchanted") + (uint)((int)Game1.uniqueIDForThisGame)));
                        __result = Utility.GetRandom(BaseEnchantment.GetAvailableEnchantmentsForItem(base_item as Tool), enchantmentRandom);
                        return;
                    }

                    // weapon forging
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 60))
                    {
                        __result = new EmeraldEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 62))
                    {
                        __result = new AquamarineEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 64))
                    {
                        __result = new RubyEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 66))
                    {
                        __result = new AmethystEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 68))
                    {
                        __result = new TopazEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 70))
                    {
                        __result = new JadeEnchantment();
                        return;
                    }

                    // deleted diamond case

                    __result = null;
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
Esempio n. 2
0
        public static void AddEnchantments(MeleeWeapon weapon)
        {
            AdvancedMeleeWeapon amw = GetAdvancedWeapon(weapon, null);

            if (amw != null && amw.enchantments.Any())
            {
                weapon.enchantments.Clear();
                foreach (AdvancedEnchantmentData aed in amw.enchantments)
                {
                    BaseWeaponEnchantment bwe = null;
                    switch (aed.type)
                    {
                    case "vampiric":
                        bwe = new VampiricEnchantment();
                        break;

                    case "jade":
                        bwe = new JadeEnchantment();
                        break;

                    case "aquamarine":
                        bwe = new AquamarineEnchantment();
                        break;

                    case "topaz":
                        bwe = new TopazEnchantment();
                        break;

                    case "amethyst":
                        bwe = new AmethystEnchantment();
                        break;

                    case "ruby":
                        bwe = new RubyEnchantment();
                        break;

                    case "emerald":
                        bwe = new EmeraldEnchantment();
                        break;

                    case "haymaker":
                        bwe = new HaymakerEnchantment();
                        break;

                    case "bugkiller":
                        bwe = new BugKillerEnchantment();
                        break;

                    case "crusader":
                        bwe = new CrusaderEnchantment();
                        break;

                    case "magic":
                        bwe = new MagicEnchantment();
                        break;

                    default:
                        bwe = new BaseWeaponEnchantment();
                        string key = aed.name;
                        context.Helper.Reflection.GetField <string>(bwe, "_displayName").SetValue(key);
                        break;
                    }
                    if (bwe != null)
                    {
                        weapon.enchantments.Add(bwe);
                        //context.Monitor.Log($"added enchantment {aed.type} to {weapon.Name} {weapon.enchantments.Count}");
                    }
                }
            }
        }