Would you like to react to this message? Create an account in a few clicks or log in to continue.

Sparky Spawner: Tips, Tricks, & Troubles

Go down

Sparky Spawner: Tips, Tricks, & Troubles Empty Sparky Spawner: Tips, Tricks, & Troubles

Post by The Amethyst Dragon Mon Jan 23, 2012 3:05 am

I'm just starting this thread as a place for everyone to post about their use of the CEP's Sparky Spawner.  Feel free to add your own tips and tricks to getting it to work the way you want, or to post questions about problems you may have getting started with it.

Documentation:

First, here's a link to the documentation I use as a place to start.  It's a pdf file that basically just contains combined and reformatted information from the existing documentation I was able to find here on the CEP forum and elsewhere, with a few examples for some of the options.  It also has a few extra options (such as setting a time of "fullmoon") recorded inside specific to my PW, but those are denoted by being in italics.

This document does not include information about spawning from the MCS (Monster Containment System), since that's not something I use in my PW.  It does cover spawning from off-palette resources, though.

Oh, and this is current up to CEP 2.62.

Note: With CEP 2.62, I added my documentation and helper items and made the Sparky Spawner a stand-alone package. It can all be found in NWN/docs/cep/sparky_spawner.

Tip/Trick: Speeding Encounter Additions to an Area:

The Sparky Spawner relies on string variables set on either the encounter area or on a trigger.  I personally just use the area version, where the creatures are spawned when a PC first enters from another area.  Manually entering all of these variables in the area properties in the toolset would take a very long time, so I do not do that.  Instead, I use a combination of predefined encounters/encounter tables and simple variables set on a placeable in each area.

The basic functionality works like this:
PC enters an area ->
- - area onEnter script runs ->
- - - - onEnter script checks to see if Sparky variables are set on area
- - - - - - if no: find "encounters" placeable in area, set the correct Sparky variables on the area from the placeable, destroy the placeable
- - - - onEnter script checks to see if encounters are currently spawned/running
- - - - - - if no: run Sparky spawning script

I use the same area onEnter script for every area in my PW, and it references an include script called sparky_enc.  This file holds a single function, LoadEncounterVariables(), which reads the data from the "encounters" placeable and uses that to write the full Sparky variables to the area's variable list.  This file also contains all of the predefined encounter data.  When adding new encounters for the module, I add them to this script and compile only my area onEnter script, then I can freely add the new encounter to any area in my module.

Jump to code: generic sparky-ized area onEnter script
Jump to code: sparky_enc include script

Once I have an encounter predefined, I simply open the area I want it in and lay down a simple "encounters" placeable I keep in my game palette (called "_Encounter Variables" (tag: "sparky_variables"), found under * CEP 2.1 Custom Palette > Module Specific*).  This blueprint has the needed integer variable names predefined (enc01 to enc10), so that all I have to do is right-click on it, select "Variables", and change an integer value to the one (or more) that I have in the sparky_enc script.  I have my code set to allow up to 10 distinct encounters in the same area (or even repeats of the same encounter for larger populations), with me simply changing each variable on the placeable, starting with number enc01.

Example: If I want my first predefined encounter set on this placeable to be some random crabs for an underwater area, I'd simply change the enc01 variable from 0 (no encounter) to 1.  When the LoadEncounterVariables() function is used, it would read the enc01 variable, reference encounter number 1, and write all the correct variables to the area's variables so that the Sparky Spawner can use that information to spawn in the crabs.

Doing the right-click on a placeable is much, much faster than opening the area's Properties > Advanced > Variables.


Last edited by The Amethyst Dragon on Mon Dec 11, 2017 8:59 am; edited 4 times in total
The Amethyst Dragon
The Amethyst Dragon
Custom Content Wyrm: CEP 2.60+

Posts : 103
Join date : 2012-01-21
Age : 48
Location : lLoc = GetLocation(oDragon);

http://www.amethyst-dragon.com/nwn

Back to top Go down

Sparky Spawner: Tips, Tricks, & Troubles Empty Re: Sparky Spawner: Tips, Tricks, & Troubles

Post by The Amethyst Dragon Mon Jan 23, 2012 3:07 am

The Amethyst Dragon's example generic area onEnter script.

Code:

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

#include "sparky_inc"
#include "sparky_enc"

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
  }
}
The Amethyst Dragon
The Amethyst Dragon
Custom Content Wyrm: CEP 2.60+

Posts : 103
Join date : 2012-01-21
Age : 48
Location : lLoc = GetLocation(oDragon);

http://www.amethyst-dragon.com/nwn

Back to top Go down

Sparky Spawner: Tips, Tricks, & Troubles Empty Re: Sparky Spawner: Tips, Tricks, & Troubles

Post by The Amethyst Dragon Mon Jan 23, 2012 3:08 am

sparky_enc include script with two example encounters.

Code:

// Sparky Predefined encounters include
// Created By: The Amethyst Dragon

// Add encounter variables to oArea based on the number entered as nTable.
// 0 = blank
void LoadEncounterVariables(object oArea, int nTable);
void LoadEncounterVariables(object oArea, int nTable)
{
if (nTable < 1) { return; }
if (GetIsObjectValid(oArea) != TRUE) { return; }

// Check for existing encounter variables (maximum of 10 encounters on an area)
int nCheckNum = GetLocalInt(oArea, "NumEnc");
if (nCheckNum < 1) nCheckNum = 0;
if (nCheckNum >= 10) return;
nCheckNum = nCheckNum + 1;
string sEncNum = "encounter_";
if (nCheckNum < 10) sEncNum = "encounter_0";
sEncNum = sEncNum + IntToString(nCheckNum); // encounter numbers need to be incremented for the Spawner to read them correctly
SetLocalInt(oArea, "NumEnc", nCheckNum);
switch (nTable)
  {
  case 1: // Underwater: Crabs
  SetLocalString(oArea, sEncNum, "v2, always, 100, table, seacrabs");
  SetLocalString(oArea, "table_seacrabs_01", "45, creature, crabr001, 2-10, random, , 1, 1");
  SetLocalString(oArea, "table_seacrabs_02", "90, creature, zep_crab003, 2-10, random, , 1, 1");
  SetLocalString(oArea, "table_seacrabs_03", "95, creature, zep_crab005, 1-3, random, , 1, 1");
  SetLocalString(oArea, "table_seacrabs_04", "100, creature, zep_crab004, 1-3, random, , 1, 1");
  break;
  case 2: // Underwater: Sea Turtles
  SetLocalString(oArea, sEncNum, "v2, always, 100, creature, tortoise002, 2-8, random, , 1, 1");
  break;
  }
}
The Amethyst Dragon
The Amethyst Dragon
Custom Content Wyrm: CEP 2.60+

Posts : 103
Join date : 2012-01-21
Age : 48
Location : lLoc = GetLocation(oDragon);

http://www.amethyst-dragon.com/nwn

Back to top Go down

Sparky Spawner: Tips, Tricks, & Troubles Empty Re: Sparky Spawner: Tips, Tricks, & Troubles

Post by The Amethyst Dragon Mon Jan 23, 2012 3:14 am

Copied from older forum:

yyrkoon wrote:We are looking at implementing Sparkys on the pw I help out and I am wondering if you have any thoughts on how it compares to Knat's Pwfse system, which we currently use.

This looks awesome and I think a hybred approach is where we will end up so I was wonder if you have ever seen someone using both systems in the same mod. I think all new areas will be using sparkys moving forward, as we are close to our mod limit, so using the Copy option looks promising.

We are also very interested in the MCS. This is a seperate system right or does Sparkys require the MCS to function? I understood the pdf as saying i can create my own area of single and 2 square rooms, populate them with my custom mobs and use that to drive Sparkies.

Anyway, any feedback and thoughts to help us with this effort is much appreciated. Keep up the good work.

solaris655 wrote:I am starting to incorperate Sparkys in the PWS I play at. I have an area that I have working, but it has a strange bug. The first time I run through it all the mobs spawn correctly. After waiting and runing back through, only one of the two types of mobs spawn. I have tried it a couple of times and it is not always the same mob that spawns, but if I try a third time the same result as the second time happens. I hope I have explained this well enough for someone to have a suggestion on how to fix this.

yyrkoon:

I am not personally familair with Knat's system, so I don't know how they would behave together. Most likely you could use a combination of both systems at the same time. It could lead to more creatures spawned in the same area if both systems are working on populating the same area, so it would be up to you to keep numbers in check for your players.

As far as I know, Sparky and MCS are different systems. You don't have to use MCS to use Sparky. Sparky will read some of the code from the MCS and can do spawns from creatures stored in it...I just don't have personal experience with that since I don't use MCS in my PW. I do use the "copy critter from a holding area" method a lot, since my module is relatively close to the 16k limit (currently about 12,700 resources)...if I don't need a creature added to the palette, I don't see a reason to put it there, especially if I want to just customize something like it's equipment.

solaris655:

I'd have to see your scripts to figure out exactly what's going on.
The Amethyst Dragon
The Amethyst Dragon
Custom Content Wyrm: CEP 2.60+

Posts : 103
Join date : 2012-01-21
Age : 48
Location : lLoc = GetLocation(oDragon);

http://www.amethyst-dragon.com/nwn

Back to top Go down

Sparky Spawner: Tips, Tricks, & Troubles Empty Re: Sparky Spawner: Tips, Tricks, & Troubles

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum