Sparkey Spawner - Tables Question

I would really like to use the table encounters for sparkey spawner. But I keep running into issues with it and I’m not quite sure why. So I setup two tiny areas linked with a area transition so I can bounce back and forth to see what spawns from the table.

Here is my encounter table from sparkey_enc

  case 39: //WildTable1
  SetLocalString(oArea, sEncNum, "v2, always, 100, table, wildtable1");
  SetLocalString(oArea, "table_wildtable1_01", "10, creature, ratdire002, 2-5, random, 1, 1, 1");
  SetLocalString(oArea, "table_wildtable1_02", "30, creature, cougar001, 1-2, random, 1, 1, 1");
  SetLocalString(oArea, "table_wildtable1_03", "50, creature, dog002, 3-6, random, 1, 1, 1");
  SetLocalString(oArea, "table_wildtable1_04", "70, creature, wolf001, 2-4, random, 1, 1, 1");
  SetLocalString(oArea, "table_wildtable1_05", "90, creature, bearblck001, 2-3, random, 1, 1, 1");
  SetLocalString(oArea, "table_wildtable1_06", "100, creature, badger001, 2-3, random, 1, 1, 1");
  break;

All that ever spawns is the row of black bears with the 90…10 times in a row. Sometimes I get a error in-game chat window:
Script Sparkey_enter, OID: 800003b0, Tag: , ERROR: TOO MANY INSTRUCTIONS

Something is referenced wrong I think, but is there a way to know what the error code is pointing too?

And if anyone knows how the encounter table should work, please let me know. I think I may be looking at it wrong.

Things look ok - Here is a table from one of my modules for comparison. It is your OnEnter script that is causing problems, so if you don’t mind posting it, we can have a look-see. You do have a random location and then request an offset from it - so I don’t know if that is the issue or not. You can see below in my random ones that I don’t put an offset. Actually, wondering where you are running the setup script that you did post - you said it was in your “sparky_enc”. When is this run? I do my setups in a script called on module load.

    SetLocalString(oArea, "table_level1_01", "10, creature, nw_kobold002:level1, 2-5, random, , 1, 1");
    SetLocalString(oArea, "table_level1_02", "18, group, orc");
    SetLocalString(oArea, "table_level1_03", "26, group, skeleton");
    SetLocalString(oArea, "table_level1_04", "34, creature, nw_bat1:level1, 3-8, random, , 1, 1");//bats are nuetral, and will flee//edited blueprint
    SetLocalString(oArea, "table_level1_05", "42, creature, nw_ogre01:level1, 1, random, , 1, 1");
    SetLocalString(oArea, "table_level1_06", "50, creature, nw_bugbeara:level1, 1, random, , 1, 1");
    SetLocalString(oArea, "table_level1_07", "53, creature, nw_wolf:level1, 1, random, , 1, 1");
    SetLocalString(oArea, "table_level1_08", "60, creature, nw_gnoll001:level1, 1, random, , 1, 1");
    SetLocalString(oArea, "table_level1_09", "68, group, goblin");
    SetLocalString(oArea, "table_level1_10", "76, creature, nw_bandit003:level1, 1-2, random, , 1, 1");
    SetLocalString(oArea, "table_level1_11", "82, creature, x3_spitcobra001:room8, 1, wp:POST_room8, , 1, 1");
    SetLocalString(oArea, "table_level1_12", "86, creature, nw_rat001:level1, 1-8, random, , 1, 1");
    SetLocalString(oArea, "table_level1_13", "92, creature, nw_wererat:level1, 1, random, , 1, 1");
    SetLocalString(oArea, "table_level1_14", "100, creature, nw_zombie01:level1, 1, random, , 1, 1");

Pardon the delay.

Sparkey_Enter

/* Generic area onEnter script for streamlined addition of Sparky Spawner variables
   Created By: The Amethyst Dragon (www.amethyst-dragon.com/nwn)

   Can be used for the onEnter script for all areas of a module. If you already
   have your own area enter script, you can add just the includes and the
   "Sparky Spawner Section" of code.

   This causes the area to check to see if Sparky variables are set on the area.

   If not, it searches for the Encounter Variables placeable object in the area
   to find out which variables to add to the area, then runs the Sparky spawning
   code.

   If no such variables or placeable are present in the area, it skips any further
   Sparky code from running.
*/

#include "sparky_inc"
#include "sparky_enc"
#include "X0_I0_PARTYWIDE"

void main()
{
object oPC = GetEnteringObject();
object oArea = OBJECT_SELF;

if (GetIsPC(oPC) == TRUE) // Nothing happens if it wasn't a PC entering the area.
  {
//////////////////////////////////////////////// Sparky Spawner Section
if (GetLocalInt(oArea, "sparkyloaded") != 1)
  {
  // Find encounters-holding placeable
  object oEncVars = GetFirstObjectInArea(oArea);
  while (oEncVars != OBJECT_INVALID)
      {
      if (GetTag(oEncVars) == "sparky_variables") { break; }
      oEncVars = GetNextObjectInArea(oArea);
      }
  if (oEncVars != OBJECT_INVALID)
      {
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc01"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc02"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc03"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc04"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc05"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc06"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc07"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc08"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc09"));
      LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc10"));
      DestroyObject(oEncVars, 1.0);
      }
  SetLocalInt(oArea, "sparkyloaded", 1);
  }
int iDisabled = GetLocalInt(oArea, "iSparkyDisabled");
int iAlreadySpawned = GetLocalInt(oArea, "iSparkySpawned");

if (GetIsDM(oPC))
  {
  SendMessageToPC(oPC, "Sparky spawns are " + (iDisabled ? "OFF" : "ON"));
  return;
  }
if (iAlreadySpawned || iDisabled)
  {
  return;
  }
SpawnEncounters(oArea);
//////////////////////////////////////////////// End Sparky Section
  }
}

I didn’t think about the offset on the random spawns. But looking at the 30+ other spawns I have going with mostly random location, I have a offset on all of them - no reason other than not knowing I shouldn’t - or secretly making it more random.

So I mainly rely on the ‘_Encounter Variables’ placeable. which has a list of int variables on it that point to the case # from Sparkey_enc for what I want to have spawn in the area when a PC enters it. So if I understand it correctly the Sparkey_Enter looks for the _encounter variable placeable when a PC enters the area, and will trigger off the case #'s referenced on it’s variables which are in sparkey_enc.

It was the offset! Thank you @Mannast

1 Like