Jump to content

Respawn killed NPC after death (original location)


Paladin555

Recommended Posts

Hi everyone,

 

I'm trying to write a script for some npc battles. I want a character who's killed to respawn after 5 seconds and spawn back to it's original location. Here's what I have so far. I can't save the script because it keeps saying: "script RespawnNPC line 6, RespawnCount not found"

 

 

Scriptname RespawnNPC
int RespawnCount
Begin OnDeath
; Increase the respawn count
RespawnCount += 1
; Respawn the NPC after a delay
delayedStart 1.0, "Respawn"
End
Function Respawn()
; Spawn a new copy of the NPC at their original location
Actor newActor = Actor.PlaceAtMe(GetBaseObject(), GetPosition(), GetRotation())
; Decrement the respawn count
RespawnCount -= 1
; Disable the old NPC
Disable()
; Destroy the old NPC after a delay
delayedStart 5.0, "DestroyOldActor"
End
Function DestroyOldActor()
; Destroy the old actor
Game.Delete(GetSelf())
End
Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...