Here is what I've divined as the related code, after a quick overview:
private boolean failedset; //random failures mod
private boolean fail; //random failures mod
private boolean failset; //random failures mod
public void rareAction(float f, boolean bool)
{
if(World.cur().diffCur.Reliability)
{
Random random = new Random();
int i = random.nextInt(100);
int FailRate = 20;
if(Mission.cur() != null)
FailRate = Mission.cur().sectFile().get("Mods", "FailureRate", 0);
if(i < FailRate)
randomfail();
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft() && !failedset)
setafail();
}
}
private void randomfail()
{
Random random = new Random();
int randomvalue = random.nextInt(1000);
int enginenum = random.nextInt(3);
int enginenumlog = enginenum + 1;
float f = World.Rnd().nextFloat();
float season = 0.0F;
float enginerandom = (float)randomvalue - season;
if(World.cur().camouflage == 2 || World.cur().camouflage == 1)
season = 500F;
else
season = 0.0F;
if(enginerandom == 10F)
{
((FlightModelMain) (super.FM)).EI.engines[0].setEngineStops(this);
super.playSound("weapon.MGunMk108s", true);
}
if(enginerandom == 150F)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setKillPropAngleDevice(this);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
{
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Prop Angle Device Damaged!");
super.playSound("weapon.MGunMk108s", true);
}
}
if(enginerandom == 56F)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setCyliderKnockOut(this, 1);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
{
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Cylinders Damaged!");
super.playSound("weapon.MGunMk108s", true);
}
}
if(enginerandom == 123F)
{
((FlightModelMain) (super.FM)).EI.engines[0].setReadyness(this, f);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
{
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Crank Case Damaged!");
super.playSound("weapon.MGunMk108s", true);
}
}
if(enginerandom == 19F)
{
((FlightModelMain) (super.FM)).AS.hitEngine(this, enginenum, 2);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
{
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Crank Case Damaged!");
super.playSound("weapon.MGunMk108s", true);
}
}
if(enginerandom == 11F)
{
((FlightModelMain) (super.FM)).AS.hitEngine(this, enginenum, 3);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
{
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Cylinders Damaged - Engine On Fire!");
super.playSound("weapon.MGunMk108s", true);
}
}
if(enginerandom == 145F)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setKillCompressor(this);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
{
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Compressor Out!");
super.playSound("weapon.MGunMk108s", true);
}
}
if(enginerandom == 32F)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setMagnetoKnockOut(this, 0);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
{
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Magneto #0 Destroyed!");
super.playSound("weapon.MGunMk108s", true);
}
}
if(enginerandom == 31F)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setMagnetoKnockOut(this, 1);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
{
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Magneto #1 Destroyed!");
super.playSound("weapon.MGunMk108s", true);
}
}
if(enginerandom == 62F)
{
((FlightModelMain) (super.FM)).AS.hitTank(this, 0, 1);
((FlightModelMain) (super.FM)).AS.doSetTankState(this, 0, 1);
}
if(enginerandom == 24F)
{
((FlightModelMain) (super.FM)).AS.setOilState(this, enginenum, 1);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Oil Filter Damaged!");
}
if(enginerandom == 36F)
{
((FlightModelMain) (super.FM)).AS.hitOil(this, enginenum);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Oil Tank Leak!");
}
if(enginerandom == 52F)
{
((FlightModelMain) (super.FM)).CT.GearControl = f;
((FlightModelMain) (super.FM)).Gears.setHydroOperable(false);
if(((Interpolate) (super.FM)).actor == World.getPlayerAircraft())
HUD.log("Gear: Hydraulic system Failed!");
}
}
private void setafail()
{
Random random = new Random();
int enginenum = random.nextInt(3);
int enginenumlog = enginenum + 1;
float f = World.Rnd().nextFloat();
int failtype = 0;
if(Mission.cur() != null)
failtype = Mission.cur().sectFile().get("Mods", "FailType", 0);
if(Time.current() < (long)(Mission.cur().sectFile().get("Mods", "FailTimer", 0) * 60))
fail = true;
if(failtype > 0 && failtype == 1 && fail)
{
((FlightModelMain) (super.FM)).EI.engines[0].setEngineStops(this);
failedset = true;
}
if(failtype > 0 && failtype == 2 && fail)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setKillPropAngleDevice(this);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Prop Angle Device Damaged!");
super.playSound("weapon.MGunMk108s", true);
failedset = true;
}
if(failtype > 0 && failtype == 3 && fail)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setCyliderKnockOut(this, 1);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Cylinders Damaged!");
super.playSound("weapon.MGunMk108s", true);
failedset = true;
}
if(failtype > 0 && failtype == 4 && fail)
{
((FlightModelMain) (super.FM)).EI.engines[0].setReadyness(this, f);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Crank Case Damaged!");
super.playSound("weapon.MGunMk108s", true);
failedset = true;
}
if(failtype > 0 && failtype == 5 && fail)
{
((FlightModelMain) (super.FM)).AS.hitEngine(this, enginenum, 2);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Crank Case Damaged!");
super.playSound("weapon.MGunMk108s", true);
failedset = true;
}
if(failtype > 0 && failtype == 6 && fail)
{
((FlightModelMain) (super.FM)).AS.hitEngine(this, enginenum, 3);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Cylinders Damaged - Engine On Fire!");
super.playSound("weapon.MGunMk108s", true);
failedset = true;
}
if(failtype > 0 && failtype == 7 && fail)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setKillCompressor(this);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Compressor Out!");
super.playSound("weapon.MGunMk108s", true);
failedset = true;
}
if(failtype > 0 && failtype == 8 && fail)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setMagnetoKnockOut(this, 0);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Magneto #0 Destroyed!");
super.playSound("weapon.MGunMk108s", true);
failedset = true;
}
if(failtype > 0 && failtype == 9 && fail)
{
((FlightModelMain) (super.FM)).EI.engines[enginenum].setMagnetoKnockOut(this, 1);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Magneto #1 Destroyed!");
super.playSound("weapon.MGunMk108s", true);
failedset = true;
}
if(failtype > 0 && failtype == 10 && fail)
{
((FlightModelMain) (super.FM)).AS.hitTank(this, 0, 1);
((FlightModelMain) (super.FM)).AS.doSetTankState(this, 0, 1);
failedset = true;
}
if(failtype > 0 && failtype == 11 && fail)
{
((FlightModelMain) (super.FM)).AS.setOilState(this, enginenum, 1);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Oil Filter Damaged!");
failedset = true;
}
if(failtype > 0 && failtype == 12 && fail)
{
((FlightModelMain) (super.FM)).AS.hitOil(this, enginenum);
HUD.log(AircraftHotKeys.hudLogWeaponId, "Failure: Engine " + enginenumlog + " Oil Tank Leak!");
failedset = true;
}
if(failtype > 0 && failtype == 13 && fail)
{
((FlightModelMain) (super.FM)).CT.GearControl = f;
((FlightModelMain) (super.FM)).Gears.setHydroOperable(false);
HUD.log("Gear: Hydraulic system Failed!");
failedset = true;
}
}