I just created this for a forum member and though it might be something others might like.
// encounter_oe
/*
A quick simple spawn system I just now created for a forum menber that gives you the
option to have random spawn locations. To implement, place in your generic triggers
on enter event and give your generic trigger a uniquie tag. Give your spawn waypoints
the same tag but append a consecutive numeric value to the tag
Example, generic trigger tag...
MOBSPAWN
Associated waypoint tags...
MOBSPAWN1
MOBSPAWN2
etc....
Set a local int named "NUMOFWPS' on WP#1 with the number of waypoints
to be chosen from for the spawn location. This system will randomly
pick between WP#1 and the qty to set as the spawn location.
Set a local int named "QTY' on on WP#1 with the total number of creatures
to be spawned.
Set a local string named "RESREF" on WP#1 with the base resref of the
creature to be spawned. Give all the creatures you want to spawn the
same resref and append a consecutive numeric value
Example stored "RESREF" value
monster
Example Creature resrefs...
monster1
monster2
etc...
Set a local int named "CREATURETYPES' on WP#1 with the numer of diferent creatures to
be spawned. Using the resref examples above that list only 2 resrefs, monster1
and monster2, set CREATURETYPES = 2 and you will get equal amounts of both in
the spawn
Set a local int named "PERCENT_CHANCE' on WP#1 for the chance of a spawn occurring.
Set a local float named "DELAY' on WP#1 for the time before the trigger is active again.
This is so that you can't activate the trigger again untill the passing in seconds
of whatever delay you set. There is a default value of 20.0 seconds
I think I covered it all. Have fun.... I like it so much I think I'll post it to
the forum. Modify to suit your needs
*/
// Set "QTY' with thE total number of creatures to be spawned
// Set "CREATURETYPES' with the numer of diferent creature to be spawned
// Set "RESREF' with the base resref
// Set "NUMOFWPS' with the number of waypoints to be chosen from for the spawn location
// Set "PERCENT_CHANCE' for the chance of a spawn occurring
void spawncreatures(int iQty, int iCreatureTypes, string sBaseTag, string sResRef, int nNbrOfWypnts, int iChance = 100);
void spawncreatures(int iQty, int iCreatureTypes, string sBaseTag, string sResRef, int nNbrOfWypnts, int iChance = 100)
{
if(d100()<=iChance)
{
string sWPTag = sBaseTag+IntToString(Random(nNbrOfWypnts)+1);
object oSpawnWP = GetWaypointByTag(sWPTag);
location lSpawnPoint = GetLocation(oSpawnWP);
int i;
for(i=0;i<iQty;i++)
{
object oSpawn = CreateObject(OBJECT_TYPE_CREATURE, sResRef+IntToString((i%iCreatureTypes)+1), lSpawnPoint);
}
}
}
void ResetEncounter(float fDelay, object oRepository)
{
DelayCommand(fDelay, SetLocalInt(oRepository, "ACTIVATED", FALSE));
}
void main()
{
object oPC = GetEnteringObject();
if(GetIsPC(oPC))
{
string sBaseTag = GetTag(OBJECT_SELF);
object oRepository = GetObjectByTag(sBaseTag+"1");
int bDoNotProcess = GetLocalInt(oRepository, "ACTIVATED");
if(bDoNotProcess==FALSE)
{
int iQty = GetLocalInt(oRepository, "QTY");
int iCTypes = GetLocalInt(oRepository, "CREATURETYPES");
string sResRef = GetLocalString(oRepository, "RESREF");
int iWPs = GetLocalInt(oRepository, "NUMOFWPS");
int iPctChance = GetLocalInt(oRepository, "PERCENT_CHANCE");
spawncreatures(iQty, iCTypes, sBaseTag, sResRef, iWPs, iPctChance);
SetLocalInt(oRepository, "ACTIVATED", TRUE);
float fDelay = GetLocalFloat(oRepository, "DELAY");
if(fDelay == 0.0)
fDelay = 20.0;
AssignCommand(GetModule(), ResetEncounter(fDelay, oRepository));
}
}
}
Modifié par KMdS!, 01 avril 2016 - 04:49 .