Jump to content

What is the Papyrus to spawn enemies from a trigger?


Recommended Posts

I am working on a horror themed mod with scary dungeons and I would like to be able to have an npc/creature spawn nearby when activating a lever, item or the activation bounding box.

 

I am already familiar with activators and traps and I thought a similar process would work to spawn enemies a bit like how the draugr and dragon priest furniture markers work. Maybe there is way to keep them idle outside the dungeon area or use a dummy cell, then place a marker for them to activate when triggered. I haven't found anything yet so I assume there might be a script to get this working.

 

Any help would be great really.

Edited by Ironman5000
Link to comment
Share on other sites

You could use something along the lines of below, but of course, switch out the quest property, to a custom property you made, if you didn't want to use that particular event type.

 

scriptName SpawnHorrorsOnActivate extends objectReference


Scene Property AmbushScene auto
Quest Property C01 auto
ReferenceAlias Property Observer auto
Cell Property MyCell auto

ACTORBASE PROPERTY spawnedEnemies AUTO
INT PROPERTY numToPlace AUTO

OBJECTREFERENCE enemy1
OBJECTREFERENCE enemy2
OBJECTREFERENCE enemy3

bool property doOnce = true auto
{if true do this only once
default == true}

bool property placeAll = true auto
{default == true
if true place all things that have been set
if false place the first thing that we find set}

objectReference property placedObjectRef auto

auto State Ready
Event OnActivate(ObjectReference akActivator)
	(C01 as C01QuestScript).AmbushLeverPulled = true
	if (!(C01 as C01QuestScript).ObserverCloseBy)
		Observer.GetReference().MoveTo((C01 as C01QuestScript).ObserverCompensationPoint)
	if (Observer.GetReference().GetParentCell() != MyCell)
		return
	endif
	endif

	AmbushScene.Start()
	GoToState("Done")
EndEvent
EndState


State Done
EndState

state DoNothing
event onActivate(objectReference triggerRef)
endEvent
endState

 

To be honest, I think it would be much more convenient, and easier to just have an activator script attached to gates. You could have gates around the lever location, and have enemies locked in these gates, then on activation, the gates open, releasing the 'horrors'.

You're better off using the movto() function rather than the placeatme one. GL with your mod.

 

Edit: If it's a trap-type event you're trying to create, it's more or less the same thing, just have a look at the trap scripts in the CK, but you'll have to adapt them of course.

Edited by kieranh7
Link to comment
Share on other sites

I'll give this a try, I would do the gate idea but the only way for it to work as a trap would be to have the enemy running at a locked door which I don't like. It works so much better when you don't know what is coming or where from.

 

I was thinking of adding a small box 'room' in the same cell, yet far away enough for the enemies to be undetectable. From here adding a door from the box to the spawn point, leaving the exit door out of the area being inaccessible so it works as a one-way teleporter, but then I would need to force the enemies to use the door when I use the activator. Kinda like the doom games really, like when you have the map cheat on to see the little triangles moving from a seperate area to yours.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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