Jump to content

Randomly spawning hostile NPCs near player


Recommended Posts

Hey guys!

 

I've been working on a mod for the past few weeks that will involve the player getting attacked at random by a hostile NPC. I've done everything else I know how to do (or managed to figure out somehow), but I just can't figure out how to do the actual core feature I just mentioned. It's a relatively simple concept on paper, just spawn a aggressive NPC somewhere near the player once in a while. That's it. But I'm struggling to figure out how to do it. I tried looking at mods that do similar things to see if I can kinda reverse-engineer this, but no luck with that since my understanding of CK is pretty limited. So if there's anyone willing to help me with this, I would greatly appreciate it.

Link to comment
Share on other sites

To create an actor reference in the game near the Player reliably, you need to make a Papyrus script. It won't be easy because you have to write a "PlaceActorAtPlayer" function yourself (as there's no such native function) that scans the area near the player (narrow / large, distance check), moves the NPC (to the nearest navmeshed ground), etc.

Link to comment
Share on other sites

  On 11/30/2022 at 6:11 PM, LarannKiar said:

To create an actor reference in the game near the Player reliably, you need to make a Papyrus script. It won't be easy because you have to write a "PlaceActorAtPlayer" function yourself (as there's no such native function) that scans the area near the player (narrow / large, distance check), moves the NPC (to the nearest navmeshed ground), etc.

Yeah, I thought I would have to write my own script. I've come to understand Papyrus a little over the past few weeks, so I'll hopefully be able to put something together. Thank you for the advice! At least now I know where to start.

Link to comment
Share on other sites

Can use quest alias(es) for spawning and driving actors, fairly simple and efficient method. Though still may need a script to (re)start the quest itself at right moment, unless events manager is involved.

Edited by hereami
Link to comment
Share on other sites

Yeah. PlayerAlias script on a Quest. Then start a timer on real time, or game time, and have a leveled spawn placed at, or anywhere close to your position. Conditionize if you must, like f.e. only on a cell change only when you move, only outside of settlements, or interiors etc.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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