mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-04 04:15:52 -04:00
132 lines
2.8 KiB
Plaintext
132 lines
2.8 KiB
Plaintext
include library.ai_lib;
|
|
include library.create;
|
|
|
|
const string npcTable = "datatables/poi/city/convo_npc.iff";
|
|
|
|
trigger OnInitialize ()
|
|
{
|
|
beginSpawning( self );
|
|
messageTo( self, "handleChatting", null, 10, false );
|
|
messageTo( self, "checkForScripts", null, 10, false );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleChatting()
|
|
{
|
|
obj_id guy1 = getObjIdObjVar( self, "guy1" );
|
|
obj_id guy2 = getObjIdObjVar( self, "guy2" );
|
|
obj_id guy3 = getObjIdObjVar( self, "guy3" );
|
|
obj_id guy4 = getObjIdObjVar( self, "guy4" );
|
|
|
|
if ( !exists(guy1) || !exists(guy2) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
faceTo (guy1, guy2);
|
|
faceTo (guy2, guy1);
|
|
faceTo (guy3, guy1);
|
|
faceTo (guy4, guy2);
|
|
setAnimationMood (guy1, "conversation");
|
|
setAnimationMood (guy2, "conversation");
|
|
setAnimationMood (guy3, "conversation");
|
|
setAnimationMood (guy4, "conversation");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleGuyOneKilled()
|
|
{
|
|
spawnGuyOne( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleGuyTwoKilled()
|
|
{
|
|
spawnGuyTwo( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleGuyThreeKilled()
|
|
{
|
|
spawnGuyThree( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleGuyFourKilled()
|
|
{
|
|
spawnGuyFour( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void spawnGuyOne( obj_id baseObject )
|
|
{
|
|
obj_id guy1 = create.themeParkObject( getRandomGuy(), 1.3f,0, "handleGuyOneKilled", 0 );
|
|
setObjVar( baseObject, "guy1", guy1 );
|
|
setCreatureStatic(guy1, true);
|
|
}
|
|
|
|
void spawnGuyTwo( obj_id baseObject )
|
|
{
|
|
obj_id guy2 = create.themeParkObject( getRandomGuy(), 1.3f,1.3f, "handleGuyTwoKilled", 0 );
|
|
setObjVar( baseObject, "guy2", guy2 );
|
|
setCreatureStatic(guy2, true);
|
|
}
|
|
|
|
void spawnGuyThree ( obj_id baseObject )
|
|
{
|
|
obj_id guy3 = create.themeParkObject( getRandomGuy(), 0,1.3f, "handleGuyThreeKilled", 0 );
|
|
setObjVar( baseObject, "guy3", guy3 );
|
|
setCreatureStatic(guy3, true);
|
|
}
|
|
|
|
void spawnGuyFour( obj_id baseObject )
|
|
{
|
|
obj_id guy4 = create.themeParkObject( getRandomGuy(), 0,0, "handleGuyFourKilled", 0 );
|
|
setObjVar( baseObject, "guy4", guy4 );
|
|
setCreatureStatic(guy4, true);
|
|
}
|
|
|
|
string getRandomGuy ()
|
|
{
|
|
location here = getLocation (getSelf());
|
|
string planet = here.area;
|
|
string[] npcList = dataTableGetStringColumnNoDefaults( npcTable, planet);
|
|
int npcNum = rand(0, npcList.length -1 );
|
|
string npc = npcList[ npcNum];
|
|
return npc;
|
|
}
|
|
|
|
void beginSpawning (obj_id self)
|
|
{
|
|
int num = rand (1,10);
|
|
if (num < 5)
|
|
{
|
|
spawnGuyOne( self );
|
|
spawnGuyTwo( self );
|
|
return;
|
|
}
|
|
|
|
if (num < 8)
|
|
{
|
|
spawnGuyOne( self );
|
|
spawnGuyTwo( self );
|
|
spawnGuyThree ( self );
|
|
return;
|
|
}
|
|
|
|
else
|
|
{
|
|
spawnGuyOne( self );
|
|
spawnGuyTwo( self );
|
|
spawnGuyThree ( self );
|
|
spawnGuyFour ( self );
|
|
return;
|
|
}
|
|
}
|
|
|
|
messageHandler checkForScripts()
|
|
{
|
|
if (hasScript (self, "theme_park.poi.launch"))
|
|
{
|
|
detachScript (self, "theme_park.poi.launch");
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
} |