Fixes an issue with vanilla silent kills not sending npc_on_death_callback, and adds a new npc_on_silent_kill_callback for use by other addons.
The vanilla gameplay_silent_kills script makes a kill "silent" by intercepting the hit before it happens, canceling the hit, and then killing the target without sending an npc_on_death_callback.
Unfortunately, not sending that callback breaks a wide variety of scripts which rely on it to know when an NPC has died. For example, this is one likely source of PAW or MilPDA mapspots getting left on something after death.
The fix in this script:
- Detects when a silent kill has happened, and sends an npc_on_death_callback with the killer listed as the actor's weapon rather than the actor themselves. NPCs will not aggro the weapon and the game will not hold the actor responsible.
- Adds a new callback to support stealth gameplay: npc_on_silent_kill_callback(victim, killer, weapon, was_melee) Params: <game_object>, <game_object>, <game_object>, <boolean>
- Adds a new gameplay statistic for "stealth_kills" and increments that stat. Right now this is for script use only; it is not yet exposed in the player's UI.
All three features can be disabled, if necessary, using flags in the script. I didn't really think this was worth putting together an MCM menu.
Scripts can register the new callback like any other in order to trap stealth kill events. The script also exposes the ID of the last NPC who was stealth-killed by the actor, for use by other scripts.
What does this do for you, as a player?
Not a lot without other addon support, to be honest. The game mostly works fine without this. It's mainly when you bring in addons which depend on npc_on_death_callback, which should work more reliably. Modders can make use of the new callback, but they have to specifically add support for it in their scripts. There is commenting in my script to help understand its usage.
This addon does not alter the way gameplay_silent_kills operates at all, not even a little. It does not change the test for whether or not a kill is silent. It just detects when one has happened, and sends the appropriate callback. It is extremely short and simple.
All of which is to say that if you're having problems with stealth kills not working, it ain't this addon.
Note: I accidentally packed up the (unaltered) vanilla copy of the silent kills script along with the original upload. That's fixed now, but since it was just the vanilla script I was using for testing, it won't change anything even if you're one of the few who downloaded that copy.
Awesome I kinda get what this does, I know you as a modder and this is a quality mod.
So where would I load this in terms of load order I have PAW but not MILSPEC installed.
10/10 from me :D
Load order should not matter. This just monkeypatches gameplay_silent_kills without overwriting it.
I noticed it did not conflict with anything awesome!
I love your mods keep up the great work my friend! 10/10
I have a mod installed that adds dots on the radar and PDAs from NPC corpses. So, sometimes it happens that the dot is not added. Will this fix help resolve this issue? And yes, in the script of the “dots on the radar” mod, there is a call to the “npc_on_death_callback” function.
Indeed, that is exactly the sort of thing this is supposed to fix. My Milspec PDA addon handles body marks on the map in the same way, and has the same issue.
If I recall correcty, when getting a bounty mission from PDA Interactive mod, sometimes a stealth kill is not recognized as yours, then, you get a message like "I know it wasnt you who finished the job, here's only half the payment". This mod should fix that problem, right?
If it depends on the npc_on_death_callback, then yes, that is likely the same issue fixed by this addon.