Files
dsrc/sku.0/sys.server/compiled/game/script/library/load_test.scriptlib
T
2013-09-10 23:17:15 -07:00

259 lines
7.8 KiB
Plaintext

// ======================================================================
//
// load_test.scriptlib
//
// Copyright 2003 Sony Online Entertainment
//
// ======================================================================
include library.space_create;
include library.space_transition;
include library.space_utils;
include library.utils;
// ======================================================================
const string VAR_AI_SHIPS = "load_test.aiShips";
const string[] REBEL_PILOT =
{
"pilot_rebel_navy",
"pilot_rebel_navy_novice",
"pilot_rebel_navy_starships_01",
"pilot_rebel_navy_weapons_01",
"pilot_rebel_navy_procedures_01",
"pilot_rebel_navy_droid_01",
"pilot_rebel_navy_starships_02",
"pilot_rebel_navy_weapons_02",
"pilot_rebel_navy_procedures_02",
"pilot_rebel_navy_droid_02",
"pilot_rebel_navy_weapons_03",
"pilot_rebel_navy_starships_03",
"pilot_rebel_navy_procedures_03",
"pilot_rebel_navy_droid_03",
"pilot_rebel_navy_starships_04",
"pilot_rebel_navy_weapons_04",
"pilot_rebel_navy_procedures_04",
"pilot_rebel_navy_droid_04",
"pilot_rebel_navy_master"
};
const string[] IMPERIAL_PILOT =
{
"pilot_imperial_navy",
"pilot_imperial_navy_novice",
"pilot_imperial_navy_starships_01",
"pilot_imperial_navy_weapons_01",
"pilot_imperial_navy_procedures_01",
"pilot_imperial_navy_droid_01",
"pilot_imperial_navy_starships_02",
"pilot_imperial_navy_weapons_02",
"pilot_imperial_navy_procedures_02",
"pilot_imperial_navy_droid_02",
"pilot_imperial_navy_weapons_03",
"pilot_imperial_navy_starships_03",
"pilot_imperial_navy_procedures_03",
"pilot_imperial_navy_droid_03",
"pilot_imperial_navy_starships_04",
"pilot_imperial_navy_weapons_04",
"pilot_imperial_navy_procedures_04",
"pilot_imperial_navy_droid_04",
"pilot_imperial_navy_master"
};
const string[] NEUTRAL_PILOT =
{
"pilot_neutral",
"pilot_neutral_novice",
"pilot_neutral_starships_01",
"pilot_neutral_weapons_01",
"pilot_neutral_procedures_01",
"pilot_neutral_droid_01",
"pilot_neutral_starships_02",
"pilot_neutral_weapons_02",
"pilot_neutral_procedures_02",
"pilot_neutral_droid_02",
"pilot_neutral_weapons_03",
"pilot_neutral_starships_03",
"pilot_neutral_procedures_03",
"pilot_neutral_droid_03",
"pilot_neutral_starships_04",
"pilot_neutral_weapons_04",
"pilot_neutral_procedures_04",
"pilot_neutral_droid_04",
"pilot_neutral_master"
};
// ======================================================================
boolean loadClientSupportEnabled()
{
String value = getConfigSetting("GameServer", "loadClientSupportEnabled");
if (value != null && (value.equals("1") || value.equals("true") || value.equals("yes")))
return true;
return false;
}
// ----------------------------------------------------------------------
void handleLoadClientSetup(obj_id clientCreature, string optionsString)
{
string shipName = "xwing";
string spaceSceneName = "space_tatooine";
int aiShipCount = 0;
string aiShipName = "xwing";
boolean battlefield = false;
int team = rand(0, 1);
if (team == 0)
team = ##"rebel";
else
team = ##"imperial";
// parse out options and set values based on them
string[] options = split(optionsString, ' ');
if (options != null)
{
for (int i = 1; i < options.length; ++i)
{
string[] optionBits = split(options[i], '=');
if (optionBits != null)
{
if (optionBits.length == 2 && optionBits[0].equalsIgnoreCase("shipName"))
shipName = optionBits[1];
else if (optionBits.length == 2 && optionBits[0].equalsIgnoreCase("spaceSceneName"))
spaceSceneName = optionBits[1];
else if (optionBits.length == 2 && optionBits[0].equalsIgnoreCase("aiShipCount"))
aiShipCount = utils.stringToInt(optionBits[1]);
else if (optionBits.length == 2 && optionBits[0].equalsIgnoreCase("aiShipName"))
aiShipName = optionBits[1];
else if (optionBits.length == 1 && optionBits[0].equalsIgnoreCase("battlefield"))
battlefield = true;
else
{
sendSystemMessageTestingOnly(clientCreature, "loadClientSetup: Bad option [" + options[i] + "] specified.");
return;
}
}
}
}
if (battlefield)
{
if (team == ##"rebel")
shipName="xwing";
else
shipName="tieinterceptor";
aiShipCount = 0;
spaceSceneName = "space_heavy1";
}
if (isSpaceScene())
{
// try to recover from bad cases where a ship could not be unpacked in space
if (!isIdValid(space_transition.getContainingShip(clientCreature)))
{
space_utils.destroyShipControlDevices(clientCreature, false);
space_utils.createShipControlDevice(clientCreature, shipName, false);
}
obj_id clientShip = space_transition.getContainingShip(clientCreature);
if (isIdValid(clientShip) && aiShipCount > 0)
{
if (!hasScript(clientShip, "space.load_test.load_test_player"))
attachScript(clientShip, "space.load_test.load_test_player");
// now in a ship in space - perform any additional setup here
// create ai ships and follow in a chain for now
obj_id[] aiShips = new obj_id[aiShipCount];
obj_id lastShip = clientShip;
for (int i = 0; i < aiShipCount; ++i)
{
obj_id aiShip = space_create.createShip(aiShipName, getTransform_o2p(lastShip).move_l(new vector(0.f, 0.f, -15.f)));
if (isIdValid(aiShip))
{
utils.setScriptVar(aiShip, "followTarget", lastShip);
attachScript(aiShip, "space.load_test.load_test_ai");
lastShip = aiShip;
aiShips[i] = aiShip;
}
}
dictionary d = clientShip.getScriptDictionary();
d.put(VAR_AI_SHIPS, aiShips);
}
}
else
{
space_utils.destroyShipControlDevices(clientCreature, false);
obj_id shipControlDevice = space_utils.createShipControlDevice(clientCreature, shipName, false);
if (isIdValid(shipControlDevice))
{
obj_id ship = space_transition.getShipFromShipControlDevice(shipControlDevice);
space_transition.setLaunchInfo(clientCreature, ship, 0, getLocation(getTopMostContainer(clientCreature)));
if (battlefield)
{
setObjVar(ship, "intBattlefieldTeam", team);
obj_id w = createWaypointInDatapad(clientCreature, new location(-6000.f, 0.f, 0.f, "space_heavy1"));
setWaypointName(w, "Rebel Base");
setWaypointActive(w, true);
w = createWaypointInDatapad(clientCreature, new location(6000.f, 0.f, 0.f, "space_heavy1"));
setWaypointActive(w, true);
setWaypointName(w, "Imperial Base");
if (team == ##"rebel")
{
setRebelSkills(clientCreature);
float x = -5000.f + rand(-100, 100);
float y = 0.f + rand(-100, 100);
float z = 0.f + rand(-100, 100);
warpPlayer(clientCreature, spaceSceneName, x, y, z, null, x, y, z);
}
else
{
setImperialSkills(clientCreature);
float x = 6000.f + rand(-100, 100);
float y = -1200.f + rand(-100, 100);
float z = 600.f + rand(-100, 100);
warpPlayer(clientCreature, spaceSceneName, x, y, z, null, x, y, z);
}
}
else
warpPlayer(clientCreature, spaceSceneName, 10.f, 0.f, 10.f, null, 10.f, 0.f, 10.f);
}
}
}
// ----------------------------------------------------------------------
void setRebelSkills(obj_id creature)
{
revokeSkills(creature, IMPERIAL_PILOT);
revokeSkills(creature, NEUTRAL_PILOT);
grantSkills(creature, REBEL_PILOT);
}
// ----------------------------------------------------------------------
void setImperialSkills(obj_id creature)
{
revokeSkills(creature, REBEL_PILOT);
revokeSkills(creature, NEUTRAL_PILOT);
grantSkills(creature, IMPERIAL_PILOT);
}
// ----------------------------------------------------------------------
void grantSkills(obj_id creature, string[] skills)
{
for (int i = 0; i < skills.length; ++i)
grantSkill(creature, skills[i]);
}
// ----------------------------------------------------------------------
void revokeSkills(obj_id creature, string[] skills)
{
for (int i = skills.length-1; i >= 0; --i)
revokeSkill(creature, skills[i]);
}
// ======================================================================