public static void Postfix(Mech __instance)
            {
                try
                {
                    Pilot pilot = __instance.GetPilot();
                    if (pilot == null)
                    {
                        return;
                    }
                    Logger.Debug($"[Mech_ApplyMoraleDefendEffects_POSTFIX] ({__instance.DisplayName}) Called");

                    int stressLevel = pilot.GetStressLevel();
                    if (stressLevel > 0)
                    {
                        stressLevel = pilot.DecreaseStressLevel(2).GetStressLevel();
                        __instance.Combat.MessageCenter.PublishMessage(new FloatieMessage(__instance.GUID, __instance.GUID, "REASSURED!", FloatieMessage.MessageNature.Inspiration));

                        string floatieMessage = Miscellaneous.GetStressLevelString(stressLevel);
                        __instance.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(__instance, floatieMessage, FloatieMessage.MessageNature.PilotInjury, true)));
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
Beispiel #2
0
        public static bool TryReduceStressLevel(Mech mech, Pilot pilot, out int stressLevel)
        {
            float modifiers = Assess.GetResistanceModifiers(mech, true);

            // Rolling...
            int   randomRoll      = (new System.Random()).Next(100);
            float reductionChance = Math.Min(modifiers, 95);
            bool  success         = (randomRoll < reductionChance);

            Logger.Debug($"[Actor_TryReduceStressLevel] ({mech.DisplayName}) Success: {success}");
            stressLevel = success ? pilot.DecreaseStressLevel(1).GetStressLevel() : pilot.GetStressLevel();

            return(success);
        }
            public static void Postfix(Mech __instance)
            {
                try
                {
                    Pilot pilot = __instance.GetPilot();
                    if (pilot == null || pilot.HasEjected)
                    {
                        Logger.Debug($"[AbstractActor_OnActivationBegin_POSTFIX] ({__instance.DisplayName}) Pilot already has ejected, aborting...");
                        return;
                    }

                    if (__instance.HasActivatedThisRound && pilot.IsDesperate())
                    {
                        Logger.Debug($"[AbstractActor_OnActivationBegin_POSTFIX] ({__instance.DisplayName}) will finish activation AND {pilot.Callsign} is desperate");

                        if (Actor.TryResistEjection(__instance, out bool criticalSuccess))
                        {
                            if (criticalSuccess)
                            {
                                // Reduce stress level
                                __instance.Combat.MessageCenter.PublishMessage(new FloatieMessage(__instance.GUID, __instance.GUID, "RESOLUTE!", FloatieMessage.MessageNature.Inspiration));
                                int    stressLevel    = pilot.DecreaseStressLevel(1).GetStressLevel();
                                string floatieMessage = Miscellaneous.GetStressLevelString(stressLevel);

                                __instance.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(__instance, floatieMessage, FloatieMessage.MessageNature.PilotInjury, true)));
                            }
                            return;
                        }
                        else
                        {
                            if (Actor.RollForEjection(__instance, pilot.GetStressLevel(), pilot.GetLastEjectionChance()))
                            {
                                // Off he goes
                                __instance.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(__instance, "FAITHLESS!", FloatieMessage.MessageNature.PilotInjury, true)));
                                __instance.EjectPilot(__instance.GUID, -1, DeathMethod.PilotEjection, false);
                            }
                        }
                        __instance.HandleDeath(__instance.GUID);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }