Repository navigation
Fix NPC-to-NPC damage checking the shooter instead of the target - #1291
Open
GuiBoneVowt wants to merge 1 commit into
Open
GuiBoneVowt wants to merge 1 commit into
GuiBoneVowt wants to merge 1 commit into
Conversation
NPC::shoot applied NPC-to-NPC damage only if the shooter was alive and not invulnerable. So an invulnerable NPC still took damage from other NPCs, an invulnerable NPC could not damage them, and a dead NPC kept getting OnNPCTakeDamage. Check the target's dead and invulnerable state, as onPlayerGiveDamage already does for damage from players. The shooter's dead check stays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When an NPC shoots another NPC,
NPC::shootonly applies the damageif (!dead_ && !invulnerable_), and those are the shooter's fields. The player → NPC path (NPCComponent::onPlayerGiveDamage) checks the target withnpc->isInvulnerable(), which matches whatNPC_SetInvulnerableis for ("Sets whether an NPC is invulnerable to damage").On current
masterthis means:OnNPCTakeDamage.This PR checks the target's dead and invulnerable state. The shooter's dead check stays, so a dead NPC still can't hurt anyone.
Testing
Windows, RelWithDebInfo, Win32 + ClangCL, on top of current
master(72bf89c). Headless gamemode: two NPCs 2 units apart,NPC_Shootwith a Deagle andNPC_ENTITY_CHECK_NONE. Ran twice on each build, same results.OnNPCTakeDamagecalledOnNPCDeathonceOnNPCTakeDamagecalledNPC_Respawn, then shot three timesOnNPCDeathtwiceCore of the test
clang-format 13 with the repo's
.clang-format: no changes.