Skip to content

NPC_Respawn doesn't affect NPC_IsDead (and it's critical) #1183

Closed

Description

@NexiusTailer

Describe the bug
NPC_Respawn doesn't call OnNPCSpawn and thus also doesn't set NPC_IsDead to false, so, many cases in NPC scripts become broken because of this fact (and also comparing to FCNPC, where same was working good on it). A truly interesting code piece was initially provided by the other guy from ru community who actively uses NPCs, and after adding some debug prints I'm sharing it below.

To Reproduce
An eloquent example of the consequences for this behavior difference is this: https://pastebin.com/UnyATnLr

You need to connect, spawn and either kill the NPC which is near you manually, or type "/killhim" command. The NPC will die, a log line "NPC was killed..." will appear and then, after 7 seconds, he'll start recursively spawned every 200 ms. That's because the main check in Dead_Spawner still passes. No OnNPCSpawn callback log will be seen as well, only constant flood of "NPC is being respawned!".

Expected behavior
Respawn just once after 7 seconds after you kill the NPC, like it happens if you use 'NPC_Spawn': https://pastebin.com/bZt3Fd5z

So in this case chat log lines are those: "NPC was killed..." -> "NPC is being respawned!" -> "NPC has been spawned"

Screenshots and/or logs
How it is now (using NPC_Respawn)
How it should be (using NPC_Spawn)

Release version
Latest release build 1.5.8.3079

Activity

  1. added
    bug
    on Jan 8, 2026
  2. stley commented on Jan 9, 2026

    @stley
    Contributor

    Checking NPC events, NPC_Respawn has also its own callback, OnNPCRespawn...
    It would be possible to redirect that call to the OnNPCSpawn callback, while also pushing some bool value to tell if its being spawned for the first time or is it being respawned, but that would be kind of a drastic change to the current scheme.
    However, NPC_Respawn did lack the death state variable resetting, so that caused it to keep respawning, as the script thinks the NPC is still dead. That should be taken care of in #1184.

  3. NexiusTailer commented on Jan 9, 2026

    @NexiusTailer
    ContributorAuthor

    Sure, I completely forgot about OnNPCRespawn callback, gonna tell that guy who has initial issue to ensure he uses the right one for non-initial spawns. Also thanks for PR fixing actual issue with resetting NPC_IsDead, that seems to be the only bug it has now.

  4. changed the title [-]NPC_Respawn doesn't call OnNPCSpawn (and it's critical)[/-] [+]NPC_Respawn doesn't call NPC_IsDead (and it's critical)[/+] on Jan 9, 2026
  5. changed the title [-]NPC_Respawn doesn't call NPC_IsDead (and it's critical)[/-] [+]NPC_Respawn doesn't affect NPC_IsDead (and it's critical)[/+] on Jan 9, 2026
  6. NexiusTailer commented on Jan 17, 2026

    @NexiusTailer
    ContributorAuthor

    Solved in #1184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions