mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
114 lines
2.4 KiB
Plaintext
114 lines
2.4 KiB
Plaintext
include library.ai_lib;
|
|
|
|
const string[] patrolPoints = {
|
|
"city1", "city2", "city3", "city4", "city5", "city6"
|
|
};
|
|
|
|
trigger OnAttach()
|
|
{
|
|
ai_lib.setDefaultCalmBehavior( self, ai_lib.BEHAVIOR_SENTINEL );
|
|
messageTo (self, "pathRandom", null, 1, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnInitialize ()
|
|
{
|
|
messageTo (self, "pathRandom", null, 1, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler pathRandom()
|
|
{
|
|
ai_lib.setPatrolRandomNamedPath(self, patrolPoints);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnLoiterMoving()
|
|
{
|
|
stop( self );
|
|
messageTo (self, "pathRandom", null, 2, false);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
trigger OnMovePathComplete()
|
|
{
|
|
messageTo (self, "pathRandom", null, rand(30,60), false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnMovePathNotFound()
|
|
{
|
|
if (hasObjVar (self, "checkingFeet"))
|
|
{
|
|
int checked = getIntObjVar (self, "checkingFeet");
|
|
if (checked > 10)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
messageTo (self, "pathRandom", null, rand(30,60), false);
|
|
checkForFeetGluedToFloor(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void checkForFeetGluedToFloor(obj_id self)
|
|
{
|
|
if (!hasObjVar (self, "checkingFeet"))
|
|
{
|
|
setObjVar (self, "checkingFeet", 1);
|
|
location here = getLocation(self);
|
|
setObjVar (self, "mightBeStuck", here);
|
|
messageTo (self, "amIStuck", null, 180, false);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
int checked = getIntObjVar (self, "checkingFeet");
|
|
checked = checked + 1;
|
|
setObjVar (self, "checkingFeet", checked);
|
|
if (checked > 10)
|
|
{
|
|
return;
|
|
}
|
|
location here = getLocation(self);
|
|
setObjVar (self, "mightBeStuck", here);
|
|
messageTo (self, "amIStuck", null, 180, false);
|
|
return;
|
|
}
|
|
}
|
|
|
|
messageHandler amIStuck()
|
|
{
|
|
location now = getLocation(self);
|
|
location here = getLocationObjVar (self, "mightBeStuck");
|
|
if (now == null || now == here)
|
|
{
|
|
//debugSpeakMsg (self, "NPC hasn't moved in 3 minutes. He needs to be cleaned up");
|
|
messageTo (self, "killIt", null, 3, false);
|
|
}
|
|
else
|
|
{
|
|
messageTo (self, "cleanUpChecks", null, 10, false);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler killIt()
|
|
{
|
|
LOG("NPC_Cleanup", "NPC: " + self + " at " + getLocation(self) + " has cleaned itself up because it couldn't find anyplace to go, according to the City_Wander script.");
|
|
destroyObject (self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
messageHandler cleanUpChecks()
|
|
{
|
|
int checks = getIntObjVar (self, "checkingFeet");
|
|
if (checks > 0)
|
|
{
|
|
checks = checks -1;
|
|
setObjVar (self, "checkingFeet", checks);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|