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

Add Essential field to Body Parts. Rework Repair Nanobots and NPC first aid action. #2482

Conversation

KheirFerrum
Copy link
Collaborator

@KheirFerrum KheirFerrum commented Mar 25, 2023

Summary

SUMMARY: Balance "Add Essential field to Body Parts. Add kcal_trigger_cost to Bionics. Rework Repair Nanobots and NPC first aid action."

Purpose of change

When I first did a pass over the Repair Nanobots in #1442 and #1508, I had no idea what I was doing with C++. Now that I sort of do I can fix up some things and make the Repair Nanobots work closer to my vision.

Also, Repair Nanobots not working on broken limbs was a bit weird, so I'm going to make it repair your broken limbs (as long as they've been splinted, or you have Lizard Regeneration)

Added kcal_trigger_cost as a parameter for bionics, only used for Repair Nanobots currently, but jsonizes kcal costs.

Describe the solution

Add essential" field to body parts. Currently only for Head and Torso. If these body parts reach 0 HP, you die.

Add kcal_trigger_cost to bionics. Only used in Repair Nanobots right now.

Swap react_cost on Repair Nanobots for trigger_cost to more accurately reflect what it does. Undo the hacks I did to make react_cost work for my purposes last time.

Bleeding has been un-RNG'd, and will now prioritize essential body parts first.

Change trigger for HP/mending to once every minute. Both will now increment all wounded/mending parts by 1HP or 1% each, provided you have enough calories and enough bionic energy. If you do not, the system will prioritize injuries first (injured essential parts considered 10 HP more injured than other parts), then broken limbs.

Describe alternatives you've considered

Placing mending changes in character::mend()

  • Feels a bit harder to track since I don't know the order of operation.

Testing

Spawned character, installed nanobots, gave enough power for a single limb, checked that when torso and arm were both similarly injured, torso was healed first, even when both were under 10 HP. Checked that when given enough power for all limbs all limbs were only healed 1 HP.

Broke one of their arms, checked that without a splint it would not heal from the Nanobots. Checked that when I put on the splint it incremented by 1% every minute.

Additional context

Head and Torso labelled essential parts. Adjusted is_dead_state() to use essential bool.

Priority parts are considered 10 points more injured for purposes of healing from nanobots and NPCs.

If healing is done and there is still power/kcal, increment any mending effect by 1%
@github-actions github-actions bot added JSON related to game datas in JSON format. src changes related to source code. labels Mar 25, 2023
@KheirFerrum KheirFerrum changed the title Add Priority field to Body Parts. Rework Repair Nanobots and NPC first aid action. Add Essential field to Body Parts. Rework Repair Nanobots and NPC first aid action. Mar 25, 2023
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

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

overall it's an welcome addition. could you refactor the code a bit before merging?

src/bionics.cpp Show resolved Hide resolved
src/character.cpp Outdated Show resolved Hide resolved
src/iuse_actor.cpp Outdated Show resolved Hide resolved
src/bionics.cpp Outdated Show resolved Hide resolved
src/bionics.cpp Outdated Show resolved Hide resolved
src/bionics.cpp Outdated Show resolved Hide resolved
src/bionics.cpp Outdated
Comment on lines 1603 to 1605
std::vector<bodypart_id> bleeding_bp_parts;
std::vector<bodypart_id> damaged_hp_parts;
std::vector<bodypart_id> mending_bp_parts;
Copy link
Member

Choose a reason for hiding this comment

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

i think optaining bleeding_bp_parts, damaged_hp_parts, and mending_bp_parts vector should be done in separate function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it sort of is? bleeding_bp_parts is updated every 30 turns while damaged_hp_parts and mending_hp_parts are updated every 1 minute. Unless you mean some character specific vector that is updated every turn, which would likely be a bit costly.

Copy link
Member

@scarf005 scarf005 Apr 3, 2023

Choose a reason for hiding this comment

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

i mean, the vectors could be initialiazed from separate static function, for example

static std::vector<bodypart_id> get_bleeding_bp_parts( const character &c )

KheirFerrum and others added 2 commits April 3, 2023 15:43
Co-authored-by: scarf <greenscarf005@gmail.com>
Added a kcal_trigger_cost parameter to bionics, only used for bio_nanobots right now though.
src/bionics.cpp Outdated Show resolved Hide resolved
@KheirFerrum KheirFerrum force-pushed the Priority-Parts,-Rework-healing/nanobots branch from 0fcbd7f to 01493ee Compare April 11, 2023 01:39
src/bionics.cpp Outdated Show resolved Hide resolved
src/bionics.cpp Show resolved Hide resolved
src/creature.cpp Outdated Show resolved Hide resolved
KheirFerrum and others added 3 commits April 18, 2023 21:15
@scarf005 scarf005 assigned scarf005 and unassigned scarf005 Apr 18, 2023
effect_map instantiates a new effect list instead of receiving the pointers, so the pointers provided by the function don't point at the bleeding effects on the character but to the effects on the effect map, which has likely ceased to exist.
@KheirFerrum KheirFerrum force-pushed the Priority-Parts,-Rework-healing/nanobots branch from 0756ed8 to 053987b Compare April 18, 2023 23:23
Reinstate effect map as a reference.
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

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

Cataclysm: Bright Nights - cbn-experimental-2023-04-09-1611-16-g053987bd7303_03
set both torso and arm's health to 10
confirmed essential part (torso) gets healed first
Cataclysm: Bright Nights - cbn-experimental-2023-04-09-1611-16-g053987bd7303_04
broke an arm, confirmed it does not heal without splints
Cataclysm: Bright Nights - cbn-experimental-2023-04-09-1611-16-g053987bd7303_05
wore splints with CBM turned off, confirmed it does not heal within minutes
Cataclysm: Bright Nights - cbn-experimental-2023-04-09-1611-16-g053987bd7303_06
wore splints with CBM turned on, confirmed it heals in minute basis. however, i think it should be more explicitly described how it interacts with splints and broken arms.

data/json/bionics.json Outdated Show resolved Hide resolved
data/json/items/bionics.json Outdated Show resolved Hide resolved
@scarf005 scarf005 merged commit f453441 into cataclysmbnteam:upload Apr 19, 2023
@KheirFerrum KheirFerrum deleted the Priority-Parts,-Rework-healing/nanobots branch April 19, 2023 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants