RATDOG/_module/nss/spawn_chk_custom.nss
Jaysyn904 909da8ff18 Added helms and dynamic goblins
Added  helms and dynamic goblins.  Added onEnter spawner scripts to all dungeon areas.  Fixed the Dishonest Patrol to be dynamic & more like PnP.  Full compile.

Co-Authored-By: Draygoth <65428430+Draygoth@users.noreply.github.com>
2022-11-30 00:45:38 -05:00

209 lines
5.5 KiB
Plaintext

//
// Spawn Check - Custom
//
#include "pqj_inc"
//void main (){}
int ParseFlagValue(string sName, string sFlag, int nDigits, int nDefault);
int ParseSubFlagValue(string sName, string sFlag, int nDigits, string sSubFlag, int nSubDigits, int nDefault);
object GetChildByTag(object oSpawn, string sChildTag);
object GetChildByNumber(object oSpawn, int nChildNum);
object GetSpawnByID(int nSpawnID);
void DeactivateSpawn(object oSpawn);
void DeactivateSpawnsByTag(string sSpawnTag);
void DeactivateAllSpawns();
void DespawnChildren(object oSpawn);
void DespawnChildrenByTag(object oSpawn, string sSpawnTag);
//
//
int SpawnCheckCustom(object oSpawn)
{
// Initialize Values
int nSpawnCheckCustom = GetLocalInt(oSpawn, "f_SpawnCheckCustom");
// Block Spawn by Default
int nProcessSpawn = FALSE;
//
// Only Make Modifications Between These Lines
// -------------------------------------------
// Check 00
if (nSpawnCheckCustom == 0)
{
// Example, Allow Spawn
nProcessSpawn = TRUE;
}
//
//
if (nSpawnCheckCustom == 1)
{
if (GetIsDawn() == TRUE || GetIsDay() == TRUE)
{
nProcessSpawn = TRUE;
SetLocalInt(oSpawn, "SpawnProcessed", FALSE);
}
else
{
int nSpawnProcessed = GetLocalInt(oSpawn, "SpawnProcessed");
if (nSpawnProcessed == FALSE)
{
nProcessSpawn = TRUE;
SetLocalInt(oSpawn, "SpawnProcessed", TRUE);
}
}
}
//
// Reproducing Predators
if (nSpawnCheckCustom == 10)
{
int nChildren = GetLocalInt(oSpawn, "ChildrenSpawned");
if (nChildren >= 10)
{
int nHappy = 0;
int nPredators;
int nNth = 1;
object oPredator = GetNearestObject(OBJECT_TYPE_CREATURE, oSpawn, nNth);
while (oPredator != OBJECT_INVALID)
{
if (GetLocalInt(oPredator, "Predator") == TRUE)
{
nPredators++;
if (GetLocalInt(oPredator, "CurrentHungerState") > 0)
{
nHappy++;
}
}
nNth++;
oPredator = GetNearestObject(OBJECT_TYPE_CREATURE, oSpawn, nNth);
}
SendMessageToAllDMs("There are " + IntToString(nPredators) + " Predators Alive.");
if (nHappy >= 2)
{
nProcessSpawn = TRUE;
}
}
else
{
nProcessSpawn = TRUE;
}
if (nProcessSpawn == TRUE)
{
SendMessageToAllDMs("A Predator is Born!");
}
}
//
//:: Spawns The Dishonest Patrol if the party's average level is over 10,
//:: they have been inside the dungeon & Sheriff Ostland is still alive.
if (nSpawnCheckCustom == 11)
{
// Initialize Variables
int nTotalPCs;
int nTotalPCLevel;
int nAveragePCLevel;
int bDungeon;
int bOstlandDead;
object oArea = GetArea(OBJECT_SELF);
// Cycle through PCs in Area
object oPC = GetFirstObjectInArea(oArea);
while (oPC != OBJECT_INVALID)
{
if (GetIsPC(oPC) == TRUE || GetIsPC(GetMaster(oPC)) == TRUE) //:: Summons & henchmen should count towards this.
{
//:: Check if the PC has entered the Dungeon yet
bDungeon++;
bDungeon = GetLocalInt(oPC, "bEnteredDungeon");
//:: Check to see if Ostland has been killed.
bOstlandDead++;
bOstlandDead = RetrieveQuestState("DishonestPatrol", oPC);
nTotalPCs++;
nTotalPCLevel = nTotalPCLevel + GetHitDice(oPC);
}
oPC = GetNextObjectInArea(oArea);
}
if (nTotalPCs > 0)
{
nAveragePCLevel = nTotalPCLevel / nTotalPCs;
}
else
{
nAveragePCLevel = 3;
}
if ((nAveragePCLevel > 10) && (bOstlandDead < 1) && (bDungeon > 0))
{
nProcessSpawn = TRUE;
}
}
//:: Spawns The Dishonest Patrol if the party's average level is over 10,
//:: they have been inside the dungeon & Sheriff Ostland is still alive.
//:: Checks for stage 1 or lower for the "Spider's Captive quest"
if (nSpawnCheckCustom == 50)
{
//:: Initialize major variables
object oArea = GetArea(OBJECT_SELF);
object oPC = GetFirstObjectInArea(oArea);
//:: Cycle through PCs in Area
while (oPC != OBJECT_INVALID)
{
//:: Check quest stage
if ( RetrieveQuestState("spiders", oPC) <= 1 )
{
nProcessSpawn = TRUE;
//SendMessageToPC(oPC, "Spawn Processed");
SetLocalInt(oSpawn, "SpawnProcessed", TRUE);
}
oPC = GetNextObjectInArea(oArea);
}
}
//:: Checks for stage 1 or lower for the "Spider's Captive quest"
//:: Checks for stage 2 or lower for the "Spider's Captive quest"
if (nSpawnCheckCustom == 51)
{
//:: Initialize major variables
object oArea = GetArea(OBJECT_SELF);
object oPC = GetFirstObjectInArea(oArea);
//:: Cycle through PCs in Area
while (oPC != OBJECT_INVALID)
{
//:: Check quest stage
if ( RetrieveQuestState("spiders", oPC) <= 2 )
{
nProcessSpawn = TRUE;
//SendMessageToPC(oPC, "Spawn Processed");
SetLocalInt(oSpawn, "SpawnProcessed", TRUE);
}
oPC = GetNextObjectInArea(oArea);
}
}
//:: Checks for stage 2 or lower for the "Spider's Captive quest"
// -------------------------------------------
// Only Make Modifications Between These Lines
//
// Return whether Spawn can Proceed
return nProcessSpawn;
}