diff --git a/sku.0/sys.server/compiled/game/script/gm/cmd.java b/sku.0/sys.server/compiled/game/script/gm/cmd.java index c0e76426b..911156200 100755 --- a/sku.0/sys.server/compiled/game/script/gm/cmd.java +++ b/sku.0/sys.server/compiled/game/script/gm/cmd.java @@ -3876,121 +3876,6 @@ public class cmd extends script.base_script } return SCRIPT_CONTINUE; } - public int cmdGmShowQuest(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException - { - StringTokenizer st = new java.util.StringTokenizer(params); - String playerOid = ""; - String logFile = ""; - if (st.hasMoreTokens()) - { - playerOid = st.nextToken(); - } - if (st.hasMoreTokens()) - { - logFile = st.nextToken(); - } - if (!playerOid.equals("")) - { - obj_id targetOid = utils.stringToObjId(playerOid); - if (!isIdNull(targetOid)) - { - String[] listQuests = gm.getAllQuests(targetOid); - String combinedQuestList = ""; - if (listQuests != null) - { - for (String listQuest : listQuests) { - combinedQuestList += listQuest + "\n"; - } - if (!combinedQuestList.equals("")) - { - if (logFile.equals("log")) - { - String dumpString = dump.getTargetInfoString(targetOid); - dumpString += "\n---------------------GM QUEST TOOL DATA------------------"; - dumpString += "\n" + combinedQuestList; - String title = "questStringAndPlayerDump" + targetOid + "_" + getGameTime(); - saveTextOnClient(self, title + ".txt", dumpString); - } - gm.createCustomUI(self, "Quest List", combinedQuestList); - CustomerServiceLog("gmQuest", "CSR: (" + self + ") " + getName(self) + " has accessed quests (" + combinedQuestList + ") from (" + targetOid + ") " + utils.getStringName(targetOid)); - } - } - } - else - { - sendSystemMessageTestingOnly(self, "Please check the OID and try again"); - } - } - else - { - sendSystemMessageTestingOnly(self, "[Syntax] /gmshowquest "); - } - return SCRIPT_CONTINUE; - } - public int cmdGmClearQuest(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException - { - StringTokenizer st = new java.util.StringTokenizer(params); - String playerOid = ""; - String questVar = ""; - if (st.hasMoreTokens()) - { - playerOid = st.nextToken(); - } - if (st.hasMoreTokens()) - { - questVar = st.nextToken(); - } - if (!playerOid.equals("") && !questVar.equals("")) - { - obj_id targetOid = utils.stringToObjId(playerOid); - if (!isIdNull(targetOid)) - { - gm.forceClearQuest(targetOid, questVar); - CustomerServiceLog("gmQuest", "CSR: (" + self + ") " + getName(self) + " has cleared (or attempted to clear) quest (" + questVar + ") from (" + targetOid + ") " + utils.getStringName(targetOid)); - } - else - { - sendSystemMessageTestingOnly(self, "Please check the OID and try again"); - } - } - else - { - sendSystemMessageTestingOnly(self, "[Syntax] /gmclearquest "); - } - return SCRIPT_CONTINUE; - } - public int cmdGmRegrantQuest(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException - { - StringTokenizer st = new java.util.StringTokenizer(params); - String playerOid = ""; - String questVar = ""; - if (st.hasMoreTokens()) - { - playerOid = st.nextToken(); - } - if (st.hasMoreTokens()) - { - questVar = st.nextToken(); - } - if (!playerOid.equals("") && !questVar.equals("")) - { - obj_id targetOid = utils.stringToObjId(playerOid); - if (!isIdNull(targetOid)) - { - gm.forceRegrantQuest(targetOid, questVar); - CustomerServiceLog("gmQuest", "CSR: (" + self + ") " + getName(self) + " has cleared and granted (or attempted to clear and grant) quest (" + questVar + ") from (" + targetOid + ") " + utils.getStringName(targetOid)); - } - else - { - sendSystemMessageTestingOnly(self, "Please check the OID and try again"); - } - } - else - { - sendSystemMessageTestingOnly(self, "[Syntax] /gmregrantquest "); - } - return SCRIPT_CONTINUE; - } public int cmdSetInstanceAuthorized(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException { if (!isGod(self)) @@ -4704,8 +4589,7 @@ public class cmd extends script.base_script params = gm.removeKeyword(params, gm.KEYWORD_TARGET); target = getTarget(self); } else { - sendSystemMessageTestingOnly(self, "[Syntax] /gmRevive -target"); - return SCRIPT_CONTINUE; + target = self; } // fix a disabled vehicle @@ -4776,4 +4660,300 @@ public class cmd extends script.base_script } } + /** + * Scripting which replicates a console command as /quest for quest-related sub-commands + * + * /quest clear oid questName + * /quest clearAllActive oid + * /quest clearAllComplete oid + * /quest complete oid questName + * /quest completeAll oid + * /quest list oid + * /quest grant oid questName + * /quest reGrant oid questName + * /quest reGrantArea range questName + */ + public int cmdQuest(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException { + + if(!isGod(self)) + { + return SCRIPT_CONTINUE; + } + StringTokenizer st = new StringTokenizer(params); + String command; + if(st.hasMoreTokens()) { + command = st.nextToken(); + } else { + showQuestCmdSyntax(self); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest list + // ******************************************************************* + if(command.equalsIgnoreCase("list")) + { + final String toParse = st.nextToken(); + target = obj_id.getObjId(Long.parseLong(toParse)); + if(!isIdValid(target)) { + sendSystemMessageTestingOnly(self, "quest list: Error: The OID you provided is not valid or you are missing an argument."); + sendSystemMessageTestingOnly(self, "Syntax: /quest list "); + return SCRIPT_CONTINUE; + } + final int[] active = questGetAllActiveQuestIds(target); + final int[] completed = questGetAllCompletedQuestIds(target); + if(active.length < 1 && completed.length < 1) + { + sendSystemMessageTestingOnly(self, "quest list: Error: The player specified has no quest history."); + return SCRIPT_CONTINUE; + } + StringBuilder activeQuests = new StringBuilder("\\#ffa500***** Active Quests *****\\#.\n\n"); + for (int quest : active) + { + activeQuests.append(quest).append(" - ").append(questGetQuestName(quest)).append("\n"); + } + StringBuilder completeQuests = new StringBuilder("\\#ffa500***** Completed Quests *****\\#.\n\n"); + for (int quest : completed) + { + completeQuests.append(quest).append(" - ").append(questGetQuestName(quest)).append("\n"); + } + final String data = "Quest Data for "+getPlayerName(target)+" ("+target+")\n\n" + activeQuests + "\n\n" + completeQuests; + sui.msgbox(self, self, data, sui.OK_ONLY, "Quest List", "noHandler"); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest grant + // ******************************************************************* + if(command.equalsIgnoreCase("grant")) + { + final String toParse = st.nextToken(); + target = obj_id.getObjId(Long.parseLong(toParse)); + if(!isIdValid(target) || !st.hasMoreTokens()) { + sendSystemMessageTestingOnly(self, "quest grant: Error: The OID you provided is not valid or you are missing an argument."); + sendSystemMessageTestingOnly(self, "Syntax: /quest grant "); + return SCRIPT_CONTINUE; + } + final String questName = st.nextToken(); + final int id = questGetQuestId(questName); + if(id == 0) + { + sendSystemMessageTestingOnly(self, "quest grant: Error: The quest name specified was not valid."); + return SCRIPT_CONTINUE; + } + if(Arrays.stream(questGetAllCompletedQuestIds(target)).anyMatch(i -> i == id) || + Arrays.stream(questGetAllActiveQuestIds(target)).anyMatch(i -> i == id)) + { + sendSystemMessageTestingOnly(self, "quest grant: Error: Player "+target+" already has quest "+questName+" as active or completed. Use /quest reGrant instead if you want to force clear and grant this quest."); + return SCRIPT_CONTINUE; + } + requestActivateQuest(id, target, target); + sendSystemMessageTestingOnly(self, "quest grant: Success. Player "+target+" was granted quest "+questName); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest reGrant + // ******************************************************************* + if(command.equalsIgnoreCase("reGrant")) + { + final String toParse = st.nextToken(); + target = obj_id.getObjId(Long.parseLong(toParse)); + if(!isIdValid(target) || !st.hasMoreTokens()) { + sendSystemMessageTestingOnly(self, "quest reGrant: Error: The OID you provided is not valid or you are missing an argument."); + sendSystemMessageTestingOnly(self, "Syntax: /quest reGrant "); + return SCRIPT_CONTINUE; + } + final String questName = st.nextToken(); + final int id = questGetQuestId(questName); + if(id == 0) + { + sendSystemMessageTestingOnly(self, "quest reGrant: Error: The quest name specified was not valid."); + return SCRIPT_CONTINUE; + } + questClearQuest(id, target); + questActivateQuest(id, target, target); + sendSystemMessageTestingOnly(self, "quest reGrant: Success. Player "+target+" was re-granted quest "+questName); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest reGrantArea + // ******************************************************************* + if(command.equalsIgnoreCase("reGrantArea")) + { + final float range = Float.parseFloat(st.nextToken()); + if(range < 1 || range > 800) + { + sendSystemMessageTestingOnly(self, "quest reGrantArea: Error: Range must be between 1 and 800."); + sendSystemMessageTestingOnly(self, "Syntax: /quest reGrantArea "); + return SCRIPT_CONTINUE; + } + if(!st.hasMoreTokens()) { + sendSystemMessageTestingOnly(self, "Syntax: /quest reGrantArea "); + return SCRIPT_CONTINUE; + } + final String questName = st.nextToken(); + final int id = questGetQuestId(questName); + if(id == 0) + { + sendSystemMessageTestingOnly(self, "quest reGrantArea: Error: The quest name specified was not valid."); + return SCRIPT_CONTINUE; + } + final obj_id[] players = getAllPlayers(getLocation(self), range); + if(players.length < 1) + { + sendSystemMessageTestingOnly(self, "quest reGrantArea: Error: No players found in this area."); + return SCRIPT_CONTINUE; + } + for (obj_id player : players) + { + questClearQuest(id, player); + questActivateQuest(id, player, player); + } + sendSystemMessageTestingOnly(self, "quest reGrantArea: Success. A total of "+players.length+" were re-granted quest "+questName); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest clear + // ******************************************************************* + if(command.equalsIgnoreCase("clear")) + { + final String toParse = st.nextToken(); + target = obj_id.getObjId(Long.parseLong(toParse)); + if(!isIdValid(target) || !st.hasMoreTokens()) { + sendSystemMessageTestingOnly(self, "quest clear: Error: The OID you provided is not valid or you are missing an argument."); + sendSystemMessageTestingOnly(self, "Syntax: /quest clear "); + return SCRIPT_CONTINUE; + } + final String questName = st.nextToken(); + final int id = questGetQuestId(questName); + if(id == 0) + { + sendSystemMessageTestingOnly(self, "quest clear: Error: The quest name specified was not valid."); + return SCRIPT_CONTINUE; + } + questClearQuest(id, target); + sendSystemMessageTestingOnly(self, "quest clear: Success. Player "+target+" was cleared of history from quest "+questName); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest clearAllActive + // ******************************************************************* + if(command.equalsIgnoreCase("clearAllActive")) + { + final String toParse = st.nextToken(); + target = obj_id.getObjId(Long.parseLong(toParse)); + if(!isIdValid(target) || !st.hasMoreTokens()) { + sendSystemMessageTestingOnly(self, "quest clearAllActive: Error: The OID you provided is not valid or you are missing an argument."); + sendSystemMessageTestingOnly(self, "Syntax: /quest clearAllActive "); + return SCRIPT_CONTINUE; + } + for (int quest : questGetAllActiveQuestIds(target)) + { + questClearQuest(quest, target); + } + sendSystemMessageTestingOnly(self, "quest clearAllActive: Success. Player "+target+" was cleared of all active quests."); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest clearAllComplete + // ******************************************************************* + if(command.equalsIgnoreCase("clearAllComplete")) + { + final String toParse = st.nextToken(); + target = obj_id.getObjId(Long.parseLong(toParse)); + if(!isIdValid(target) || !st.hasMoreTokens()) { + sendSystemMessageTestingOnly(self, "quest clearAllComplete: Error: The OID you provided is not valid or you are missing an argument."); + sendSystemMessageTestingOnly(self, "Syntax: /quest clearAllComplete "); + return SCRIPT_CONTINUE; + } + for (int quest : questGetAllCompletedQuestIds(target)) + { + questClearQuest(quest, target); + } + sendSystemMessageTestingOnly(self, "quest clearAllComplete: Success. Player "+target+" was cleared of all completed quests."); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest complete + // ******************************************************************* + if(command.equalsIgnoreCase("complete")) + { + final String toParse = st.nextToken(); + target = obj_id.getObjId(Long.parseLong(toParse)); + if(!isIdValid(target) || !st.hasMoreTokens()) { + sendSystemMessageTestingOnly(self, "quest complete: Error: The OID you provided is not valid or you are missing an argument."); + sendSystemMessageTestingOnly(self, "Syntax: /quest complete "); + return SCRIPT_CONTINUE; + } + final String questName = st.nextToken(); + final int id = questGetQuestId(questName); + if(id == 0) + { + sendSystemMessageTestingOnly(self, "quest complete: Error: The quest name specified was not valid."); + return SCRIPT_CONTINUE; + } + if(!Arrays.stream(questGetAllActiveQuestIds(target)).anyMatch(i -> i == id)) + { + sendSystemMessageTestingOnly(self, "quest complete: Error: Player "+target+" does not have "+questName+" as active. You will need to grant/re-grant it first to complete it."); + return SCRIPT_CONTINUE; + } + requestCompleteQuest(id, target); + sendSystemMessageTestingOnly(self, "quest complete: Success. Player "+target+" was flagged as having completed quest "+questName); + return SCRIPT_CONTINUE; + } + + // ******************************************************************* + // /quest completeAll + // ******************************************************************* + if(command.equalsIgnoreCase("completeAll")) + { + final String toParse = st.nextToken(); + target = obj_id.getObjId(Long.parseLong(toParse)); + if(!isIdValid(target) || !st.hasMoreTokens()) { + sendSystemMessageTestingOnly(self, "quest completeAll: Error: The OID you provided is not valid or you are missing an argument."); + sendSystemMessageTestingOnly(self, "Syntax: /quest completeAll "); + return SCRIPT_CONTINUE; + } + for (int quest : questGetAllActiveQuestIds(target)) + { + requestCompleteQuest(quest, target); + } + sendSystemMessageTestingOnly(self, "quest completeAll: Success. Player "+target+" was granted completion of all active quests."); + return SCRIPT_CONTINUE; + } + + return SCRIPT_CONTINUE; + } + + public void showQuestCmdSyntax(obj_id self) + { + sendSystemMessageTestingOnly(self, "Outputting nested commands and syntax of /quest to console"); + sendConsoleMessage(self, "\\#ffff00 ============ Syntax: /quest commands ============ \\#."); + sendConsoleMessage(self, "\\#00ffff clear \\#bfff00 \\#."); + sendConsoleMessage(self, "clears the record of the given player having activated or completed the given quest."); + sendConsoleMessage(self, "\\#00ffff clearAllActive \\#bfff00 \\#."); + sendConsoleMessage(self, "clears the record of the given player having activated or completed all of their currently active quests."); + sendConsoleMessage(self, "\\#00ffff clearAllComplete \\#bfff00 \\#."); + sendConsoleMessage(self, "clears the record of the given player having activated or completed all of their currently completed quests."); + sendConsoleMessage(self, "\\#00ffff complete \\#bfff00 \\#."); + sendConsoleMessage(self, "triggers the completion of the given quest for the given player (with rewards popup)."); + sendConsoleMessage(self, "\\#00ffff completeAll \\#bfff00 \\#."); + sendConsoleMessage(self, "triggers the completion of all active quests for the given player (with rewards popup)."); + sendConsoleMessage(self, "\\#00ffff list \\#bfff00 \\#."); + sendConsoleMessage(self, "returns a window with a list of all active and completed quests for the provided player."); + sendConsoleMessage(self, "\\#00ffff grant \\#bfff00 \\#."); + sendConsoleMessage(self, "grants the specified player the specified quest (not a forced grant, player must accept quest)."); + sendConsoleMessage(self, "\\#00ffff reGrant \\#bfff00 \\#."); + sendConsoleMessage(self, "re-grants the specified player the specified quest by clearing its history first then granting it (forced grant)."); + sendConsoleMessage(self, "\\#00ffff reGrantArea \\#bfff00 \\#."); + sendConsoleMessage(self, "performs a reGrant on the given quest for all players within the given range (for events)."); + sendConsoleMessage(self, "\\#ffff00 ============ ============ ============ ============ \\#."); + } + } diff --git a/sku.0/sys.shared/compiled/game/datatables/command/command_table.tab b/sku.0/sys.shared/compiled/game/datatables/command/command_table.tab index 4a0cb30d7..b029bdc7d 100755 --- a/sku.0/sys.shared/compiled/game/datatables/command/command_table.tab +++ b/sku.0/sys.shared/compiled/game/datatables/command/command_table.tab @@ -725,7 +725,6 @@ getVeteranRewardTimeCs immediate cmdGetVeteranRewardTime admin 1 1 1 1 1 1 giveItem immediate giveItem 0 0 1 1 required 1 0 0 giveMaintenanceToVendor immediate giveMaintenanceToVendor 0 1 1 0 1 1 none 0 0 givevendormaint immediate giveVendorMaint 1 1 0 1 1 optional 0 4 0 -gmClearQuest immediate cmdGmClearQuest admin 0 1 gm.cmd none 0 40 csr 0 gmCreateClassResource immediate gmCreateClassResource admin 0 1 1 40 csr 0 gmCreateSpecificResource immediate gmCreateSpecificResource admin 0 1 1 40 csr 0 gmForceCommand immediate gmForceCommand admin 0 1 1 40 csr 0 @@ -733,9 +732,7 @@ gmForceRank immediate cmdGMForceRank admin 1 1 0 1 gmFsVillage immediate cmdGMFsVillage admin 1 1 0 1 1 0 0 0 0 optional 0 40 csr 0 gmJediState immediate gmJediState admin 0 1 1 gm.cmd optional 0 40 csr 0 gmr immediate cmdGmRevive admin 1 1 0 1 1 gm.cmd none 0 40 csr 0 -gmregrantQuest immediate cmdGmRegrantQuest admin 0 1 gm.cmd none 0 40 csr 0 gmRevive immediate cmdGmRevive admin 1 1 0 1 1 gm.cmd none 0 40 csr 0 -gmShowQuest immediate cmdGmShowQuest admin 0 1 gm.cmd none 0 40 csr 0 gmWeapon immediate cmdGmWeapon admin 1 1 0 1 1 0 0 0 0 optional 0 40 csr 0 goto immediate cmdGoto failAdmin admin 1 1 0 1 1 gm.cmd optional 0 0 40 csr 0 grantBadge immediate cmdGrantBadge failAdmin admin 1 1 0 1 1 gm.cmd optional 0 0 40 csr 0 @@ -1927,3 +1924,4 @@ april_fools_boss_emote commandClicky normal april_fools_boss_emote failSpecialAt me_hot_ae_1 commandClicky normal me_hot_ae_1 failSpecialAttack 1 me_hot_ae_1 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 1 1 1 1 1 other all 2 combat_ranged 0 0 combat 1 ALL HEAVY me_hot 0 0.25 10 1 me_hot_ae_2 commandClicky normal me_hot_ae_2 failSpecialAttack 1 me_hot_ae_2 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 1 1 1 1 1 other all 2 combat_ranged 0 0 combat 1 ALL HEAVY me_hot 0 0.25 10 1 me_hot_ae_3 commandClicky normal me_hot_ae_3 failSpecialAttack 1 me_hot_ae_3 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 1 1 1 1 1 other all 2 combat_ranged 0 0 combat 1 ALL HEAVY me_hot 0 0.25 10 1 +quest immediate cmdQuest failAdmin admin 1 1 0 1 1 gm.cmd none 0 0 csr 0