Files
dsrc/sku.0/sys.server/compiled/game/script/working/justin/utilities.script
T

207 lines
4.9 KiB
Plaintext

include library.create;
include library.quests;
include library.chat;
include library.factions;
include library.utils;
include library.fs_quests;
include java.io.File;
include java.io.FileInputStream;
include java.io.FileWriter;
include java.io.InputStream;
include java.lang.Math;
include java.lang.Runtime;
void usage(obj_id self)
{
chat.chat(self, "Usagement!: utility <cmd> [<args ...>]");
chat.chat(self, "commands: ");
chat.chat(self, "grantSkills - grant all skills to yourself");
chat.chat(self, "quest - execute a quest command dammit!!?");
chat.chat(self, " activate <name> - activate a quest named <name> from player.quests datatable");
chat.chat(self, " clear - clear all quest bits");
chat.chat(self, "spawn <name> - spawn a creature from creatures.tab");
chat.chat(self, "faction <faction name> <pounts - set your faction standing");
chat.chat(self, "makeFsVillageEligible");
chat.chat(self, "makeFsVillageIneligible");
chat.chat(self, "unlock <branch> - unlock fs branch using the fs_quests library. E.g. force_sensitive_combat_prowess_ranged_speed");
}
trigger OnSpeaking(string text)
{
if(text.startsWith("utility"))
{
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
st.nextToken();
String cmd = st.nextToken();
if(cmd == "grantSkills")
{
grantSkill(self, "combat_unarmed_master");
obj_id pInv = utils.getInventoryContainer( self );
if(isIdValid(pInv))
{
createObject("object/tangible/terminal/terminal_character_builder.iff", pInv, "");
}
/*
int numRows = dataTableGetNumRows("datatables/skill/skills.iff");
int iter = 0;
for(iter = 0; iter < numRows; ++iter)
{
String skillName = dataTableGetString("datatables/skill/skills.iff", iter, "NAME");
if(! hasSkill(self, skillName))
{
grantSkill(self, skillName);
}
}
*/
}
else if(cmd == "completed")
{
String arg1 = st.nextToken();
if(arg1 != null)
{
Object[] params = new Object[3];
params[0] = self;
params[1] = arg1;
params[2] = new Boolean(true);
script_entry.runScripts("OnForceSensitiveQuestCompleted", params);
}
}
else if(cmd == "showOff")
{
chat.chat(self, "Hi there BANDIT!!!");
}
else if(cmd == "quest")
{
String arg1 = st.nextToken();
if(arg1 != null)
{
if(arg1 == "activate")
{
String arg2 = st.nextToken();
if(arg2 != null)
{
//quests.activate(arg2, self, null);
int questId = questGetQuestId(arg2);
questActivateQuest(questId, self, null);
}
}
else if(arg1 == "clear")
{
String arg2 = st.nextToken();
if(arg2 != null)
{
int questId = questGetQuestId(arg2);
questClearQuest(questId, self);
}
}
}
}
else if(cmd == "faction")
{
String arg1 = st.nextToken();
if(arg1 != null)
{
String arg2 = st.nextToken();
if(arg2 != null)
{
int points = utils.stringToInt(arg2);
factions.setFactionStanding(self, arg1, points);
chat.chat(self, "set faction standing for " + arg1 + " to " + points);
}
else
{
usage(self);
}
}
else
{
usage(self);
}
}
else if(cmd == "requestLocation")
{
requestLocation (self, "testrequest", getLocation(self), 512.0f, 128.0f, true, true);
}
else if(cmd == "spawn")
{
String arg1 = st.nextToken();
if(arg1 != null)
{
location l = getLocation(self);
l.x += 2;
obj_id creature = create.createCreature(arg1, l, true);
}
}
else if(cmd == "makeFsVillageEligible")
{
fs_quests.makeVillageEligible(self);
}
else if(cmd == "makeFsVillageIneligible")
{
removeObjVar(self, fs_quests.VAR_VILLAGE_ELIGIBLE);
}
else if(cmd == "unlock")
{
String arg1 = st.nextToken();
if(arg1 != null)
{
boolean success = fs_quests.unlockBranch(self, arg1);
if(! success)
{
chat.chat(self, "could not unlock " + arg1);
}
else
{
chat.chat(self, arg1 + " has been unlocked");
}
}
}
else if(cmd == "rad2deg")
{
String arg1 = st.nextToken();
if(arg1 != null)
{
float rads = utils.stringToFloat(arg1);
float degs = (float)Math.toDegrees(rads);
chat.chat(self, "" + degs);
}
}
else if(cmd == "cover")
{
chat.chat(self, "calling setCreatureCoverVisibility("+ self + ", true)");
setCreatureCoverVisibility(self, false);
}
else if(cmd == "uncover")
{
setCreatureCoverVisibility(self, true);
}
else if(cmd == "getcover")
{
if(getCreatureCoverVisibility(self))
{
chat.chat(self, "I am visible");
}
else
{
chat.chat(self, "I am not visible");
}
}
else
{
usage(self);
}
}
return SCRIPT_CONTINUE;
}
trigger OnLocationReceived (string locationId, obj_id locationObject, location locationLocation, float locationRadius)
{
LOG("testlocation", "locationId=" + locationId);
chat.chat(self, "locationId=" + locationId);
chat.chat(self, "locationObject = " + locationObject);
destroyObject(locationObject);
return SCRIPT_CONTINUE;
}