예제 #1
0
 static void HandgunPatch_Slamfire(HandgunSlide __instance)
 {
     if (Meatyceiver.enableBrokenFirearmFailures.Value)
     {
         float chance = Meatyceiver.slamfireRate.Value * Meatyceiver.generalMult.Value;
         if (Meatyceiver.CalcFail(chance, __instance.Handgun))
         {
             __instance.Handgun.DropHammer(false);
         }
     }
 }
예제 #2
0
 static void ClosedBoltPatch_Slamfire(ClosedBolt __instance)
 {
     if (Meatyceiver.enableBrokenFirearmFailures.Value)
     {
         string failureName = "Slam fire";
         float  chance      = Meatyceiver.slamfireRate.Value * Meatyceiver.generalMult.Value;
         if (Meatyceiver.CalcFail(chance, __instance.Weapon))
         {
             __instance.Weapon.DropHammer();
         }
     }
 }
예제 #3
0
 public static bool CalcLightPrimerStrikeFail(FVRPhysicalObject obj)
 {
     if (!isAmmoFailEnabled)
     {
         return(true);
     }
     //if it fails, don't run the routine that fires it
     if (Meatyceiver.CalcFail(Meatyceiver.LPSFailureRate.Value * Meatyceiver.generalMult.Value, obj))
     {
         return(false);
     }
     return(true);
 }
        static bool ClosedBoltPatch_HammerFollow(ClosedBoltWeapon __instance)
        {
            if (!Meatyceiver.enableBrokenFirearmFailures.Value)
            {
                return(true);
            }
            float chance = Meatyceiver.HFRate.Value * Meatyceiver.generalMult.Value;

            if (Meatyceiver.CalcFail(chance, __instance))
            {
                return(false);
            }
            return(true);
        }
        private static bool HFHandgun(bool isManual, Handgun __instance)
        {
            if (!Meatyceiver.enableBrokenFirearmFailures.Value)
            {
                return(true);
            }
            float chance = Meatyceiver.HFRate.Value * Meatyceiver.generalMult.Value;

            if (Meatyceiver.CalcFail(chance, __instance))
            {
                return(false);
            }
            return(true);
        }
예제 #6
0
        static bool HandgunPatch_FailureToLockSlide(Handgun __instance)
        {
            if (!Meatyceiver.enableBrokenFirearmFailures.Value)
            {
                return(true);
            }
            string failureName = "Failure to lock slide";
            float  chance      = Meatyceiver.FTLSlide.Value * Meatyceiver.generalMult.Value;

            if (Meatyceiver.CalcFail(chance, __instance))
            {
                return(false);
            }
            return(true);
        }
 static bool RollingBlockPatch_FailureToExtract(FVRFireArmChamber __instance)
 {
     if (!Meatyceiver.enableFirearmFailures.Value)
     {
         return(true);
     }
     if (__instance.Firearm is RollingBlock)
     {
         string failureName = "Rolling block FTE";
         float  chance      = Meatyceiver.breakActionFTE.Value * (Meatyceiver.generalMult.Value - 1) * Meatyceiver.breakActionFTEMultAffect.Value;
         if (Meatyceiver.CalcFail(chance, __instance.Firearm))
         {
             return(false);
         }
     }
     return(true);
 }
        static bool GeneralPatch_FailureToExtract(FVRInteractiveObject __instance)
        {
            //these firearms will break if an FTE is caused
            if (__instance is BoltActionRifle || __instance is LeverActionFirearm)
            {
                return(false);
            }
            if (!Meatyceiver.enableFirearmFailures.Value)
            {
                return(true);
            }
            float             chance = Meatyceiver.FTERate.Value * Meatyceiver.generalMult.Value;
            FVRPhysicalObject obj    = null;

            if (__instance is ClosedBolt)
            {
                obj = (__instance as ClosedBolt).Weapon;
            }
            if (__instance is HandgunSlide)
            {
                obj = (__instance as HandgunSlide).Handgun;
            }
            if (__instance is OpenBoltReceiverBolt)
            {
                obj = (__instance as OpenBoltReceiverBolt).Receiver;
            }
            if (Meatyceiver.CalcFail(chance, obj))
            {
                __instance.RotationInterpSpeed = 2;
                return(false);
            }
//			rand = (float)randomVar.Next(0, 10001) / 100;
//			chance = stovepipeRate.Value * generalMult.Value;
//			consoleDebugging(0, FTEfailureName, rand, chance);
//			if (rand <= chance)
//			{
//				consoleDebugging(1, FTEfailureName, rand, chance);
//				return false;
//			}
            return(true);
        }
 static bool RevolverPatch_FailureToExtract(FVRFireArmChamber __instance)
 {
     if (!Meatyceiver.enableFirearmFailures.Value)
     {
         return(true);
     }
     if (__instance.Firearm is Revolver)
     {
         if (__instance.RotationInterpSpeed == 1)
         {
             string failureName = "Revolver FTE";
             float  chance      = Meatyceiver.revolverFTE.Value * (Meatyceiver.generalMult.Value - 1) * Meatyceiver.revolverFTEGenMultAffect.Value;
             if (Meatyceiver.CalcFail(chance, __instance.Firearm))
             {
                 __instance.RotationInterpSpeed = 2;
                 return(false);
             }
         }
     }
     return(true);
 }
        static bool BreakActionPatch_FailureToExtract(BreakActionWeapon __instance, FVRFireArm chamber)
        {
            if (!Meatyceiver.enableFirearmFailures.Value)
            {
                return(true);
            }
            if (MCM.HasFlag(chamber, states.StuckRound))
            {
                return(false);
            }
            float chance = Meatyceiver.breakActionFTE.Value
                           * (Meatyceiver.generalMult.Value - 1)
                           * Meatyceiver.breakActionFTEMultAffect.Value;

            if (Meatyceiver.CalcFail(chance, __instance))
            {
                MCM.AddFlag(chamber, states.StuckRound);
                return(false);
            }
            return(true);
        }
        static bool DefaultPatch_FailureToFeed(FVRFireArm __instance)
        {
            float failureinc = 0;

            if (!isFirearmFailEnabled)
            {
                return(true);
            }
            if (__instance.Magazine != null && Meatyceiver.enableMagUnreliability.Value)
            {
                if (!__instance.Magazine.IsBeltBox)
                {
                    //if the box mag's cap is over the cap that would begin failures
                    if (__instance.Magazine.m_capacity > Meatyceiver.minRoundCount.Value)
                    {
                        //diff between mag cap and min round cap and multuiply by failure inc per round
                        float baseFailureInc =
                            (__instance.Magazine.m_capacity - Meatyceiver.minRoundCount.Value)
                            * Meatyceiver.failureIncPerRound.Value;
                        //failure inc = the failure inc * general mult - 1 * mag unreliability (?)
                        failureinc = baseFailureInc +
                                     (baseFailureInc
                                      * Meatyceiver.generalMult.Value - 1
                                      * Meatyceiver.magUnreliabilityGenMultAffect.Value);
                    }
                }
            }
            //then calculate the rate, + what we just got before
            float chance = Meatyceiver.HFRate.Value
                           * Meatyceiver.generalMult.Value
                           + failureinc;

            //throw that meat pile n calc
            if (Meatyceiver.CalcFail(chance, __instance))
            {
                return(false);
            }
            return(true);
        }