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

192 lines
7.4 KiB
Plaintext

// Githzhanik spawn
#include "antistuck_h"
void fnSpawn(string sVar);
/////////////////////////////////////////////////////////////////////// MAIN
void main()
{
object oArea=OBJECT_SELF;
object oPC=GetEnteringObject();
object oGith1=GetLocalObject(oArea,"oGith1");
object oGith2=GetLocalObject(oArea,"oGith2");
object oGith3=GetLocalObject(oArea,"oGith3");
object oGith4=GetLocalObject(oArea,"oGith4");
object oGith5=GetLocalObject(oArea,"oGith5");
object oGith6=GetLocalObject(oArea,"oGith6");
object oGith7=GetLocalObject(oArea,"oGith7");
object oGith8=GetLocalObject(oArea,"oGith8");
if (GetIsPC(oPC)==TRUE)
{ // is PC
SendMessageToPC(oPC,"You have entered the City of Githzhanik.");
if (oGith1==OBJECT_INVALID) fnSpawn("oGith1");
if (oGith2==OBJECT_INVALID) fnSpawn("oGith2");
if (oGith3==OBJECT_INVALID) fnSpawn("oGith3");
if (oGith4==OBJECT_INVALID) fnSpawn("oGith4");
if (oGith5==OBJECT_INVALID) fnSpawn("oGith5");
if (oGith6==OBJECT_INVALID) fnSpawn("oGith6");
if (oGith7==OBJECT_INVALID) fnSpawn("oGith7");
if (oGith8==OBJECT_INVALID) fnSpawn("oGith8");
ExecuteScript("area_visit",OBJECT_SELF);
} // is PC
}
////////////////////////////////////////////////////////////////////// MAIN
void fnDespawn(object oOb)
{
if (GetIsInCombat(oOb)==FALSE&&IsInConversation(oOb)==FALSE)
{ // despawn
DestroyObject(oOb);
} // despawn
else
{
DelayCommand(30.0,fnDespawn(oOb));
}
} // fnDespawn()
void fnOrganizedWandering()
{
object oDest;
object oMe=OBJECT_SELF;
if (GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,oMe,1)==OBJECT_INVALID) fnDespawn(oMe);
if (GetIsInCombat(oMe)==FALSE&&IsInConversation(oMe)==FALSE)
{ // move
oDest=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,d20());
if (oDest!=OBJECT_INVALID&&d6()>2)
{ // move
AssignCommand(oMe,ASActionMoveToObject(oDest,FALSE,2.0));
} // move
} // move
DelayCommand(12.0,fnOrganizedWandering());
} // fnOrganizedWandering()
void fnFollow(object oMaster)
{
if (oMaster!=OBJECT_INVALID&&GetArea(oMaster)==GetArea(OBJECT_SELF))
{ // master exists
if (GetDistanceBetween(oMaster,OBJECT_SELF)>3.5)
{ // move closer
if (GetIsInCombat(OBJECT_SELF)==FALSE&&IsInConversation(OBJECT_SELF)==FALSE)
{ // okay to move
AssignCommand(OBJECT_SELF,ASActionMoveToObject(oMaster,TRUE,2.9));
} // okay to move
} // move closer
} // master exists
else
{ // if no perceived enemies despawn
if (GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,OBJECT_SELF,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN)==OBJECT_INVALID)
{ // okay to despawn
fnDespawn(OBJECT_SELF);
} // okay to despawn
} // if no perceived enemies despawn
DelayCommand(8.0,fnFollow(oMaster));
} // fnFollow()
void fnSpawn(string sVar)
{
int nR;
object oWP=GetWaypointByTag("GITH_SPAWN"+IntToString(d4()));
object oCR;
object oC1;
object oC2;
if (oWP!=OBJECT_INVALID)
{ // spawn here
nR=d10();
switch(nR)
{ // pick encounter switch
case 1: { // gith
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankigith",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // gith
case 2: { // githyanki warlock
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarlock",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // githyanki warlock
case 3: { // githyanki warrior
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarrior",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // githyanki warrior
case 4: { // githyanki light squad
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarrior",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
oC1=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarrior",GetLocation(oWP));
oC2=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarrior",GetLocation(oWP));
SetLocalObject(oC1,"oMaster",oCR);
SetLocalObject(oC2,"oMaster",oCR);
AssignCommand(oC1,fnFollow(oCR));
AssignCommand(oC2,fnFollow(oCR));
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // githyanki light squad
case 5: { // githyanki heavy squad
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarlock",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
oC1=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarrior",GetLocation(oWP));
oC2=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarrior",GetLocation(oWP));
SetLocalObject(oC1,"oMaster",oCR);
SetLocalObject(oC2,"oMaster",oCR);
AssignCommand(oC1,fnFollow(oCR));
AssignCommand(oC2,fnFollow(oCR));
oC1=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarrior",GetLocation(oWP));
oC2=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarrior",GetLocation(oWP));
SetLocalObject(oC1,"oMaster",oCR);
SetLocalObject(oC2,"oMaster",oCR);
AssignCommand(oC1,fnFollow(oCR));
AssignCommand(oC2,fnFollow(oCR));
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // githyanki heavy squad
case 6: { // githyanki woman
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwoman",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // githyanki woman
case 7: { // githyanki woman #2
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwoman2",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // githyanki woman #2
case 8: { // githyanki man
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiman",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // githyanki man
case 9: { // githyanki man and woman
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiman",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
if (d4()<3) oC1=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwoman",GetLocation(oWP));
else { oC1=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwoman2",GetLocation(oWP)); }
SetLocalObject(oC1,"oMaster",oCR);
AssignCommand(oC1,fnFollow(oCR));
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
break;
} // githyanki man and woman
case 10: { // githyanki elite squad
oCR=CreateObject(OBJECT_TYPE_CREATURE,"githyankiwarlock",GetLocation(oWP));
AssignCommand(oCR,fnOrganizedWandering());
DelayCommand(HoursToSeconds(6),fnDespawn(oCR));
oC1=CreateObject(OBJECT_TYPE_CREATURE,"githyankigith",GetLocation(oWP));
oC2=CreateObject(OBJECT_TYPE_CREATURE,"githyankigith",GetLocation(oWP));
SetLocalObject(oC1,"oMaster",oCR);
SetLocalObject(oC2,"oMaster",oCR);
AssignCommand(oC1,fnFollow(oCR));
AssignCommand(oC2,fnFollow(oCR));
break;
} // githyanki elite squad
default: break;
} // pick encounter switch
if (oCR!=OBJECT_INVALID) SetLocalObject(GetArea(oWP),sVar,oCR);
} // spawn here
} // fnSpawn()