public static void LoadMines() { if (!File.Exists(@".\Mines.ini")) { MineSetList.Add(new MineSet(1)); MineSetList.Add(new MineSet(2)); SaveMines(); return; } InIReader reader = new InIReader(@".\Mines.ini"); int i = 0; MineSet Mine; while (reader.ReadByte("Mine" + i.ToString(), "SpotRegenRate", 255) != 255) { Mine = new MineSet(); Mine.Name = reader.ReadString("Mine" + i.ToString(), "Name", Mine.Name); Mine.SpotRegenRate = reader.ReadByte("Mine" + i.ToString(), "SpotRegenRate", Mine.SpotRegenRate); Mine.MaxStones = reader.ReadByte("Mine" + i.ToString(), "MaxStones", Mine.MaxStones); Mine.HitRate = reader.ReadByte("Mine" + i.ToString(), "HitRate", Mine.HitRate); Mine.DropRate = reader.ReadByte("Mine" + i.ToString(), "DropRate", Mine.DropRate); Mine.TotalSlots = reader.ReadByte("Mine" + i.ToString(), "TotalSlots", Mine.TotalSlots); int j = 0; while (reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MinSlot", 255) != 255) { Mine.Drops.Add(new MineDrop() { ItemName = reader.ReadString("Mine" + i.ToString(), "D" + j.ToString() + "-ItemName", ""), MinSlot = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MinSlot", 255), MaxSlot = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MaxSlot", 255), MinDura = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MinDura", 255), MaxDura = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MaxDura", 255), BonusChance = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-BonusChance", 255), MaxBonusDura = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MaxBonusDura", 255) }); j++; } MineSetList.Add(Mine); i++; } }
public static void LoadMines() { if (!File.Exists(ConfigPath + @".\Mines.ini")) { MineSetList.Add(new MineSet(1)); MineSetList.Add(new MineSet(2)); SaveMines(); return; } InIReader reader = new InIReader(ConfigPath + @".\Mines.ini"); int i = 0; MineSet Mine; while (reader.ReadByte("Mine" + i.ToString(), "SpotRegenRate", 255) != 255) { Mine = new MineSet(); Mine.Name = reader.ReadString("Mine" + i.ToString(), "Name", Mine.Name); Mine.SpotRegenRate = reader.ReadByte("Mine" + i.ToString(), "SpotRegenRate", Mine.SpotRegenRate); Mine.MaxStones = reader.ReadByte("Mine" + i.ToString(), "MaxStones", Mine.MaxStones); Mine.HitRate = reader.ReadByte("Mine" + i.ToString(), "HitRate", Mine.HitRate); Mine.DropRate = reader.ReadByte("Mine" + i.ToString(), "DropRate", Mine.DropRate); Mine.TotalSlots = reader.ReadByte("Mine" + i.ToString(), "TotalSlots", Mine.TotalSlots); int j = 0; while (reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MinSlot", 255) != 255) { Mine.Drops.Add(new MineDrop() { ItemName = reader.ReadString("Mine" + i.ToString(), "D" + j.ToString() + "-ItemName", ""), MinSlot = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MinSlot", 255), MaxSlot = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MaxSlot", 255), MinDura = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MinDura", 255), MaxDura = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MaxDura", 255), BonusChance = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-BonusChance", 255), MaxBonusDura = reader.ReadByte("Mine" + i.ToString(), "D" + j.ToString() + "-MaxBonusDura", 255) }); j++; } MineSetList.Add(Mine); i++; } }
public void GetMinePayout(MineSet Mine) { if ((Mine.Drops == null) || (Mine.Drops.Count == 0)) return; if (FreeSpace(Info.Inventory) == 0) return; byte Slot = (byte)Envir.Random.Next(Mine.TotalSlots); for (int i = 0; i < Mine.Drops.Count; i++) { MineDrop Drop = Mine.Drops[i]; if ((Drop.MinSlot <= Slot) && (Drop.MaxSlot >= Slot) && (Drop.Item != null)) { UserItem item = Envir.CreateDropItem(Drop.Item); if (item.Info.Type == ItemType.Ore) { item.CurrentDura = (ushort)Math.Min(ushort.MaxValue, (Drop.MinDura + Envir.Random.Next(Math.Max(0, Drop.MaxDura - Drop.MinDura))) * 1000); if ((Drop.BonusChance > 0) && (Envir.Random.Next(100) <= Drop.BonusChance)) item.CurrentDura = (ushort)Math.Min(ushort.MaxValue, item.CurrentDura + (Envir.Random.Next(Drop.MaxBonusDura) * 1000)); } if (CheckGroupQuestItem(item)) continue; if (CanGainItem(item, false)) { GainItem(item); Report.ItemChanged("MinePayout", item, item.Count, 2); } return; } } }