Jump to content

Spawning NPCs (unlimited amount) when a button is pressed - Creation K


hughbe

Recommended Posts

 

First, you have to put an activator (let's say a pullchain).

 

Then, you have to put an xmarker (type xmarker in the filter box and select *all) in the cage you want.

 

Then double click on the activator reference, go to scripts, add, new script.

 

Give it a name (let's say SpawnChainSCR) and leave ObjectReference as the type.

 

Right click on the script and click "edit source".

 

Now paste this

Scriptname SpawnChainSCR Extends ObjectReference

import game
import debug

ActorBase property myNPC auto

ObjectReference property SpawnPlace auto

Event OnActivate(ObjectReference akActionRef)
    SpawnPlace.PlaceActorAtMe(myNPC, x)
EndEvent

Where x is the difficulty of the encounter (0-4).

 

If the NPC doesn't attack you, replace the placeatme stuff with

SpawnPlace.PlaceActorAtMe(myNPC, x).StartCombat(Game.GetPlayer())

Save the script and exit.

 

Then double click on the script and edit the properties values with the stuff you want (so myNPC with any actor you want and SpawnPlace with the xmarker).

 

This script will spawn a NPC everytime you activate the pullchain. You can also spawn different enemies depending on how many times you activate it, but it's a bit more tricky. Let me know

 

Worked like clockwork.. gangbusters! thanks and kudos for putting this quick and easy script to just get it done. That was the last thing I wanted in my instance.. finally i can take a break.

 

BTW if this doesnt compile for you (as it didnt for me), I had to put a real npc name and give the x a number, I used 4. That compiled fine.. then you adjust the variables as he says.

Edited by Hannibalektr
Link to comment
Share on other sites

  • 3 months later...

First, you have to put an activator (let's say a pullchain).

 

Then, you have to put an xmarker (type xmarker in the filter box and select *all) in the cage you want.

 

Then double click on the activator reference, go to scripts, add, new script.

 

Give it a name (let's say SpawnChainSCR) and leave ObjectReference as the type.

 

Right click on the script and click "edit source".

 

Now paste this

Scriptname SpawnChainSCR Extends ObjectReference

import game
import debug

ActorBase property myNPC auto

ObjectReference property SpawnPlace auto

Event OnActivate(ObjectReference akActionRef)
    SpawnPlace.PlaceActorAtMe(myNPC, x)
EndEvent
Where x is the difficulty of the encounter (0-4).

 

If the NPC doesn't attack you, replace the placeatme stuff with

SpawnPlace.PlaceActorAtMe(myNPC, x).StartCombat(Game.GetPlayer())
Save the script and exit.

 

Then double click on the script and edit the properties values with the stuff you want (so myNPC with any actor you want and SpawnPlace with the xmarker).

 

This script will spawn a NPC everytime you activate the pullchain. You can also spawn different enemies depending on how many times you activate it, but it's a bit more tricky. Let me know

 

this one don´t work for me. i can compile the skript without errors but when i start giving it Propertys it do not compile.

CK drops the edited propertys outside the Script and returns me a compiling error. if i fix it manualy by putting it inside the event the compiler works flawless but the script do not work in the game :/

Link to comment
Share on other sites

  • 2 years later...

By the powers of necromancy I bring back this thread!

 

I appreciate this old thread. Worked really well for me too several years later. I wonder though, does anybody know what I might add to this script to get more than 1 enemy spawning in at 1 time? Flip the lever/button and 3 giants appear and so on. Thanks.

Edited by Ahondara
Link to comment
Share on other sites

  • 3 months later...

First, you have to put an activator (let's say a pullchain).

 

Then, you have to put an xmarker (type xmarker in the filter box and select *all) in the cage you want.

 

Then double click on the activator reference, go to scripts, add, new script.

 

Give it a name (let's say SpawnChainSCR) and leave ObjectReference as the type.

 

Right click on the script and click "edit source".

 

Now paste this

Scriptname SpawnChainSCR Extends ObjectReference

import game
import debug

ActorBase property myNPC auto

ObjectReference property SpawnPlace auto

Event OnActivate(ObjectReference akActionRef)
    SpawnPlace.PlaceActorAtMe(myNPC, x)
EndEvent
Where x is the difficulty of the encounter (0-4).

 

If the NPC doesn't attack you, replace the placeatme stuff with

SpawnPlace.PlaceActorAtMe(myNPC, x).StartCombat(Game.GetPlayer())
Save the script and exit.

 

Then double click on the script and edit the properties values with the stuff you want (so myNPC with any actor you want and SpawnPlace with the xmarker).

 

This script will spawn a NPC everytime you activate the pullchain. You can also spawn different enemies depending on how many times you activate it, but it's a bit more tricky. Let me know

 

Thanks gasti89, This is very clear and worked perfectly. I'm respawning goats for my werewolf faster than you can say Colonel Sanders.

Link to comment
Share on other sites

  • 2 months later...

Did you set the property properly for SpawnPlace?

 

Assuming you did, the issue is likely that you did not navmesh the area if it is a new cell you are making.

 

Yeah, you're right Korodic, the navmesh. I figured that would be the mistake and I've solved it (I had to look for a video tutorial in goggle) but I got it. Thanks for your quick response. :smile:

Edited by joshep1986
Link to comment
Share on other sites

  • Recently Browsing   0 members

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