public static void Postfix(SimGameState __instance, List <TemporarySimGameResult> ___TemporaryResultTracker) { List <Pilot> list = new List <Pilot>(__instance.PilotRoster); list.Add(__instance.Commander); for (int j = 0; j < list.Count; j++) { Pilot pilot = list[j]; if (pilot.pilotDef.PilotTags.Contains("pilot_lightinjury") && pilot.Injuries == 0) { pilot.StatCollection.ModifyStat <int>("Light Injury", 0, "Injuries", StatCollection.StatOperation.Set, 1, -1, true); } if (pilot.pilotDef.TimeoutRemaining != 0) { int FatigueTime = pilot.pilotDef.TimeoutRemaining; pilot.pilotDef.SetTimeoutTime(FatigueTime - 1); } if (pilot.pilotDef.TimeoutRemaining == 0 && pilot.pilotDef.PilotTags.Contains("pilot_fatigued")) { pilot.pilotDef.PilotTags.Remove("pilot_fatigued"); } if (pilot.pilotDef.TimeoutRemaining == 0 && pilot.pilotDef.PilotTags.Contains("pilot_lightinjury")) { pilot.pilotDef.PilotTags.Remove("pilot_lightinjury"); pilot.StatCollection.ModifyStat <int>("Light Injury Healed", 0, "Injuries", StatCollection.StatOperation.Set, 0, -1, true); } if (pilot.pilotDef.PilotTags.Contains("PF_pilot_morale_low")) { pilot.pilotDef.PilotTags.Remove("PF_pilot_morale_low"); pilot.pilotDef.PilotTags.Add("pilot_morale_low"); var eventTagSet = new TagSet(); Traverse.Create(eventTagSet).Field("items").SetValue(new string[] { "pilot_morale_low" }); Traverse.Create(eventTagSet).Field("tagSetSourceFile").SetValue("Tags/PilotTags"); Traverse.Create(eventTagSet).Method("UpdateHashCode").GetValue(); var EventTime = new TemporarySimGameResult(); EventTime.ResultDuration = settings.LowMoraleTime - 2; EventTime.Scope = EventScope.MechWarrior; EventTime.TemporaryResult = true; EventTime.AddedTags = eventTagSet; Traverse.Create(EventTime).Field("targetPilot").SetValue(pilot); Traverse.Create(__instance).Method("AddOrRemoveTempTags", new[] { typeof(TemporarySimGameResult), typeof(bool) }). GetValue(EventTime, true); ___TemporaryResultTracker.Add(EventTime); } } }
public static void Prefix(SimGameState __instance, bool updateMorale, List <TemporarySimGameResult> ___TemporaryResultTracker) { var settings = Pre_Control.Settings; if (updateMorale) { var expenseLevel = __instance.CompanyStats.GetValue <int>("ExpenseLevel"); if (expenseLevel < 0) { expenseLevel = expenseLevel * 2; } int dMechTech = expenseLevel * settings.MechTechScale; int dMedTech = expenseLevel; if (!settings.AdjustTechs) { dMechTech = 0; dMedTech = 0; } var StartingMechTech = __instance.CompanyStats.GetValue <int>("MechTechSkill"); var StartingMedTech = __instance.CompanyStats.GetValue <int>("MedTechSkill"); var MechTChange = StartingMechTech + dMechTech; var MedTChange = StartingMedTech + dMedTech; if (MechTChange < 1) { MechTChange = 1; } if (MedTChange < 1) { MedTChange = 1; } __instance.CompanyStats.Set <int>("MechTechSkill", MechTChange); __instance.CompanyStats.Set <int>("MedTechSkill", MedTChange); Fields.DeltaMechTech = StartingMechTech - MechTChange; Fields.DeltaMedTech = StartingMedTech - MedTChange; Fields.ExpenseLevel = __instance.CompanyStats.GetValue <int>("ExpenseLevel"); SaveFields = new SaveFields(Fields.ExpenseLevel, Fields.DeltaMechTech, Fields.DeltaMedTech); SaveHandling.SerializeMTMA(); //Pilot Quirk area foreach (Pilot pilot in __instance.PilotRoster) { if (pilot.pilotDef.PilotTags.Contains("pilot_noble") && settings.QuirksEnabled) { if (pilot.pilotDef.PilotTags.Contains("pilot_morale_high")) { pilot.pilotDef.PilotTags.Remove("pilot_morale_high"); } if (pilot.pilotDef.PilotTags.Contains("pilot_morale_low")) { pilot.pilotDef.PilotTags.Remove("pilot_morale_low"); } if (Fields.ExpenseLevel == 2) { pilot.pilotDef.PilotTags.Add("pilot_morale_high"); var eventTagSet = new TagSet(); Traverse.Create(eventTagSet).Field("items").SetValue(new string[] { "pilot_morale_high" }); Traverse.Create(eventTagSet).Field("tagSetSourceFile").SetValue("Tags/PilotTags"); Traverse.Create(eventTagSet).Method("UpdateHashCode").GetValue(); var EventTime = new TemporarySimGameResult(); EventTime.ResultDuration = 29; EventTime.Scope = EventScope.MechWarrior; EventTime.TemporaryResult = true; EventTime.AddedTags = eventTagSet; Traverse.Create(EventTime).Field("targetPilot").SetValue(pilot); Traverse.Create(__instance).Method("AddOrRemoveTempTags", new[] { typeof(TemporarySimGameResult), typeof(bool) }). GetValue(EventTime, true); ___TemporaryResultTracker.Add(EventTime); } else if (Fields.ExpenseLevel < 0) { pilot.pilotDef.PilotTags.Add("pilot_morale_low"); var eventTagSet = new TagSet(); Traverse.Create(eventTagSet).Field("items").SetValue(new string[] { "pilot_morale_low" }); Traverse.Create(eventTagSet).Field("tagSetSourceFile").SetValue("Tags/PilotTags"); Traverse.Create(eventTagSet).Method("UpdateHashCode").GetValue(); var EventTime = new TemporarySimGameResult(); EventTime.ResultDuration = 29; EventTime.Scope = EventScope.MechWarrior; EventTime.TemporaryResult = true; EventTime.AddedTags = eventTagSet; Traverse.Create(EventTime).Field("targetPilot").SetValue(pilot); Traverse.Create(__instance).Method("AddOrRemoveTempTags", new[] { typeof(TemporarySimGameResult), typeof(bool) }). GetValue(EventTime, true); ___TemporaryResultTracker.Add(EventTime); } } } foreach (Pilot pilot in __instance.PilotRoster) { var rng = new System.Random(); int Roll = rng.Next(1, 100); if (pilot.pilotDef.PilotTags.Contains("pilot_dishonest") && settings.QuirksEnabled) { if (Roll <= 33) { pilot.pilotDef.PilotTags.Add("pilot_drunk"); pilot.pilotDef.PilotTags.Remove("pilot_unstable"); pilot.pilotDef.PilotTags.Remove("pilot_rebellious"); } else if (Roll > 33 && Roll <= 66) { pilot.pilotDef.PilotTags.Remove("pilot_drunk"); pilot.pilotDef.PilotTags.Add("pilot_unstable"); pilot.pilotDef.PilotTags.Remove("pilot_rebellious"); } else { pilot.pilotDef.PilotTags.Remove("pilot_drunk"); pilot.pilotDef.PilotTags.Remove("pilot_unstable"); pilot.pilotDef.PilotTags.Add("pilot_rebellious"); } } } } }