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

Moving quadrupedally through certain traps now applies appropriate damage to arms/hands #74662

Merged
merged 47 commits into from
Jun 29, 2024

Conversation

GalacticApple
Copy link
Contributor

@GalacticApple GalacticApple commented Jun 19, 2024

Summary

Bugfixes "Updates trapfunc.cpp to consider quadrupedal movement"

Purpose of change

This is something of a follow-up to #74639. I realized that certain traps, namely lava, goo pits, caltrops and bear traps don't damage your arms/hands when moving through them quadrupedally. I also noticed that there's a "quadruped_half" effect which was meant to be for when you only have Paws and Digitigrade, so I updated enchantments.json to make use of it.

Describe the solution

I updated the functions in trapfunc.cpp to consider if a character has either the quadruped_full or quadruped_half effects. I also updated the functions changed in #74639 to consider quadruped_half.

As an example, beartraps can now snag your arm if you move over them on all-fours.

Describe alternatives you've considered

I may or may not come across other situations where you should hurt your hands when moving like that.

Testing

Compiled and tested on my personal copy of CDDA.

Additional context

@github-actions github-actions bot added [JSON] Changes (can be) made in JSON [C++] Changes (can be) made in C++. Previously named `Code` Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Mechanics: Enchantments / Spells Enchantments and spells <Bugfix> This is a fix for a bug (or closes open issue) new contributor labels Jun 19, 2024
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Jun 19, 2024
GalacticApple and others added 8 commits June 18, 2024 20:59
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Jun 19, 2024
@anothersimulacrum
Copy link
Member

@Venera3 Do you have any advice on how to have this use less hardcoded bodypart id checks?

@Venera3
Copy link
Member

Venera3 commented Jun 19, 2024

Well.
The proper way to do this is to jetisson the whole enchantment into effect into hardcoded effect check jank and just move it to a new movement mode. For that you'd need to add a way for traits to add movement modes and a ground_contact list to movemodes (they are thankfully unhardcoded otherwise so it's a smaller undertaking than it sounds), then reroute the checks to hurt the ground contact of your current movemode.

Otherwise you're stuck with the ugly if you have the effect hurt all your hands and feet solution with get_all_bodyparts_of_type (or similar, I'm not sure what the function is called).

I'd be thankful if you took the high road and tackled the first solution but I'm not gonna be a stick in the mud if you go with the second if that's too much.

@GalacticApple
Copy link
Contributor Author

GalacticApple commented Jun 19, 2024

I think tackling the former would be a future pull request for me.

Also, wouldn't the former require a total rework of how traps apply damage? Each trap pretty much applies damage in a unique way.

@Venera3
Copy link
Member

Venera3 commented Jun 19, 2024

Unhardcoding traps is long overdue, but having a common target bp selector is preferable to twelve counts of hardcoded effect checks into hardcoded bp assignments even without that.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jun 19, 2024
Copy link
Member

@anothersimulacrum anothersimulacrum left a comment

Choose a reason for hiding this comment

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

You should make a function, something like std::vector<bodypart_id> Creature::get_ground_contact_bodyparts() const, which does this effect check, and returns the appropriate bodyparts.

This would use Creature::get_all_body_parts_of_type to return either foot body parts or foot and hand body parts, depending on the result of the effect check.

This would then replace everywhere here that you are manually specifying bodypart ids.

src/map_field.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/creature.cpp Outdated Show resolved Hide resolved
src/creature.cpp Outdated Show resolved Hide resolved
src/creature.cpp Outdated Show resolved Hide resolved
src/map_field.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
src/trapfunc.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the astyled astyled PR, label is assigned by github actions label Jun 21, 2024
src/trapfunc.cpp Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions and removed astyled astyled PR, label is assigned by github actions labels Jun 23, 2024
src/creature.cpp Outdated Show resolved Hide resolved
src/creature.cpp Outdated Show resolved Hide resolved
src/map_field.cpp Outdated Show resolved Hide resolved
GalacticApple and others added 2 commits June 23, 2024 15:08
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions and removed astyled astyled PR, label is assigned by github actions labels Jun 23, 2024
src/creature.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the astyled astyled PR, label is assigned by github actions label Jun 26, 2024
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Jun 26, 2024
Copy link
Member

@anothersimulacrum anothersimulacrum left a comment

Choose a reason for hiding this comment

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

Looks great!

src/trapfunc.cpp Outdated Show resolved Hide resolved
GalacticApple and others added 2 commits June 26, 2024 19:19
Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>
@GalacticApple
Copy link
Contributor Author

Do I need it to pass all the checks?

@anothersimulacrum
Copy link
Member

Only the required checks. If it fails the others and it's not the fault of this PR, it's okay.

@Maleclypse Maleclypse merged commit 16c3df3 into CleverRaven:master Jun 29, 2024
23 of 27 checks passed
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 <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Mechanics: Enchantments / Spells Enchantments and spells new contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants