RATDOG/_module/nss/spawn_chk_pcs.nss
Jaysyn904 2e30722043 Level One rework
Revamped Level One: North & Level One: Central to be as close to PnP as possible.  Added Level One: Latrene 3 area.  Added efreeti appearance from CEP3.  Revamped efreeti bottle to be like PnP (no wishes, yet)
2023-09-23 22:02:32 -04:00

209 lines
6.1 KiB
Plaintext

//
// Spawn Check - PCs
//
//:: void main (){}
#include "pqj_inc"
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 SpawnCheckPCs(object oSpawn)
{
// Initialize Values
object oPC;
object oArea = GetArea(oSpawn);
string sSpawnName = GetLocalString(oSpawn, "f_Flags");
location lSpawn = GetLocation(oSpawn);
int nCheckPCs = GetLocalInt(oSpawn, "f_SpawnCheckPCs");
float fCheckPCsRadius = GetLocalFloat(oSpawn, "f_CheckPCsRadius");
// Block Spawn by Default
int nProcessSpawn = FALSE;
// Cycle through PCs
if (fCheckPCsRadius > -1.0)
{
oPC = GetFirstObjectInShape(SHAPE_SPHERE, fCheckPCsRadius, lSpawn, FALSE, OBJECT_TYPE_CREATURE);
}
else
{
oPC = GetFirstObjectInArea(oArea);
}
while (oPC != OBJECT_INVALID)
{
if (GetIsPC(oPC) == TRUE)
{
//
// Only Make Modifications Between These Lines
// -------------------------------------------
//:: Example Check 00
if (nCheckPCs == 0)
{
// Example, Allow Spawn
nProcessSpawn = TRUE;
}
//:: Example Check 00
//:: Spawn with a Skill Check
if (nCheckPCs == 1)
{
// Get Current Number of Children
int nSpawnCount = GetLocalInt(oSpawn, "SpawnCount");
if (nSpawnCount == 0)
{
// DC of Hidden Placeable
int nItemDC = 20;
// Player's Skill
int nSkill = GetSkillRank(SKILL_SEARCH, oPC);
// Do Skill Check
int nDCCheck = d20() + nSkill;
if (nDCCheck >= nItemDC)
{
// Placeable Spotted!
string sSpotted = "You notice a thingamathingy!";
FloatingTextStringOnCreature(sSpotted, oPC, TRUE);
//Spawn it!
nProcessSpawn = TRUE;
}
}
}
//:: Spawn with a Skill Check
//:: Spawn with a 25DC Skill Check
if (nCheckPCs == 2)
{
// Get Current Number of Children
int nSpawnCount = GetLocalInt(oSpawn, "SpawnCount");
if (nSpawnCount == 0)
{
// DC of Hidden Placeable
int nItemDC = 25;
// Player's Skill
int nSkill = GetSkillRank(SKILL_SEARCH, oPC);
// Do Skill Check
int nDCCheck = d20() + nSkill;
if (nDCCheck >= nItemDC)
{
// Placeable Spotted!
string sSpotted = "You notice a hidden compartment in one of the daggers with ring in it.";
FloatingTextStringOnCreature(sSpotted, oPC, TRUE);
//Spawn it!
nProcessSpawn = TRUE;
}
}
}
//:: Spawn with a 25DC Skill Check
//:: Spawn Based on Journal Quest Entry
if (nCheckPCs == 3)
{
// Check Journal Quest Entry
int nQuest = GetLocalInt(oPC, "NW_JOURNAL_ENTRYQuest1");
if (nQuest == 1)
{
// Quest Entry is 1, Spawn!
nProcessSpawn = TRUE;
}
}
//:: Spawn Based on Journal Quest Entry
// Spawn Based on Item in PC Inventory
if (nCheckPCs == 4)
{
// Check Player for Item
object oItem = GetFirstItemInInventory(oPC);
while (oItem != OBJECT_INVALID)
{
if (GetTag(oItem) == "MysticKey")
{
// Item Found, Spawn!
nProcessSpawn = TRUE;
}
oItem = GetNextItemInInventory(oPC);
}
}
// Spawn Based on Item in PC Inventory
//:: Checks for non-completion of "The Outcasts" quest.
if (nCheckPCs == 5)
{
//:: Check Journal Quest Entry
int nQuest = RetrieveQuestState("outcasts", oPC);
if (nQuest <= 2)
{
//:: Quest Entry is less than 3, Spawn!
nProcessSpawn = TRUE;
}
}
//:: Checks for non-completion of "The Outcasts" quest.
//:: #52 - Spawn if Drusilla isn't dead
if (nCheckPCs == 52)
{
// Check Journal Quest Entry
int nQuest = RetrieveQuestState("VengefulDruid", oPC);
if (nQuest <= 89)
{
// Quest Entry is less to or equal to 89, Spawn!
nProcessSpawn = TRUE;
}
}
//:: #52 - Spawn if Drusilla isn't dead
//:: #99 Checks to see if a nearby PC is using Detect Magic.
if (nCheckPCs == 99)
{
// Check if player is using Detect Magic (spellID 1576)
if (GetHasSpellEffect(1576, oPC))
{
nProcessSpawn = TRUE;
}
}
//:: #99 Checks to see if a nearby PC is using Detect Magic.
// -------------------------------------------
// Only Make Modifications Between These Lines
//
}
// Retreive Next PC
if (fCheckPCsRadius > -1.0)
{
oPC = GetNextObjectInShape(SHAPE_SPHERE, fCheckPCsRadius, lSpawn, FALSE, OBJECT_TYPE_CREATURE);
}
else
{
oPC = GetNextObjectInArea(oArea);
}
}
// Return whether Spawn can Proceed
return nProcessSpawn;
}