Below the Surface - kill enemies that are at negative HP; fix Blob HP #211
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Issue 1: (the main one)
Currently enemies are only killed if they're jumped on and have exactly 0 HP (the game essentially 0-indexes HP by coding its HP check in this way). This leads to the possibility that enemies can be brought to less than 0 HP and then become functionally invulnerable.
The check has been changed from
== 0
to<= 0
, and some explanatory comments have been added since 0-indexing HP is extremely unusual.Issue 2: (a minor side thing)
Most enemies spawn with 0 HP (essentially 1 HP because HP is functionally 0-indexed). However, the Blob enemy is explicitly noted in a comment as being intended to die with 3 jumps, but was set to 3 (and thus functionally 4) HP.
The Blob's HP has been changed to 2 (which is the functionally-3 it seems it was intended to have), and explanatory comments have been added since 0-indexing HP is extremely unusual.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
After figuring out the logic used by the game for HP / enemy death calculations, I confirmed the logic using temporary debugging outputs and played for a few minutes to check the debugging outputs. I then verified my changes worked as expected (e.g., no more invulnerable enemies caused by attacking them before jumping on them*, and Blob dies in exactly 3 jumps) by playing a build with and without the changes applied.
* this also relates to changes made in #202
Testing Checklist
N/A
Checklist
I have made corresponding changes to the documentation(N/A)