Files
dsrc/sku.0/sys.server/compiled/game/script/poi/wounded/master.script
T
2013-09-10 23:17:15 -07:00

238 lines
5.2 KiB
Plaintext

/**
* Copyright (c) ©2000,2001 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: master.script
* Description: master poi object script: POI = deliverance
* @author $Author: rpalacio $
* @version $Revision: #1 $
*/
/***** INCLUDES ********************************************************/
include library.poi;
include library.scenario;
include library.locations;
include library.utils;
include library.ai_lib;
/***** INHERITS ********************************************************/
inherits theme_park.poi.base;
/***** CONSTANTS *******************************************************/
const string SCENARIO_NAME = "wounded";
//SCRIPT DEFINES
const string BASE_PATH = "poi." + SCENARIO_NAME;
const string SCRIPT_MASTER = BASE_PATH + ".master";
const string SCRIPT_MEDIATOR = BASE_PATH + ".mediator";
const string SCRIPT_LEADER_INV = BASE_PATH + ".leader_inv";
//DATATABLE DEFINES
const string TBL = "datatables/poi/" + SCENARIO_NAME + "/setup.iff";
//SCENARIO STATES
const int STATE_UNKNOWN = 0;
const int STATE_THEATER_COMPLETE = 1;
const int STATE_INIT_ENTER = 2;
const int STATE_INIT_COMPLETE = 3;
const int STATE_RUN_ENTER = 4;
const int STATE_RUN_COMPLETE = 5;
const int STATE_SCENARIO_COMPLETE = 6;
/***** TRIGGERS *******************************************************/
trigger OnAttach()
{
LOG("poiWounded", "************ POI(" + SCENARIO_NAME + ") LAUNCH: " + getGameTime() + " ************");
dictionary params = scenario.getRandomScenario(TBL);
if ( params == null )
{
messageTo(self, scenario.HANDLER_DESTROY_SELF, null, 3, false);
return SCRIPT_CONTINUE;
}
string name = params.getString(scenario.COL_NAME);
LOG("poiWounded", "**** SCENARIO: " + name + " ***");
int idx = params.getInt(scenario.DICT_IDX);
string convo = params.getString(scenario.COL_CONVO);
if ( convo.equals("") )
{
messageTo(self, scenario.HANDLER_DESTROY_SELF, null, 3, false);
return SCRIPT_CONTINUE;
}
setObjVar(self, scenario.VAR_SCENARIO_IDX, idx);
setObjVar(self, scenario.VAR_SCENARIO_NAME, SCENARIO_NAME);
setObjVar(self, scenario.VAR_SCENARIO_CONVO, convo);
string theaterTemplate = params.getString(scenario.COL_THEATER);
if ( theaterTemplate.equals("") )
{
return SCRIPT_CONTINUE;
}
obj_id theater = poi.createObject(self, "theater", theaterTemplate, 0, 0);
if ( (theater == null) || (theater == obj_id.NULL_ID) )
{
scenario.cleanup(self);
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
trigger OnInitialize()
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
trigger OnUnloadedFromMemory()
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
/***** MESSAGEHANDLERS *************************************************/
messageHandler handleTheaterComplete()
{
LOG("poiWounded", "handleTheaterComplete: entered...");
int idx = getIntObjVar(self, scenario.VAR_SCENARIO_IDX);
dictionary d = dataTableGetRow(TBL, idx);
obj_id[] buildings = new obj_id[0];
java.util.Enumeration keys = params.keys();
if ( keys.hasMoreElements() )
{
buildings = params.getObjIdArray(keys.nextElement());
}
if ( (buildings == null) || (buildings.length == 0) )
{
}
else
{
}
messageTo(self, scenario.HANDLER_INIT_SCENARIO, d, 1, false);
LOG("poiWounded", "handleTheaterComplete: exiting...");
return SCRIPT_CONTINUE;
}
messageHandler initScenario()
{
LOG("poiWounded", "initScenario: entered...");
if ( (params == null) || (params.isEmpty()) )
{
scenario.cleanup(self);
return SCRIPT_CONTINUE;
}
location myLoc = getLocation(self);
string mType = params.getString(scenario.COL_MEDIATOR);
if ( (mType == null) || (mType.equals("")) )
{
return SCRIPT_CONTINUE;
}
else
{
int cnt = rand(3,7);
for ( int i = 0; i < cnt; i++ )
{
location loc = locations.getGoodLocationAroundLocation(myLoc, 2f, 2f, 8f, 8f);
if ( loc == null )
{
loc = myLoc;
}
obj_id actor = poi.createNpc(self, scenario.MEDIATOR + "_" + i, mType, loc);
if ( (actor == null) || (actor == obj_id.NULL_ID) )
{
}
else
{
attachScript(actor, SCRIPT_MEDIATOR);
if ( i == 0 ) //leader
{
obj_id inv = utils.getInventoryContainer(actor);
if ( (inv == null) || (inv == obj_id.NULL_ID) )
{
//DOH!
}
else
{
attachScript(inv, SCRIPT_LEADER_INV);
}
}
ai_lib.setDefaultCalmBehavior(actor, ai_lib.BEHAVIOR_LOITER);
setYaw(actor, rand(-180,180));
}
}
}
LOG("poiWounded", "initScenario: exiting...");
return SCRIPT_CONTINUE;
}
messageHandler runScenario()
{
LOG("poiWounded", "runScenario: entered...");
LOG("poiWounded", "runScenario: exiting...");
return SCRIPT_CONTINUE;
}
messageHandler cleanupScenario()
{
scenario.cleanup(self);
return SCRIPT_CONTINUE;
}
messageHandler destroySelf()
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
messageHandler handleActorDeath()
{
if ( params == null )
{
return SCRIPT_CONTINUE;
}
obj_id actor = params.getObjId(scenario.DICT_OBJID);
string name = params.getString(scenario.DICT_NAME);
resizeable string[] dead = getResizeableStringArrayObjVar(self, scenario.VAR_SCENARIO_DEAD);
dead = utils.addElement(dead, name);
setObjVar(self, scenario.VAR_SCENARIO_DEAD, dead);
return SCRIPT_CONTINUE;
}
messageHandler handleTimer()
{
return SCRIPT_CONTINUE;
}