Yes it is possible. I did a random spawner on the vault which could be modified to do what you want.
http://nwvault.ign.c....Detail&id=3318
Although this spawner has a lot of things you don't need such as spawning randome creatures from a list.
I made a variation of this spawner which might more likely suit your needs. What it does is spawn to a random newly created waypoint, so it's always random, at a certain distance from the PC. I use the method of creating a new waypoint while destroying the old one to which the creatures last spawned and usually I spawn 3 groups 2 of them hostile to the 3rd. So 3 groups of 3-4 creatures each which could be used to reach your 12.
I use a for loop to spawn more than one creature.
Here is one that does not use a for loop and just spawns creatures to that waypoint with the tag: Spawn. The resref of my (Waypoint) Spawn is waypoint006 so I just create another one of them within the script after the spawn occurs.
#include "NW_I0_GENERIC"
void main()
{
object oPC = GetEnteringObject();
object oArea = GetArea (oPC);
object oWaypoint = GetFirstObjectInArea(oArea);
float fDistance = GetDistanceBetweenLocations(GetLocation(oWaypoint), GetLocation(oPC));
location lWP1 = GetRandomLocation(oArea,oPC,fDistance/2);
if (!GetIsPC(oPC))
return;
if(GetLocalInt(oArea,"Done") == 1)
return;
//so it does not spawn continously
while (GetIsObjectValid(oWaypoint) && GetLocalInt(oArea, "Ran") < 5)
{
if (GetTag(oWaypoint)!="Spawn")
oWaypoint = GetNextObjectInArea(oArea);
else if (GetTag(oWaypoint)=="Spawn")
{
CreateObject(OBJECT_TYPE_CREATURE,"npcresref",GetLocation(oWaypoint));
CreateObject(OBJECT_TYPE_CREATURE,"npcresref",GetLocation(oWaypoint));
CreateObject(OBJECT_TYPE_CREATURE,"npcresref",GetLocation(oWaypoint));
CreateObject(OBJECT_TYPE_CREATURE,"npcreref,GetLocation(oWaypoint));
//should create 12 npc's in groups of 3 at a time.
DestroyObject(oWaypoint, 2.0);
SetLocalInt(oArea,"Ran", GetLocalInt(oArea,"Ran")+1);
oWaypoint = GetNextObjectInArea(oArea);
}
object oWaypoint1 = CreateObject(OBJECT_TYPE_WAYPOINT, "waypoint006", lWP1);
//create a new random waypoint resref of the Spawn waypoint
}
SetLocalInt(oArea,"Done",1);
DelayCommand (200.0, SetLocalInt(oArea, "Done", 0));
DelayCommand (202.0, SetLocalInt(oArea, "Ran", 0));
//resets the Ran and Done locals so the spawning mechanism will work again.
}
Oh nd you have to set at least one Waypoint with the Tag Spawn down in the area.
This may not be the best or cleanest way to do this but it works so there you have it.
You cold also put down a bunch of waypoints with the tag Spawn and get rid of the creation of a new Spawn waypoint. So each time the script is triggered the creatures would spawn to a new waypoint while destroying the old one.
Modifié par ffbj, 15 décembre 2010 - 02:35 .