Cataclysm-dda: [RFC] Flatbed carrier implementation

Created on 18 Feb 2019  路  4Comments  路  Source: CleverRaven/Cataclysm-DDA

Flatbed carriers

A vehicle flatbed carrier is a continuous collection of flatbed carrier parts, with R rows and C columns. A flatbed carrier can carry another vehicle. Carried vehicles can't collide independently of the carrying vehicle, but can be damaged if the carrying vehicle collides with something.

Activating

Activating an empty flatbed carrier lets you load it with an adjacent vehicle that has a footprint of no more than R rows and C columns, or possibly C rows and R columns if I let you load them facing left instead of forward. Activating a loaded flatbed carrier lets you unload it.

When a vehicle is loaded on a flatbed carrier, it is loaded into the upper left of the carrier. Each part of the carried vehicle sets some variables in the base item of the flatbed carrier "underneath" it: the carried vehicle's unique ID, the pivot point of the carried vehicle, and the mount point of the carried vehicle's structure part "on" the flatbed carrier. The carried vehicle gets special flag to indicate that it's carried (and a unique ID for the carrying vehicle), and the carrier vehicle has a vector of carried vehicle records: unique ID, pivot point, and mass.

Movement

in map::vehproceed(), carried vehicles are skipped and their vehicle::act_on_map() is not called. Instead, at the end the carrier's call to map::move_vehicle(), map::displace_vehicle() is called for each carried vehicle (this will require re-iterating through the get_vehicles list to find them but whatever).

the collision code ignores any vehicle with a carried flag - they cannot cause or participate directly in collisions. Since they're bound to a carrying vehicle that can collide with things, and collision damage to the carrying vehicle propagates to the carried vehicle, this shouldn't be an issue.

Damage

vehicle::damage() will check if there's a carried vehicle at that location, and if so, call damage() for that vehicle. vehicle::damage_all() will transmit damage to carried vehicles, shifting the impact point to the carried vehicle's mount reference.

If a carried vehicle needs to split or shed parts, it will update the carrying vehicle about its new condition.

Loaded flatbed carriers will be indestructible, but since the carried vehicle can get wrecked normally and thereby unload the flatbed carrier, I don't think this will be an exploit. (It might be possible to check if half or more of a flatbed carrier array is "destroyed", then then dump the carried car and disintegrate the flatbed carrier).

Nested carried vehicles

I don't think there's any issue with putting a cart on a bike's flatbed carrier, putting the bike in the flatbed carrier of a pickup truck, and then loading the stack onto the flatbed carrier of a trailer. Movement sequence would be trailer moves which causes the pickup to move which causes

Misc

The carried vehicle can't be accessed while being carried (maybe). It still has weight, and it's weight is added to the carrying vehicle's mass at the flatbed tile carrying the carried vehicle's pivot point (by definition, this is the center of mass).

Crude pictures:

carrying vehicle:          carried vehicle:
/===\                      /\    AB [0,-1] [1, -1]
|#X#|                      ##  CD [0, 0] [1, 0]
h---d                      hd  EF  [0, 1] [1, 1] 
|123|                      pivot point [1, 0]
|456|
Pivot point at X

the carried golfcart is loaded facing left on the pickup, with flatbed carriers carrying these parts:
1: (B) [1, -1]
2: (D) [1, 0]
3: (F) [1, 1]
4: (A) [0, -1]
5: (C) [0, 0]
6: (F) [1, 0]

The golfcart is going swing around wildly as the pickup moves and turns, but as long as it's on a nearby map I don't think that should be too much of a problem.

Development plan

I'm going to do some cleanup work related to vehicle footprints and then start hacking away at this. I expect it will take a month or two.

Feedback and informed suggestions appreciated.

Vehicles [C++]

Most helpful comment

I would like to say that this feature horrifies me and I hope that everyone involved comes out the other side as sane and healthy as they came in. Good luck, everyone.

All 4 comments

How the carried vehicle will be loaded to/unloaded from the flatbed? Should the carrier have a boom crane installed or nearby? Or maybe a winch? Either way it should be possible to use such equipment without a flatbed as well to move vehicles by few tiles. Could be useful to clean roads of broken vehicles.

Please don't complicate my complicated idea by adding additional complicated features. Pulling stuff via a winch is going to be hard to implement (at least in part because as soon as I enable a winch to pull a wreck out of the way, someone is going to want to use the winch to tow a trailer and I'll need to get that working).

I would like to say that this feature horrifies me and I hope that everyone involved comes out the other side as sane and healthy as they came in. Good luck, everyone.

This is not going to happen in 0.E.

Was this page helpful?
0 / 5 - 0 ratings