diff --git a/src/main/java/cam72cam/immersiverailroading/entity/Locomotive.java b/src/main/java/cam72cam/immersiverailroading/entity/Locomotive.java index ab18cf7b6..8877704b6 100644 --- a/src/main/java/cam72cam/immersiverailroading/entity/Locomotive.java +++ b/src/main/java/cam72cam/immersiverailroading/entity/Locomotive.java @@ -66,7 +66,7 @@ public abstract class Locomotive extends FreightTank { @TagField("cogging") private boolean cogging = false; - private boolean slipping = false; + protected boolean slipping = false; /* * @@ -404,7 +404,7 @@ protected final double getStaticTractiveEffort(Speed speed) { * 9.8 // M/S/S * (slipping ? STEEL.kineticFriction(STEEL)/2 : STEEL.staticFriction(STEEL)) * slipCoefficient(speed) - / getDefinition().factorOfAdhesion() + * (4/getDefinition().factorOfAdhesion()) // Physics are tuned to an adhesion factor of 4 * Config.ConfigBalance.tractionMultiplier; } @@ -611,21 +611,16 @@ public void setBell(int newBell) { } public double slipCoefficient(Speed speed) { - double slipMult = 1.0; + double slipMult = 0.5; //TODO Assumes dirty rails. Set this back to 1.0 and adjust physics coefficients World world = getWorld(); if (world.isPrecipitating() && world.canSeeSky(getBlockPosition())) { if (world.isRaining(getBlockPosition())) { - slipMult = 0.6; + slipMult *= 0.6; } if (world.isSnowing(getBlockPosition())) { - slipMult = 0.4; + slipMult *= 0.4; } } - // Wheel balance messing with friction - if (speed.metric() != 0) { - double balance = 1d/(Math.abs(speed.metric())+300) / (1d/300); - slipMult *= balance; - } return slipMult; } diff --git a/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveDiesel.java b/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveDiesel.java index 5b88dcd91..f334fb806 100644 --- a/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveDiesel.java +++ b/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveDiesel.java @@ -167,7 +167,7 @@ public double getAppliedTractiveEffort(Speed speed) { if (getDefinition().hasDynamicTractionControl) { double max = getStaticTractiveEffort(speed); if (Math.abs(applied) > max) { - return Math.copySign(max, applied); + return Math.copySign(max, applied) * 0.95; } } diff --git a/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveSteam.java b/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveSteam.java index 4f2825388..9dff33b17 100644 --- a/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveSteam.java +++ b/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveSteam.java @@ -132,7 +132,25 @@ public double getTractiveEffortNewtons(Speed speed) { return (getDefinition().cab_forward ? -1 : 1) * super.getTractiveEffortNewtons(speed); } - @Override + @Override + public double slipCoefficient(Speed speed) { + double slipMult = super.slipCoefficient(speed); + // Wheel balance messing with friction + if (speed.metric() != 0) { + double balance = 1d/(Math.abs(speed.metric())+300) / (1d/300); + slipMult *= balance; + } + + // TODO better approximation + // assume wheel diameter == 5m + double ratio = 0.35; + double hammer = ratio + (slipping ? 0 : Math.abs(Math.sin(Math.toRadians(360 * distanceTraveled / (5f * gauge.scale()/ 2))) * (1-ratio))); + slipMult *= hammer; + + return slipMult; + } + + @Override protected double simulateWheelSlip() { return (getDefinition().cab_forward ? -1 : 1) * super.simulateWheelSlip(); }