Jump to content

NPC Spawner and Kill Trigger/Door Scripting Help Please


Recommended Posts

As the title says. I could really use some help creating two scripts for my Underworld City mod map. Being a noob to scripting. I have been banging my head against the wall for hours with little results.

Basically I am guessing what I need are two simple scripts for the Population NPC refresh cycle to be functional. First script applied would be applied to the LeveledCharacters/Actors placed throughout the city. It would spawn in an additional one every Shyrim Hour. Second script applied to a Door/Trigger that deletes an Actor when it interacts with the Door/Trigger. This would delete/despawn the NPCs when they finish their walk/route through the city. Thus keeping a constant flow of fresh randomized NPC wandering around the city. AND continuous random hostile encounters since I have a few baddies mixed into the level list. If possible, I am guessing these scripts would be simple to write but... I'm a noob.

I was able to get a simple on death cleanup script working. Without it the city quickly becomes... well... messy.

Event OnDeath(Actor akKiller)
    Utility.wait(60)
    self.disable()
    self.delete()
    Self.DeleteWhenAble()
EndEvent

Is the script above safe? I would imagine a very similar script could be written for the Door/Trigger. Any help would be greatly appreciated 🙂

Edited by LCountach
Link to comment
Share on other sites

The WIDeadBodyCleanupScript does something similar but also deals with a couple of additional details.  You may want to take a look at it, or even use it on your temp actors.

Since npcs tend to pick up weapons, you may want to add something to prevent them from destroying special weapons when they die.

 

Link to comment
Share on other sites

6 hours ago, xkkmEl said:

The WIDeadBodyCleanupScript does something similar but also deals with a couple of additional details.  You may want to take a look at it, or even use it on your temp actors.

Since npcs tend to pick up weapons, you may want to add something to prevent them from destroying special weapons when they die.

 

I wasn't even aware of that kind of potential mishap. Thankyou for the comment.

Link to comment
Share on other sites

  • 5 weeks later...
Posted (edited)

I am getting a little closer. I was able to create a Trigger Box and attach a simple script that kills any Actor on contact.

Event OnTriggerEnter(ObjectReference akActionRef)
 If akActionRef
  (akActionRef as Actor).kill()
 EndIf
EndEvent

However, I am really struggling with the re-spawn script. I am trying to adapt this script.

ActorBase Property ActorBaseProperty Auto

Event OnDeath(Actor akKiller)
    Debug.MessageBox("Killed NPC")
    Utility.wait(60)
    Self.PlaceActorAtMe(ActorBaseProperty)
    Utility.wait(10)
    self.disable()
    self.delete()
    Self.DeleteWhenAble()
EndEvent

EDIT: I am so happy I got it partially working! Now I need to somehow make another Property that can be set with the drop down menu in CK. Similar to how ActorBaseProperty was. So I can chose where the NPC re-spawns. Like on a marker or something? Instead of popping up where the NPC died with PlaceActorAtMe. As it is, it doesn't look good and also causes a Death Loop when the citizens reach the Trigger Box at the end of their rout. A script that simply spawns another one in every Skyrim hour at the original spawn point would also solve the problem and there would be more citizens roaming around. Then the re-spawn script could be trimmed back into a simple cleanup script again.

Any help would be appreciated.

Edited by LCountach
Link to comment
Share on other sites

  • Recently Browsing   0 members

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