Jump to content

Creation Kit: Quest to spawn NPC in interior cell


Recommended Posts

Hi everyone. I've been working on a player home mod which includes a husky living in it. I have the husky coded to do what I want. I got the idea that I'd like to spawn an NPC in the player home. The extent of this idea is that when the player enters the home, there's a random chance that an NPC will be in the home which the player can "have fun with". I've looked at quests aliases before and know there's an option for Create Reference In / At some object or cell. So this seems like a realistic approach to what I want to do. With that said, can anyone provided step by step instructions on what I need to do to make this happen? And of course, anyone contributing answers will be credited in my mod when I upload it to LL. Thanks in advance

Link to comment

If you want a random chance for the NPC to be there, you are probably better of with a script. An Alias with fill type "Create reference" will ALWAYS create that npc.

 

AN Idea for said script

 

scriptname myscript extends objectreference

;Attach this to a random Object inside your home, NPC will appear here.

 

Actor property MyNPC Auto

Actor ActorCache

int property probability Auto

 

;Spawn NPC when Cell is loaded

Event OnCellAttach()

   if utility.randomInt(0, 100) <= propability

        ActorCache=self.placeAtme(MyNPC)

   endIf

EndEvent

 

;delete NPC when Cell is unloaded to avoid safe Bloat

Event OnCellDetach()

   ActorCache.delete()

EndEvent

Link to comment
12 hours ago, Pamatronic said:

If you want a random chance for the NPC to be there, you are probably better of with a script. An Alias with fill type "Create reference" will ALWAYS create that npc.

 

AN Idea for said script

 

scriptname myscript extends objectreference

;Attach this to a random Object inside your home, NPC will appear here.

 

Actor property MyNPC Auto

Actor ActorCache

int property probability Auto

 

;Spawn NPC when Cell is loaded

Event OnCellAttach()

   if utility.randomInt(0, 100) <= propability

        ActorCache=self.placeAtme(MyNPC)

   endIf

EndEvent

 

;delete NPC when Cell is unloaded to avoid safe Bloat

Event OnCellDetach()

   ActorCache.delete()

EndEvent

 

Yes, that sounds like a much better idea. And Prison Alternative looks promising too. Thanks a lot my friend ?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use