From a2abc5a42f6b62b1c4333176ca360b186d152b53 Mon Sep 17 00:00:00 2001 From: mgrbo Date: Sun, 14 Jun 2020 17:37:50 +0200 Subject: [PATCH] more text for mech assembly, salvage hopefully fixed full head ejection not counting as kill, salvage more logging --- BTSimpleMechAssembly/SimpleMechAssembly_Main.cs | 4 ++-- .../SimpleMechAssembly_StructurePointBasedSalvage.cs | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/BTSimpleMechAssembly/SimpleMechAssembly_Main.cs b/BTSimpleMechAssembly/SimpleMechAssembly_Main.cs index 9f24407..fb97c33 100644 --- a/BTSimpleMechAssembly/SimpleMechAssembly_Main.cs +++ b/BTSimpleMechAssembly/SimpleMechAssembly_Main.cs @@ -264,14 +264,14 @@ public static void QueryMechAssemblyPopup(SimGameState s, MechDef d, MechBayPane return; } List mechs = GetAllAssemblyVariants(s, d); - string desc = "Yang: We have Parts for the following mech variants. What should i build?\n\n"; + string desc = $"Yang: Concerning the [[DM.MechDefs[{d.Description.Id}],{d.Chassis.Description.UIName} {d.Chassis.VariantName}]]: {d.Chassis.YangsThoughts}\n\n We have Parts for the following mech variants. What should i build?\n"; foreach (MechDef m in mechs) { int count = s.GetItemCount(m.Description.Id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY); if (count <= 0 && !CheckOmniKnown(s, d, m)) continue; int com = GetNumberOfMechsOwnedOfType(s, m); - desc += string.Format("[[DM.MechDefs[{4}],{0} {1}]] ({2} Parts/{3} Complete)\n", m.Chassis.Description.UIName, m.Chassis.VariantName, count, com, m.Description.Id); + desc += $"[[DM.MechDefs[{m.Description.Id}],{m.Chassis.Description.UIName} {m.Chassis.VariantName}]] ({count} Parts/{com} Complete)\n"; } GenericPopupBuilder pop = GenericPopupBuilder.Create("Assemble Mech?", desc); pop.AddButton("-", delegate diff --git a/BTSimpleMechAssembly/SimpleMechAssembly_StructurePointBasedSalvage.cs b/BTSimpleMechAssembly/SimpleMechAssembly_StructurePointBasedSalvage.cs index d696772..c3e4b86 100644 --- a/BTSimpleMechAssembly/SimpleMechAssembly_StructurePointBasedSalvage.cs +++ b/BTSimpleMechAssembly/SimpleMechAssembly_StructurePointBasedSalvage.cs @@ -53,8 +53,11 @@ public static bool Prefix(Contract __instance, List enemyMechs, List foreach (UnitResult u in enemyMechs) { - if (!(u.pilot.IsIncapacitated || u.mech.IsDestroyed || u.mech.Inventory.Any((x) => x.Def != null && x.Def.CriticalComponent && x.DamageLevel == ComponentDamageLevel.Destroyed))) + if (!(u.pilot.IsIncapacitated || u.pilot.HasEjected || u.mech.IsDestroyed || u.mech.Inventory.Any((x) => x.Def != null && x.Def.CriticalComponent && x.DamageLevel == ComponentDamageLevel.Destroyed))) + { + log.Log($"skipping salvage for mech {u.mech.Description.UIName} {u.mech.Chassis.VariantName}, cause its not dead"); continue; + } GenerateSalvageForMech(__instance, u, s, ___finalPotentialSalvage); } @@ -96,7 +99,7 @@ public static bool Prefix(Contract __instance, List enemyMechs, List private static void GenerateSalvageForMech(Contract __instance, UnitResult u, SimGameState s, List ___finalPotentialSalvage) { ILog log = SimpleMechAssembly_Main.Log; - log.Log("generating salvage for mech " + u.mech.Description.Name); + log.Log($"generating salvage for mech {u.mech.Chassis.Description.UIName} {u.mech.Chassis.VariantName}"); float maxstruct = 0; float currstruct = 0; foreach (ChassisLocations c in LP) @@ -113,7 +116,7 @@ private static void GenerateSalvageForMech(Contract __instance, UnitResult u, Si int maxparts = Math.Min(s.Constants.Story.DefaultMechPartMax, SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageMaxPartsFromMech); int minparts = 1; float parts = left * maxparts; - log.Log(string.Format("calculated parts {0}", parts)); + log.Log(string.Format("calculated parts {0}, ct is {1} of total points", parts, u.mech.GetChassisLocationDef(ChassisLocations.CenterTorso).InternalStructure * SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageHighPriorityFactor / maxstruct)); float fract = parts - (float) Math.Floor(parts); float rand = s.NetworkRandom.Float(0f, 1f); if (parts < minparts)