mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-09-28 14:13:01 -04:00
196 lines
4.5 KiB
Plaintext
196 lines
4.5 KiB
Plaintext
/**
|
|
|
|
*
|
|
* Title: master.script
|
|
* Description: master poi object script: POI = heromark
|
|
|
|
*/
|
|
|
|
//------------------------------------------------
|
|
// Includes
|
|
//------------------------------------------------
|
|
|
|
include library.poi;
|
|
include library.scenario;
|
|
include library.ai_lib;
|
|
include ai.ai_combat;
|
|
|
|
//------------------------------------------------
|
|
// Inherits
|
|
//------------------------------------------------
|
|
|
|
inherits theme_park.poi.base;
|
|
|
|
//------------------------------------------------
|
|
// Constants
|
|
//------------------------------------------------
|
|
|
|
const string SCENARIO_NAME = "heromark";
|
|
const string LOG_NAME = "poiHeroMark Master";
|
|
const string BASE_PATH = "poi." + SCENARIO_NAME;
|
|
const string SCRIPT_MEDIATOR = BASE_PATH + ".mediator";
|
|
const string MEDIATOR_TYPE = "MEDIATOR_TYPE";
|
|
const string SCENARIO_THEATER = "object/building/poi/camp/tatooine_traders_camp_small.iff";
|
|
const string TBL = "datatables/poi/" + SCENARIO_NAME + "/setup.iff";
|
|
const int mediatorCoordsX[] = { 8, -2, 6, -3, -5, 0 };
|
|
const int mediatorCoordsZ[] = { 2, 0, 1, -10, 1, -6 };
|
|
|
|
//------------------------------------------------
|
|
// Methods
|
|
//------------------------------------------------
|
|
|
|
//------------------------------------------------
|
|
// OnAttach
|
|
//------------------------------------------------
|
|
|
|
trigger OnAttach()
|
|
{
|
|
if ( !scenario.initScenario( self, TBL ) )
|
|
scenario.cleanup( self );
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// OnInitialize
|
|
//------------------------------------------------
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
scenario.cleanup( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// OnUnloadedFromMemory
|
|
//------------------------------------------------
|
|
|
|
trigger OnUnloadedFromMemory()
|
|
{
|
|
scenario.cleanup( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// cleanupScenario
|
|
//------------------------------------------------
|
|
|
|
messageHandler cleanupScenario()
|
|
{
|
|
scenario.cleanup( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// destroySelf
|
|
//------------------------------------------------
|
|
|
|
messageHandler destroySelf()
|
|
{
|
|
destroyObject( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// initScenario
|
|
//
|
|
// Called by message from OnAttach.
|
|
// This calls all methods necessary to set up the POI.
|
|
//------------------------------------------------
|
|
|
|
messageHandler initScenario()
|
|
{
|
|
// Validate parameters.
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
scenario.cleanup(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/*
|
|
Environment Setup
|
|
*/
|
|
|
|
// Get our mediator type.
|
|
string mtype = params.getString( "MEDIATOR_TEMPLATE" );
|
|
setObjVar( self, MEDIATOR_TYPE, mtype );
|
|
|
|
// Create teams.
|
|
scenario.createTeam( self, "mediator", self.toString() + "_mediator" );
|
|
|
|
/*
|
|
Spawn Theaters
|
|
*/
|
|
|
|
if ( !createTheaters( self ) )
|
|
{
|
|
scenario.cleanup( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// createTheaters
|
|
//
|
|
// Spawns the theaters for the scenario.
|
|
//------------------------------------------------
|
|
|
|
boolean createTheaters( obj_id self )
|
|
{
|
|
// Create the theater.
|
|
obj_id theater = poi.createObject( SCENARIO_THEATER, 0, 0 );
|
|
if ( (theater == null) || (theater == obj_id.NULL_ID) )
|
|
return false;
|
|
|
|
// Store theater reference.
|
|
setObjVar( self, "theater", theater );
|
|
|
|
return true;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// handleTheaterComplete
|
|
//
|
|
// Called when the theaters load.
|
|
//------------------------------------------------
|
|
|
|
messageHandler handleTheaterComplete()
|
|
{
|
|
/*
|
|
Spawn Mediators
|
|
*/
|
|
|
|
if ( !createMediator( self ) )
|
|
{
|
|
scenario.cleanup( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// createMediator
|
|
//
|
|
// Creates the mediator.
|
|
//------------------------------------------------
|
|
|
|
boolean createMediator( obj_id self )
|
|
{
|
|
// Spawn the scenario mediator (prisoner leader).
|
|
string type = getStringObjVar( self, MEDIATOR_TYPE );
|
|
string ident = "mediator_0";
|
|
location loc = getLocation( self );
|
|
obj_id mediator = scenario.createTeamNpc( self, "mediator", type, ident, loc );
|
|
if ( (mediator == null) || (mediator == obj_id.NULL_ID) )
|
|
return false;
|
|
|
|
// Assign initial behavior to the mediator.
|
|
ai_lib.setDefaultCalmBehavior( mediator, ai_lib.BEHAVIOR_SENTINEL );
|
|
attachScript( mediator, SCRIPT_MEDIATOR );
|
|
|
|
return true;
|
|
}
|