Jump to content

[LE] Spawning NPCs randomly at night: is this the best way?


opusGlass

Recommended Posts

I'm trying to spawn enemy NPCs at random intervals of time, say maybe once every few game days, but only at night. I have an idea of how I will achieve this but I'm just not sure if it's the best way:

 

I will create a quest that starts enabled, and attach it to the player via an alias. I'll attach a script to that, which uses RegisterForSingleUpdate to run a basic check function every several hours. In that function, I will check the time of day. If it's night time, I will run a random check to decide whether or not to spawn. If it succeeds, I will spawn an NPC at some distance from the player. I will put an alias on that NPC with a second script attached. I will call RegisterForSingleUpdate on this NPC to schedule a de-spawn for him. When the NPC's update comes in, I will check if he is far away from the player -- if so, I will delete him.

 

So, what do you guys think? Will this work? Is there a better/easier way?

Link to comment
Share on other sites

I think you might want to use some packages for this. Have a look at the random vampire attack quests. There is one that specifically has them attack the player. Even the Dragon Attack player quest may be useful.

 

Okay, thanks. I looked into it and it seems those quests are hooked through the Script Event story manager node. I've never worked with Story Manager before so I've got a lot to learn. One concern I have -- do you know if two mods that add a quest to the same story manager node will conflict with each other?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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