Files
dsrc/sku.0/sys.server/compiled/game/script/systems/battlefield/battlefield_utility.script
T
2013-09-10 23:17:15 -07:00

259 lines
7.6 KiB
Plaintext

/**********************************************************************
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: battlefield_utility
* Description: a player script for managing battlefields. For testing only.
*
* @author $Author:$
* @version $Revision:$
**********************************************************************/
/***** INCLUDES ********************************************************/
include library.battlefield;
include library.factions;
include library.regions;
include library.utils;
/***** CONSTANTS *******************************************************/
/***** TRIGGERS ********************************************************/
trigger OnSpeaking(string text)
{
location loc = getLocation(self);
if (text.startsWith("bfdestroy"))
{
// Format: bfdestroy <master battlefield obj_id>
// Use this only if all else fails. This will not clean up player variables and such.
obj_id target = getLookAtTarget(self);
if (target != null)
loc = getLocation(target);
else
{
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
LOG("LOG_CHANNEL", "tokens -> " + st.countTokens() + " nextToken ->" + st.nextToken());
if (st.hasMoreTokens())
{
string target_str = st.nextToken();
LOG("LOG_CHANNEL", "target_str ->" + target_str);
target = utils.stringToObjId(target_str);
if (target != null)
loc = getLocation(target);
}
}
battlefield.destroyBattlefield(target);
}
if (text.startsWith("endbattle"))
{
// Format: endbattle <master battlefield obj_id>
// Resets the battlefield game as if time had just expired. If the game breaks,
// this is the best way to get it going again.
obj_id target = getLookAtTarget(self);
if (target == null || target == obj_id.NULL_ID)
{
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
LOG("LOG_CHANNEL", "tokens -> " + st.countTokens() + " nextToken ->" + st.nextToken());
if (st.hasMoreTokens())
{
string target_str = st.nextToken();
LOG("LOG_CHANNEL", "target_str ->" + target_str);
target = utils.stringToObjId(target_str);
}
}
if (target != null && target != obj_id.NULL_ID)
{
battlefield.endBattlefield(target);
sendSystemMessageTestingOnly(self, "Battle ended.");
}
}
if (text == "battlefield")
{
// Creates all battlefields defined in the battlefield datatable for the planet.
// You only need to do this once.
string area = getCurrentSceneName();
battlefield.createBattlefieldRegions(area);
//createBattlefield(self);
sendSystemMessageTestingOnly(self, "Battlefields created.");
}
if (text == "destroyall")
{
string area = getCurrentSceneName();
battlefield.destroyBattlefieldRegions(area);
sendSystemMessageTestingOnly(self, "Battlefields destroyed.");
}
if (text.startsWith("delta"))
{
// Format: delta <obj_id>
// Determines the delta location of your position with respect to the specified obj_id.
// This is the coordinate system used in defining objects within a battlefield.
obj_id target = obj_id.NULL_ID;
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
LOG("LOG_CHANNEL", "tokens -> " + st.countTokens() + " nextToken ->" + st.nextToken());
if (st.hasMoreTokens())
{
string target_str = st.nextToken();
LOG("LOG_CHANNEL", "target_str ->" + target_str);
target = utils.stringToObjId(target_str);
}
if (target == null)
target = getLookAtTarget(self);
if (target != null && target != obj_id.NULL_ID)
{
location targ_loc = getLocation(target);
float delta_x = targ_loc.x - loc.x;
float delta_y = targ_loc.y - loc.y;
float delta_z = targ_loc.z - loc.z;
LOG("LOG_CHANNEL", "delta ->" + "(" + delta_x + ", " + delta_y + ", " + delta_z + ")");
sendSystemMessageTestingOnly(self, "(" + delta_x + ", " + delta_y + ", " + delta_z + ")");
}
}
if (text == "clearbattleobjs")
{
// Resets the player's battlefield objvars. Works on self or on a lookat target.
// This should only be done when the player is outside of the battlefield.
obj_id target = getLookAtTarget(self);
if (target != null && target != obj_id.NULL_ID)
{
if (hasObjVar(target, battlefield.VAR_BATTLEFIELD))
removeObjVar(target, battlefield.VAR_BATTLEFIELD);
}
else
{
if (hasObjVar(self, battlefield.VAR_BATTLEFIELD))
removeObjVar(self, battlefield.VAR_BATTLEFIELD);
}
}
if (text == "nuke")
{
// Destroys everything withing 20m that is not a player. If it's not a player, it's
// destroyed, so becareful!
// This is needed in those rare cases when something from the battlefield is not properly
// cleaned-up.
obj_id[] objects = getObjectsInRange(loc, 20.0f);
for (int i = 0; i < objects.length; i++)
{
if (!isPlayer(objects[i]))
{
LOG("LOG_CHANNEL", "object deleted ->" + objects[i]);
destroyObject(objects[i]);
}
}
}
if (text == "meganuke")
{
// Same as nuke, except with a 250m range. Use this in those rare cases where the battlefield
// completely screws up, leaving lots of stray objects.
obj_id[] objects = getObjectsInRange(loc, 250.0f);
for (int i = 0; i < objects.length; i++)
{
if (!isPlayer(objects[i]))
{
LOG("LOG_CHANNEL", "object deleted ->" + objects[i]);
destroyObject(objects[i]);
}
}
}
if (text == "faction")
{
// Grants 250 faction points to whatever faction the target has joined on the battlefield.
obj_id target = getLookAtTarget(self);
if (target != null)
{
region bf = battlefield.getBattlefield(target);
int faction_id = pvpBattlefieldGetFaction(target, bf);
string faction = factions.getFactionNameByHashCode(faction_id);
sendSystemMessageTestingOnly(self, "faction ->" + faction);
factions.addFactionStanding(self, faction, 250.0f);
}
else
{
int faction_id = pvpGetAlignedFaction(self);
string faction = factions.getFactionNameByHashCode(faction_id);
sendSystemMessageTestingOnly(self, "faction ->" + faction);
factions.addFactionStanding(self, faction, 250.0f);
}
}
if (text.startsWith("warp"))
{
obj_id target = obj_id.NULL_ID;
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
LOG("LOG_CHANNEL", "tokens -> " + st.countTokens() + " nextToken ->" + st.nextToken());
if (st.hasMoreTokens())
{
string planet = st.nextToken();
LOG("LOG_CHANNEL", "planet ->" + planet);
float x = (float)utils.stringToInt(st.nextToken());
float y = (float)utils.stringToInt(st.nextToken());
float z = (float)utils.stringToInt(st.nextToken());
LOG("LOG_CHANNEL", "loc ->" + x + "/" + y + "/" + z);
warpPlayer(self, planet, x, y, z, null, 0.0f, 0.0f, 0.0f);
}
}
if (text == "bfobject")
{
region bf = battlefield.getBattlefield(self);
if (bf != null)
{
obj_id bf_object = battlefield.getMasterObjectFromRegion(bf);
sendSystemMessageTestingOnly(self, "bf_object ->" + bf_object);
}
}
if (text.startsWith("getposture"))
{
obj_id target = obj_id.NULL_ID;
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
LOG("LOG_CHANNEL", "tokens -> " + st.countTokens() + " nextToken ->" + st.nextToken());
if (st.hasMoreTokens())
{
string target_str = st.nextToken();
LOG("LOG_CHANNEL", "target_str ->" + target_str);
target = utils.stringToObjId(target_str);
}
if (isIdValid(target))
sendSystemMessageTestingOnly(self, "posture ->" + getPosture(target));
}
return SCRIPT_CONTINUE;
}
/***** MESSAGEHANDLERS *************************************************/
/***** COMMANDHANDLERS *************************************************/
/***** FUNCTIONS *******************************************************/