Пример #1
0
        public static bool RollForEjection(Mech mech, float chance)
        {
            Pilot pilot = mech.GetPilot();

            if (mech == null || mech.IsDead || (mech.IsFlaggedForDeath && !mech.HasHandledDeath))
            {
                return(false);
            }
            if (mech.IsProne && SimpleEjectionSystem.Settings.KnockedDownCannotEject)
            {
                return(false);
            }
            if (!mech.CanBeHeadShot || (pilot != null && !pilot.CanEject))
            {
                return(false);
            }

            int randomRoll = (new System.Random()).Next(100);

            mech.AddEjectionRoll();
            bool success = (randomRoll < chance);

            Logger.Debug($"[Actor_RollForEjection] ({mech.DisplayName}) Resisted: {!success}");

            return(success);
        }