ChrisHPZ Posted May 22, 2021 Posted May 22, 2021 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
Pamatronic Posted May 22, 2021 Posted May 22, 2021 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
ChrisHPZ Posted May 22, 2021 Author Posted May 22, 2021 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 ?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.