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

Fix character volume calculation #74348

Merged
merged 8 commits into from
Jun 15, 2024

Conversation

feinorgh
Copy link
Contributor

@feinorgh feinorgh commented Jun 6, 2024

Summary

Balance "Bring volume calculations for player body more in line with realistic examples"

Purpose of change

After the addition of volume calculations in #74162, my current character could no longer use any vehicles. The change is well meaning and brings realism, which I like, but the values seemed off, so I set out to make reasonably sized characters (both height and weight wise) able to get into car seats again, while retaining the limits for huge characters.

Describe the solution

I looked up how to calculate volume in the real world, from body density, which itself is dependent on the body fat to muscle and bone ratio, and age (age is NOT included in these calculations currently).

I tried calculating the volume sizes for various heights and sizes to see if they seem reasonable, the results can be found here: #74263.

I changed the volume calculation method for the character, and adjusted the unit tests accordingly.

The previous tests now pass. I removed some assertions based on assumptions on a default character having exactly 70 000 ml volume at 175 cm height, but the functional tests for getting into a vehicle and being cramped now works.

I play tested with my current character too (200 cm tall, normal weight), and she can now get into a car seat, even though she gets the "cramped" debuff.

Describe alternatives you've considered

Another approach would be to change the way car seats and volume calculations are performed, but this seemed like a MUCH bigger task, which would bring little benefit to the game or the maintainability of vehicles and vehicle parts.

Testing

The tests for the volume calculations and getting into a vehicle works, and gives the same results as before.

I've play tested the change, and now my character has to take off her rucksack to be able to sit in the driver seat, but she can drive the car, even though it's cramped.

Additional context

Tawnya Ivey _2024-06-06T13-10-24
With military rucksack on.

Tawnya Ivey _2024-06-06T13-11-02
With military rucksack taken off.

Tawnya Ivey _2024-06-06T13-08-47
Driving nude, in the middle of summer.

@github-actions github-actions bot added Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` Game: Balance Balancing of (existing) in-game features. json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jun 6, 2024
@IdleSol
Copy link
Contributor

IdleSol commented Jun 6, 2024

There's a problem with bionics in this method. If I understand correctly, we are using the average human body density.

But by installing the module, we increase the mass of the character. Or we change his density, since installing a module does not change the volume or height of the character. The formula does not take this into account.

Just for reference, installing all bionics will give a minimum of +60 kg. (Quick test with scales: naked man 77 kg, the same with all bionics: "error: weight more than 150 kg").

@feinorgh
Copy link
Contributor Author

feinorgh commented Jun 6, 2024

There's a problem with bionics in this method. If I understand correctly, we are using the average human body density.

But by installing the module, we increase the mass of the character. Or we change his density, since installing a module does not change the volume or height of the character. The formula does not take this into account.

Just for reference, installing all bionics will give a minimum of +60 kg. (Quick test with scales: naked man 77 kg, the same with all bionics: "error: weight more than 150 kg").

Ah, I understand. The formula assumes fat, bone and muscle. I suppose we can subtract the weight of the installed bionics from the total weight and use that?

I'll give it a try and see what I can come up with.

@feinorgh
Copy link
Contributor Author

feinorgh commented Jun 6, 2024

There's a problem with bionics in this method. If I understand correctly, we are using the average human body density.

But by installing the module, we increase the mass of the character. Or we change his density, since installing a module does not change the volume or height of the character. The formula does not take this into account.

Just for reference, installing all bionics will give a minimum of +60 kg. (Quick test with scales: naked man 77 kg, the same with all bionics: "error: weight more than 150 kg").

At a closer look, bodyweight() returns the current weight of the character without bionics. However, when your character is standing on a scale, their weight is calculated by get_weight(), which sums bodyweight(), inventory weight, weight of worn items, weight of wielded items, and the weight of installed bionics. So I think the original calculation is correct, bodyweight() returns only the base weight of the character, and the density calculation holds.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jun 6, 2024
@feinorgh
Copy link
Contributor Author

feinorgh commented Jun 8, 2024

I did some deeper research into body volume calculations, the results of which can be found here: https://github.com/feinorgh/body_volume_calculation

I have not compared the results of the implementation in C++ with the Python variants, further adjustments might be needed to fine tune it.

Anyway, hopefully this helps with estimating the usefulness of the PR.

@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. NPC / Factions NPCs, AI, Speech, Factions, Ownership [JSON] Changes (can be) made in JSON Missions Quests and missions Map / Mapgen Overmap, Mapgen, Map extras, Map display Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Spawn Creatures, items, vehicles, locations appearing on map Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies Monsters Monsters both friendly and unfriendly. Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. [Markdown] Markdown issues and PRs Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves Mods: Magiclysm Anything to do with the Magiclysm mod Mods: Aftershock Anything to do with the Aftershock mod Mods: Generic Guns Anything to do with Generic Guns labels Jun 8, 2024
@Maleclypse Maleclypse removed Mods: Generic Guns Anything to do with Generic Guns Mods: Dark Days of the Dead Anything related to the DDotD mod (classic style zombies) Mods: Dinomod Anything to do with the Dinoclysm mod (DinoMod) Mods: Magiclysm Anything to do with the Magiclysm mod Mods: No Hope Relating to the mod No Hope Mods: Innawood 🌲 Anything to do with Innawood mod Mods: TropiCataclysm 🌴 Having to do with the tropical region mod for DDA. Mods: Mind Over Matter NPC / Factions NPCs, AI, Speech, Factions, Ownership Spawn Creatures, items, vehicles, locations appearing on map Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies Monsters Monsters both friendly and unfriendly. Mods: Xedra Evolved Anything to do with Xedra Evolved labels Jun 11, 2024
tests/char_volume_test.cpp Show resolved Hide resolved
tests/char_volume_test.cpp Show resolved Hide resolved
Relying on volumes down to the ml allows us to make changes to volume
calculations, and keep the tests withing reasaonable boundaries.

references CleverRaven#74263
@github-actions github-actions bot added Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` Game: Balance Balancing of (existing) in-game features. labels Jun 11, 2024
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jun 11, 2024
Copy link
Member

@RenechCDDA RenechCDDA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any concerns I've mentioned have been addressed. The Brozek formula is a more accurate way to measure human body volume. Tests have been properly updated to account for the new formula.

@dseguin dseguin merged commit 175eae4 into CleverRaven:master Jun 15, 2024
20 of 26 checks passed
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jun 15, 2024
@feinorgh feinorgh deleted the fix_character_volume_calculation branch June 15, 2024 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Game: Balance Balancing of (existing) in-game features. json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants