private void ProcessLootItem(uint containerID, string containerName, int landcell, string location, IdentResponse identResponse) { // Player Corpses if (containerName == "Corpse of Father Of Sin" || containerName == "Corpse of Copastetic" || containerName == "Corpse of Blumenkind" || containerName == "Corpse of Cyberkiller" || containerName == "Corpse of Sholdslastridelc" || containerName == "Corpse of Thisistheendmyonlyfriendtheend") { Interlocked.Increment(ref skippedLines); return; } // Housing containers can contain anything if (containerName == "Chest") { Interlocked.Increment(ref skippedLines); return; } // These landscape containers seem to be multi-tier if (containerName == "Runed Chest" || containerName == "Coral Encrusted Chest") { Interlocked.Increment(ref skippedLines); return; } // These items are odd-balls that were found in corpses. Possibly code error, or maybe a player put the item in the corpse? // Corpse of Grave Rat if (identResponse.Id == 0xDD2B79A9 && identResponse.StringValues[Mag.Shared.Constants.StringValueKey.Name] == "Electric Spine Glaive") { Interlocked.Increment(ref skippedLines); return; } // Corpse of Drudge Slave if (identResponse.Id == 0xDC94F88A && identResponse.StringValues[Mag.Shared.Constants.StringValueKey.Name] == "Heavy Crossbow") { Interlocked.Increment(ref skippedLines); return; } if (identResponse.Id == 0xDC9AE6E2 && identResponse.StringValues[Mag.Shared.Constants.StringValueKey.Name] == "Katar") { Interlocked.Increment(ref skippedLines); return; } // Corpse of Mercenary if (identResponse.Id == 0xABCC0A35 && identResponse.StringValues[Mag.Shared.Constants.StringValueKey.Name] == "Studded Leather Breastplate") { Interlocked.Increment(ref skippedLines); return; } // Not sure why corpses are being detected as inside a container, probably a data bug if (identResponse.ObjectClass == Mag.Shared.ObjectClass.Corpse) { Interlocked.Increment(ref skippedLines); return; } lock (processLockObject) { List <ContainerInfo> containers; if (containersLoot.ContainsKey(containerName)) { containers = containersLoot[containerName]; } else { containers = new List <ContainerInfo>(); containersLoot.Add(containerName, containers); } ContainerInfo containerInfo = null; foreach (var container in containers) { if (container.Id == containerID && container.Name == containerName && container.Landcell == landcell && container.Location == location) { containerInfo = container; break; } } if (containerInfo == null) { containerInfo = new ContainerInfo { Id = containerID, Name = containerName, Landcell = landcell, Location = location }; containers.Add(containerInfo); } // Does this item already exist? foreach (var item in containerInfo.Items) { if (item.Id == identResponse.Id) { return; } } containerInfo.Items.Add(identResponse); return; } }
private void OnLoadFilesComplete() { if (chkGeneratecontainersLootJson.Checked) { var workignOutputJsonFolder = Path.Combine(txtOutputPath.Text, DateTime.Now.ToString("yyyy-MM-dd HH-mm") + " containers json"); if (!Directory.Exists(workignOutputJsonFolder)) { Directory.CreateDirectory(workignOutputJsonFolder); } foreach (var kvp in containersLoot) { var containersLootJson = JsonConvert.SerializeObject(kvp.Value); File.WriteAllText(Path.Combine(workignOutputJsonFolder, $"{kvp.Key}.json"), containersLootJson); } return; } var workignOutputFolder = Path.Combine(txtOutputPath.Text, DateTime.Now.ToString("yyyy-MM-dd HH-mm")); if (!Directory.Exists(workignOutputFolder)) { Directory.CreateDirectory(workignOutputFolder); } // Calculate the stats StatsCalculator.Calculate(containersLoot); // Populate the Containers tab var dt = new DataTable(); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Tier", typeof(int)); dt.Columns.Add("Hits", typeof(int)); dt.Columns.Add("Average Items", typeof(float)); dt.Columns.Add("Total Items", typeof(int)); foreach (var stats in StatsCalculator.StatsByContainerNameAndTier) { var dr = dt.NewRow(); dr["Name"] = stats.ContainerName; dr["Tier"] = stats.Tier; dr["Hits"] = stats.TotalContainers; dr["Average Items"] = stats.TotalItems / (float)stats.TotalContainers; dr["Total Items"] = stats.TotalItems; dt.Rows.Add(dr); } dataGridView1.DataSource = dt; dataGridView1.Columns["Hits"].DefaultCellStyle.Format = "N0"; dataGridView1.Columns["Average Items"].DefaultCellStyle.Format = "0.0"; dataGridView1.Columns["Total Items"].DefaultCellStyle.Format = "N0"; for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (i == 0) { continue; } dataGridView1.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridView1.AutoResizeColumns(); // Output stats by tier foreach (var kvp in StatsCalculator.StatsByLootTier) { File.WriteAllText(Path.Combine(workignOutputFolder, "Tier " + kvp.Key + " (No Chests).txt"), kvp.Value.ToString()); } // Output stats by container name foreach (var stats in StatsCalculator.StatsByContainerNameAndTier) { File.WriteAllText(Path.Combine(workignOutputFolder, "Container " + stats.ContainerName + $" (T{stats.Tier}).txt"), stats.ToString()); } // Audit all the containers for anomolies File.Delete(Path.Combine(workignOutputFolder, "Tier Container Audit.txt")); foreach (var stats in StatsCalculator.StatsByContainerNameAndTier) { // Chests of the same name can contain multiple tiers if (ContainerInfo.IsChest(stats.ContainerName)) { continue; } outputAuditLine = false; ContainerTierAuditSpells(stats, 1, Mag.Shared.Spells.Spell.BuffLevels.I, Mag.Shared.Spells.Spell.BuffLevels.III); ContainerTierAuditSpells(stats, 2, Mag.Shared.Spells.Spell.BuffLevels.III, Mag.Shared.Spells.Spell.BuffLevels.V); ContainerTierAuditSpells(stats, 3, Mag.Shared.Spells.Spell.BuffLevels.IV, Mag.Shared.Spells.Spell.BuffLevels.VI); ContainerTierAuditSpells(stats, 4, Mag.Shared.Spells.Spell.BuffLevels.IV, Mag.Shared.Spells.Spell.BuffLevels.VI); ContainerTierAuditSpells(stats, 5, Mag.Shared.Spells.Spell.BuffLevels.V, Mag.Shared.Spells.Spell.BuffLevels.VII); ContainerTierAuditSpells(stats, 6, Mag.Shared.Spells.Spell.BuffLevels.VI, Mag.Shared.Spells.Spell.BuffLevels.VII); ContainerTierAuditSpells(stats, 7, Mag.Shared.Spells.Spell.BuffLevels.VI, Mag.Shared.Spells.Spell.BuffLevels.VIII); ContainerTierAuditSpells(stats, 8, Mag.Shared.Spells.Spell.BuffLevels.VI, Mag.Shared.Spells.Spell.BuffLevels.VIII); ContainerTierAuditWieldReqs(stats, 1, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 2, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 0, 250 }); ContainerTierAuditWieldReqs(stats, 3, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 0, 250, 300 }); ContainerTierAuditWieldReqs(stats, 4, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 0, 250, 300, 325 }); ContainerTierAuditWieldReqs(stats, 5, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 300, 325, 350 }); ContainerTierAuditWieldReqs(stats, 6, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 350, 370, 400 }); ContainerTierAuditWieldReqs(stats, 7, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 370, 400, 420 }); ContainerTierAuditWieldReqs(stats, 8, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.TwoHandedCombat, (int)Skill.HeavyWeapons, (int)Skill.LightWeapons, (int)Skill.FinesseWeapons }, new HashSet <int> { 400, 420, 430 }); ContainerTierAuditWieldReqs(stats, 1, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 2, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 0, 250 }); ContainerTierAuditWieldReqs(stats, 3, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 0, 250, 270 }); ContainerTierAuditWieldReqs(stats, 4, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 250, 270, 290 }); ContainerTierAuditWieldReqs(stats, 5, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 270, 290, 315 }); ContainerTierAuditWieldReqs(stats, 6, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 315, 335, 360 }); ContainerTierAuditWieldReqs(stats, 7, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 335, 360, 375 }); ContainerTierAuditWieldReqs(stats, 8, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.MissileWeapons }, new HashSet <int> { 360, 375, 385 }); ContainerTierAuditWieldReqs(stats, 1, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 2, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 3, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0 }); ContainerTierAuditWieldReqs(stats, 4, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0, 290 }); ContainerTierAuditWieldReqs(stats, 5, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0, 290, 310 }); ContainerTierAuditWieldReqs(stats, 6, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 0, 290, 310, 330, 355 }); ContainerTierAuditWieldReqs(stats, 7, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 330, 355, 375 }); ContainerTierAuditWieldReqs(stats, 8, (int)WieldRequirement.RawSkill, new HashSet <int> { (int)Skill.WarMagic, (int)Skill.VoidMagic }, new HashSet <int> { 355, 375, 385 }); if (outputAuditLine) { File.AppendAllText(Path.Combine(workignOutputFolder, "Tier Container Audit.txt"), Environment.NewLine); } } }