diff --git a/sku.0/sys.server/compiled/game/script/gm/.gitignore b/sku.0/sys.server/compiled/game/script/gm/.gitignore deleted file mode 100644 index 8b1378917..000000000 --- a/sku.0/sys.server/compiled/game/script/gm/.gitignore +++ /dev/null @@ -1 +0,0 @@ - diff --git a/sku.0/sys.server/compiled/game/script/gm/cmd.java b/sku.0/sys.server/compiled/game/script/gm/cmd.java new file mode 100644 index 000000000..c4bcdf571 --- /dev/null +++ b/sku.0/sys.server/compiled/game/script/gm/cmd.java @@ -0,0 +1,4283 @@ +package script.gm; + +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 java.util.StringTokenizer; +import script.library.arena; +import script.library.badge; +import script.library.city; +import script.library.colors; +import script.library.craftinglib; +import script.library.create; +import script.library.dump; +import script.library.factions; +import script.library.force_rank; +import script.library.fs_counterstrike; +import script.library.fs_dyn_village; +import script.library.fs_quests; +import script.library.gm; +import script.library.hue; +import script.library.jedi_trials; +import script.library.loot; +import script.library.money; +import script.library.npe; +import script.library.quests; +import script.library.pclib; +import script.library.player_structure; +import script.library.ship_ai; +import script.library.skill; +import script.library.sui; +import script.library.target_dummy; +import script.library.trace; +import script.library.utils; +import script.library.veteran_deprecated; +import script.library.xp; +import script.library.weapons; +import script.library.static_item; + +public class cmd extends script.base_script +{ + public cmd() + { + } + public int cmdGetPlayerId(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /getPlayerId "); + return SCRIPT_CONTINUE; + } + StringTokenizer st = new StringTokenizer(params); + String name = st.nextToken(); + obj_id playerId = getPlayerIdFromFirstName(toLower(name)); + if (isIdValid(playerId)) + { + sendSystemMessageTestingOnly(self, "getPlayerId: player '" + name + "' has object id: " + playerId); + } + else + { + sendSystemMessageTestingOnly(self, "getPlayerId: The system was unable to find a player named '" + name + "'"); + } + return SCRIPT_CONTINUE; + } + public int cmdAiIgnore(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + obj_id ship = getPilotedShip(self); + if (hasObjVar(self, "gm")) + { + removeObjVar(self, "gm"); + if (isIdValid(ship)) + { + ship_ai.unitSetAutoAggroImmune(ship, false); + ship_ai.unitSetDamageAggroImmune(ship, false); + } + sendSystemMessageTestingOnly(self, "aiIgnore[OFF]: AI will now aggro you as normal and fight back."); + } + else + { + setObjVar(self, "gm", 1); + if (isIdValid(ship)) + { + ship_ai.unitRemoveFromAllAttackTargetLists(ship); + ship_ai.unitSetAutoAggroImmune(ship, true); + ship_ai.unitSetDamageAggroImmune(ship, true); + } + sendSystemMessageTestingOnly(self, "aiIgnore[ON]: AI will no longer aggro you or fight back."); + } + return SCRIPT_CONTINUE; + } + public int cmdForceCommand(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target) || !isPlayer(target) || params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /forceCommand -target (with lookat target)"); + return SCRIPT_CONTINUE; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + sendSystemMessageTestingOnly(self, "[Syntax] /forceCommand -target (with lookat target)"); + return SCRIPT_CONTINUE; + } + StringTokenizer st = new StringTokenizer(params); + String cmd = st.nextToken(); + obj_id cmdTarget = null; + String cmdParams = ""; + while (st.hasMoreTokens()) + { + String tmp = st.nextToken(); + if (tmp != null && !tmp.equalsIgnoreCase("")) + { + cmdParams += tmp + " "; + } + } + cmdParams.trim(); + sendSystemMessageTestingOnly(self, "/forceCommand: attempting to queue command: '" + cmd + " " + cmdParams + "' for (" + target + ")" + getName(target)); + return SCRIPT_CONTINUE; + } + public int cmdMoney(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + dictionary d = gm.parseTarget(params, target, "CREDITS"); + if (d == null) + { + return SCRIPT_CONTINUE; + } + else if (d.isEmpty()) + { + } + else + { + params = d.getString("params"); + obj_id oid = d.getObjId("oid"); + if (isIdValid(oid)) + { + target = oid; + } + else + { + target = self; + } + } + if (params == null || params.equalsIgnoreCase("")) + { + showMoneySyntax(self); + return SCRIPT_CONTINUE; + } + StringTokenizer st = new StringTokenizer(toLower(params)); + String arg = st.nextToken(); + if (arg.equalsIgnoreCase("balance")) + { + gm.showMoneyStatus(self, target); + return SCRIPT_CONTINUE; + } + else if (arg.equalsIgnoreCase("wipe")) + { + queueCommand(self, (2070221263), target, "cash 0", COMMAND_PRIORITY_DEFAULT); + queueCommand(self, (2070221263), target, "bank 0", COMMAND_PRIORITY_DEFAULT); + return SCRIPT_CONTINUE; + } + if (st.hasMoreTokens()) + { + String sAmt = st.nextToken(); + if (arg.equalsIgnoreCase("cash")) + { + if (gm.setBalance(target, money.MT_CASH, sAmt)) + { + sendSystemMessageTestingOnly(self, "[CREDITS] Processing CASH update: (" + target + ")" + utils.getStringName(target) + " amt = " + sAmt); + } + else + { + sendSystemMessageTestingOnly(self, "[CREDITS] System rejected the CASH update: (" + target + ")" + utils.getStringName(target) + " amt = " + sAmt); + } + return SCRIPT_CONTINUE; + } + else if (arg.equalsIgnoreCase("bank")) + { + if (gm.setBalance(target, money.MT_BANK, sAmt)) + { + sendSystemMessageTestingOnly(self, "[CREDITS] Processing BANK update: (" + target + ")" + utils.getStringName(target) + " amt = " + sAmt); + } + else + { + sendSystemMessageTestingOnly(self, "[CREDITS] System rejected the BANK update: (" + target + ")" + utils.getStringName(target) + " amt = " + sAmt); + } + return SCRIPT_CONTINUE; + } + } + showMoneySyntax(self); + return SCRIPT_CONTINUE; + } + public void showMoneySyntax(obj_id self) throws InterruptedException + { + sendSystemMessageTestingOnly(self, "[Syntax] /credits [-target]|[-id:] cash|bank (+|-)"); + sendSystemMessageTestingOnly(self, "[Syntax] /credits [-target]|[-id:] balance"); + } + public int cmdBroadcast(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + queueCommand(self, (-351572629), target, params, COMMAND_PRIORITY_DEFAULT); + return SCRIPT_CONTINUE; + } + public int cmdBroadcastPlanet(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (params != null && !params.equalsIgnoreCase("")) + { + sendSystemMessagePlanetTestingOnly(params); + } + else + { + sendSystemMessageTestingOnly(self, "[Syntax] /broadcastPlanet "); + return SCRIPT_CONTINUE; + } + return SCRIPT_CONTINUE; + } + public int cmdBroadcastGalaxy(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (params != null && !params.equalsIgnoreCase("")) + { + sendSystemMessageGalaxyTestingOnly(params); + } + else + { + sendSystemMessageTestingOnly(self, "[Syntax] /broadcastGalaxy "); + return SCRIPT_CONTINUE; + } + return SCRIPT_CONTINUE; + } + public int cmdBroadcastArea(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + final float MAX_RANGE = 256.0f; + final String KEYWORD_RANGE = "-range:"; + float range = 0f; + String message = ""; + if (params.indexOf(KEYWORD_RANGE) > -1) + { + dictionary d = parseRange(params); + range = d.getFloat("range"); + message = d.getString("params"); + if (range <= 0) + { + sendSystemMessageTestingOnly(self, "[Error] /broadcastArea: Invalid broadcast range specified"); + sendSystemMessageTestingOnly(self, "[Syntax] /broadcastArea -range: "); + return SCRIPT_CONTINUE; + } + if (message == null || message.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Error] /broadcastArea: Invalid or no broadcast message specified"); + sendSystemMessageTestingOnly(self, "[Syntax] /broadcastArea -range: "); + return SCRIPT_CONTINUE; + } + } + else + { + sendSystemMessageTestingOnly(self, "[Syntax] /broadcastArea -range: "); + sendSystemMessageTestingOnly(self, "[Example] /broadcastArea -range:100 Hello world!"); + return SCRIPT_CONTINUE; + } + if (range > MAX_RANGE) + { + range = MAX_RANGE; + sendSystemMessageTestingOnly(self, "[Warning] /broadcastArea: Maximum range is " + MAX_RANGE + " meters. Your broadcast has been limited to that area."); + } + obj_id[] players = getAllPlayers(getLocation(self), range); + if (players == null || players.length == 0) + { + sendSystemMessageTestingOnly(self, "[Error] /broadcastArea: No players within range"); + return SCRIPT_CONTINUE; + } + for (int i = 0; i < players.length; i++) + { + if (isIdValid(players[i]) && isPlayer(players[i])) + { + sendSystemMessageTestingOnly(players[i], message); + } + } + return SCRIPT_CONTINUE; + } + public dictionary parseRange(String params) throws InterruptedException + { + final String KEYWORD_RANGE = "-range:"; + dictionary ret = new dictionary(); + if (params == null || params.equalsIgnoreCase("")) + { + return ret; + } + int idx = params.indexOf(KEYWORD_RANGE); + if (idx == -1) + { + return ret; + } + String retString = ""; + float retRange = Float.NEGATIVE_INFINITY; + StringTokenizer st = new StringTokenizer(params); + while (st.hasMoreTokens()) + { + String arg = st.nextToken(); + if (arg.startsWith(KEYWORD_RANGE)) + { + String sRange = arg.substring(KEYWORD_RANGE.length()); + retRange = utils.stringToFloat(sRange); + } + else + { + retString += arg + " "; + } + } + if (retRange != Float.NEGATIVE_INFINITY) + { + ret.put("range", retRange); + ret.put("params", retString.trim()); + } + return ret; + } + public int cmdKill(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target) || !isMob(target)) + { + sendSystemMessageTestingOnly(self, "/kill: you must have a valid creature target to use this command"); + return SCRIPT_CONTINUE; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + sendSystemMessageTestingOnly(self, "[Syntax] /kill -target"); + return SCRIPT_CONTINUE; + } + if (isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/kill: you must use /killPlayer to kill a player!"); + } + else + { + if (!isIncapacitated(target)) + { + setPosture(target, POSTURE_INCAPACITATED); + } + } + return SCRIPT_CONTINUE; + } + public int cmdKillPlayer(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target) || !isPlayer(target) || isDead(target)) + { + sendSystemMessageTestingOnly(self, "/killPlayer: you must have a valid, alive player target to use this command"); + return SCRIPT_CONTINUE; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + sendSystemMessageTestingOnly(self, "[Syntax] /killPlayer -target"); + return SCRIPT_CONTINUE; + } + setPosture(target, POSTURE_INCAPACITATED); + pclib.coupDeGrace(target, target, true, true); + return SCRIPT_CONTINUE; + } + public int cmdFreezePlayer(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (params.indexOf(gm.KEYWORD_ID) > -1) + { + dictionary ret = gm.parseObjId(params); + target = ret.getObjId("oid"); + } + if (isIdValid(target) && isGameObjectTypeOf(getGameObjectType(target), GOT_ship)) + { + target = getShipPilot(target); + } + if (isIdValid(target) && isPlayer(target)) + { + setState(target, STATE_FROZEN, true); + } + else + { + sendSystemMessageTestingOnly(self, "[Syntax] /freezePlayer [-target]|[-id:]"); + } + return SCRIPT_CONTINUE; + } + public int cmdUnfreezePlayer(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (params.indexOf(gm.KEYWORD_ID) > -1) + { + dictionary ret = gm.parseObjId(params); + target = ret.getObjId("oid"); + } + if (isIdValid(target) && isGameObjectTypeOf(getGameObjectType(target), GOT_ship)) + { + target = getShipPilot(target); + } + if (isIdValid(target) && isPlayer(target)) + { + setState(target, STATE_FROZEN, false); + } + else + { + sendSystemMessageTestingOnly(self, "[Syntax] /unfreezePlayer [-target]|[-id:]"); + } + return SCRIPT_CONTINUE; + } + public int cmdShowFactionInformation(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + dictionary ret = gm.parseTarget(params, target, "showFactionInformation"); + obj_id tmpTarget = ret.getObjId("oid"); + if (isIdValid(tmpTarget)) + { + target = tmpTarget; + } + else + { + target = self; + } + params = ret.getString("params"); + if (params == null) + { + params = ""; + } + } + if (!isMob(target) && !hasObjVar(target, "pvpCanAttack")) + { + String name = getEncodedName(target); + string_id sid_name = utils.unpackString(name); + if (sid_name != null) + { + name = getString(sid_name); + } + sendSystemMessageTestingOnly(self, "/showFactionInformation: (" + target + ")" + name + " is not a valid target"); + return SCRIPT_CONTINUE; + } + gm.showFactionInformation(self, target); + return SCRIPT_CONTINUE; + } + public int cmdSetFaction(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + if (params.indexOf(gm.KEYWORD_ID) > -1) + { + dictionary d = gm.parseObjId(params); + obj_id tmpTarget = d.getObjId("oid"); + if (isIdValid(tmpTarget)) + { + target = tmpTarget; + } + else + { + sendSystemMessageTestingOnly(self, "/setFaction: Unable to parse a valid object id!"); + return SCRIPT_CONTINUE; + } + params = d.getString("params"); + } + else + { + target = self; + } + } + boolean isAdHoc = false; + if (params.indexOf(gm.KEYWORD_ADHOC) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_ADHOC); + isAdHoc = true; + } + if (params == null || params.equalsIgnoreCase("") || (isPlayer(target) && isAdHoc)) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setFaction [-target] (declared|covert|onleave) "); + sendSystemMessageTestingOnly(self, "[Syntax] /setFaction [-target] clear"); + sendSystemMessageTestingOnly(self, "[Syntax] /setFaction [-target] [-adhoc] (declared|covert) (AI ONLY)"); + return SCRIPT_CONTINUE; + } + StringTokenizer st = new StringTokenizer(toLower(params)); + String faction = ""; + boolean declared = false; + boolean onleave = false; + boolean makeNeutral = false; + boolean clearFlags = false; + while (st.hasMoreTokens()) + { + String arg = st.nextToken(); + if (arg.equalsIgnoreCase("declared")) + { + declared = true; + } + else if (arg.equalsIgnoreCase("covert")) + { + declared = false; + } + else if (arg.equalsIgnoreCase("neutral")) + { + makeNeutral = true; + } + else if (arg.equalsIgnoreCase("onleave")) + { + onleave = true; + } + else if (arg.equalsIgnoreCase("clear")) + { + clearFlags = clearFlags; + } + else + { + if (arg.equalsIgnoreCase("imperial")) + { + faction = "Imperial"; + } + else if (arg.equalsIgnoreCase("rebel")) + { + faction = "Rebel"; + } + else + { + faction = arg; + } + } + } + boolean updateFaction = false; + int facNum = factions.AD_HOC_FACTION; + if (faction != null && !faction.equalsIgnoreCase("")) + { + facNum = factions.getFactionNumber(faction); + if (facNum == factions.AD_HOC_FACTION) + { + if (!isPlayer(target)) + { + if (!isAdHoc) + { + sendSystemMessageTestingOnly(self, "/setFaction: you must use '-adhoc' to set AIs to non-standard factions"); + return SCRIPT_CONTINUE; + } + else + { + sendSystemMessageTestingOnly(self, "/setFaction: attempting to update " + utils.getStringName(target) + "'s faction!"); + factions.setFaction(target, faction); + return SCRIPT_CONTINUE; + } + } + else + { + sendSystemMessageTestingOnly(self, "/setFaction: you may not set players to adhoc factions!"); + return SCRIPT_CONTINUE; + } + } + } + if (clearFlags) + { + sendSystemMessageTestingOnly(self, "/setFaction: clearing all temp enemy flags..."); + pvpRemoveAllTempEnemyFlags(target); + } + if (makeNeutral) + { + sendSystemMessageTestingOnly(self, "/setFaction: assigning neutral status..."); + pvpMakeNeutral(target); + } + else + { + if (faction != null && !faction.equalsIgnoreCase("") && facNum != factions.AD_HOC_FACTION) + { + int factionHashCode = dataTableGetInt(factions.FACTION_TABLE, facNum, "pvpFaction"); + if (factionHashCode != factions.AD_HOC_FACTION && factionHashCode != 0) + { + pvpSetAlignedFaction(target, factionHashCode); + } + else + { + sendSystemMessageTestingOnly(self, "/setFaction: unable to update " + utils.getStringName(target) + "'s faction to '" + faction + "'!"); + return SCRIPT_CONTINUE; + } + } + if (declared) + { + pvpMakeDeclared(target); + } + else if (onleave) + { + pvpMakeOnLeave(target); + } + else + { + pvpMakeCovert(target); + } + } + if (isMob(target) || hasObjVar(target, "pvpCanAttack")) + { + sendSystemMessageTestingOnly(self, "/setFaction: displaying " + utils.getStringName(target) + "'s updated faction information!"); + queueCommand(self, (-532090019), target, "", COMMAND_PRIORITY_DEFAULT); + } + return SCRIPT_CONTINUE; + } + public int cmdSetFactionStanding(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setFactionStanding: use /setFaction to set AI factions"); + return SCRIPT_CONTINUE; + } + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setFactionStanding [-target] (+|-)"); + return SCRIPT_CONTINUE; + } + StringTokenizer st = new StringTokenizer(toLower(params)); + if (st.countTokens() != 2) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setFactionStanding [-target] (+|-)"); + return SCRIPT_CONTINUE; + } + String faction = st.nextToken(); + if (faction.equalsIgnoreCase("imperial")) + { + faction = "Imperial"; + } + else if (faction.equalsIgnoreCase("rebel")) + { + faction = "Rebel"; + } + int mod = 0; + String sAmt = st.nextToken(); + if (sAmt.startsWith("-")) + { + mod = -1; + } + if (sAmt.startsWith("+")) + { + mod = 1; + sAmt = sAmt.substring(1); + } + float amt = utils.stringToFloat(sAmt); + if (amt == Float.NEGATIVE_INFINITY) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setFactionStanding [-target] (+|-)"); + return SCRIPT_CONTINUE; + } + int facNum = factions.AD_HOC_FACTION; + if (faction != null && !faction.equalsIgnoreCase("")) + { + facNum = factions.getFactionNumber(faction); + if (facNum == factions.AD_HOC_FACTION) + { + sendSystemMessageTestingOnly(self, "/setFactionStanding: you may not set standing to non-standard factions"); + return SCRIPT_CONTINUE; + } + else + { + if (mod != 0) + { + sendSystemMessageTestingOnly(self, "/setFactionStanding: modifying '" + faction + "' by " + amt); + factions.addFactionStanding(target, faction, amt); + } + else + { + sendSystemMessageTestingOnly(self, "/setFactionStanding: setting '" + faction + "' to " + amt); + factions.setFactionStanding(target, faction, amt); + } + } + } + sendSystemMessageTestingOnly(self, "/setFactionStanding: displaying " + utils.getStringName(target) + "'s updated faction information!"); + queueCommand(self, (-532090019), target, "", COMMAND_PRIORITY_DEFAULT); + return SCRIPT_CONTINUE; + } + public int cmdGetRank(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target) || !isPlayer(target)) + { + target = self; + } + int rank = pvpGetCurrentGcwRank(target); + String faction = factions.getFaction(target); + sendSystemMessageTestingOnly(self, "(" + target + ") " + getName(target) + "'s rank = (" + rank + ") " + getString(new string_id("faction_recruiter", factions.getRankName(rank, faction)))); + return SCRIPT_CONTINUE; + } + public int cmdSetRank(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (utils.hasScriptVar(self, "setRank.pid")) + { + int oldpid = utils.getIntScriptVar(self, "setRank.pid"); + sui.closeSUI(self, oldpid); + utils.removeScriptVarTree(self, "setRank"); + } + dictionary d = gm.parseTarget(params, target, "SETRANK"); + if (d == null) + { + return SCRIPT_CONTINUE; + } + else if (d.isEmpty()) + { + } + else + { + params = d.getString("params"); + obj_id oid = d.getObjId("oid"); + if (isIdValid(oid)) + { + target = oid; + } + else + { + target = self; + } + } + if (!isIdValid(target) || !isPlayer(target)) + { + target = self; + } + String faction = factions.getFaction(target); + if (params == null || params.equalsIgnoreCase("")) + { + int rank = pvpGetCurrentGcwRank(target); + String title = "Set Player Rank"; + String prompt = "Select the desired rank to set the player to.\n\n"; + prompt += "Target = (" + target + ") " + getName(target) + "\n"; + prompt += "Current Rank = (" + rank + ") " + getString(new string_id("faction_recruiter", factions.getRankName(rank, faction))); + Vector entries = new Vector(); + entries.setSize(0); + for (int i = 0; i <= factions.MAXIMUM_RANK; i++) + { + entries = utils.addElement(entries, "(" + i + ") " + getString(new string_id("faction_recruiter", factions.getRankName(i, faction)))); + } + int pid = sui.listbox(self, self, prompt, sui.OK_CANCEL, title, entries, "handleSetRankSelection"); + if (pid > -1) + { + utils.setScriptVar(self, "setRank.pid", pid); + utils.setScriptVar(self, "setRank.target", target); + gm.attachHandlerScript(self); + } + } + int newrank = utils.stringToInt(params); + if (newrank < 0 || newrank > factions.MAXIMUM_RANK) + { + sendSystemMessageTestingOnly(self, "/setRank: unable to parse rank. Please choose a rank between 0 & " + factions.MAXIMUM_RANK); + return SCRIPT_CONTINUE; + } + if (factions.setRank(target, newrank)) + { + int urank = pvpGetCurrentGcwRank(target); + sendSystemMessageTestingOnly(self, "(" + target + ") " + getName(target) + "'s rank updated to (" + urank + ") " + getString(new string_id("faction_recruiter", factions.getRankName(urank, faction)))); + } + else + { + sendSystemMessageTestingOnly(self, "The system was unable to update (" + target + ") " + getName(target) + "'s rank updated to (" + newrank + ") " + getString(new string_id("faction_recruiter", factions.getRankName(newrank, faction)))); + } + return SCRIPT_CONTINUE; + } + public int cmdGrantSkill(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/grantSkill: you must be targetting a player to use this command"); + return SCRIPT_CONTINUE; + } + String prompt = "You are attempting to modify the skills for \\#pcontrast3 " + getName(target) + "\\#..\n\n"; + prompt += "Please choose an option:"; + int pid = sui.listbox(self, self, prompt, sui.OK_CANCEL, "GM GRANT SKILL", gm.ROADMAP_SKILL_OPTIONS, "handleGmGrantSkillOptions", true, false); + utils.setScriptVar(self, "gmGrantSkill.target", target); + return SCRIPT_CONTINUE; + } + public int cmdRevokeSkill(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/revokeSkill: you must be targetting a player to use this command"); + return SCRIPT_CONTINUE; + } + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /revokeSkill [-target] "); + return SCRIPT_CONTINUE; + } + params = toLower(params); + String[] skills = dataTableGetStringColumnNoDefaults(skill.TBL_SKILL, "NAME"); + if (skills == null || skills.length == 0) + { + sendSystemMessageTestingOnly(self, "/grantSkill: unable to retrieve canonical skill listing!"); + return SCRIPT_CONTINUE; + } + if ((toLower(params)).equalsIgnoreCase("list")) + { + listSkills(self, skills); + return SCRIPT_CONTINUE; + } + revokeSkill(target, params); + sendSystemMessageTestingOnly(self, "You revoke " + params + " from (" + target + ") " + utils.getStringName(target)); + CustomerServiceLog("Skill", "CSR: (" + self + ") " + getName(self) + " has revoked skill '" + params + "' from (" + target + ") " + utils.getStringName(target)); + return SCRIPT_CONTINUE; + } + public void listSkills(obj_id self, String[] skills) throws InterruptedException + { + Vector entries = new Vector(); + entries.setSize(0); + for (int i = 0; i < skills.length; i++) + { + String stringname = getString(new string_id("skl_n", skills[i])); + if (stringname != null && !stringname.equalsIgnoreCase("")) + { + String linedata = "(" + stringname + ") " + skills[i]; + entries = utils.addElement(entries, linedata); + } + } + String listTitle = "SKILL LISTING"; + String listPrompt = "A listing of all the currently used skills"; + sui.listbox(self, self, listPrompt, sui.OK_ONLY, listTitle, entries, "noHandler", true, false); + } + public int cmdSearchCorpse(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (utils.hasScriptVar(self, gm.SCRIPTVAR_SEARCHCORPSE_PID)) + { + int pid = utils.getIntScriptVar(self, gm.SCRIPTVAR_SEARCHCORPSE_PID); + forceCloseSUIPage(pid); + utils.removeScriptVar(self, gm.SCRIPTVAR_SEARCHCORPSE_TARGET); + utils.removeScriptVar(self, gm.SCRIPTVAR_SEARCHCORPSE_PID); + } + if (!isIdValid(target)) + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/searchCorpse: you can only review player corpse history"); + return SCRIPT_CONTINUE; + } + if (!hasObjVar(target, pclib.VAR_CORPSE_BASE)) + { + sendSystemMessageTestingOnly(self, "/searchCorpse: (" + target + ") " + utils.getStringName(target) + " has no corpse history!"); + return SCRIPT_CONTINUE; + } + boolean showStamp = true; + boolean showKiller = true; + obj_id[] corpses = utils.getObjIdBatchObjVar(target, pclib.VAR_CORPSE_ID); + if (corpses == null || corpses.length == 0) + { + removeObjVar(target, pclib.VAR_CORPSE_BASE); + sendSystemMessageTestingOnly(self, "/searchCorpse: (" + target + ") " + utils.getStringName(target) + " has no corpse history!"); + return SCRIPT_CONTINUE; + } + int[] stamps = utils.getIntBatchObjVar(target, pclib.VAR_CORPSE_STAMP); + if (stamps == null || stamps.length == 0 || stamps.length != corpses.length) + { + sendSystemMessageTestingOnly(self, "/searchCorpse: (" + target + ") " + utils.getStringName(target) + " has a bad corpse stamp history!"); + showStamp = false; + } + obj_id[] killers = utils.getObjIdBatchObjVar(target, pclib.VAR_CORPSE_KILLER); + if (killers == null || killers.length == 0 || killers.length != corpses.length) + { + sendSystemMessageTestingOnly(self, "/searchCorpse: (" + target + ") " + utils.getStringName(target) + " has a bad killer history!"); + showKiller = false; + } + Vector entries = new Vector(); + entries.setSize(0); + for (int i = 0; i < corpses.length; i++) + { + String linedata = "id:" + corpses[i]; + if (showKiller) + { + linedata += " k:" + killers[i]; + } + if (showStamp) + { + linedata += " t:" + stamps[i]; + } + entries = utils.addElement(entries, linedata); + } + if (killers != null && killers.length > 0) + { + String prompt = "Corpse history for target: \n(" + target + ") " + utils.getStringName(target); + prompt += "\n\nCurrent Time = " + getGameTime(); + String title = "/searchCorpse: " + target; + int pid = sui.listbox(self, self, prompt, sui.OK_CANCEL, title, entries, "handleSearchCorpseSui"); + if (pid > -1) + { + utils.setScriptVar(self, gm.SCRIPTVAR_SEARCHCORPSE_TARGET, target); + utils.setScriptVar(self, gm.SCRIPTVAR_SEARCHCORPSE_PID, pid); + gm.attachHandlerScript(self); + return SCRIPT_CONTINUE; + } + } + sendSystemMessageTestingOnly(self, "/searchCorpse: was unable to construct a valid interface!"); + return SCRIPT_CONTINUE; + } + public int cmdSetSpeed(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + boolean valid = false; + if (isPlayer(target)) + { + obj_id ship = getPilotedShip(target); + if (isIdValid(ship)) + { + target = ship; + } + valid = true; + } + else if (isGameObjectTypeOf(getGameObjectType(target), GOT_ship)) + { + valid = true; + } + if (!valid) + { + sendSystemMessageTestingOnly(self, "/setSpeed: you must be targeting a player or ship to use this command"); + return SCRIPT_CONTINUE; + } + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setSpeed [-target] "); + return SCRIPT_CONTINUE; + } + float multiplier = 1f; + StringTokenizer st = new StringTokenizer(params); + while (st.hasMoreTokens()) + { + float tmp = utils.stringToFloat(st.nextToken()); + if (tmp > 0f) + { + multiplier = tmp; + } + } + if (multiplier > 0f && multiplier <= 10f) + { + setMovementPercent(target, multiplier); + } + float newSpeed = getMovementPercent(target); + sendSystemMessageTestingOnly(self, "(" + target + ") " + utils.getStringName(target) + "'s new speed multiplier = " + newSpeed); + return SCRIPT_CONTINUE; + } + public int cmdSetName(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setName [-target] "); + return SCRIPT_CONTINUE; + } + setName(target, params); + return SCRIPT_CONTINUE; + } + public int cmdSetFirstName(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/setFirstName: you must be targetting a player to use this command"); + return SCRIPT_CONTINUE; + } + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setFirstName [-target] "); + return SCRIPT_CONTINUE; + } + if (params.indexOf(" ") > -1) + { + sendSystemMessageTestingOnly(self, "/setFirstName: spaces are not allowed in a first name"); + return SCRIPT_CONTINUE; + } + String name = utils.getStringName(target); + String newname = name; + if (name != null && !name.equalsIgnoreCase("")) + { + StringTokenizer st = new StringTokenizer(name); + String fname = st.nextToken(); + newname = params; + while (st.hasMoreTokens())newname += " " + st.nextToken(); + } + if (newname.equalsIgnoreCase(name)) + { + sendSystemMessageTestingOnly(self, "/setFirstName: name NOT updated..."); + } + else + { + if (setName(target, newname)) + { + sendSystemMessageTestingOnly(self, "/setFirstName: " + name + " will now be known as " + newname); + } + else + { + sendSystemMessageTestingOnly(self, "/setFirstName: system disallowed name change..."); + } + } + return SCRIPT_CONTINUE; + } + public int cmdSetLastName(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/setLastName: you must be targetting a player to use this command"); + return SCRIPT_CONTINUE; + } + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setLastName [-target] "); + return SCRIPT_CONTINUE; + } + String name = utils.getStringName(target); + String newname = name; + if (name != null && !name.equalsIgnoreCase("")) + { + StringTokenizer st = new StringTokenizer(name); + String fname = st.nextToken(); + newname = fname + " " + params; + } + if (newname.equalsIgnoreCase(name)) + { + sendSystemMessageTestingOnly(self, "/setLastName: name NOT updated..."); + } + else + { + if (setName(target, newname)) + { + sendSystemMessageTestingOnly(self, "/setLastName: " + name + " will now be known as " + newname); + } + else + { + sendSystemMessageTestingOnly(self, "/setLastName: system disallowed name change..."); + } + } + return SCRIPT_CONTINUE; + } + public int cmdGrantBadge(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/grantBadge: you must be targetting a player to use this command"); + return SCRIPT_CONTINUE; + } + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /grantBadge [-target] or "); + return SCRIPT_CONTINUE; + } + int idx = utils.stringToInt(params); + String badgeName = ""; + if (idx < 0) + { + badgeName = params; + } + else + { + badgeName = getCollectionSlotName(idx); + } + if ((badgeName == null) || (badgeName.length() == 0)) + { + sendSystemMessageTestingOnly(self, "Error: badge name " + badgeName + " is not a valid badge."); + return SCRIPT_CONTINUE; + } + if (badge.grantBadge(target, badgeName)) + { + sendSystemMessageTestingOnly(self, "/grantBadge: you grant badge " + badgeName + " to (" + target + ")" + utils.getStringName(target)); + } + else + { + sendSystemMessageTestingOnly(self, "/grantBadge: you are UNABLE to grant badge " + badgeName + " to (" + target + ")" + utils.getStringName(target)); + } + return SCRIPT_CONTINUE; + } + public int cmdRevokeBadge(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/revokeBadge: you must be targetting a player to use this command"); + return SCRIPT_CONTINUE; + } + if (params == null || params.equalsIgnoreCase("")) + { + sendSystemMessageTestingOnly(self, "[Syntax] /revokeBadge [-target] "); + return SCRIPT_CONTINUE; + } + int idx = utils.stringToInt(params); + if (idx < 0) + { + sendSystemMessageTestingOnly(self, "[Syntax] /revokeBadge [-target] "); + return SCRIPT_CONTINUE; + } + String badgeName = getCollectionSlotName(idx); + if ((badgeName == null) || (badgeName.length() == 0)) + { + sendSystemMessageTestingOnly(self, "Error: badge number " + idx + " is not a valid badge."); + return SCRIPT_CONTINUE; + } + if (badge.revokeBadge(target, badgeName, true)) + { + sendSystemMessageTestingOnly(self, "/revokeBadge: you revoke badge #" + idx + " from (" + target + ")" + utils.getStringName(target)); + } + else + { + sendSystemMessageTestingOnly(self, "/revokeBadge: you are UNABLE to revoke badge #" + idx + " from (" + target + ")" + utils.getStringName(target)); + } + return SCRIPT_CONTINUE; + } + public int cmdShowExperience(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "/showFactionInformation: you must be targetting a player to use this command"); + return SCRIPT_CONTINUE; + } + if (utils.hasScriptVar(self, gm.SCRIPTVAR_SHOWEXPERIENCE_PID)) + { + int oldPid = utils.getIntScriptVar(self, gm.SCRIPTVAR_SHOWEXPERIENCE_PID); + forceCloseSUIPage(oldPid); + utils.removeScriptVar(self, gm.SCRIPTVAR_SHOWEXPERIENCE_PID); + } + String title = "EXPERIENCE LISTING"; + String prompt = "Experience Listing for player:\n(" + target + ")" + utils.getStringName(target); + prompt += "\n\nNOTE: THIS INFORMATION IS NOT REAL-TIME UPDATED! TIME: " + getGameTime(); + Vector entries = new Vector(); + entries.setSize(0); + int pid = sui.listbox(self, self, prompt, sui.OK_ONLY, title, entries, "cleanupShowFaction"); + if (pid > -1) + { + utils.setScriptVar(self, gm.SCRIPTVAR_SHOWEXPERIENCE_PID, pid); + } + return SCRIPT_CONTINUE; + } + public int cmdSetExperience(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + if (!isIdValid(target)) + { + target = self; + } + if (params.indexOf(gm.KEYWORD_TARGET) > -1) + { + params = gm.removeKeyword(params, gm.KEYWORD_TARGET); + } + else + { + target = self; + } + if (!isPlayer(target)) + { + sendSystemMessageTestingOnly(self, "[Syntax] /setExperience: this command may only be used on players"); + return SCRIPT_CONTINUE; + } + if (params == null || params.equalsIgnoreCase("")) + { + showSetExperienceSyntax(self); + return SCRIPT_CONTINUE; + } + String[] xpTypes = xp.getXpTypes(self); + if (xpTypes == null || xpTypes.length == 0) + { + sendSystemMessageTestingOnly(self, "/setExperience: unable to retrieve canonical xp listing!"); + return SCRIPT_CONTINUE; + } + if ((toLower(params)).equalsIgnoreCase("list")) + { + Vector entries = new Vector(); + entries.setSize(0); + for (int i = 0; i < xpTypes.length; i++) + { + String stringname = getString(new string_id("exp_n", xpTypes[i])); + if (stringname != null && !stringname.equalsIgnoreCase("")) + { + String linedata = "(" + stringname + ") " + xpTypes[i]; + entries = utils.addElement(entries, linedata); + } + } + String listTitle = "XP TYPES"; + String listPrompt = "A listing of all the currently used xp types"; + sui.listbox(self, self, listPrompt, sui.OK_ONLY, listTitle, entries, "noHandler"); + return SCRIPT_CONTINUE; + } + StringTokenizer st = new StringTokenizer(toLower(params)); + if (st.countTokens() != 2) + { + showSetExperienceSyntax(self); + return SCRIPT_CONTINUE; + } + String xp_type = st.nextToken(); + if (utils.getElementPositionInArray(xpTypes, xp_type) == -1) + { + sendSystemMessageTestingOnly(self, "/setExperience: '" + xp_type + "' is not a valid xp type."); + sendSystemMessageTestingOnly(self, "/setExperience: use '/setExperience list' for a valid listing"); + return SCRIPT_CONTINUE; + } + int xp_amt = getExperiencePoints(target, xp_type); + if (st.hasMoreTokens()) + { + String sAmt = st.nextToken(); + int amt = 0; + if (sAmt.startsWith("+") || sAmt.startsWith("-")) + { + amt = utils.stringToInt(sAmt.substring(1)); + if (amt == -1) + { + sendSystemMessageTestingOnly(self, "/setExperience: invalid xp delta parameter..."); + } + if (sAmt.startsWith("-")) + { + amt = -amt; + } + } + else + { + amt = utils.stringToInt(sAmt); + if (amt == -1) + { + sendSystemMessageTestingOnly(self, "/setExperience: invalid xp amount: '" + sAmt + "'"); + } + amt = amt - xp_amt; + } + if (amt != 0) + { + dictionary resultData = new dictionary(); + resultData.put("target", target); + resultData.put("xp_type", xp_type); + xp.grantUnmodifiedExperience(target, xp_type, amt, "cmdSetExperienceResult", resultData); + } + } + return SCRIPT_CONTINUE; + } + public void showSetExperienceSyntax(obj_id self) throws InterruptedException + { + sendSystemMessageTestingOnly(self, "[Syntax] /setExperience [-target] (+|-)"); + sendSystemMessageTestingOnly(self, "[Syntax] /setExperience list"); + } + public int cmdFindObject(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + obj_id objToFind = utils.stringToObjId(params); + if (!isIdValid(objToFind)) + { + sendSystemMessageTestingOnly(self, "[Syntax] /findObject objid"); + } + else + { + sendSystemMessageTestingOnly(self, "Searching for object: " + objToFind); + gm.attachHandlerScript(self); + findObjectAnywhere(objToFind, self); + } + return SCRIPT_CONTINUE; + } + public int cmdFindObjectByTemplate(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException + { + java.util.StringTokenizer st = new java.util.StringTokenizer(params); + if (st.countTokens() != 1) + { + sendSystemMessageTestingOnly(self, "Format: findObjectByTemplate