Skip to content

Commit

Permalink
more text for mech assembly, salvage hopefully fixed full head ejecti…
Browse files Browse the repository at this point in the history
…on not counting as kill, salvage more logging
  • Loading branch information
mcb5637 committed Jun 14, 2020
1 parent fc6e528 commit a2abc5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions BTSimpleMechAssembly/SimpleMechAssembly_Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ public static void QueryMechAssemblyPopup(SimGameState s, MechDef d, MechBayPane
return;
}
List<MechDef> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ public static bool Prefix(Contract __instance, List<UnitResult> 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);
}

Expand Down Expand Up @@ -96,7 +99,7 @@ public static bool Prefix(Contract __instance, List<UnitResult> enemyMechs, List
private static void GenerateSalvageForMech(Contract __instance, UnitResult u, SimGameState s, List<SalvageDef> ___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)
Expand All @@ -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)
Expand Down

0 comments on commit a2abc5a

Please sign in to comment.