static void Postfix(Mech __instance, ref float amt, StabilityChangeSource source) { try { Logger.Debug("[Mech_AddInstability_POSTFIX] __instance.DisplayName: " + __instance.DisplayName); //Logger.Debug("[Mech_AddInstability_POSTFIX] amt: " + amt); Logger.Debug("[Mech_AddInstability_POSTFIX] source: " + source); if (source != StabilityChangeSource.Jumping) { return; } float maxStability = __instance.MaxStability; Logger.Debug("[Mech_AddInstability_PREFIX] maxStability: " + maxStability); float currentStability = (float)AccessTools.Property(typeof(Mech), "_stability").GetValue(__instance, null); Logger.Debug("[Mech_AddInstability_PREFIX] currentStability: " + currentStability); float unsteadyThreshold = __instance.UnsteadyThreshold; Logger.Debug("[Mech_AddInstability_PREFIX] unsteadyThreshold: " + unsteadyThreshold); float percentStability = __instance.StabilityPercentage; Logger.Debug("[Mech_AddInstability_PREFIX] percentStability: " + percentStability); __instance.NeedsInstabilityCheck = true; // Fails if unit is already unsteady before the jump -> gains evasion even though unsteady //__instance.CheckForInstability(); if (currentStability > unsteadyThreshold) { // Add floatie again if unit WAS ALREADY unsteady and still is after jumping if (__instance.IsUnsteady) { __instance.Combat.MessageCenter.PublishMessage(new FloatieMessage(__instance.GUID, __instance.GUID, "UNSTEADY", FloatieMessage.MessageNature.Debuff)); } // Would make Mech fall if attacked by anything in this state /* * if (__instance.IsUnsteady && percentStability >= 1f ) * { * __instance.Combat.MessageCenter.PublishMessage(new FloatieMessage(__instance.GUID, __instance.GUID, "OFF BALANCE", FloatieMessage.MessageNature.Debuff)); * __instance.FlagForKnockdown(); * } */ // Will strip all evasion if over threshold after landing __instance.ApplyUnsteady(); } } catch (Exception e) { Logger.Error(e); } }
static void Prefix(Mech __instance, float amt, StabilityChangeSource source, string sourceGuid) { if (amt > 0f) { float currentStability = __instance.CurrentStability + amt; float maxStability = __instance.MaxStability; if (currentStability / maxStability >= 1.25f) { //doing 25% stability damage over the maximum will result in a knockdown __instance.FlagForKnockdown(); } } }
private static void Postfix(Mech __instance, float amt, StabilityChangeSource source, string sourceGuid) { if (__instance == null) { Log.Debug?.Write("No mech\n"); return; } Log.Debug?.Write($"{new string('═', 46)}\n"); Log.Debug?.Write($"{__instance.DisplayName} :{__instance.GUID } took {amt} Stability Damage from {source}\n"); //DamageHelper.BatchHeatDamage(__instance, amt); if (__instance.isHasStability()) { __instance.IncomingDamage().Stability(amt); } }
static void Postfix(SelectionStateMove __instance, ref float __result) { Mod.Log.Trace?.Write("SSM:PSFS - entered."); MeleeAttack selectedAttack = ModState.GetSelectedAttack(__instance.SelectedActor); if (__instance.SelectedActor is Mech selectedMech && selectedAttack != null && __instance.PotentialMeleeTarget != null) { float newStability = selectedMech.CurrentStability + selectedAttack.AttackerInstability; List <WayPoint> waypoints = ActorMovementSequence.ExtractWaypointsFromPath(selectedMech, selectedMech.Pathing.CurrentPath, selectedMech.Pathing.ResultDestination, selectedMech.Pathing.CurrentMeleeTarget, selectedMech.Pathing.MoveType); StabilityChangeSource changeSource = StabilityChangeSource.Moving; if (WayPoint.GetDistFromWaypointList(selectedMech.CurrentPosition, waypoints) < 1f) { changeSource = StabilityChangeSource.RemainingStationary; } float minStability = selectedMech.GetMinStability(changeSource, newStability); Mod.Log.Debug?.Write($"Stability change for {CombatantUtils.Label(selectedMech)} => " + $"current: {selectedMech.CurrentStability} projectedNew: {selectedAttack.AttackerInstability} " + $"totalChange: {newStability} afterDump: {minStability}"); __result = minStability; } }