HoS_PRC8/_mod/_module/nss/outerplane_hb.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

158 lines
5.1 KiB
Plaintext

#include "antistuck_h"
int fnCountResidents()
{ // return how many NPCs in the area
int nRet=0;
int nC=1;
object oCr=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,OBJECT_SELF,nC,CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_NOT_PC);
while(oCr!=OBJECT_INVALID)
{ // count
nRet++;
nC++;
oCr=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,OBJECT_SELF,nC,CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_NOT_PC);
} // count
return nRet;
} // fnCountResidents()
void fnDestroyContainer(object oContainer)
{ // empty items
object oItem=GetFirstItemInInventory(oContainer);
while(oItem!=OBJECT_INVALID)
{
DelayCommand(0.2,DestroyObject(oItem));
oItem=GetNextItemInInventory(oContainer);
}
DelayCommand(0.3,DestroyObject(oContainer));
} // fnDestroyContainer()
void fnWander()
{ // wander
object oMe=OBJECT_SELF;
object oEnemy=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,oMe,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN);
int nR;
if (GetIsInCombat(oMe)!=TRUE&&oEnemy==OBJECT_INVALID)
{ // wander
oEnemy=GetNearestObject(OBJECT_TYPE_ITEM,oMe,1);
if (oEnemy!=OBJECT_INVALID&&GetDistanceBetween(oEnemy,oMe)<20.0)
{ // cleanup item
AssignCommand(oMe,ClearAllActions());
AssignCommand(oMe,ActionMoveToObject(oEnemy,TRUE,1.0));
AssignCommand(oMe,ActionDoCommand(fnDestroyContainer(oEnemy)));
} // cleanup item
else
{ // check for containers
oEnemy=GetNearestObject(OBJECT_TYPE_PLACEABLE,oMe,1);
if (oEnemy!=OBJECT_INVALID&&GetDistanceBetween(oEnemy,oMe)<20.0&&GetHasInventory(oEnemy)==TRUE)
{ // empty container
AssignCommand(oMe,ClearAllActions());
AssignCommand(oMe,ActionMoveToObject(oEnemy,TRUE,1.0));
AssignCommand(oMe,ActionDoCommand(fnDestroyContainer(oEnemy)));
} // empty container
else
{ // move
nR=d20();
oEnemy=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,nR);
AssignCommand(oMe,ASActionMoveToObject(oEnemy,FALSE,1.0));
} // move
}// check for containers
} // wander
DelayCommand(15.0,fnWander());
} // fnWander()
object fnSpawn(string sRes,location lLoc,int nVis=VFX_FNF_SUMMON_MONSTER_1)
{ // create creature
object oRet;
effect eVis=EffectVisualEffect(nVis);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVis,lLoc,1.0);
oRet=CreateObject(OBJECT_TYPE_CREATURE,sRes,lLoc,FALSE);
return oRet;
} // fnSpawn()
void fnDestroy()
{ // destroy self
object oMe=OBJECT_SELF;
object oEnemy=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,oMe,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN);
effect eVis=EffectVisualEffect(VFX_FNF_IMPLOSION);
if (GetIsInCombat(oMe)!=TRUE&&oEnemy==OBJECT_INVALID)
{ // Destroy Self
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVis,GetLocation(oMe),3.0);
DelayCommand(1.0,DestroyObject(oMe));
} // Destroy Self
else
{ // wait a bit longer
DelayCommand(20.0,fnDestroy());
} // wait a bit longer
} // fnDestroy()
void main()
{
object oFirst=GetFirstObjectInArea(OBJECT_SELF);
object oMe=OBJECT_SELF;
object oPC;
int nC=fnCountResidents();
int nR;
int nActivity=GetLocalInt(oMe,"nPlanarActivity");
string sRes;
int nSP=d6();
object oSpawnPoint=GetWaypointByTag("INB_SPAWN"+IntToString(nSP));
location lLoc=GetLocation(oSpawnPoint);
oFirst=GetNearestObject(OBJECT_TYPE_WAYPOINT,oFirst,1);
oPC=GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,oFirst,1);
if (oPC!=OBJECT_INVALID)
{ // PCs are present
if (nC<4)
{ // spawn okay
nR=d100();
if (nR<5+nActivity)
{ // spawn something
SetLocalInt(oMe,"nPlanarActivity",0);
nR=d100();
if (nR<51)
{ // mephits
nR=d100();
if (nR<21) sRes="mepdust001";
else if (nR<41) sRes="mepfire001";
else if (nR<61) sRes="mepice001";
else if (nR<81) sRes="mepearth001";
else { sRes="mepmagma001"; }
} // mephits
else if (nR<91)
{ // Slaad
oSpawnPoint=GetModule();
nR=d100()+(GetLocalInt(oSpawnPoint,"nEvilPower")/50);
if (nR<34)
sRes="slaadred001";
else if (nR<54)
sRes="slaadbl001";
else if (nR<74)
sRes="slaadgrn001";
else if (nR<94)
sRes="slaadgray001";
else if (nR<114)
sRes="slaaddeth001";
else if (nR<134)
sRes="slaadwhite002";
else { sRes="slaadblack002"; }
} // Slaad
else
{ // something else
oSpawnPoint=GetModule();
nR=d100()+(GetLocalInt(oSpawnPoint,"nEvilPower")/50);
if (nR<34)
sRes="movanicdeva";
else if (nR<67)
sRes="fire001";
else if (nR<100)
sRes="erinyes001";
else if (nR<110)
sRes="devil002";
else { sRes="devil003"; }
} // something else
oSpawnPoint=fnSpawn(sRes,lLoc);
AssignCommand(oSpawnPoint,fnWander());
AssignCommand(oSpawnPoint,DelayCommand(HoursToSeconds(4),fnDestroy()));
} // spawn something
} // spawn okay
} // PCs are present
DelayCommand(2.0,ExecuteScript("area_hb_clean",OBJECT_SELF));
} // main