private static void Postfix(Mech __instance, ref float __result) { int turnsOverheated = __instance.StatCollection.GetValue <int>("TurnsOverheated"); if (__instance.IsOverheated && turnsOverheated > 0) { __result -= CBTHeat.GetOverheatedMovePenaltyForTurn(turnsOverheated); } }
private static void Postfix(ToHit __instance, ref float __result, AbstractActor attacker) { if (attacker is Mech) { Mech mech = (Mech)attacker; int turnsOverheated = mech.StatCollection.GetValue <int>("TurnsOverheated"); if (turnsOverheated > 0) { float modifier = CBTHeat.GetHeatToHitModifierForTurn(turnsOverheated); __result = modifier; } else { __result = 0f; } } }
private static void Prefix(Mech __instance, string sourceID, int stackItemID) { ILog heatLogger = HBS.Logging.Logger.GetLogger("CombatLog.Heat", LogLevel.Warning); if (heatLogger.IsLogEnabled) { heatLogger.Log(string.Format("[CBTHeat] Is Overheated: {0}", __instance.IsOverheated)); } if (__instance.IsOverheated) { CBTPilotingRules rules = new CBTPilotingRules(__instance.Combat); float gutsTestChance = rules.GetGutsModifier(__instance); float skillRoll = __instance.Combat.NetworkRandom.Float(); float ammoRoll = __instance.Combat.NetworkRandom.Float(); int turnsOverheated = __instance.StatCollection.GetValue <int>("TurnsOverheated"); float shutdownPercentage = CBTHeat.GetShutdownPercentageForTurn(turnsOverheated); float ammoExplosionPercentage = CBTHeat.GetAmmoExplosionPercentageForTurn(turnsOverheated); if (heatLogger.IsLogEnabled) { heatLogger.Log(string.Format("[CBTHeat] Turns Overheated: {0}", turnsOverheated)); heatLogger.Log(string.Format("[CBTHeat] Intiating Shutdown Override Check")); heatLogger.Log(string.Format("[CBTHeat] Guts Skill: {0}", (float)__instance.SkillGuts)); heatLogger.Log(string.Format("[CBTHeat] Guts Divisor: {0}", CBTHeat.Settings.GutsDivisor)); heatLogger.Log(string.Format("[CBTHeat] Guts Bonus: {0}", gutsTestChance)); heatLogger.Log(string.Format("[CBTHeat] Skill Roll: {0}", skillRoll)); heatLogger.Log(string.Format("[CBTHeat] Skill + Guts Roll: {0}", skillRoll + gutsTestChance)); heatLogger.Log(string.Format("[CBTHeat] Ammo Roll: {0}", ammoRoll)); heatLogger.Log(string.Format("[CBTHeat] Ammo + Guts Roll: {0}", ammoRoll + gutsTestChance)); heatLogger.Log(string.Format("[CBTHeat] Skill Target: {0}", shutdownPercentage)); heatLogger.Log(string.Format("[CBTHeat] Ammo Roll Target: {0}", ammoExplosionPercentage)); } if (CBTHeat.Settings.UseGuts) { ammoRoll = ammoRoll + gutsTestChance; skillRoll = skillRoll + gutsTestChance; } MultiSequence sequence = new MultiSequence(__instance.Combat); sequence.SetCamera(CameraControl.Instance.ShowDeathCam(__instance, false, -1f), 0); if (CBTHeat.CanAmmoExplode(__instance)) { if (ammoRoll < ammoExplosionPercentage) { __instance.Combat.MessageCenter.PublishMessage(new FloatieMessage(__instance.GUID, __instance.GUID, "Ammo Overheated!", FloatieMessage.MessageNature.CriticalHit)); var ammoBox = __instance.ammoBoxes.Where(box => box.CurrentAmmo > 0).OrderByDescending(box => box.CurrentAmmo / box.AmmoCapacity).FirstOrDefault(); if (ammoBox != null) { var fakeHit = new WeaponHitInfo(stackItemID, -1, -1, -1, string.Empty, string.Empty, -1, null, null, null, null, null, null, null, AttackDirection.None, Vector2.zero, null); ammoBox.DamageComponent(fakeHit, ComponentDamageLevel.Destroyed, true); } return; } sequence.AddChildSequence(new ShowActorInfoSequence(__instance, "Ammo Explosion Avoided!", FloatieMessage.MessageNature.Debuff, true), sequence.ChildSequenceCount - 1); } if (!__instance.IsPastMaxHeat) { if (skillRoll < shutdownPercentage) { if (heatLogger.IsLogEnabled) { heatLogger.Log(string.Format("[CBTHeat] Skill Check Failed! Initiating Shutdown")); } MechEmergencyShutdownSequence mechShutdownSequence = new MechEmergencyShutdownSequence(__instance); sequence.AddChildSequence(mechShutdownSequence, sequence.ChildSequenceCount - 1); __instance.StatCollection.Set <int>("TurnsOverheated", 0); } else { if (heatLogger.IsLogEnabled) { heatLogger.Log(string.Format("[CBTHeat] Skill Check Succeeded!")); } sequence.AddChildSequence(new ShowActorInfoSequence(__instance, "Shutdown Override Successful!", FloatieMessage.MessageNature.Buff, true), sequence.ChildSequenceCount - 1); turnsOverheated += 1; __instance.StatCollection.Set <int>("TurnsOverheated", turnsOverheated); } } sequence.AddChildSequence(new DelaySequence(__instance.Combat, 2f), sequence.ChildSequenceCount - 1); __instance.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(sequence)); } else { int turnsOverheated = __instance.StatCollection.GetValue <int>("TurnsOverheated"); if (turnsOverheated > 0) { __instance.StatCollection.Set <int>("TurnsOverheated", 0); } } }
private static void Postfix(CombatHUDStatusPanel __instance, Mech mech) { var type = __instance.GetType(); MethodInfo methodInfo = type.GetMethod("ShowDebuff", (BindingFlags.NonPublic | BindingFlags.Instance), null, new Type[] { typeof(SVGAsset), typeof(Text), typeof(Text), typeof(Vector3), typeof(bool) }, new ParameterModifier[5]); int turnsOverheated = mech.StatCollection.GetValue <int>("TurnsOverheated"); if (mech.IsShutDown) { methodInfo.Invoke(__instance, new object[] { LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.StatusShutDownIcon, new Text("SHUT DOWN", new object[0]), new Text("This target is easier to hit, and Called Shots can be made against this target.", new object[0]), __instance.defaultIconScale, false }); } else if (mech.IsOverheated) { string descr = string.Format("This unit may trigger a Shutdown at the end of the turn unless heat falls below critical levels.\nShutdown Chance: {0:P2}\nAmmo Explosion Chance: {1:P2}", CBTHeat.GetShutdownPercentageForTurn(turnsOverheated), CBTHeat.GetAmmoExplosionPercentageForTurn(turnsOverheated)); methodInfo.Invoke(__instance, new object[] { LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.StatusOverheatingIcon, new Text("OVERHEATING", new object[0]), new Text(descr, new object[0]), __instance.defaultIconScale, false }); } }