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 Unique wounds for woundables #4

Merged

Conversation

nikthechampiongr
Copy link

@nikthechampiongr nikthechampiongr commented May 5, 2024

About the PR

Adds singleton wounds. Referred to as unique in the code.

If a wound conflicts with a unique wound when it is being added due to damage, then the next lowest non conflicting wound will be added and the conflicting wound's severity will be reset to 1. The severity does not reset if this is attempted with the wound command.

Technical details

The check is done in 2 places:

  • OnWoundInsertAttempt() in order to make it impossible for a conflicting wound to be added to a woundable.
  • TryGetWoundProtoFromDamage() where it will also return the conflicting wound if it's what led to the function's result. An edge case here: If multiple unique wounds conflict in a row then only the last one will be returned to have its severity reset. Furthermore, because we don't actually have a wound entity for the wound prototypes we are trying we do not know if those wounds are unique. This means that for every wound that is tried, we have to go through every other wound on the woundable to find unique wounds and see if their prototypes match. OnWoundInsertAttempt uses an overload of the function used to check this which immediately returns if the wound that's being inserted isn't unique since we can assume that no wounds of this type are unique.

Checking is done by ConflictsWithUniqueWound() which returns a boolean indicating if a wound conflicts, and the conflicting wound if found.

Media

  • I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

Changelog

If a wound prototype is marked as unique then only one can exist on a
woundable. If someone gains a wound from damage which conflicts with a
unique wound then the unique wound will have its severity reset to 1.
@Jezithyr Jezithyr merged commit c148cd0 into Jezithyr:MedicalRefactor May 6, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants