Skip to content
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

Breaking vehicles - ready! #4169

Merged
merged 9 commits into from Nov 9, 2013

Conversation

Projects
None yet
3 participants
@ianestrachan
Copy link
Contributor

commented Nov 5, 2013

Closes #3797:

  • Parts that take damage while at 0 HP have a chance of being destroyed. (rng(0, partMaxHP) < damageToPart)
  • Destroyed parts get broken into pieces defined in their JSON entries and removed from the vehicle entirely. Comments highly appreciated - I pulled the current piece lists out of thin air
  • Only non-critical frames can be destroyed, but even non-critical frames will have all mounted parts torn off if damaged while at 0 HP. Torn off parts are dropped intact (preserving damage) as if removed with a hacksaw and wrench.
  • Parts at 0 HP also get broken into pieces if removed or replaced.

Should make clearing wreckage easier. I recommend that whoever tests this debugs themselves a sledgehammer and smashes a car into bits; it's surprisingly fun.

@kevingranade

This comment has been minimized.

Copy link
Member

commented Nov 6, 2013

Either later or in this PR, how about scatterring, or even better flinging
the parts a bit? I have a sneaking suspicion anything shrapnel-related
would be well recieved.

@ianestrachan

This comment has been minimized.

Copy link
Contributor Author

commented Nov 6, 2013

Actually, they are scattered when broken off from damage. The break_part_into_pieces function has an optional parameter on the end that scatters pieces if set to true. Currently it's ±1 square, sometimes 0, in each direction, something that could be improved later.

Flinging the actual parts around as projectiles would be amazing (and potentially deadly to those standing nearby) but I haven't any idea how to do that.

@ianestrachan

This comment has been minimized.

Copy link
Contributor Author

commented Nov 6, 2013

Going to beef up the amount of metal reclaimed from parts being broken into pieces, going by the weight of the resulting pieces.

Scrap metal: 113
Steel chunk: 340
Steel lump: 1360

No more sheet metal, since anything being smashed from a collision or torn off of a car is unlikely to still be a flat and smooth sheet of metal after that happens. (Also it has 1000 weight, so the lump is better)

I'm going to aim for about a 50% reclamation rate with (where possible) at least one of each of scrap/chunks/lumps.

@ianestrachan

This comment has been minimized.

Copy link
Contributor Author

commented Nov 7, 2013

I think we're good to go. I got some segfaults, but I'm certain they're due to a bug that's been fixed since I started this (specifically, not being able to move to the south or east, and not being able to long-range teleport near monsters). I completely smashed a couple of vehicles until they were totally destroyed (serious fun, though explosions are surprisingly bad at taking out vehicles) and didn't seem to have any problems.

@kevingranade kevingranade merged commit 9ef8569 into CleverRaven:master Nov 9, 2013

1 check passed

default Merged build finished.
Details

@ianestrachan ianestrachan deleted the ianestrachan:breaking-vehicles branch Nov 9, 2013

@yobbobanana

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2013

I seem to have come across a serious problem with this, in that removing parts actually changes the parts vector. And parts are referred to by their index in the parts vector. And the indices are carried over after removing parts, and then used to remove parts.

Specifically unless i'm reading it completely incorrectly, vehicle::damage_direct is removing random parts by removing the part "p" after removing other parts (each of which can of course cause the meaning of "p" to change), and even worse, doing so every iteration while iterating over a list of parts which includes p.

If it so happens that "p" is the final part in the parts list, removing any other part causes a segfault when "p" is later removed. Even if it's not, random other parts will be removed.

The more i look at the way vehicle parts are handled, the less i want to have anything to do with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.