CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.59k stars 4.17k forks source link

Vehicle parts should be removed from the vehicle given enough bashing. Also Destroyed parts should drop scrap metal on removal. #3797

Closed dwarfkoala closed 10 years ago

dwarfkoala commented 11 years ago

See the title. I found it a bit illogical that you can remove 2 tons of steel from a smashed up vehicle and get nothing back. Also it seems that no matter how much you bash a piece of a car, the piece is still attached.

Rivet-the-Zombie commented 11 years ago

I second this.

ianestrachan commented 11 years ago

There's a part flag (UNMOUNT_ON_DAMAGE or something to that effect, spikes and blades have it) that has this effect, so it should be easy to spread it.

Certain parts should just vanish, like windshields (or at least scatter glass shards everywhere). Being able to break it into its components would be ideal, but most parts are just solid metal so scrap metal is a nice approximation.

NaturesWitness commented 11 years ago

This sounds really cool, and modifying the unmount-on-damage code should work for most parts, but the frame parts are going to need a little extra work so that either; 1 - they can't be destroyed if anything is still on top of them 2 - if they're destroyed, anything else on that square is either forcibly uninstalled or destroyed

Personally, I like the idea that if a frame is destroyed, any other parts on that square get instantly uninstalled and drop to the ground, either as the component they're built from or as scrap metal, depending on how damaged the part was before the frame failed.

i2amroy commented 11 years ago

Definitely agree on this one.

ianestrachan commented 11 years ago

The frame being destroyed should indeed remove all parts in the square; the frame gets converted to scrap metal and the others parts all just get dropped (possibly taking damage in the process).

I like to think of it as having parts of the vehicle get torn off and go flying into the air. Goodbye, door! It was nice knowing you.

This might have interesting effects on wreckage, since parts in overlapping squares get utterly destroyed. I can either revert that, or (more entertainingly) keep the two vehicles separate with the pile of twisted scrap metal and glass shards separating them.

EDIT: Or keep one vehicle intact (but heavily damaged) and obliterate all the parts on the other vehicle. One of them "won" that collision.

dwarfkoala commented 11 years ago

I would, however, like to note that we should be very careful as to not make ramming an impossibility. A decent ram plate or ram part or something should be able to survive some serious ramming before it snaps or whatever. Balance, of course, will be an issue.

dwarfkoala commented 11 years ago

Also, would it be interesting to make car crashes not drop scrap metal but instead create a tile of metal wreckage where a part snaps off? representing a car piece that's been so mangled and is so heavy that it's basically impossible to remove without a tool?

ianestrachan commented 11 years ago

This wouldn't affect how much damage a part can sustain - the part's durability (HP, basically) determines that. The only difference would be that once your ram bars and extra frames at the front get dropped to 0, they are destroyed totally, instead of still floating there with 0 HP.

KA101 commented 11 years ago

@ianestrachan Just to make sure we're all on the same page: UNMOUNT_ON_DAMAGE takes "grey" as the time to unmount, not "light green and below"? The WS does not menace with spikes. ;-)

ianestrachan commented 11 years ago

I have no idea what threshold UNMOUNT_ON_DAMAGE takes effect at.

Let's find out! FOR SCIENCE!

if (parts[p].hp <= 0 && part_flag(p, "UNMOUNT_ON_DAMAGE"))
{
  g->m.spawn_item(global_x() + parts[p].precalc_dx[0],
                         global_y() + parts[p].precalc_dy[0],
                         part_info(p).item, g->turn);
  remove_part(p);
}

vehicle.cpp line 2710, though I believe that it creates a new item in mint condition when this happens. But the important part is the parts[p].hp <= 0; that is, it must be completely broken.

So probably what should be done is we add a "SCRAP_WHEN_DESTROYED" or "SCRAP_ON_DAMAGE" flag, or similar, to implement the new functionality.

I actually realized that destroying frames is a terrible idea because if the (0, 0) frame is destroyed then all kinds of horrible things (read: segfaults) will happen. We may want to just exclude that frame, though.

kevingranade commented 11 years ago

Sounds good, that one frame will be indestructable, but if you have a non pathalogical vehicle and you're all the way down to 0,0 you already have issues. What do you think about: Only tear off frames on the perimiter (or just weighted)? Recheck broken frames for tearing off if hit again?

ianestrachan commented 11 years ago

Since I think the PR to only make hit stuff damaged got merged, only perimeter parts are likely to get torn off anyway unless you drop a mininuke on a car and run away - an edge case, to be sure.

kevingranade commented 11 years ago

Or a gas tank explosion, or you drop a grenade. It's certainly an edge case though.

On Thu, Oct 24, 2013 at 12:07 PM, Ian Strachan notifications@github.comwrote:

Since I think the PR to only make hit stuff damaged got merged, only perimeter parts are likely to get torn off anyway unless you drop a mininuke on a car and run away - an edge case, to be sure.

— Reply to this email directly or view it on GitHubhttps://github.com/CleverRaven/Cataclysm-DDA/issues/3797#issuecomment-27010830 .

NaturesWitness commented 11 years ago

I just realized something; if how Cata saves vehicles is anything like how vehicles.json works (tile-by-tile, in order) removing frames from just about anywhere on a vehicle could cause major headaches, if it separates different parts of the vehicle or otherwise invalidates the build order. I think the perimeter approach may be the best way to go, otherwise this could turn into a big mess very fast.

kevingranade commented 11 years ago

The main thing is that the frames stay connected. We either have to only allow perimeter pieces to break off, or handle chunks breaking loose somehow. It'd be kind of awesome if we ended up with vehicles fracturing into multiple sub-wrecks, possibly still moving.

On Thu, Oct 24, 2013 at 2:33 PM, NaturesWitness notifications@github.comwrote:

I just realized something; if how Cata saves vehicles is anything like how vehicles.json works (tile-by-tile, in order) removing frames from just about anywhere on a vehicle could cause major headaches, if it separates different parts of the vehicle or otherwise invalidates the build order. I think the perimeter approach may be the best way to go, otherwise this could turn into a big mess very fast.

— Reply to this email directly or view it on GitHubhttps://github.com/CleverRaven/Cataclysm-DDA/issues/3797#issuecomment-27022865 .

ianestrachan commented 11 years ago

removing frames from just about anywhere on a vehicle could cause major headaches, if it separates different parts of the vehicle or otherwise invalidates the build order

The current check on whether or not you can remove a frame can probably be re-used, as it does a breadth-first-search to see if removing a part would cause a vehicle to be bisected.

ianestrachan commented 10 years ago

I am working on this right now. It is the most fun PR I've had to test in a while: I debug spawn a car and a sledgehammer and go to town with the smash key.

Possible ideas for handing shearing of cars:

  1. Disallow, so frames never get removed if they would break a vehicle in two
  2. Allow if it's not the (0, 0) part, and then turn the half that doesn't have (0, 0) in it back into items
  3. Break any part - if the (0, 0) frame is destroyed, the entire vehicle collapses into items

Currently leaning towards option 2, maybe 3 if I can set things up right. Ideally, making two vehicles out of the other parts would be ideal, but rather complicated (since their (0, 0)s would need to be recalculated) and probably best left for another time.

KA101 commented 10 years ago

I'm thinking 2 at most. Having a "Critical Frame" that governs where the vehicle breaks requires the player to keep track of it or have a functionally-random Critical Existence Failure.

(I'm betting that 0,0 is the starting frame. @EkarusRyndren: quick, which was the first frame on the RMCC?)

ianestrachan commented 10 years ago

(0, 0) is indeed the starting frame. You can't remove it without suddenly, segmentation fault! because the map keeps track of vehicles through their xpos/ypos which is based off of the (0, 0) frame. If it's ever destroyed, it has to be the last thing in the vehicle.

As hilarious as a Critical Existence Failure might be, having an entire car suddenly collapse into pieces, it's probably best not to do that. It shouldn't be exploitable, though.

I actually think that, for now, I'll go with 1, and revisit this later to actually split vehicles into sub-vehicles.

kevingranade commented 10 years ago

I agree disallow is fine for now, so they only erode off the edges. Going to love me some broken in half vehicles once that works though :D

Shadowdarke commented 10 years ago

And the eventual ability to recalculate frame (0,0) lends itself to allowing us to weld two vehicles (or sub-vehicles) into one!

dwarfkoala commented 10 years ago

on #4169 as it is it seems like a part that is damaged at 0 hp may break into parts which are deposited on the ground. Non critical frames and frames with nothing else on it may break, if broken parts are removed via vehicle menu they get broken into pieces.

Also, taking a quick look over the code, scrap metal seems like a huge reduction of mass from a frame or a plating. What about changing the scrap metal to lumps of steel?

On the 0,0 frame issue, I think that until 0,0 recalculation is possible that the 0,0 frame should be indestructible. I also think that a sheared off vehicle part should create a new vehicle instead of the pile of welded parts spontaneously disintegrating.

If that's not possible, then I think that option 1 would be the best for now. Option 3 alone, i would say, is absolutely a bad idea. No reason why smashing a "particular" piece of a car should make the entire car spontanously disintegrate, even if it happens to weigh 20 tons and take up a map tile of space.

ianestrachan commented 10 years ago

This discussion probably belongs in the PR's thread itself, but I'll reply here:

Non critical frames and frames with nothing else on it may break, if broken parts are removed via vehicle menu they get broken into pieces.

Almost correct. Frames that have stuff on them can break, which will 'tear off' the mounted parts. For instance, if you smash the frame under a damaged (but not broken) gasoline tank, the tank will be torn off, dropping a marked metal tank on the ground. This happens even for critical frames - the only difference is the frame isn't removed, but the stuff on it gets torn off.

Also, taking a quick look over the code, scrap metal seems like a huge reduction of mass from a frame or a plating. What about changing the scrap metal to lumps of steel?

The PR is marked with [CR] because I pulled the min-max ranges of thin air. Bear in mind, these are things that have been smashed to hell, so you shouldn't get a 1:1 ratio of scrap back - there should be some loss. Some bigger parts use steel chunks, and boards sometimes give sheet metal.

If you have some specific suggestions for new amounts of pieces, please comment on #4169 before it is merged and I'll happily see if I can update it.

Finally, regarding a Critical Existence Failure, even just breaking the smaller half didn't feel right, so I went with the "don't break critical frames" plan for now. Creating new vehicles is out of the scope of this PR - it could well be done later, but this is a perfectly acceptable solution for now.

EkarusRyndren commented 10 years ago

@KA101 On the most recent build it's in the lower right hand corner before the "wall" on the most recent build of the MFB it's the middle-right of the main storage area (the 7 long section of solar panels)

That said rather than have frames "break off" why not make them once broken slow the vehicle down, make it more difficult to control, etc.

@dwarfkoala Awhile back I suggested a plow for vehicles but my vehicle suggestions I think have kinda faded into the background. (see thread: http://smf.cataclysmdda.com/index.php?topic=3465.0 it goes on for awhile with some good and bad sugestions) All that said if we can get armor working properly that could help (Armor takes the damage that'd normally go to other parts unless the part can't be armored (headlights) or it's a "Critical hit")

ianestrachan commented 10 years ago

Armor's been changed recently(-ish) so you can now armor any part you like. It's supposed to take damage before any other part in the square; if it isn't, that's a bug.

EkarusRyndren commented 10 years ago

@ianestrachan I don't know what version armor was fixed in but as it stands you can't put armor on any tile with a board or storage item, you used to be able to XD

dwarfkoala commented 10 years ago

Ianestrachan, I see what you're thinking, but I believe in that case that where you have metal scraps you should scale up to steel chunks, and where you have steel chunks, you should scale up to lumps of steel.

As a crude measure, it takes 4 chunks of steel to make a lump of steel, and 24 lumps of steel to make a hard plating. It takes 8 lumps of steel for steel plating, 3 lumps for a frame, 8 lumps of steel and some spikes for spiked plating, 4 scrap metal for a sheet metal, at least 3 lumps for a welding rig and 4 lumps for a RV kitchen unit, 4 pipes, 2 springs, and 12 leather for a seat, about 3 lumps for vehicle controls, 2 pipes and sheet metal for a muffler. It takes 2 sheet metal (8 scrap metal or 2 chunks) to make a tank.

For these simpler devices, I would suggest recovery of 50% - 75%. Even if you somehow managed to screw up hard plating really badly, I doubt you'd get 1-3 chunks of steel, which is equivalent to, at most, 3/4 of a lump of steel, which, if you assume a hard plating to be 24 lumps of steel, is 1/32 of the original hard plating mass. I think the hard plating would be broken off the vehicle long before only 1/32 of the original product remained.

So if we go 50 - 75%, Welding rig - 1-2 lumps of steel RV unit - 2-3 lumps of steel Seat - 2-3 pipes, 0-1 springs, 6-9 leather muffler - 0-1 pipes, 0-1 sheet metal steel plating (and everything you can make with it, presumably) - 4-6 lumps of steel steel frames (and everything you can make with it, presumably) - 1-2 lumps of steel, hard plating - 12- 18 lumps of steel. metal tank (all types, presumably) - 0-1 sheet metal and 2-3 scrap metal

I have no idea what engines would look like, but those measurements assume a 50-75% recovery rate, which is reasonable to me, but 25 - 50% might appeal to you as well.

dwarfkoala commented 10 years ago

Ooh, and it takes 12 solar cells to make a solar panel, 2 power converters and 2 amplifier circuits and 20 copper wire.

So assuming 50 - 75% recovery rate, you'd get 6 - 9 solar cells, 0-1 power converters, 0-1 amplifier circuits, and 10-15 copper wire. Seems to me though that fragiler stuff like solar panels should get greatly reduced smashing spoils though.

ianestrachan commented 10 years ago

@EkarusRyndren See #3898, it was merged 9 days ago.

@dwarfkoala Sounds reasonable, I'll put a [WIP] tag on the PR and see if any of the maintainers has some extra input on that.

EkarusRyndren commented 10 years ago

@dwarfkoala Solar panels are made of more fragile stuff though. Stuff that'd easily be broken beyond repair.

dwarfkoala commented 10 years ago

That's true. It's open to debate.

Since you're a big vehicle user, do you have any idea what type of spoils we're talking about when it comes to engines and wheels? I found that on maximum yield, a wide wheel drops 70 plastic chunks, a regular wheel drops 40, a motorbike wheel drops 33, small wheels drop 9 plastic chunks, bicycle wheels drop 28. Unfortunately, this does not take into account the metal when you cut the wheels into chunks, so I have no idea how to decide what wheels should drop.

ianestrachan commented 10 years ago

Bear in mind that you can also break stuff by going to a vehicle and smashing it with something until it breaks, so we don't want to give the player too much loot, or the first wreck they come across will give them a lifetime supply of metal.

EkarusRyndren commented 10 years ago

@dwarfkoala ...I had no idea you could cut up tires truth be told. XD that said a tire would (ideally) have several kinds of broken:

Popped/Flat, vehicle will still move but it's harder control (provided you don't have redundant tires) Running on the Rim, the rubber of the tire is gone now, considerably more difficult to drive and gives a wonderful light show and noise and lastly the whole damn thing is gone this would be the "gone" broken presumably.

@ianestrachan shrugs All things considered scrap metal is incredibly easy to come by as is inside a city. Though a "broken" object shouldn't have nearly as much /useable/ scrap metal. so maybe the heaps of metal that come with helicopter wrecks should be done instead.

dwarfkoala commented 10 years ago

But we also have to consider that in a real life situation with all those cars laying about, metal would be plentiful. A lifetime supply of metal is an interesting idea, but it is similar to merely dismantling more or less intact vehicle parts. I, for one, have built megavehicles by salvaging car chassis and so forth for a couple seasons, without having to go and find new metal much at all.

Then again, I play size 7 cities. It's open to interpretation.

EkarusRyndren commented 10 years ago

@dwarfkoala having built more than a few mega vehicles as you've called them... I find the easiest way to get parts is to burn down cities for the rebar and cannibalize the ungodly plentiful vehicles inside it to build the vehicle. Find or build a welding rig and stick a storage battery on it and a solar panel and go from there.

dwarfkoala commented 10 years ago

The lifetime supply of metal thing is probably mostly limited by the time it takes to turn it into something useful. before you can go and use a pile of lumps of steel, you need a welder or a crucible or something to actually shape the metal. If you could smash up cars for metal, it'd still take ages to weld it all into the original components.

EkarusRyndren commented 10 years ago

@dwarfkoala exactly, even with the Hardware store machine it's still a long, slow process. Still, I don't think broken parts should drop a lot of useful things.

dwarfkoala commented 10 years ago

But then again, it shouldn't drop nothing as it does right now. I find it unreasonable that you can dismantle a completely smashed up RV and have nothing to show for it, the thousands of pounds of steel somehow disappearing.

maybe it would be more balanced to reduce the drops to 25% - 50%. I think that being able to "easily" build vehicles is an issue that making metal more plentiful won't change. After all, you used Rebar to feed your vehicle, something easily accessible to anyone with a matchbook. Perhaps welding rods or something might be the balancing factor, but until that happens, I don't think that breaking apart vehicle parts should be put on the shelf.

EkarusRyndren commented 10 years ago

@dwarfkoala Finding supplies wasn't the hard part, the hard part for me is just keeping the area secure from assorted critters. If roaming hordes become a thing, or world-destroying weather it might be a bit harder to build a vehicle quickly XD But that's something for another discussion.

dwarfkoala commented 10 years ago

Yup. For now I believe that the 50 -75% mark is fairly reasonable, at least for steel-only parts like plating and frames. Would you agree with that?

On Tue, Nov 5, 2013 at 6:08 PM, EkarusRyndren notifications@github.comwrote:

@dwarfkoala https://github.com/dwarfkoala Finding supplies wasn't the hard part, the hard part for me is just keeping the area secure from assorted critters. If roaming hordes become a thing, or world-destroying weather it might be a bit harder to build a vehicle quickly XD But that's something for another discussion.

— Reply to this email directly or view it on GitHubhttps://github.com/CleverRaven/Cataclysm-DDA/issues/3797#issuecomment-27834576 .

EkarusRyndren commented 10 years ago

@dwarfkoala sounds good to me, the fragile stuff really should drop recoverable parts, I mean it's supposed to be destroyed. But a hunk of steel is a little hard to completely obliterate.

dwarfkoala commented 10 years ago

Also, some testing on a day or so old experimental showed that it's possible for something with steel plating in its tile to be destroyed before the steel plating is damaged. Is this intended.

On Tue, Nov 5, 2013 at 6:24 PM, EkarusRyndren notifications@github.comwrote:

@dwarfkoala https://github.com/dwarfkoala sounds good to me, the fragile stuff really should drop recoverable parts, I mean it's supposed to be destroyed. But a hunk of steel is a little hard to completely obliterate.

— Reply to this email directly or view it on GitHubhttps://github.com/CleverRaven/Cataclysm-DDA/issues/3797#issuecomment-27835624 .

dwarfkoala commented 10 years ago

From what I can tell, steel plating is supposed to be destroyed before anything beneath it, so if you had plating on top of a board, and you hit a wall just hard enough to destroy one of the parts, it would be the plating that gets destroyed every time. Do I have this right?

I attached steel plating and a V8 to a bicycle and hit a wall at 250 MPH. The steel plating was not destroyed but the wheel and frame underneath were. Is this what's intended?

dwarfkoala commented 10 years ago

made a pic: image

KA101 commented 10 years ago

Uh, the tire's a LOT more fragile than the plating, and some (read: a LOT of) impact would come through at 250 MPH.

EkarusRyndren commented 10 years ago

@KA101 Not to mention I'm pretty sure Tires are ignored armor wise. (or at least were)

ianestrachan commented 10 years ago

It's supposed to damage plating first, but that may only apply to certain damage sources (like collisions with monsters)? Probably bears more investigation.

Also, I don't think the "stop collisions damaging across the vehicle" thing ever happened, so it could be shock damage in addition to the plating being hit.

dwarfkoala commented 10 years ago

I would, however, like to note that plating seems to be quite useful in actually armoring the parts in its square. When I debugged a scooter with 3 V8 engines, going at 250 MPH, and frames on opposite sides, one with steel plating and one without. Then I debugspawned some walls to test how the frames reacted, and was pleased to note that the frame with plating and frame only went to yellow damage while the one without was broken completely. On a monster test with repaired frames, the steel plated one continued to display much more durability.

I guess that the plating over something not taking damage first in all situations is reasonable, because if you ram something at high enough speeds to seriously damage the plating, the stuff beneath it would probably feel some shock damage. Still something to consider. Should I open an issue or does it work more or less as intended?

ianestrachan commented 10 years ago

There's already an issue for shock damage, #3053.