Files
dsrc/sku.0/sys.server/compiled/game/script/hnguyen/initialize_starport.script
T

73 lines
1.9 KiB
Plaintext

/**
* initialize_starport.script
*
* Assumes this script is attached to a character
*/
//----------------------------------------------------------
include java.util.StringTokenizer;
include library.utils;
include library.player_structure;
include library.travel;
//----------------------------------------------------------
trigger OnHearSpeech(obj_id objSpeaker, string strText)
{
if (objSpeaker != self)
return SCRIPT_CONTINUE;
if (strText.startsWith("initializeStarport "))
{
StringTokenizer st = new StringTokenizer(strText);
if (st.countTokens() == 2)
{
string command = st.nextToken();
obj_id starportOid = utils.stringToObjId(st.nextToken());
if (!hasScript(starportOid, "structure.municipal.starport"))
{
sendSystemMessageTestingOnly(self, "object " + starportOid + " doesn't have script structure.municipal.starport");
}
else
{
sendSystemMessageTestingOnly(self, "inializing starport " + starportOid);
// Ignore this for the case of civic starports.
if ( player_structure.isCivic( starportOid ) )
{
sendSystemMessageTestingOnly(self, "starport " + starportOid + " is civic");
}
else
{
// Add the structure's travel point.
string planet = getCurrentSceneName();
string travel_point = travel.getTravelPointName(starportOid);
int travel_cost = travel.getTravelCost(starportOid);
if (travel_point == null || travel_cost == -1)
{
sendSystemMessageTestingOnly(self, "starport " + starportOid + " has null travel point or travel cost of -1");
}
else
{
location loc = getPlanetTravelPointLocation(planet, travel_point);
if (loc != null)
{
sendSystemMessageTestingOnly(self, "starport " + starportOid + " is already registered with the travel system");
}
else
{
travel.initializeStarport(starportOid, travel_point, travel_cost,false);
}
}
}
}
}
}
return SCRIPT_CONTINUE;
}