Author Sticky: Post Working Scripts Here
Arckon Posted: Friday, 05 July 07:58AM
OK, another derivation on the same D&D encounter system thread noted above.

Based on Mollarom's script, I adopted my derivation to the use of only the nearest spawn point, and it certainly works much more smoothly, I guess since it is only doing a spawn for each player, instead of for each spawn point in the area.

Anyway, to use this instaed of my prior scheme, just remove the area OnEnter script, and use the following code template for the area encounter include file.

Code:
////////////////////

//: This is the include file for generating the encounters for the specific area named.

//: It is capable of creating multiple creature types in each spawn. This script 

//:  allows for up to any number of spawn points. 

//:  

//: Based on work by LuckDragon and others, modified by RG Cheek 7-4-02

void Area_1_test_Chk (object oPlayer) {

  int nNumMons, i;

  string creaturetype;

  int NUM_SPAWNPOINTS = 6;

  int SP_cntr;

    object oTarget = GetNearestObjectByTag ("SP_Area_1_Test", oPlayer, 1);

    location lTargLoc =  GetLocation(oTarget);

      int nIsEncounter = d4(1);

      if (nIsEncounter == 1) {

        int nWhichMon = d2(1);  // max value should correspond to the number 

                                //   of case statements

        switch (nWhichMon) {

          case 1:

            nNumMons = d4(2);

            creaturetype = "nw_mepsalt";

            for (i=0;i<nNumMons;i++) {

              object oCreated = CreateObject( OBJECT_TYPE_CREATURE, creaturetype, lTargLoc, FALSE);

              SetLocalObject(oCreated, "TargetPC", oPlayer);

            }

            break;

          case 2:

            nNumMons = d4(1);

            creaturetype = "nw_bearblck";

            for (i=0;i<nNumMons;i++) {

              object oCreated = CreateObject( OBJECT_TYPE_CREATURE, creaturetype, lTargLoc, FALSE);

              SetLocalObject(oCreated, "TargetPC", oPlayer);

            }

            nNumMons = d2(1);

            creaturetype = "nw_boar";

            for (i=0;i<nNumMons;i++) {

              object oCreated = CreateObject( OBJECT_TYPE_CREATURE, creaturetype, lTargLoc, FALSE);

              SetLocalObject(oCreated, "TargetPC", oPlayer);

            }

            break;

        }

      }

}