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

feat(balance): increase variety of potential damage states for spawned vehicles #4746

Merged
merged 3 commits into from
Jun 6, 2024

Conversation

chaosvolt
Copy link
Member

@chaosvolt chaosvolt commented Jun 6, 2024

Purpose of change

It's a famous Cata meme, on Zero Day every tire in the world magically explodes. While all the other mechanisms for spawning a vehicle disabled in the game's code are more subtle and natural-looking, the "wreck the tires" code always looks jarring with how it vehicles only ever generate with intact wheels or with all wheels busted. It not only looks odd, but means the player rarely gets to contend with the "unbalanced" and "no steering" conditions.

Along the way, in looking at the code I found myself rapidly being tempted to tinker with the code a bit more to flesh out the variation in spawn conditions further.

Describe the solution

In vehicle.cpp, set the destroyTires behavior in vehicle::init_state to pick wheels to destroy a number of tries equal to the number of wheels it has, instead of intentionally trying to overkill the wheels with 100 attempts. Idea is, since it will target a random wheel each time and might try to hit the same wheel more than once, the odds of it wrecking every single wheel go down the more wheels the vehicle has, any the damage to wheels will fittingly appear more random and look less obviously faked.

In addition, as a bonus cars set to spawn damaged but not disabled can now also make a single bonus roll to spawn with a busted wheel and some added potential to spawn with a random amount of wrecked windshields. A single 5% chance to bust one wheel and a 5% chance per windshield, respectively.

Next, set it so that reactors, minifridges, and minifreezers only spawn active some of the time, adding more variation to whether a car with those features that spawns will drain its batteries and/or plutonium while left idle before you get to it.

Describe alternatives you've considered

Screaming.

Testing

  1. Compiled and load-tested.
  2. Temporarily set the code to always pop tires on disabled vehicles for testing.
  3. Spawned in multiple disabled cars, number and location of destroyed tires was random.
  4. Spawned in a semi truck, the back wheels were a more pleasing mishmash of wrecked and intact wheels.
  5. Went back to current setup and started spawning lightly-damaged cars, some have busted windshields now, a tire busted, etc.
  6. Spawned in RVs, no longer always spawn with the fridge running.
  7. Spawned in an atomic car, confirmed that the reactor doesn't always spawn running, and that this doesn't somehow break being able to turn it on.
  8. Checked affected file for astyle.

Status of a car that spawned messed up in an uncommon way due to the new randomization:
image

A semi showing how more wheels means better chance to still be drivable:
image

Additional context

image

Checklist

@github-actions github-actions bot added the src changes related to source code. label Jun 6, 2024
@github-actions github-actions bot added the tests changes related to tests label Jun 6, 2024
@Lamandus
Copy link
Contributor

Lamandus commented Jun 6, 2024

grafik

grafik

works very well. No errors while testing.

@chaosvolt chaosvolt merged commit 25ea154 into cataclysmbnteam:main Jun 6, 2024
13 checks passed
@chaosvolt chaosvolt deleted the goofy-ahh-tires-exploding branch June 6, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code. tests changes related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants