Beispiel #1
0
        public static void AddDefaultShrineDrops()
        {
            var t1 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier1);
            var t2 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier2);
            var t3 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier3);
            var eq = ItemDropAPI.GetDefaultEquipmentDropList();

            var shrineSelections = new[] {
                new List <ItemIndex> {
                    ItemIndex.None
                }.ToSelection(ItemDropAPI.DefaultShrineFailureWeight),
                t1.ToSelection(ItemDropAPI.DefaultShrineTier1Weight),
                t2.ToSelection(ItemDropAPI.DefaultShrineTier2Weight),
                t3.ToSelection(ItemDropAPI.DefaultShrineTier3Weight),
                eq.ToSelection(ItemDropAPI.DefaultShrineEquipmentWeight)
            };

            foreach (var sel in shrineSelections)
            {
                sel.IsDefaults = true;
            }

            RemoveDefaultDrops(ItemDropLocation.Shrine);
            ItemDropAPI.AddDrops(ItemDropLocation.Shrine, shrineSelections);
        }
        public static void AddBossDefaultDrops()
        {
            ItemDropAPI.IncludeSpecialBossDrops = true;

            var t2 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier2);

            ItemDropAPI.AddDropInformation(ItemDropLocation.Boss, t2.ToSelection());
        }
Beispiel #3
0
 private static void RemoveDefaultDrops(ItemDropLocation location)
 {
     if (ItemDropAPI.Selection.ContainsKey(location))
     {
         ItemDropAPI.RemoveDrops(location,
                                 ItemDropAPI.Selection[location]
                                 .Where(sel => sel.IsDefaults)
                                 .ToArray());
     }
 }
Beispiel #4
0
        public static void AddLunarChestDefaultDrops()
        {
            var lun = ItemDropAPI.GetDefaultLunarDropList();

            var lunarSelections = lun.ToSelection();

            lunarSelections.IsDefaults = true;

            RemoveDefaultDrops(ItemDropLocation.LunarChest);
            ItemDropAPI.AddDrops(ItemDropLocation.LunarChest, lunarSelections);
        }
Beispiel #5
0
        public static void AddEquipmentChestDefaultDrops()
        {
            var eq = ItemDropAPI.GetDefaultEquipmentDropList();

            var equipmentSelections = eq.ToSelection();

            equipmentSelections.IsDefaults = true;

            RemoveDefaultDrops(ItemDropLocation.EquipmentChest);
            ItemDropAPI.AddDrops(ItemDropLocation.EquipmentChest, eq.ToSelection());
        }
Beispiel #6
0
        public static void AddChestDefaultDrops()
        {
            var t1 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier1);
            var t2 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier2);
            var t3 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier3);

            var chestSelections = new[] {
                t1.ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                t2.ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                t3.ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance)
            };

            var lockboxSelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1).ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2).ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3).ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance)
            };

            var utilitySelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1, ItemTag.Utility).ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2, ItemTag.Utility).ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3, ItemTag.Utility).ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance),
            };

            var damageSelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1, ItemTag.Damage).ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2, ItemTag.Damage).ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3, ItemTag.Damage).ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance),
            };

            var healingSelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1, ItemTag.Healing).ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2, ItemTag.Healing).ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3, ItemTag.Healing).ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance),
            };

            var scavSelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1).ToSelection(ItemDropAPI.DefaultScavBackpackTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2).ToSelection(ItemDropAPI.DefaultScavBackpackTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3).ToSelection(ItemDropAPI.DefaultScavBackpackTier3DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Lunar).ToSelection(ItemDropAPI.DefaultScavBackpackLunarDropChance),
            };

            ItemDropAPI.AddDrops(ItemDropLocation.UtilityChest, utilitySelections);
            ItemDropAPI.AddDrops(ItemDropLocation.DamageChest, damageSelections);
            ItemDropAPI.AddDrops(ItemDropLocation.HealingChest, healingSelections);

            ItemDropAPI.AddDrops(ItemDropLocation.Lockbox, lockboxSelections);
            ItemDropAPI.AddDrops(ItemDropLocation.SmallChest, chestSelections);
            ItemDropAPI.AddDrops(ItemDropLocation.MediumChest, t2.ToSelection(ItemDropAPI.DefaultMediumChestTier2DropChance), t3.ToSelection(ItemDropAPI.DefaultMediumChestTier3DropChance));
            ItemDropAPI.AddDrops(ItemDropLocation.LargeChest, t3.ToSelection(ItemDropAPI.DefaultLargeChestTier3DropChance));
            ItemDropAPI.AddDrops(ItemDropLocation.ScavBackPack, scavSelections);
        }
Beispiel #7
0
        public static void AddBossDefaultDrops()
        {
            ItemDropAPI.IncludeSpecialBossDrops = true;

            var t2 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier2);

            var t2selections = t2.ToSelection();

            t2selections.IsDefaults = true;

            RemoveDefaultDrops(ItemDropLocation.Boss);
            ItemDropAPI.AddDrops(ItemDropLocation.Boss, t2selections);
        }
Beispiel #8
0
        private static void DropRewards(ILContext il)
        {
            var cursor = new ILCursor(il).Goto(0);

            cursor.GotoNext(MoveType.After, x => x.MatchCallvirt(typeof(Run).GetMethod("get_participatingPlayerCount")));
            cursor.Index += 1;

            cursor.EmitDelegate <Func <int> >(() => BossDropParticipatingPlayerCount ?? Run.instance.participatingPlayerCount);

            cursor.Emit(OpCodes.Stloc_0);

            cursor.GotoNext(x => x.MatchCall(typeof(PickupIndex).GetMethodCached("get_itemIndex")));

            var itemIndex = Reflection.ReadLocalIndex(cursor.Next.Next.OpCode, cursor.Next.Next.Operand);

            cursor.GotoNext(x => x.MatchCall(typeof(PickupIndex).GetConstructorCached(new[] { typeof(ItemIndex) })));
            cursor.GotoPrev(x => x.OpCode == OpCodes.Ldloca_S);

            var pickupIndex = (VariableDefinition)cursor.Next.Operand;

            cursor.Goto(0);

            cursor.GotoNext(x => x.MatchStloc(itemIndex));
            cursor.Emit(OpCodes.Stloc_S, itemIndex);


            cursor.Emit(OpCodes.Ldarg_0);
            cursor.Emit(OpCodes.Dup);
            cursor.Emit(OpCodes.Ldfld, typeof(BossGroup).GetFieldCached("rng"));
            cursor.EmitDelegate <Func <BossGroup, Xoroshiro128Plus, PickupIndex> >((self, rng) => {
                var norm = rng.nextNormalizedFloat;

                if (self.forceTier3Reward)
                {
                    var t3List    = ItemDropAPI.GetDefaultDropList(ItemTier.Tier3);
                    var selection = t3List.ToSelection();
                    return(GetSelection(new List <PickupSelection> {
                        selection
                    }, norm));
                }
                else
                {
                    return(GetSelection(ItemDropLocation.Boss, norm));
                }
            });

            cursor.Emit(OpCodes.Stloc_S, pickupIndex);
            cursor.Emit(OpCodes.Ldloca_S, pickupIndex);
            cursor.Emit(OpCodes.Call, typeof(PickupIndex).GetMethodCached("get_itemIndex"));
        }
        public static void AddChestDefaultDrops()
        {
            var t1 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier1);
            var t2 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier2);
            var t3 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier3);

            var chestSelections = new List <PickupSelection> {
                t1.ToSelection(ItemDropAPI.DefaultChestTier1DropChance),
                t2.ToSelection(ItemDropAPI.DefaultChestTier2DropChance),
                t3.ToSelection(ItemDropAPI.DefaultChestTier3DropChance)
            };

            ItemDropAPI.AddDropInformation(ItemDropLocation.SmallChest, chestSelections);
            ItemDropAPI.AddDropInformation(ItemDropLocation.MediumChest, t2.ToSelection(0.8f), t3.ToSelection(0.2f));
            ItemDropAPI.AddDropInformation(ItemDropLocation.LargeChest, t3.ToSelection());
        }
Beispiel #10
0
        private static void AddEquipmentAction(List <EquipmentDef> equipmentDefinitions)
        {
            foreach (var customEquipment in EquipmentDefinitions)
            {
                equipmentDefinitions.Add(customEquipment.EquipmentDef);

                R2API.Logger.LogInfo($"Custom Equipment: {customEquipment.EquipmentDef.nameToken} added");
            }

            var equipments      = EquipmentDefinitions.Where(c => c.EquipmentDef.canDrop && !c.EquipmentDef.isLunar).Select(x => x.EquipmentDef.equipmentIndex).ToArray();
            var lunarEquipments = EquipmentDefinitions.Where(c => c.EquipmentDef.canDrop && c.EquipmentDef.isLunar).Select(x => x.EquipmentDef.equipmentIndex).ToList();

            ItemDropAPI.AddToDefaultEquipment(equipments);
            ItemDropAPI.AddDrops(ItemDropLocation.LunarChest, lunarEquipments.ToSelection());

            _equipmentCatalogInitialized = true;
        }
Beispiel #11
0
        public static void AddDefaultShrineDrops()
        {
            var t1 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier1);
            var t2 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier2);
            var t3 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier3);
            var eq = ItemDropAPI.GetDefaultEquipmentDropList();

            var shrineSelections = new List <PickupSelection> {
                new List <ItemIndex> {
                    ItemIndex.None
                }.ToSelection(ItemDropAPI.DefaultShrineFailureWeight),
                t1.ToSelection(ItemDropAPI.DefaultShrineTier1Weight),
                t2.ToSelection(ItemDropAPI.DefaultShrineTier2Weight),
                t3.ToSelection(ItemDropAPI.DefaultShrineTier3Weight),
                eq.ToSelection(ItemDropAPI.DefaultShrineEquipmentWeight)
            };

            ItemDropAPI.AddDropInformation(ItemDropLocation.Shrine, shrineSelections);
        }
Beispiel #12
0
        private static void AddItemAction(List <ItemDef> itemDefinitions)
        {
            foreach (var customItem in ItemDefinitions)
            {
                itemDefinitions.Add(customItem.ItemDef);

                R2API.Logger.LogInfo($"Custom Item: {customItem.ItemDef.nameToken} added");
            }

            var t1Items    = ItemDefinitions.Where(x => x.ItemDef.tier == ItemTier.Tier1).Select(x => x.ItemDef.itemIndex).ToArray();
            var t2Items    = ItemDefinitions.Where(x => x.ItemDef.tier == ItemTier.Tier2).Select(x => x.ItemDef.itemIndex).ToArray();
            var t3Items    = ItemDefinitions.Where(x => x.ItemDef.tier == ItemTier.Tier3).Select(x => x.ItemDef.itemIndex).ToArray();
            var lunarItems = ItemDefinitions.Where(x => x.ItemDef.tier == ItemTier.Lunar).Select(x => x.ItemDef.itemIndex).ToArray();
            var bossItems  = ItemDefinitions.Where(x => x.ItemDef.tier == ItemTier.Boss).Select(x => x.ItemDef.itemIndex).ToArray();

            ItemDropAPI.AddToDefaultByTier(ItemTier.Tier1, t1Items);
            ItemDropAPI.AddToDefaultByTier(ItemTier.Tier2, t2Items);
            ItemDropAPI.AddToDefaultByTier(ItemTier.Tier3, t3Items);
            ItemDropAPI.AddToDefaultByTier(ItemTier.Lunar, lunarItems);
            ItemDropAPI.AddToDefaultByTier(ItemTier.Boss, bossItems);

            _itemCatalogInitialized = true;
        }
Beispiel #13
0
        public static void AddChestDefaultDrops()
        {
            var t1 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier1);
            var t2 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier2);
            var t3 = ItemDropAPI.GetDefaultDropList(ItemTier.Tier3);

            var chestSelections = new[] {
                t1.ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                t2.ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                t3.ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance)
            };

            var lockboxSelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1).ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2).ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3).ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance)
            };

            var utilitySelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1, ItemTag.Utility).ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2, ItemTag.Utility).ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3, ItemTag.Utility).ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance),
            };

            var damageSelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1, ItemTag.Damage).ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2, ItemTag.Damage).ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3, ItemTag.Damage).ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance),
            };

            var healingSelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1, ItemTag.Healing).ToSelection(ItemDropAPI.DefaultSmallChestTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2, ItemTag.Healing).ToSelection(ItemDropAPI.DefaultSmallChestTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3, ItemTag.Healing).ToSelection(ItemDropAPI.DefaultSmallChestTier3DropChance),
            };

            var scavSelections = new[] {
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier1).ToSelection(ItemDropAPI.DefaultScavBackpackTier1DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier2).ToSelection(ItemDropAPI.DefaultScavBackpackTier2DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Tier3).ToSelection(ItemDropAPI.DefaultScavBackpackTier3DropChance),
                ItemDropAPI.GetDefaultDropList(ItemTier.Lunar).ToSelection(ItemDropAPI.DefaultScavBackpackLunarDropChance),
            };

            var allSelections = new[] { chestSelections, lockboxSelections, utilitySelections, damageSelections, healingSelections, scavSelections };

            foreach (var selGroup in allSelections)
            {
                foreach (var sel in selGroup)
                {
                    sel.IsDefaults = true;
                }
            }

            var allLocations = new[] { ItemDropLocation.UtilityChest, ItemDropLocation.DamageChest, ItemDropLocation.HealingChest,
                                       ItemDropLocation.Lockbox, ItemDropLocation.SmallChest, ItemDropLocation.MediumChest, ItemDropLocation.LargeChest, ItemDropLocation.ScavBackPack };

            foreach (var selLoc in allLocations)
            {
                RemoveDefaultDrops(selLoc);
            }

            ItemDropAPI.AddDrops(ItemDropLocation.UtilityChest, utilitySelections);
            ItemDropAPI.AddDrops(ItemDropLocation.DamageChest, damageSelections);
            ItemDropAPI.AddDrops(ItemDropLocation.HealingChest, healingSelections);

            ItemDropAPI.AddDrops(ItemDropLocation.Lockbox, lockboxSelections);
            ItemDropAPI.AddDrops(ItemDropLocation.SmallChest, chestSelections);
            ItemDropAPI.AddDrops(ItemDropLocation.MediumChest, t2.ToSelection(ItemDropAPI.DefaultMediumChestTier2DropChance), t3.ToSelection(ItemDropAPI.DefaultMediumChestTier3DropChance));
            ItemDropAPI.AddDrops(ItemDropLocation.LargeChest, t3.ToSelection(ItemDropAPI.DefaultLargeChestTier3DropChance));
            ItemDropAPI.AddDrops(ItemDropLocation.ScavBackPack, scavSelections);
        }
Beispiel #14
0
        public static void AddLunarChestDefaultDrops()
        {
            var lun = ItemDropAPI.GetDefaultLunarDropList();

            ItemDropAPI.AddDropInformation(ItemDropLocation.LunarChest, lun.ToSelection());
        }
Beispiel #15
0
        public static void AddEquipmentChestDefaultDrops()
        {
            var eq = ItemDropAPI.GetDefaultEquipmentDropList();

            ItemDropAPI.AddDropInformation(ItemDropLocation.EquipmentChest, eq.ToSelection());
        }