Fix excess projectiles in the same tick impacting entities that die that tick #6532
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.
Issue
If multiple projectiles hit a target in the same tick, they will all impact it regardless of the target's HP.
For example, 6 TML (36000 damage) placed in a line will all impact a 13000 HP shield if they hit on the same tick. In general, any line/concave formation of units could be susceptible to this bug.
This is because collisions are checked for all projectiles before any impact scripts are run, so the usual
OnCollisionCheck
if self.DisallowCollisions then return false end
doesn't work ifDisallowCollisions
is adjusted due to damage taken from impacts.Description of the proposed changes
DisallowCollisions
in theOnImpact
function of the projectile, so that projectiles have an up-to-date status on the entity's collision as HP gets adjusted due to previous impacts.DisallowCollisions
boolean to shields because:_IsUp
would be an extra check for all projectiles_IsUp
is adjusted by state changes, which are forked threads that happen after all impact scripts are run.Testing done on the proposed changes
Use a logging statement to see how many projectiles impact a unit or shield and how many impact the terrain. The projectiles are from 15 TML stacked on top of each other, although realistic scenarios like 6 TML in a line can also impact a shield in the same tick.
The logging statement shows that just enough projectiles to kill the unit/shield hit it, and the rest passed on to hit the terrain behind/under it.
Tested with a shield, a Ythotha (unit with death animation), Percival (standard unit), and a Tempest (sinking animation unit). Before the changes, all 15 TML would impact the target, and after the changes only the necessary amount impact the target.
Checklist