private void btnFixStuckFleeing_Click(object sender, EventArgs evar) { DialogResult res = MessageBox.Show("Do you want to try fix stuck minions? If so, make sure you do not save to the same map file OR have made a backup!", "Confirm fix", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (res == DialogResult.Cancel) { return; } int fixedMinions = 0; LayFile lay = SaveGamePlugin.LayFile; List <LayEntity> entities = new List <LayEntity>(); for (int i = 100; i < 113; i++) { entities = lay.FindEntities(i.ToString()); for (int e = 0; e < entities.Count; e++) { LayEntity minion = entities[e]; if (minion.Stats.Health.ToInteger() < 1) { if ((minion.GetProperty("IsDead") != null) || (minion.GetProperty("IsUnconscious") != null) || (minion.GetProperty("IsIncapacitated") != null)) { continue; } minion.GetProperty("EarmarkedForEntityID").Value = "0"; minion.GetProperty("ForceDesert").Value = "false"; if (minion.GetProperty("InteractionObject") != null) { minion.GetProperty("InteractionObject").Deleted = true; } if (minion.GetProperty("InteractionSlotIndex") != null) { minion.GetProperty("InteractionSlotIndex").Deleted = true; } if (minion.GetProperty("InteractionTermReq") != null) { minion.GetProperty("InteractionTermReq").Deleted = true; } fixedMinions++; } } } MessageBox.Show("Fixed " + fixedMinions.ToString() + " minion(s). Be sure to test out if the fix worked!", "Fix applied.", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btlCleanDeadMinions_Click(object sender, EventArgs ex) { DialogResult res = MessageBox.Show("Do you want to try clean hidden dead minions? If so, make sure you do not save to the same map file OR have made a backup!", "Confirm fix", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (res == DialogResult.Cancel) { return; } int fixedMinions = 0; LayFile lay = SaveGamePlugin.LayFile; List <LayEntity> entities = new List <LayEntity>(); for (int i = 100; i < 113; i++) { entities = lay.FindEntities(i.ToString()); for (int e = 0; e < entities.Count; e++) { LayEntity minion = entities[e]; if (minion.Stats.Health.ToInteger() < 1) { if ((minion.GetProperty("IsDead") != null) && (minion.GetProperty("IsUnconscious") != null) && (minion.GetProperty("IsIncapacitated") != null) && (minion.GetProperty("Destroyed") != null) && (minion.GetProperty("NotInGame") == null)) { int cnt = 0; List <LayProperty> props = lay.FindProperties("EntityID"); foreach (LayProperty prop in props) { if (prop.Value == minion.EntityID) { cnt++; } } if (cnt == 1) { minion.Delete(); fixedMinions++; } } } } } MessageBox.Show("Cleaned " + fixedMinions.ToString() + " dead hidden minion(s). Be sure to test out if the fix worked!", "Fix applied.", MessageBoxButtons.OK, MessageBoxIcon.Information); }