mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
who isn't sick of converting the freaking scripts? this negates the need
This commit is contained in:
@@ -0,0 +1,367 @@
|
||||
package script.event;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.create;
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
|
||||
public class shuttle extends script.base_script
|
||||
{
|
||||
public shuttle()
|
||||
{
|
||||
}
|
||||
public static final String[] PROMPT_TEXT =
|
||||
{
|
||||
"Enter \"setup\" to setup data, \"data\" to view current data, \"quit\" to end. After setup type \"f\" to have the shuttle do an automatic fly-by. Type \"m\" to spawn and manually control the shuttle then use \"land\" to make it land, \"leave\" to make it take off.",
|
||||
"Which of the following shuttles will spawn? Type \"lambda\", \"shuttle\", \"transport\" or \"theed transport\".",
|
||||
"Travel to the location where you'd like the shuttle to land and type \"here\" in the box to set its spawn point.",
|
||||
"Would you like the shuttle to spawn NPCs upon landing? Answer \"yes\" or \"no\".",
|
||||
"Enter the spawn name of the NPC (e.g. stormtrooper, nightsister_elder)",
|
||||
"Enter the number of NPCs to spawn.",
|
||||
"Enter a phrase that you would like to use to recover the UI. When you say this exact phrase, the UI window will re-appear."
|
||||
};
|
||||
public static final String[] TITLE =
|
||||
{
|
||||
"Standby",
|
||||
"Shuttle Type",
|
||||
"Landing Area",
|
||||
"Spawn NPCs on Landing?",
|
||||
"NPC Template",
|
||||
"Number of NPCs",
|
||||
"UI Recovery Phrase"
|
||||
};
|
||||
public static final String[] SHUTTLE_TEMPLATE =
|
||||
{
|
||||
"object/creature/npc/theme_park/lambda_shuttle.iff",
|
||||
"object/creature/npc/theme_park/player_shuttle.iff",
|
||||
"object/creature/npc/theme_park/player_transport.iff",
|
||||
"object/creature/npc/theme_park/player_transport_theed_hangar.iff"
|
||||
};
|
||||
public static final String[] SHUTTLE_NAME =
|
||||
{
|
||||
"Lambda Shuttle",
|
||||
"Shuttle",
|
||||
"Transport",
|
||||
"Transport"
|
||||
};
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!isGod(self))
|
||||
{
|
||||
detachScript(self, "event.shuttle");
|
||||
removeObjVar(self, "event.shuttle");
|
||||
sendSystemMessage(self, "You must be in God Mode to use this script.", null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int shuttleType = 0;
|
||||
float heading = 0.0f;
|
||||
int numSpawns = 0;
|
||||
String magicWord = "hi";
|
||||
int setupStep = 0;
|
||||
String template = "";
|
||||
location spawnPoint = getLocation(self);
|
||||
int setupCompleted = 0;
|
||||
setObjVar(self, "event.shuttle.shuttleType", shuttleType);
|
||||
setObjVar(self, "event.shuttle.heading", heading);
|
||||
setObjVar(self, "event.shuttle.numSpawns", numSpawns);
|
||||
setObjVar(self, "event.shuttle.magicWord", magicWord);
|
||||
setObjVar(self, "event.shuttle.setupStep", setupStep);
|
||||
setObjVar(self, "event.shuttle.template", template);
|
||||
setObjVar(self, "event.shuttle.spawnPoint", spawnPoint);
|
||||
setObjVar(self, "event.shuttle.setupCompleted", setupCompleted);
|
||||
showUI(self, self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnHearSpeech(obj_id self, obj_id speaker, String text) throws InterruptedException
|
||||
{
|
||||
String magicWord = getStringObjVar(self, "event.shuttle.magicWord");
|
||||
if (text.equals(magicWord))
|
||||
{
|
||||
showUI(self, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int showUI(obj_id self, obj_id player) throws InterruptedException
|
||||
{
|
||||
int current = getIntObjVar(self, "event.shuttle.setupStep");
|
||||
int pid = sui.inputbox(self, self, PROMPT_TEXT[current], TITLE[current], "handleUIdata", 255, false, "");
|
||||
return pid;
|
||||
}
|
||||
public int handleUIdata(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String magicWord = getStringObjVar(self, "event.shuttle.magicWord");
|
||||
int current = getIntObjVar(self, "event.shuttle.setupStep");
|
||||
int bp = sui.getIntButtonPressed(params);
|
||||
String text = sui.getInputBoxText(params);
|
||||
if (bp == sui.BP_CANCEL)
|
||||
{
|
||||
if (current == 0)
|
||||
{
|
||||
sendSystemMessage(self, "Your UI window was closed. To recover the window later for use say \"" + magicWord + "\". Please make note of this word.", null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (current > 0)
|
||||
{
|
||||
sendSystemMessage(self, "***WARNING: Your UI window was closed in the middle of setup. To recover the window and finish setup say \"" + magicWord + "\".", null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
if (text == null || text.equals(""))
|
||||
{
|
||||
sendSystemMessage(self, "You entered a null or invalid value, please try again.", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
}
|
||||
setObjVar(self, "event.shuttle.lastData", text);
|
||||
messageTo(self, "storeLastDataObjVar", null, 0, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int storeLastDataObjVar(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int setupCompleted = getIntObjVar(self, "event.shuttle.setupCompleted");
|
||||
int setupStep = getIntObjVar(self, "event.shuttle.setupStep");
|
||||
String lastDataStr = getStringObjVar(self, "event.shuttle.lastData");
|
||||
if (lastDataStr.equals("setup"))
|
||||
{
|
||||
setObjVar(self, "event.shuttle.setupStep", 1);
|
||||
setObjVar(self, "event.shuttle.setupCompleted", 0);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (setupCompleted == 1)
|
||||
{
|
||||
if (lastDataStr.equals("m"))
|
||||
{
|
||||
messageTo(self, "spawnShuttle", null, 0, false);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (lastDataStr.equals("f"))
|
||||
{
|
||||
messageTo(self, "spawnShuttle", null, 0, false);
|
||||
messageTo(self, "doFlyBy", null, 5, false);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (lastDataStr.equals("land"))
|
||||
{
|
||||
obj_id shuttle = getObjIdObjVar(self, "event.shuttle.shuttle");
|
||||
if (!isIdValid(shuttle))
|
||||
{
|
||||
sendSystemMessage(self, "WARNING: Did not find a valid shuttle to message so nothing happened.", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
messageTo(shuttle, "landShuttle", null, 1, false);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (lastDataStr.equals("leave"))
|
||||
{
|
||||
obj_id shuttle = getObjIdObjVar(self, "event.shuttle.shuttle");
|
||||
if (!isIdValid(shuttle))
|
||||
{
|
||||
sendSystemMessage(self, "WARNING: Did not find a valid shuttle to message so nothing happened.", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
messageTo(shuttle, "takeOff", null, 1, false);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
if (lastDataStr.equals("data"))
|
||||
{
|
||||
String template = getStringObjVar(self, "event.shuttle.template");
|
||||
int shuttleType = getIntObjVar(self, "event.shuttle.shuttleType");
|
||||
int numSpawns = getIntObjVar(self, "event.shuttle.numSpawns");
|
||||
float offset = getFloatObjVar(self, "event.shuttle.offset");
|
||||
sendSystemMessage(self, "Shuttle: " + SHUTTLE_NAME[shuttleType] + ". Number of Spawns: " + numSpawns + " . Spawn Template: " + template + ".", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (lastDataStr.equals("quit"))
|
||||
{
|
||||
removeObjVar(self, "event.shuttle");
|
||||
detachScript(self, "event.shuttle");
|
||||
sendSystemMessage(self, "Many thank you for your playing.", null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (setupStep == 0)
|
||||
{
|
||||
sendSystemMessage(self, "Enter \"setup\" to setup data, \"data\" to view current data, \"quit\" to end. After setup type \"f\" to have the shuttle do an automatic fly-by. Type \"m\" to spawn and manually control the shuttle then use \"land\" to make it land, \"leave\" to make it take off.", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (setupStep == 1)
|
||||
{
|
||||
if (lastDataStr.equals("lambda"))
|
||||
{
|
||||
setObjVar(self, "event.shuttle.shuttleType", 0);
|
||||
setObjVar(self, "event.shuttle.setupStep", 2);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (lastDataStr.equals("shuttle"))
|
||||
{
|
||||
setObjVar(self, "event.shuttle.shuttleType", 1);
|
||||
setObjVar(self, "event.shuttle.setupStep", 2);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (lastDataStr.equals("transport"))
|
||||
{
|
||||
setObjVar(self, "event.shuttle.shuttleType", 2);
|
||||
setObjVar(self, "event.shuttle.setupStep", 2);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (lastDataStr.equals("theed transport"))
|
||||
{
|
||||
setObjVar(self, "event.shuttle.shuttleType", 3);
|
||||
setObjVar(self, "event.shuttle.setupStep", 2);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
sendSystemMessage(self, "You must type \"lambda\", \"shuttle\", \"transport\" or \"theed transport\". Try again.", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (setupStep == 2)
|
||||
{
|
||||
if (lastDataStr.equals("here"))
|
||||
{
|
||||
location spawnPoint = getLocation(self);
|
||||
float heading = getYaw(self);
|
||||
setObjVar(self, "event.shuttle.heading", heading);
|
||||
setObjVar(self, "event.shuttle.spawnPoint", spawnPoint);
|
||||
setObjVar(self, "event.shuttle.setupStep", 3);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
sendSystemMessage(self, "You must stand where you want the shuttle to land and type \"here\". Try again.", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (setupStep == 3)
|
||||
{
|
||||
if (lastDataStr.equals("yes"))
|
||||
{
|
||||
setObjVar(self, "event.shuttle.setupStep", 4);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (lastDataStr.equals("no"))
|
||||
{
|
||||
setObjVar(self, "event.shuttle.numSpawns", 0);
|
||||
setObjVar(self, "event.shuttle.setupStep", 6);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
sendSystemMessage(self, "You must answer either \"yes\" or \"no\". Try again.", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (setupStep == 4)
|
||||
{
|
||||
setObjVar(self, "event.shuttle.template", lastDataStr);
|
||||
setObjVar(self, "event.shuttle.setupStep", 5);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (setupStep == 5)
|
||||
{
|
||||
int lastDataInt = utils.stringToInt(lastDataStr);
|
||||
if (lastDataInt >= 0 && lastDataInt <= 10)
|
||||
{
|
||||
setObjVar(self, "event.shuttle.numSpawns", lastDataInt);
|
||||
setObjVar(self, "event.shuttle.setupStep", 6);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
sendSystemMessage(self, "You must specify a number between 0 and 10. Try again.", null);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (setupStep == 6)
|
||||
{
|
||||
setObjVar(self, "event.shuttle.magicWord", lastDataStr);
|
||||
setObjVar(self, "event.shuttle.setupStep", 0);
|
||||
sendSystemMessage(self, TITLE[setupStep] + ": " + lastDataStr, null);
|
||||
setObjVar(self, "event.shuttle.setupCompleted", 1);
|
||||
messageTo(self, "continueCollectingData", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int continueCollectingData(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
showUI(self, self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int spawnShuttle(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int numSpawns = getIntObjVar(self, "event.shuttle.numSpawns");
|
||||
location spawnPoint = getLocationObjVar(self, "event.shuttle.spawnPoint");
|
||||
float heading = getFloatObjVar(self, "event.shuttle.heading");
|
||||
int shuttleType = getIntObjVar(self, "event.shuttle.shuttleType");
|
||||
obj_id shuttle = create.object(SHUTTLE_TEMPLATE[shuttleType], spawnPoint);
|
||||
if (numSpawns > 0)
|
||||
{
|
||||
String template = getStringObjVar(self, "event.shuttle.template");
|
||||
setObjVar(shuttle, "event.shuttle.template", template);
|
||||
}
|
||||
setObjVar(self, "event.shuttle.shuttle", shuttle);
|
||||
setObjVar(shuttle, "event.shuttle.owner", self);
|
||||
setObjVar(shuttle, "event.shuttle.numSpawns", numSpawns);
|
||||
setObjVar(shuttle, "event.shuttle.shuttleType", shuttleType);
|
||||
if (shuttleType < 3)
|
||||
{
|
||||
setYaw(shuttle, heading + 180);
|
||||
}
|
||||
else
|
||||
{
|
||||
setYaw(shuttle, heading);
|
||||
}
|
||||
setName(shuttle, SHUTTLE_NAME[shuttleType]);
|
||||
detachScript(shuttle, "ai.ai");
|
||||
detachScript(shuttle, "ai.creature_combat");
|
||||
detachScript(shuttle, "skeleton.humanoid");
|
||||
detachScript(shuttle, "systems.combat.combat_actions");
|
||||
detachScript(shuttle, "systems.combat.credit_for_kills");
|
||||
stop(shuttle);
|
||||
if (shuttleType > 0)
|
||||
{
|
||||
setPosture(shuttle, POSTURE_PRONE);
|
||||
}
|
||||
attachScript(shuttle, "event.shuttle_control");
|
||||
sendSystemMessage(self, "Created shuttle with OID " + shuttle, null);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int doFlyBy(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id shuttle = getObjIdObjVar(self, "event.shuttle.shuttle");
|
||||
messageTo(shuttle, "performFlyBy", null, 0, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int getRidOfOwner(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, "event.shuttle.shuttle");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user