Jump to content

Help with NPC spawner script


Recommended Posts

So, i've been trying to create a arena style mod in which you basically pull a chain on the wall to spawn a enemy NPC at a specific location in the center of said arena.

I've already placed the chain activator, an invisible marker to serve as the spawn point, and set said invisible marker as a parent to the chain on the render window, i've also made the script that would spawn a mod added NPC and linked it to the invisible marker, however back in game nothing happens when i pull the chain.

Heres the script:

scriptName aaaArenaSpawn extends ObjectReference
function OnActivate(ObjectReference akActionRef)
ObjectReference aaaSpawnTheMobs = self.PlaceAtMe(Game.GetFormEx(0x200EB9D5), 1, false, false)
; I've set the default invisible marker's name over on the render window reference to aaaSpawnTheMobs
endFunction

Could use some help regarding this, is my script defective somehow or is it the creation kit inplementation?
Link to comment
Share on other sites

Create a property on your script for the marker where you want the NPC to spawn. Then adjust the script.

 

You should end up with something like:

 

 

ScriptName myScript Extends ObjectReference

ObjectReference Property myMarker Auto

Event OnActivate(ObjectReference akActionRef)
  If akActionRef == Game.GetPlayer()
    Form myNPC == Game.GetFormFromFile(0x000EB9D5,"ModName")
    myMarker.PlaceAtMe(myNPC,1,false,false)
  EndIf
EndEvent

 

Personally, I would avoid using any function that relies on a form ID that includes the load order position. If the load order changes, the script may not be pointing to the correct thing. I would recommend using GetFormFromFile instead. The inclusion of the plugin name tells the game which plugin to get the form from and continues to work even if the load order changes between different mod setups.

 

PlaceActorAtMe may also be something to look into using.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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