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

Small enhancement to Character Modifiers #55253

Merged
merged 6 commits into from
Feb 12, 2022

Conversation

dseguin
Copy link
Member

@dseguin dseguin commented Feb 9, 2022

Summary

None

Purpose of change

Minor enhancement to #53069.
JSONify the fall damage and slip prevention modifiers added in #54555.

Describe the solution

Add the ability to define an array of limb scores affecting a character modifier (as well as a combo operation, either ADD or MULT).

{
  "type": "character_mod",
  "id": "limb_fall_mod",
  "description": "Fall damage modifier",
  "mod_type": "x",
  "value": { "limb_score": [ "move_speed", "footing", "reaction" ], "limb_score_op": "x" }
}

Also add the ability to specify a weighted list (with a custom denominator):

{
  "type": "character_mod",
  "id": "slip_prevent_mod",
  "description": "Slip prevention modifier",
  "mod_type": "x",
  "value": {
    "limb_score": [ [ "grip", 3.0 ], [ "lift", 2.0 ], "footing" ],
    "override_encumb": true,
    "limb_score_op": "+",
    "denominator": 6.0
  }
}

Describe alternatives you've considered

I get the impression that JSON is not very friendly to arbitrary arithmetic :P

Testing

Added test cases to check that added/multiplied limb scores in character modifiers are correctly calculated:

./tests/cata_test -d yes --rng-seed time "Multi-limbscore modifiers"

Additional context

Ping: @Venera3

@github-actions github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Feb 9, 2022
@Maleclypse Maleclypse added <Bugfix> This is a fix for a bug (or closes open issue) <Enhancement / Feature> New features, or enhancements on existing and removed json-styled JSON lint passed, label assigned by github actions labels Feb 9, 2022
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Feb 9, 2022
@Maleclypse Maleclypse added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON labels Feb 9, 2022
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 9, 2022
@github-actions github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Feb 9, 2022
@dseguin dseguin marked this pull request as ready for review February 9, 2022 23:59
@PatrikLundell
Copy link
Contributor

It requires a fair bit of guesswork to figure out that 'x' is supposed to mean multiplication (in the snipped in the post: the code seems to use the only marginally better '"'), assuming I guessed correctly... I would suggest to let the strings contain words, or at least abbreviations of words, such as "ADD", "MULT", etc.

JSON is actively hostile to anything that requires documentation...

@Zireael07
Copy link
Contributor

IIRC Cata devs managed to inject comments into JSON via some hack or other - this is a case of something that needs a comment.

@PatrikLundell
Copy link
Contributor

On the comment tangent: It works to add "data" elements with names of "//", "//1", etc. followed by the documentation string in at least some places (I've used it with construction recipes). I suspect anything starting with double slashes are left unmatched against the actual pattern the JSON parsing is looking for. It's a shame the nutjob creating JSON threw out support for actual comments in a rage fit over perceived misuse of comments as processing directives by someone, though.

@Venera3
Copy link
Member

Venera3 commented Feb 10, 2022

Sweet! Now, this probably counts as "arbitrary arithmetic", but do you think weighted averages would be doable? Slipping down uses (game.cpp:11970ish)

    slip /= ( u.get_limb_score( limb_score_grip ) * 3 + u.get_limb_score(
                  limb_score_lift, body_part_type::type::num_types,
                  1 ) * 2 + u.get_limb_score( limb_score_footing ) ) / 6;

to make gripping more important than the rest. It's not a big thing if it's more trouble than it's worth, addition/multiplication already covers a lot of the bases.

@dseguin
Copy link
Member Author

dseguin commented Feb 10, 2022

I guess I have more work to do :P

But really, it shouldn't be too hard to implement weighted lists. I'll add that to these changes.

@dseguin dseguin marked this pull request as draft February 10, 2022 14:29
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 10, 2022
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 10, 2022
@dseguin dseguin marked this pull request as ready for review February 10, 2022 23:32
@kevingranade kevingranade merged commit a87e677 into CleverRaven:master Feb 12, 2022
@dseguin dseguin deleted the multi_limbscore_modifiers branch February 12, 2022 00:52
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` <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants