RATDOG/_module/nss/sparky_enter.nss
Jaysyn904 e870de8a20 File Reorganization
File Reorganization.  Initialized ratdog_creature hak & added Project Q overrides & other models.  Continued dynamic swapover & upgrade.
2021-10-02 03:15:34 -04:00

77 lines
2.5 KiB
Plaintext

/* 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"
#include "spawn_functions"
void main()
{
object oPC = GetEnteringObject();
object oArea = OBJECT_SELF;
ExecuteScript("spawn_smpl_onen2");
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
}
}