New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CR]Falling vehicles #13436
[CR]Falling vehicles #13436
Conversation
Should be ready, I think. Not perfect, but I didn't see it breaking any existing functionality or acting too weird. Most issues are with the way damage is spread: a falling vehicle will lose HP from random or arbitrary parts, losing seatbelts, clocks, roofs and seats before frames. |
This colud be useful. Now if only I could drag shopping carts up/down stairs... owo |
if( moored > num - 1 ) { | ||
// destroy vehicle (sank to nowhere) | ||
destroy_vehicle( &veh ); | ||
// The returned pointer is always a dangling one! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa, stop right there, what's that? You're returning an invalid non-null pointer on purpose? The caller has no way to distinguish it from a valid non-null pointer. And I see the returned pointer being used:
const vehicle *veh = vehproceed();
if( veh == nullptr ) {
break;
} else {
on_vehicle_moved( veh->smz ); // Hello undefined behavior.
}
Changed Fixed the "falling with no velocity" bug and possibly a separate bug with same cause (I didn't expect initialized Reworked collision sounds a bit. A vehicle will now produce a crashing sound on its own, not just by bashing terrain in front of it. |
Conflicts: src/map.cpp
When you drive a car across a ledge and all wheels end up in midair, but one (non-wheel) part of the vehicle is still over floor the game says "Your %s can't move on this terrain." and the vehicle stops immediately, but without any effects from the sudden deceleration. This is probably fine for now, as a proper behavior would require inclined vehicles with some of its parts on the lower level and some of them on the upper level. Another slight inconsistency (but fine for now): vehicles (and furniture) support other vehicles on top of them, but they don't support creatures on top of them. For example: when pushing a welding cart across a ledge on top of another vehicles, it stays on the upper level (and can be pulled back). But if my character moves on the same spot in the air, it falls down into the (sometimes impassable) vehicle part below. |
Most likely the hardest part of #6823
Vehicles are marked as "falling" when they drive over a ledge, terrain/furniture under them stops supporting their weight or vehicle moves from under them.
A falling vehicle is "active" in the same way one with
of_turn > 0
is.It will check all tiles underneath it. If all of them are open air and no tiles under those offer support, it will accelerate down and fall.
Falling vehicle will collide with things on its way. I disabled floor breaking for now; current collision calculations are too unbalanced at high mass*velocity, which would cause heavy vehicles to sink in solid rock like a red hot nickel ball in butter. Vehicle-vehicle collisions work OK, though.
Also fixed two minor bugs: colliding with a monster while driving in reverse would not fling it, but drive over it. Driving over a monster at low enough speed would damage it, but also have vehicle phase into it.
Includes some more or less minor changes to code:
vehicle::collision
's argument list. Most of those were return values that can be extracted in the processing of the most important one anyway.vehicle::wheelcache
, which existed for a while but wasn't used. Implemented avehicle::floating
- similar thing but for floating parts.map::update_vehicle_cache
intoadd_vehicle_to_cache
andupdate_vehicle_cache
.update_
takes a z-level argument. This argument is necessary to properly update vehicles moving from one z-level to another (otherwise the entire vehicle cache would have to be rebuilt).