mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-03 03:15:55 -04:00
144 lines
4.0 KiB
Plaintext
144 lines
4.0 KiB
Plaintext
include library.create;
|
|
include library.utils;
|
|
//include java.util.StringTokenizer;
|
|
//include ai.ai_combat;
|
|
include library.ai_lib;
|
|
|
|
trigger OnAttach()
|
|
{
|
|
messageTo(self, "ep3demoCleanUpBattle", null, 36000, false);
|
|
startBattle(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
float timeStamp = getFloatObjVar(self, "ep3demo.timeStamp");
|
|
float rightNow = getGameTime();
|
|
|
|
if(rightNow - timeStamp > 36000)
|
|
{
|
|
destroyObject(self);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAddedToWorld()
|
|
{
|
|
float timeStamp = getFloatObjVar(self, "ep3demo.timeStamp");
|
|
float rightNow = getGameTime();
|
|
|
|
if(rightNow - timeStamp > 36000)
|
|
{
|
|
destroyObject(self);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void startBattle(obj_id self)
|
|
{
|
|
string[] aggressorTemplate = getStringArrayObjVar(self, "ep3demo.aggressorTemplate");
|
|
string[] victimTemplate = getStringArrayObjVar(self, "ep3demo.victimTemplate");
|
|
int aggressorNumber = getIntObjVar(self, "ep3demo.aggressorNumber");
|
|
int victimNumber = getIntObjVar(self, "ep3demo.victimNumber");
|
|
location here = getLocation(self);
|
|
|
|
for(int i = 0; i < aggressorNumber; i++)
|
|
{
|
|
int aggRoll = rand(0, aggressorTemplate.length-1);
|
|
|
|
location spawnLoc = utils.getRandomLocationInRing(here, 1, 16);
|
|
obj_id aggressor = create.object(aggressorTemplate[aggRoll], spawnLoc);
|
|
ai_lib.setDefaultCalmBehavior(aggressor, ai_lib.BEHAVIOR_SENTINEL );
|
|
|
|
setObjVar(aggressor, "ep3demo.mom", self);
|
|
utils.setScriptVar(aggressor, "ep3demo.aggressor", 1);
|
|
setObjVar(aggressor, "ep3demo.spawnPoint", spawnLoc);
|
|
attachScript(aggressor, "event.ep3demo.combatant");
|
|
}
|
|
|
|
for(int i = 0; i < victimNumber; i++)
|
|
{
|
|
int victRoll = rand(0, victimTemplate.length-1);
|
|
|
|
location theOtherSpawnLoc = utils.getRandomLocationInRing(here, 1, 16);
|
|
obj_id victim = create.object(victimTemplate[victRoll], theOtherSpawnLoc);
|
|
ai_lib.setDefaultCalmBehavior(victim, ai_lib.BEHAVIOR_SENTINEL );
|
|
|
|
setObjVar(victim, "ep3demo.mom", self);
|
|
utils.setScriptVar(victim, "ep3demo.victim", 1);
|
|
setObjVar(victim, "ep3demo.spawnPoint", theOtherSpawnLoc);
|
|
attachScript(victim, "event.ep3demo.combatant");
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
trigger OnHearSpeech(obj_id objSpeaker, string strText)
|
|
{
|
|
|
|
if(!isGod(objSpeaker))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(toLower(strText).startsWith("stop battle"))
|
|
{
|
|
sendSystemMessage(objSpeaker, "Ending battle...", null);
|
|
destroyObject(self);
|
|
}
|
|
|
|
if(toLower(strText).startsWith("restart battle"))
|
|
{
|
|
sendSystemMessage(objSpeaker, "Spawning fresh combatants...", null);
|
|
startBattle(self);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler ep3demoCleanUpBattle()
|
|
{
|
|
destroyObject(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler spawnAnotherVictim()
|
|
{
|
|
|
|
string[] victimTemplate = getStringArrayObjVar(self, "ep3demo.victimTemplate");
|
|
int victRoll = rand(0, victimTemplate.length-1);
|
|
location here = getLocation(self);
|
|
location theOtherSpawnLoc = utils.getRandomLocationInRing(here, 1, 16);
|
|
obj_id victim = create.object(victimTemplate[victRoll], theOtherSpawnLoc);
|
|
ai_lib.setDefaultCalmBehavior(victim, ai_lib.BEHAVIOR_SENTINEL );
|
|
|
|
setObjVar(victim, "ep3demo.mom", self);
|
|
// setObjVar(victim, "ep3demo.victim", victim);
|
|
utils.setScriptVar(victim, "ep3demo.victim", 1);
|
|
setObjVar(victim, "ep3demo.spawnPoint", theOtherSpawnLoc);
|
|
attachScript(victim, "event.ep3demo.combatant");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler spawnAnotherAggressor()
|
|
{
|
|
string[] aggressorTemplate = getStringArrayObjVar(self, "ep3demo.aggressorTemplate");
|
|
int aggRoll = rand(0, aggressorTemplate.length-1);
|
|
location here = getLocation(self);
|
|
location spawnLoc = utils.getRandomLocationInRing(here, 1, 16);
|
|
obj_id aggressor = create.object(aggressorTemplate[aggRoll], spawnLoc);
|
|
ai_lib.setDefaultCalmBehavior(aggressor, ai_lib.BEHAVIOR_SENTINEL );
|
|
|
|
setObjVar(aggressor, "ep3demo.mom", self);
|
|
// setObjVar(aggressor, "ep3demo.aggressor", aggressor);
|
|
utils.setScriptVar(aggressor, "ep3demo.aggressor", 1);
|
|
setObjVar(aggressor, "ep3demo.spawnPoint", spawnLoc);
|
|
attachScript(aggressor, "event.ep3demo.combatant");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
} |