Rivens Realistic Train Acceleration (based on cargo) - Space Age


This mod makes train acceleration more realistic and depend on the amount of Cargo. (youtube demo included)

Tweaks
8 months ago
1.1 - 2.0
3.72K
Trains

i [solved] Possible to make train length affect braking distance?

1 year, 10 months ago

Hi

I'm using the mod, really like it. However, it feels odd when an empty 1-1 train going at 50km/h takes the same distance to stop as a partially loaded 1-8 train moving at the same speed.

I saw in an earlier discussion that making the braking distance depend on cargo is not possible, but what about changing it depending on the number of train cars?

Or is there something wrong with my setup and the braking distance should already be different? I tried with and without the mod and they were the same. I have Bob's logistics mod but no other train-modifying mods.

Thanks

1 year, 10 months ago
(updated 1 year, 10 months ago)

The issue is that mods are not really able to directly affect braking distance. The easiest way to increase braking distance is to increase the weight of the vehicles. A side effect of this is that the trains consume more fuel, and are deadlier on impact with a player.

The core game logic calculates all the braking, based on the current speed, the train mass and the braking power (affected by research).

It's easy to detect acceleration, and reduce it, because you're simply reducing the speed-increase, and then it simply takes longer to arrive.

It's easy to detect deceleration, and reduce it, but that means you'll overshoot your destination. To work around this, it means that you have to calculate (almost every frame) what the stopping point is (either simply a station, or checking all rail-signals along the projected path), and how far it is, what your (calculated) braking distance is, and whether you should already be braking. It's quite tricky to get this right, and has a serious performance impact.

Long story short: it's hard, and slow - and I'm not sure it's worth it.

1 year, 10 months ago

Hey Filipi, I attempted to implement a new braking algorithm in the 0.1.23 release. It's both dependent on the mass of the train, and the number of locomotives/wagons. The mass of the train has the greatest effect, because I'm reasonably sure that in reality each carriage has its own brakes, which are controlled by the locomotive.

1 year, 9 months ago
(updated 1 year, 9 months ago)

Hi, sorry for not replying, I haven't visited this page in a while.

I downloaded the update but it seems to work in an odd way. A filled 1-4 train takes significantly less time to stop than a filled 1-1 train (same speed, fuel, locomotive). It's true that in reality each car has brakes, but longer trains take longer to stop.

Maybe there's a way to invert this behaviour?

Anyway I appreciate you trying to improve the mod, but I think I will stick to the previous version, I don't like this new braking system.

Thanks

[deleted message]
1 year, 9 months ago
(updated 1 year, 9 months ago)

Hey Filipi, thanks for your honest feedback. I released 0.1.24 where cargo/fluid-wagons have less braking force, and locomotives more.

In my testing I got these results:
- For empty wagons: number of wagons does not really matter for the braking distance (as the brakes per wagon can cope)
- For filled wagons: the more wagons, the longer the braking distance (as the brakes per wagon are not strong enough)
I think this matches your expectations, as a filled 1L4C train will now take longer to stop than a 1L1C train.

I also made the braking calculations substantially less of a performance hog.

5 months ago

Have you thought about using invisible wagons to add the item weight to the train? You'd simply add "wagon" entities without image/hitbox with weights in powers of 2, and then add a combination of these wagons to the train when it leaves its station (on_train_changed_state event), so the total weight of the invisible wagons adds up to the mass of the cargo.

These wagons would need to have no braking power and friction/air resistance, and functionally infinite max_speed, so they don't affect the train in other ways than adding weight.

When the train arrives at its destination, you could remove the wagons again.

I don't know how small you could make the wagons - they might still make the train slightly longer (which might affect intersections), but it might also be possible to put the whole wagon stack inside the bounding box of the training train entity. Either way, the performance benefits might outweigh having slightly different constraints on train lengths...

5 months ago
(updated 5 months ago)

Adding and removing carriages will replace the entire Train in the game-engine. This interferes with a lot of subtle game mechanics, like pumps disconnecting and trains losing their slot in the 'train limit' queue of their destination. I played around with swapping out carriages in one of my other mods (by replacing carriages with heavier ones as cargo increased) but while it was conceptually a neat solution to a complex problem, it resulted in train-logic being subtly broken in a dozen ways. ;'-)

5 months ago

Thanks for telling me this - I was considering making my own train weight mod using wagon switching, but if it causes that much issues, I won't bother :)

Pumps disconnecting wouldn't matter if you only add/remove wagons when the train status changes (ie. it leaves(/ or arrives?) at a station), but train limit queue slots sound like something you couldn't fix in lua...

New response