Killing hostile NPCs won't give "Killed innocent" morale debuff anymore #78371
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.
Summary
Bugfixes "Killing hostile NPCs won't give "Killed innocent" morale debuff anymore"
Purpose of change
At the moment, to NOT get the morale debuff for killing NPCs, said NPC has to be
guaranteed_hostile
. This condition is true if at least one of the following conditions is true:is_enemy
, which means that he must have NPC attitude of killing us (NPCATT_KILL
) or fleeing from us (NPCATT_FLEE
orNPCATT_FLEE_TEMP
).There are situations where hostile NPC isn't aware of us yet and thus is ignoring us and thus his NPC attitude is
NPCATT_NULL
. This means that first condition from the list above will be false.As @mlangsdorf said in #30124 (comment), there might be some bugs or errors in faction assignment or evaluation, and this might be the reason why second condition from the list above also becomes false.
If both conditions are false, killing hostile NPC will give us a morale debuff.
Describe the solution
Added a check for hostile creature attitude, i.e.
Creature::Attitude::HOSTILE
. Hostile NPCs which haven't seen us yet (and thus not angry at us and not trying to kill us yet) have this attitude, and thus won't be considered as innocent, even if faction check fail for some reason.In any case, if these changes won't fix the issue, this additional check for creature attitude won't hurt.
Describe alternatives you've considered
None.
Testing
I conducted A LOT of testing using several methods from #30124 and #71341, i.e. killing bandits spawned through Old Guard representative's mission, bandits in road block, bandits in
bandits_garage
and some others. I wasn't able to reproduce the original issue. If anyone has a save which can reliably reproduce the issue, please give it to me, I'll try to test it myself.Additional context
None.