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

78 lines
2.2 KiB
Plaintext

// contest_start
void fnJump(object oSpawn,string sRun)
{
object oRun;
if (GetIsObjectValid(oSpawn))
{
if (GetArea(oSpawn)!=GetArea(OBJECT_SELF))
{ // brute force
AssignCommand(OBJECT_SELF,ClearAllActions(TRUE));
AssignCommand(OBJECT_SELF,JumpToObject(oSpawn));
DelayCommand(0.5,fnJump(oSpawn,sRun));
} // brute force
else
{ // move to waypoint
oRun=GetWaypointByTag(sRun);
if (GetIsObjectValid(oRun))
{ // move
AssignCommand(OBJECT_SELF,ActionForceMoveToObject(oRun,TRUE,3.0,20.0));
} // move
} // move to waypoint
}
else
{
SendMessageToPC(GetFirstPC(),"SPAWN WAYPOINT DOES NOT EXIST");
}
}
void main()
{
object oDM=GetLastUsedBy();
string sWP="CONTESTANT_";
string sSpawn="ARENA_SPAWN_";
string sRun="ARENA_RUN_";
int nN;
object oWP;
object oNPC;
float fD;
int bDone=FALSE;
nN=1;
SendMessageToPC(oDM,"The CONTEST has begun!");
while(!bDone)
{ // send contestants
bDone=TRUE;
oWP=GetWaypointByTag(sWP+"A");
if (GetIsObjectValid(oWP))
{ // waypoint exists
oNPC=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oWP,nN);
if (GetIsObjectValid(oNPC))
{ // check distance
if(GetDistanceBetween(oNPC,oWP)<16.0)
{ // close enough
bDone=FALSE;
ChangeToStandardFaction(oNPC,STANDARD_FACTION_HOSTILE);
oWP=GetWaypointByTag(sSpawn+"A");
AssignCommand(oNPC,fnJump(oWP,sRun+"A"));
} // close enough
} // check distance
} // waypoint exists
oWP=GetWaypointByTag(sWP+"B");
if (GetIsObjectValid(oWP))
{ // waypoint exists
oNPC=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oWP,nN);
if (GetIsObjectValid(oNPC))
{ // check distance
if(GetDistanceBetween(oNPC,oWP)<16.0)
{ // close enough
bDone=FALSE;
ChangeToStandardFaction(oNPC,STANDARD_FACTION_DEFENDER);
oWP=GetWaypointByTag(sSpawn+"B");
AssignCommand(oNPC,fnJump(oWP,sRun+"B"));
} // close enough
} // check distance
} // waypoint exists
nN++;
} // send contestants
}