// false is punchin' out public static bool SavedVsEject(AbstractActor actor, float savingThrow) { LogReport("Panic save failure requires eject save"); try { if (actor.IsPilotable && actor.GetPilot() != null && actor.GetPilot().StatCollection.GetValue <bool>("CanEject") == false) { LogReport($"Pilot CanEject Stat false - {(modSettings.ObeyPilotCanEjectStat ? "":"NOT")} obeying"); LogActor(actor, true); if (modSettings.ObeyPilotCanEjectStat) { return(true); } } if (actor.IsPilotable && actor.GetPilot() != null && actor.GetPilot().pilotDef.PilotTags.Contains("pilot_cannot_eject")) { LogReport($"Pilot pilot_cannot_eject Tag set - {(modSettings.ObeyPilotCannotEjectTag ? "" : "NOT")} obeying"); LogActor(actor, true); if (modSettings.ObeyPilotCannotEjectTag) { return(true); } } } catch (Exception ex) { LogDebug(ex); } var pilotTracker = TrackedActors.First(tracker => tracker.Guid == actor.GUID); if (pilotTracker.PreventEjection) { LogReport("Ejection forbidden after crit unless already stressed or panicked"); pilotTracker.PreventEjection = false; return(true); } DrawHeader(); if (actor is Mech mech && modSettings.QuirksEnabled) { if (mech.pilot.pilotDef.PilotTags.Contains("pilot_dependable")) { savingThrow -= modSettings.DependableModifier; LogReport($"{"Dependable",-20} | {modSettings.DependableModifier,10} | {savingThrow,10:F3}"); } } // calculate result if (modSettings.VehiclesCanPanic && actor is Vehicle) { savingThrow = Math.Max(0f, savingThrow - modSettings.BaseVehicleEjectionResist); LogReport($"{"Base ejection resist",-20} | {modSettings.BaseVehicleEjectionResist,10} | {savingThrow,10:F3}"); } else if (actor is Mech) { savingThrow = Math.Max(0f, savingThrow - modSettings.BaseEjectionResist); LogReport($"{"Base ejection resist",-20} | {modSettings.BaseEjectionResist,10} | {savingThrow,10:F3}"); } savingThrow = (float)Math.Round(savingThrow); LogReport($"{"Eject multiplier",-20} | {modSettings.EjectChanceFactor,10} | {savingThrow,10:F3}"); var roll = Random.Range(1, 100); LogReport(new string('-', 46)); LogReport($"{"Saving throw",-20} | {savingThrow,-5:###}{roll,5} | {"Roll",10}"); LogReport(new string('-', 46)); if (!modSettings.AlwaysPanic && savingThrow < 1) { LogReport("Negative saving throw| skipping"); SaySpamFloatie(actor, $"{modSettings.PanicSpamEjectResistString}"); return(true); } // cap the saving throw by the setting savingThrow = (int)Math.Min(savingThrow, modSettings.MaxEjectChance); SaySpamFloatie(actor, $"{modSettings.PanicSpamSaveString}:{savingThrow} {modSettings.PanicSpamRollString}:{roll}!"); if (!modSettings.AlwaysPanic && roll >= savingThrow) { LogReport("Successful ejection save"); SaySpamFloatie(actor, $"{modSettings.PanicSpamSaveString}! {ActorHealth(actor):#.#}%"); return(true); } // TODO can it be written if (mech != null) ? I don't know and testing it is a PITA! if (actor is Mech m) { if (modSettings.QuirksEnabled && m.MechDef.Chassis.ChassisTags.Contains("mech_quirk_noeject")) { LogReport("This mech can't eject (quirk)"); actor.Combat.MessageCenter.PublishMessage( new AddSequenceToStackMessage( new ShowActorInfoSequence(actor, "Mech quirk: Can't eject", FloatieMessage.MessageNature.PilotInjury, true))); return(true); } if (modSettings.QuirksEnabled && m.pilot.pilotDef.PilotTags.Contains("pilot_drunk") && m.pilot.pilotDef.TimeoutRemaining > 0) { LogReport("Drunkard - not ejecting"); actor.Combat.MessageCenter.PublishMessage( new AddSequenceToStackMessage( new ShowActorInfoSequence(actor, "Pilot quirk: Drunkard won't eject", FloatieMessage.MessageNature.PilotInjury, true))); return(true); } } LogReport("Failed ejection save: Punchin\' Out!!"); return(false); }
// false is punchin' out public static bool SavedVsEject(AbstractActor actor, float savingThrow) { LogReport("Panic save failure requires eject save"); var pilotTracker = TrackedActors.First(tracker => tracker.Mech == actor.GUID); if (pilotTracker.PreventEjection) { LogReport("Ejection forbidden after crit unless already stressed or panicked"); pilotTracker.PreventEjection = false; return(true); } DrawHeader(); if (actor is Mech mech && modSettings.QuirksEnabled) { if (mech.pilot.pilotDef.PilotTags.Contains("pilot_dependable")) { savingThrow -= modSettings.DependableModifier; LogReport($"{"Dependable",-20} | {modSettings.DependableModifier,10} | {savingThrow,10:F3}"); } } // calculate result if (modSettings.VehiclesCanPanic && actor is Vehicle) { savingThrow = Math.Max(0f, savingThrow - modSettings.BaseVehicleEjectionResist); LogReport($"{"Base ejection resist",-20} | {modSettings.BaseVehicleEjectionResist,10} | {savingThrow,10:F3}"); } else if (actor is Mech) { savingThrow = Math.Max(0f, savingThrow - modSettings.BaseEjectionResist); LogReport($"{"Base ejection resist",-20} | {modSettings.BaseEjectionResist,10} | {savingThrow,10:F3}"); } if (modSettings.VehiclesCanPanic && actor is Vehicle) { savingThrow = damageWithHeatDamage; } savingThrow = (float)Math.Round(savingThrow); LogReport($"{"Eject multiplier",-20} | {modSettings.EjectChanceFactor,10} | {savingThrow,10:F3}"); var roll = Random.Range(1, 100); LogReport(new string('-', 46)); LogReport($"{"Saving throw",-20} | {savingThrow,-5:###}{roll,5} | {"Roll",10}"); LogReport(new string('-', 46)); if (savingThrow <= 0) { LogReport("Negative saving throw| skipping"); SaySpamFloatie(actor, "EJECT RESIST!"); return(true); } // cap the saving throw by the setting savingThrow = (int)Math.Min(savingThrow, modSettings.MaxEjectChance); SaySpamFloatie(actor, $"SAVE: {savingThrow} ROLL: {roll}!"); if (roll >= savingThrow) { LogReport("Successful ejection save"); SaySpamFloatie(actor, $"EJECT SAVE! HEALTH: {ActorHealth(actor):#.#}%"); return(true); } // TODO can it be written if (mech != null) ? I don't know and testing it is a PITA! if (actor is Mech m) { if (modSettings.QuirksEnabled && m.MechDef.Chassis.ChassisTags.Contains("mech_quirk_noeject")) { LogReport("This mech can't eject (quirk)"); actor.Combat.MessageCenter.PublishMessage( new AddSequenceToStackMessage( new ShowActorInfoSequence(actor, "Mech quirk: Can't eject", FloatieMessage.MessageNature.PilotInjury, true))); return(true); } if (modSettings.QuirksEnabled && m.pilot.pilotDef.PilotTags.Contains("pilot_drunk") && m.pilot.pilotDef.TimeoutRemaining > 0) { LogReport("Drunkard - not ejecting"); actor.Combat.MessageCenter.PublishMessage( new AddSequenceToStackMessage( new ShowActorInfoSequence(actor, "Pilot quirk: Drunkard won't eject", FloatieMessage.MessageNature.PilotInjury, true))); return(true); } } LogReport("Failed ejection save: Punchin\' Out!!"); return(false); }