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

Weakpoints (Part 7): Add monster defenses #51979

Merged
merged 11 commits into from
Oct 2, 2021

Conversation

Joshua-Chin
Copy link
Contributor

@Joshua-Chin Joshua-Chin commented Sep 30, 2021

Summary

Features "Let monster defend their weak points"

Purpose of change

Monster should be able to defend their weak points. For example, a zombie bio-operator might raise its hands to protect its eyes, or a turtle might retract it head into its shell. In addition, these defenses may vary based on the type of attack.

Describe the solution

Interface

Add support for the following weakpoint fields

  • The coverage_mult field is a constant multiplier on the base coverage.
  • The difficulty field acts as a soft gating function on the attacker's skill. It multiplies the coverage by the probability that a sample from a normal distribution, centered on the attacker's skill with standard deviation 2, exceeds the difficulty.

Contributors will be able to specify different values for coverage_mult and difficulty depending on the attack type. The following types of attacks are supported:

  • Melee Stab: weapons like spears and polearms
  • Melee Cut: weapons like swords and knives
  • Melee Bash: weapons like clubs and hammers
  • Ranged: projectiles and thrown items

The shorthands all, melee, point, and broad are also support. See MONSTER.md for more information.

Implementation
  • Add the weakpoint_difficulty struct to weakpoint.h, and implement the JSON parsing.
  • Add the attack_type enum to theweakpoint_attack data struct.
  • Delay setting the fields of weakpoint_attack as late as possible. This reduces the level of code duplication. (e.g. setting the source for projectiles, melee attacks, and melee techniques, when it could be set just once.)
  • Handle the defensive calculations in weakpoint::hit_chance.

Describe alternatives you've considered

See #51915 for discussion and alternatives.

Testing

Manual testing with weakpoint_mon

Additional context

Closes #51915

@Joshua-Chin Joshua-Chin added <Enhancement / Feature> New features, or enhancements on existing Game: Mechanics Change Code that changes how major features work [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly. labels Sep 30, 2021
@Joshua-Chin Joshua-Chin changed the title Weakpoints (Part 6): Add monster defenses Weakpoints (Part 7): Add monster defenses Sep 30, 2021
@lgtm-com
Copy link

lgtm-com bot commented Sep 30, 2021

This pull request fixes 1 alert when merging d58892b into e379588 - view on LGTM.com

fixed alerts:

  • 1 for Declaration hides parameter

@Joshua-Chin Joshua-Chin marked this pull request as draft October 1, 2021 17:04
@Joshua-Chin Joshua-Chin marked this pull request as ready for review October 1, 2021 22:24
@Joshua-Chin
Copy link
Contributor Author

@I-am-Erk FYI, this PR updates weakpoint_attack.is_melee into the more fine grain enum weakpoint_attack.type.

@I-am-Erk I-am-Erk merged commit b91ddc9 into CleverRaven:master Oct 2, 2021
@I-am-Erk
Copy link
Member

I-am-Erk commented Oct 2, 2021

Arright looks like I gotta do some refinement of weakpoint JSON now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Game: Mechanics Change Code that changes how major features work Monsters Monsters both friendly and unfriendly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weakpoints: Monster Defenses
2 participants