From a8fbc4a9fac7b78752564bc52b9eba762519562f Mon Sep 17 00:00:00 2001 From: Cekis Date: Sat, 23 Apr 2016 08:06:56 +0100 Subject: [PATCH] Audited Barada and the TCG Barn Ranchhand conversation scripts. --- .../game/script/conversation/barada.java | 389 ++++-------------- .../script/conversation/barn_ranchhand.java | 297 +++---------- .../conversation/base/conversation_base.java | 26 ++ 3 files changed, 152 insertions(+), 560 deletions(-) mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/conversation/barada.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/conversation/barn_ranchhand.java diff --git a/sku.0/sys.server/compiled/game/script/conversation/barada.java b/sku.0/sys.server/compiled/game/script/conversation/barada.java old mode 100644 new mode 100755 index 26f66d4fb..60d0d3596 --- a/sku.0/sys.server/compiled/game/script/conversation/barada.java +++ b/sku.0/sys.server/compiled/game/script/conversation/barada.java @@ -1,410 +1,162 @@ package script.conversation; -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.ai_lib; import script.library.chat; import script.library.groundquests; import script.library.utils; +import script.*; -public class barada extends script.base_script +public class barada extends script.conversation.base.conversation_base { + public String conversation = "conversation.barada"; + public String c_stringFile = "conversation/barada"; + public barada() { + super.scriptName = "barada"; + super.conversation = conversation; + super.c_stringFile = c_stringFile; } - public static String c_stringFile = "conversation/barada"; - public boolean barada_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException + private boolean barada_condition_completedBarada(obj_id player) throws InterruptedException { - return true; + return groundquests.hasCompletedQuest(player, "quest/jabba_barada_v2"); } - public boolean barada_condition_completedBarada(obj_id player, obj_id npc) throws InterruptedException + private boolean barada_condition_completedPorcellus(obj_id player) throws InterruptedException { - if (groundquests.hasCompletedQuest(player, "quest/jabba_barada_v2")) - { - return true; - } - return false; + return groundquests.hasCompletedQuest(player, "quest/jabba_porcellus"); } - public boolean barada_condition_completedPorcellus(obj_id player, obj_id npc) throws InterruptedException + private boolean barada_condition_findingParts(obj_id player) throws InterruptedException { - if (groundquests.hasCompletedQuest(player, "quest/jabba_porcellus")) - { - return true; - } - return false; + return groundquests.isTaskActive(player, "quest/jabba_barada_v2", "suspiciousParts"); } - public boolean barada_condition_findingParts(obj_id player, obj_id npc) throws InterruptedException + private boolean barada_condition_killingCompetition(obj_id player) throws InterruptedException { - if (groundquests.isTaskActive(player, "quest/jabba_barada_v2", "suspiciousParts")) - { - return true; - } - return false; + return groundquests.isTaskActive(player, "quest/jabba_barada_v2", "PodRaceVillainy"); } - public boolean barada_condition_killingCompetition(obj_id player, obj_id npc) throws InterruptedException + private boolean barada_condition_readyToReturn(obj_id player) throws InterruptedException { - if (groundquests.isTaskActive(player, "quest/jabba_barada_v2", "PodRaceVillainy")) - { - return true; - } - return false; + return groundquests.isTaskActive(player, "quest/jabba_barada_v2", "readyToReturn"); } - public boolean barada_condition_readyToReturn(obj_id player, obj_id npc) throws InterruptedException - { - if (groundquests.isTaskActive(player, "quest/jabba_barada_v2", "readyToReturn")) - { - return true; - } - return false; - } - public void barada_action_grantBaradaQuest(obj_id player, obj_id npc) throws InterruptedException + private void barada_action_grantBaradaQuest(obj_id player) throws InterruptedException { groundquests.requestGrantQuest(player, "quest/jabba_barada_v2"); } - public void barada_action_sendBaradaDoneSignal(obj_id player, obj_id npc) throws InterruptedException + private void barada_action_sendBaradaDoneSignal(obj_id player, obj_id npc) throws InterruptedException { faceTo(npc, player); groundquests.sendSignal(player, "doneWithBarada"); groundquests.grantQuest(player, "pointer_bib_fortuna"); } - public void barada_action_clearPointer(obj_id player, obj_id npc) throws InterruptedException + private void barada_action_clearPointer(obj_id player, obj_id npc) throws InterruptedException { faceTo(npc, player); groundquests.sendSignal(player, "found_barada"); } - public void barada_action_facePlayer(obj_id player, obj_id npc) throws InterruptedException - { - faceTo(npc, player); - } - public int barada_handleBranch5(obj_id player, obj_id npc, string_id response) throws InterruptedException + private int barada_handleBranch5(obj_id player, string_id response) throws InterruptedException { if (response.equals("s_13")) { - if (barada_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_15"); - int numberOfResponses = 0; - boolean hasResponse = false; - boolean hasResponse0 = false; - if (barada_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse0 = true; - } - boolean hasResponse1 = false; - if (barada_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse1 = true; - } - if (hasResponse) - { - int responseIndex = 0; - string_id responses[] = new string_id[numberOfResponses]; - if (hasResponse0) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_17"); - } - if (hasResponse1) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_36"); - } - utils.setScriptVar(player, "conversation.barada.branchId", 6); - npcSpeak(player, message); - npcSetConversationResponses(player, responses); - } - else - { - utils.removeScriptVar(player, "conversation.barada.branchId"); - npcEndConversationWithMessage(player, message); - } - return SCRIPT_CONTINUE; - } + return craft_response(new String[] {"s_15", "s_17", "s_36"}, 6, player); } if (response.equals("s_40")) { - if (barada_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_42"); - utils.removeScriptVar(player, "conversation.barada.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } + utils.removeScriptVar(player, conversation + ".branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_42")); + return SCRIPT_CONTINUE; } return SCRIPT_DEFAULT; } - public int barada_handleBranch6(obj_id player, obj_id npc, string_id response) throws InterruptedException + private int barada_handleBranch6(obj_id player, string_id response) throws InterruptedException { if (response.equals("s_17")) { - if (barada_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_24"); - int numberOfResponses = 0; - boolean hasResponse = false; - boolean hasResponse0 = false; - if (barada_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse0 = true; - } - boolean hasResponse1 = false; - if (barada_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse1 = true; - } - if (hasResponse) - { - int responseIndex = 0; - string_id responses[] = new string_id[numberOfResponses]; - if (hasResponse0) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_26"); - } - if (hasResponse1) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_34"); - } - utils.setScriptVar(player, "conversation.barada.branchId", 7); - npcSpeak(player, message); - npcSetConversationResponses(player, responses); - } - else - { - utils.removeScriptVar(player, "conversation.barada.branchId"); - npcEndConversationWithMessage(player, message); - } - return SCRIPT_CONTINUE; - } + return craft_response(new String[] {"s_24", "s_26", "s_34"}, 7, player); } if (response.equals("s_36")) { - if (barada_condition__defaultCondition(player, npc)) - { - barada_action_grantBaradaQuest(player, npc); - string_id message = new string_id(c_stringFile, "s_38"); - utils.removeScriptVar(player, "conversation.barada.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } + barada_action_grantBaradaQuest(player); + utils.removeScriptVar(player, conversation + ".branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_38")); + return SCRIPT_CONTINUE; } return SCRIPT_DEFAULT; } - public int barada_handleBranch7(obj_id player, obj_id npc, string_id response) throws InterruptedException + private int barada_handleBranch7(obj_id player, string_id response) throws InterruptedException { if (response.equals("s_26")) { - if (barada_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_28"); - int numberOfResponses = 0; - boolean hasResponse = false; - boolean hasResponse0 = false; - if (barada_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse0 = true; - } - boolean hasResponse1 = false; - if (barada_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse1 = true; - } - if (hasResponse) - { - int responseIndex = 0; - string_id responses[] = new string_id[numberOfResponses]; - if (hasResponse0) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_30"); - } - if (hasResponse1) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_32"); - } - utils.setScriptVar(player, "conversation.barada.branchId", 8); - npcSpeak(player, message); - npcSetConversationResponses(player, responses); - } - else - { - utils.removeScriptVar(player, "conversation.barada.branchId"); - npcEndConversationWithMessage(player, message); - } - return SCRIPT_CONTINUE; - } + return craft_response(new String[] {"s_28", "s_30", "s_32"}, 8, player); } if (response.equals("s_34")) { - if (barada_condition__defaultCondition(player, npc)) - { - barada_action_grantBaradaQuest(player, npc); - string_id message = new string_id(c_stringFile, "s_38"); - utils.removeScriptVar(player, "conversation.barada.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } + barada_action_grantBaradaQuest(player); + utils.removeScriptVar(player, conversation + ".branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_38")); + return SCRIPT_CONTINUE; } return SCRIPT_DEFAULT; } - public int barada_handleBranch8(obj_id player, obj_id npc, string_id response) throws InterruptedException + private int barada_handleBranch8(obj_id player, string_id response) throws InterruptedException { if (response.equals("s_30")) { - if (barada_condition__defaultCondition(player, npc)) - { - barada_action_grantBaradaQuest(player, npc); - string_id message = new string_id(c_stringFile, "s_38"); - utils.removeScriptVar(player, "conversation.barada.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } + barada_action_grantBaradaQuest(player); + utils.removeScriptVar(player, conversation + ".branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_38")); + return SCRIPT_CONTINUE; } if (response.equals("s_32")) { - if (barada_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_42"); - utils.removeScriptVar(player, "conversation.barada.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } + utils.removeScriptVar(player, conversation + ".branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_42")); + return SCRIPT_CONTINUE; } return SCRIPT_DEFAULT; } public int OnInitialize(obj_id self) throws InterruptedException { - if ((!isMob(self)) || (isPlayer(self))) - { - detachScript(self, "conversation.barada"); - } - setCondition(self, CONDITION_CONVERSABLE); setCondition(self, CONDITION_INTERESTING); - return SCRIPT_CONTINUE; + return super.OnInitialize(self); } public int OnAttach(obj_id self) throws InterruptedException { - setCondition(self, CONDITION_CONVERSABLE); setCondition(self, CONDITION_INTERESTING); - return SCRIPT_CONTINUE; - } - public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info menuInfo) throws InterruptedException - { - int menu = menuInfo.addRootMenu(menu_info_types.CONVERSE_START, null); - menu_info_data menuInfoData = menuInfo.getMenuItemById(menu); - menuInfoData.setServerNotify(false); - setCondition(self, CONDITION_CONVERSABLE); - return SCRIPT_CONTINUE; - } - public int OnIncapacitated(obj_id self, obj_id killer) throws InterruptedException - { - clearCondition(self, CONDITION_CONVERSABLE); - detachScript(self, "conversation.barada"); - return SCRIPT_CONTINUE; - } - public boolean npcStartConversation(obj_id player, obj_id npc, String convoName, string_id greetingId, prose_package greetingProse, string_id[] responses) throws InterruptedException - { - Object[] objects = new Object[responses.length]; - System.arraycopy(responses, 0, objects, 0, responses.length); - return npcStartConversation(player, npc, convoName, greetingId, greetingProse, objects); + return super.OnAttach(self); } public int OnStartNpcConversation(obj_id self, obj_id player) throws InterruptedException { - obj_id npc = self; - if (ai_lib.isInCombat(npc) || ai_lib.isInCombat(player)) + if (ai_lib.isInCombat(self) || ai_lib.isInCombat(player)) { return SCRIPT_OVERRIDE; } - if (barada_condition_completedBarada(player, npc)) + faceTo(self, player); + if (barada_condition_completedBarada(player)) { - barada_action_facePlayer(player, npc); - string_id message = new string_id(c_stringFile, "s_4"); - chat.chat(npc, player, message); + chat.chat(self, player, new string_id(c_stringFile, "s_4")); return SCRIPT_CONTINUE; } - if (barada_condition_readyToReturn(player, npc)) + if (barada_condition_readyToReturn(player)) { - barada_action_sendBaradaDoneSignal(player, npc); - string_id message = new string_id(c_stringFile, "s_23"); - chat.chat(npc, player, message); + barada_action_sendBaradaDoneSignal(player, self); + chat.chat(self, player, new string_id(c_stringFile, "s_23")); return SCRIPT_CONTINUE; } - if (barada_condition_killingCompetition(player, npc)) + if (barada_condition_killingCompetition(player)) { - barada_action_facePlayer(player, npc); - string_id message = new string_id(c_stringFile, "s_20"); - chat.chat(npc, player, message); + chat.chat(self, player, new string_id(c_stringFile, "s_20")); return SCRIPT_CONTINUE; } - if (barada_condition_findingParts(player, npc)) + if (barada_condition_findingParts(player)) { - barada_action_facePlayer(player, npc); - string_id message = new string_id(c_stringFile, "s_19"); - chat.chat(npc, player, message); + chat.chat(self, player, new string_id(c_stringFile, "s_19")); return SCRIPT_CONTINUE; } - if (barada_condition_completedPorcellus(player, npc)) + if (barada_condition_completedPorcellus(player)) { - barada_action_clearPointer(player, npc); - string_id message = new string_id(c_stringFile, "s_11"); - int numberOfResponses = 0; - boolean hasResponse = false; - boolean hasResponse0 = false; - if (barada_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse0 = true; - } - boolean hasResponse1 = false; - if (barada_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse1 = true; - } - if (hasResponse) - { - int responseIndex = 0; - string_id responses[] = new string_id[numberOfResponses]; - if (hasResponse0) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_13"); - } - if (hasResponse1) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_40"); - } - utils.setScriptVar(player, "conversation.barada.branchId", 5); - npcStartConversation(player, npc, "barada", message, responses); - } - else - { - chat.chat(npc, player, message); - } - return SCRIPT_CONTINUE; + barada_action_clearPointer(player, self); + return craft_repeater(new String[] {"s_11", "s_13", "s_40"}, 5, player, self); } - if (barada_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_44"); - chat.chat(npc, player, message); - return SCRIPT_CONTINUE; - } - chat.chat(npc, "Error: All conditions for OnStartNpcConversation were false."); + chat.chat(self, player, new string_id(c_stringFile, "s_44")); return SCRIPT_CONTINUE; } public int OnNpcConversationResponse(obj_id self, String conversationId, obj_id player, string_id response) throws InterruptedException @@ -413,26 +165,25 @@ public class barada extends script.base_script { return SCRIPT_CONTINUE; } - obj_id npc = self; - int branchId = utils.getIntScriptVar(player, "conversation.barada.branchId"); - if (branchId == 5 && barada_handleBranch5(player, npc, response) == SCRIPT_CONTINUE) + int branchId = utils.getIntScriptVar(player, conversation + ".branchId"); + if (branchId == 5 && barada_handleBranch5(player, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } - if (branchId == 6 && barada_handleBranch6(player, npc, response) == SCRIPT_CONTINUE) + if (branchId == 6 && barada_handleBranch6(player, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } - if (branchId == 7 && barada_handleBranch7(player, npc, response) == SCRIPT_CONTINUE) + if (branchId == 7 && barada_handleBranch7(player, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } - if (branchId == 8 && barada_handleBranch8(player, npc, response) == SCRIPT_CONTINUE) + if (branchId == 8 && barada_handleBranch8(player, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } - chat.chat(npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); - utils.removeScriptVar(player, "conversation.barada.branchId"); + chat.chat(self, "Error: Fell through all branches and responses for OnNpcConversationResponse."); + utils.removeScriptVar(player, conversation + ".branchId"); return SCRIPT_CONTINUE; } } diff --git a/sku.0/sys.server/compiled/game/script/conversation/barn_ranchhand.java b/sku.0/sys.server/compiled/game/script/conversation/barn_ranchhand.java old mode 100644 new mode 100755 index 2f4e08abb..0994529f9 --- a/sku.0/sys.server/compiled/game/script/conversation/barn_ranchhand.java +++ b/sku.0/sys.server/compiled/game/script/conversation/barn_ranchhand.java @@ -1,33 +1,19 @@ package script.conversation; +import script.library.*; 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.ai_lib; -import script.library.beast_lib; -import script.library.callable; -import script.library.chat; -import script.library.conversation; -import script.library.player_structure; -import script.library.tcg; -import script.library.utils; - -public class barn_ranchhand extends script.base_script +public class barn_ranchhand extends script.conversation.base.conversation_base { + public String conversation = "conversation.barn_ranchhand"; + public String c_stringFile = "conversation/barn_ranchhand"; public barn_ranchhand() { + super.scriptName = "barn_ranchhand"; + super.conversation = conversation; + super.c_stringFile = c_stringFile; } - public static String c_stringFile = "conversation/barn_ranchhand"; - public boolean barn_ranchhand_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException - { - return true; - } - public boolean barn_ranchhand_condition_isBuildingOwner(obj_id player, obj_id npc) throws InterruptedException + private boolean barn_ranchhand_condition_isBuildingOwner(obj_id player, obj_id npc) throws InterruptedException { obj_id building = getTopMostContainer(npc); if (isIdValid(building)) @@ -40,76 +26,47 @@ public class barn_ranchhand extends script.base_script } return false; } - public boolean barn_ranchhand_condition_playerHasBeasts(obj_id player, obj_id npc) throws InterruptedException + private boolean barn_ranchhand_condition_playerHasBeasts(obj_id player) throws InterruptedException { - if (beast_lib.getTotalBeastControlDevices(player) > 0) - { - return true; - } - return false; + return beast_lib.getTotalBeastControlDevices(player) > 0; } - public boolean barn_ranchhand_condition_ranchhandHasBeasts(obj_id player, obj_id npc) throws InterruptedException + private boolean barn_ranchhand_condition_ranchhandHasBeasts(obj_id npc) throws InterruptedException { - if (tcg.getTotalBarnStoredBeastsFromRanchhand(npc) > 0) - { - return true; - } - return false; + return tcg.getTotalBarnStoredBeastsFromRanchhand(npc) > 0; } - public boolean barn_ranchhand_condition_noBeasts(obj_id player, obj_id npc) throws InterruptedException + private boolean barn_ranchhand_condition_noBeasts(obj_id player, obj_id npc) throws InterruptedException { - if (beast_lib.getTotalBeastControlDevices(player) > 0 || tcg.getTotalBarnStoredBeastsFromRanchhand(npc) > 0) - { - return false; - } - return true; + return !(beast_lib.getTotalBeastControlDevices(player) > 0 || tcg.getTotalBarnStoredBeastsFromRanchhand(npc) > 0); } - public boolean barn_ranchhand_condition_barnIsFull(obj_id player, obj_id npc) throws InterruptedException + private boolean barn_ranchhand_condition_barnIsFull(obj_id npc) throws InterruptedException { return tcg.getTotalBarnStoredBeastsFromRanchhand(npc) >= tcg.MAX_NUM_BARN_PETS; } - public boolean barn_ranchhand_condition_playerIsFull(obj_id player, obj_id npc) throws InterruptedException + private boolean barn_ranchhand_condition_playerIsFull(obj_id player) throws InterruptedException { return callable.hasMaxStoredCombatPets(player); } - public void barn_ranchhand_action_storeBeast(obj_id player, obj_id npc) throws InterruptedException + private void barn_ranchhand_action_storeBeast(obj_id player, obj_id npc) throws InterruptedException { tcg.barnStoreBeastPrompt(player, npc); - return; } - public void barn_ranchhand_action_reclaimBeast(obj_id player, obj_id npc) throws InterruptedException + private void barn_ranchhand_action_reclaimBeast(obj_id player, obj_id npc) throws InterruptedException { obj_id barn = getTopMostContainer(npc); if (isIdValid(barn)) { tcg.barnReclaimBeastPrompt(player, barn, npc); } - return; } - public void barn_ranchhand_action_displayBeast(obj_id player, obj_id npc) throws InterruptedException + private void barn_ranchhand_action_displayBeast(obj_id player, obj_id npc) throws InterruptedException { obj_id barn = getTopMostContainer(npc); if (isIdValid(barn)) { tcg.barnDisplayBeastPrompt(player, barn, npc); } - return; } - public String barn_ranchhand_tokenTO_barnOwnerNamePossessive(obj_id player, obj_id npc) throws InterruptedException - { - String name = "the"; - obj_id building = getTopMostContainer(npc); - if (isIdValid(building)) - { - String buildingOwnerName = getStringObjVar(building, player_structure.VAR_OWNER); - if (buildingOwnerName != null && buildingOwnerName.length() > 0) - { - name = "" + toUpper(buildingOwnerName, 0) + "'s"; - } - } - return name; - } - public String barn_ranchhand_tokenTO_barnOwnerName(obj_id player, obj_id npc) throws InterruptedException + private String barn_ranchhand_tokenTO_barnOwnerName(obj_id player, obj_id npc) throws InterruptedException { String name = "Sir"; if (getGender(player) == GENDER_FEMALE) @@ -127,78 +84,56 @@ public class barn_ranchhand extends script.base_script } return name; } - public int barn_ranchhand_handleBranch1(obj_id player, obj_id npc, string_id response) throws InterruptedException + private int barn_ranchhand_handleBranch1(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_6")) { - if (barn_ranchhand_condition_barnIsFull(player, npc)) + if (barn_ranchhand_condition_barnIsFull(npc)) { - string_id message = new string_id(c_stringFile, "s_27"); utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } - if (barn_ranchhand_condition__defaultCondition(player, npc)) - { - barn_ranchhand_action_storeBeast(player, npc); - string_id message = new string_id(c_stringFile, "s_9"); - utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); - npcEndConversationWithMessage(player, message); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_27")); return SCRIPT_CONTINUE; } + barn_ranchhand_action_storeBeast(player, npc); + utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_9")); + return SCRIPT_CONTINUE; } if (response.equals("s_11")) { - if (barn_ranchhand_condition_playerIsFull(player, npc)) + if (barn_ranchhand_condition_playerIsFull(player)) { - string_id message = new string_id(c_stringFile, "s_28"); utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } - if (barn_ranchhand_condition__defaultCondition(player, npc)) - { - barn_ranchhand_action_reclaimBeast(player, npc); - string_id message = new string_id(c_stringFile, "s_14"); - utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); - npcEndConversationWithMessage(player, message); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_28")); return SCRIPT_CONTINUE; } + barn_ranchhand_action_reclaimBeast(player, npc); + utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_14")); + return SCRIPT_CONTINUE; } if (response.equals("s_19")) { - if (barn_ranchhand_condition__defaultCondition(player, npc)) - { - barn_ranchhand_action_displayBeast(player, npc); - string_id message = new string_id(c_stringFile, "s_20"); - utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } + barn_ranchhand_action_displayBeast(player, npc); + utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_20")); + return SCRIPT_CONTINUE; } if (response.equals("s_23")) { - if (barn_ranchhand_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_24"); - utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } + utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_24")); + return SCRIPT_CONTINUE; } return SCRIPT_DEFAULT; } - public int barn_ranchhand_handleBranch8(obj_id player, obj_id npc, string_id response) throws InterruptedException + private int barn_ranchhand_handleBranch8(obj_id player, string_id response) throws InterruptedException { if (response.equals("s_26")) { - if (barn_ranchhand_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_30"); - utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); - npcEndConversationWithMessage(player, message); - return SCRIPT_CONTINUE; - } + utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); + npcEndConversationWithMessage(player, new string_id(c_stringFile, "s_30")); + return SCRIPT_CONTINUE; } return SCRIPT_DEFAULT; } @@ -224,147 +159,28 @@ public class barn_ranchhand extends script.base_script } return SCRIPT_CONTINUE; } - public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info menuInfo) throws InterruptedException - { - int menu = menuInfo.addRootMenu(menu_info_types.CONVERSE_START, null); - menu_info_data menuInfoData = menuInfo.getMenuItemById(menu); - menuInfoData.setServerNotify(false); - setCondition(self, CONDITION_CONVERSABLE); - faceTo(self, player); - return SCRIPT_CONTINUE; - } - public int OnIncapacitated(obj_id self, obj_id killer) throws InterruptedException - { - clearCondition(self, CONDITION_CONVERSABLE); - detachScript(self, "conversation.barn_ranchhand"); - return SCRIPT_CONTINUE; - } - public boolean npcStartConversation(obj_id player, obj_id npc, String convoName, string_id greetingId, prose_package greetingProse, string_id[] responses) throws InterruptedException - { - Object[] objects = new Object[responses.length]; - System.arraycopy(responses, 0, objects, 0, responses.length); - return npcStartConversation(player, npc, convoName, greetingId, greetingProse, objects); - } public int OnStartNpcConversation(obj_id self, obj_id player) throws InterruptedException { - obj_id npc = self; - if (ai_lib.isInCombat(npc) || ai_lib.isInCombat(player)) + if (ai_lib.isInCombat(self) || ai_lib.isInCombat(player)) { return SCRIPT_OVERRIDE; } - if (barn_ranchhand_condition_isBuildingOwner(player, npc)) + if (barn_ranchhand_condition_isBuildingOwner(player, self)) { - string_id message = new string_id(c_stringFile, "s_4"); - int numberOfResponses = 0; - boolean hasResponse = false; - boolean hasResponse0 = false; - if (barn_ranchhand_condition_playerHasBeasts(player, npc)) + if (barn_ranchhand_condition_playerHasBeasts(player)) { - ++numberOfResponses; - hasResponse = true; - hasResponse0 = true; + return craft_response_prose(new String[] {"s_4", "s_6"}, 1, player, self, barn_ranchhand_tokenTO_barnOwnerName(player, self)); } - boolean hasResponse1 = false; - if (barn_ranchhand_condition_ranchhandHasBeasts(player, npc)) + if (barn_ranchhand_condition_ranchhandHasBeasts(self)) { - ++numberOfResponses; - hasResponse = true; - hasResponse1 = true; + return craft_response_prose(new String[] {"s_4", "s_11", "s_19"}, 1, player, self, barn_ranchhand_tokenTO_barnOwnerName(player, self)); } - boolean hasResponse2 = false; - if (barn_ranchhand_condition_ranchhandHasBeasts(player, npc)) + if (barn_ranchhand_condition_noBeasts(player, self)) { - ++numberOfResponses; - hasResponse = true; - hasResponse2 = true; + return craft_response_prose(new String[] {"s_4", "s_23"}, 1, player, self, barn_ranchhand_tokenTO_barnOwnerName(player, self)); } - boolean hasResponse3 = false; - if (barn_ranchhand_condition_noBeasts(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse3 = true; - } - if (hasResponse) - { - int responseIndex = 0; - string_id responses[] = new string_id[numberOfResponses]; - if (hasResponse0) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_6"); - } - if (hasResponse1) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_11"); - } - if (hasResponse2) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_19"); - } - if (hasResponse3) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_23"); - } - utils.setScriptVar(player, "conversation.barn_ranchhand.branchId", 1); - prose_package pp = new prose_package(); - pp.stringId = message; - pp.actor.set(player); - pp.target.set(npc); - pp.other.set(barn_ranchhand_tokenTO_barnOwnerName(player, npc)); - npcStartConversation(player, npc, "barn_ranchhand", null, pp, responses); - } - else - { - prose_package pp = new prose_package(); - pp.stringId = message; - pp.actor.set(player); - pp.target.set(npc); - pp.other.set(barn_ranchhand_tokenTO_barnOwnerName(player, npc)); - chat.chat(npc, player, null, null, pp); - } - return SCRIPT_CONTINUE; } - if (barn_ranchhand_condition__defaultCondition(player, npc)) - { - string_id message = new string_id(c_stringFile, "s_22"); - int numberOfResponses = 0; - boolean hasResponse = false; - boolean hasResponse0 = false; - if (barn_ranchhand_condition__defaultCondition(player, npc)) - { - ++numberOfResponses; - hasResponse = true; - hasResponse0 = true; - } - if (hasResponse) - { - int responseIndex = 0; - string_id responses[] = new string_id[numberOfResponses]; - if (hasResponse0) - { - responses[responseIndex++] = new string_id(c_stringFile, "s_26"); - } - utils.setScriptVar(player, "conversation.barn_ranchhand.branchId", 8); - prose_package pp = new prose_package(); - pp.stringId = message; - pp.actor.set(player); - pp.target.set(npc); - pp.other.set(barn_ranchhand_tokenTO_barnOwnerNamePossessive(player, npc)); - npcStartConversation(player, npc, "barn_ranchhand", null, pp, responses); - } - else - { - prose_package pp = new prose_package(); - pp.stringId = message; - pp.actor.set(player); - pp.target.set(npc); - pp.other.set(barn_ranchhand_tokenTO_barnOwnerNamePossessive(player, npc)); - chat.chat(npc, player, null, null, pp); - } - return SCRIPT_CONTINUE; - } - chat.chat(npc, "Error: All conditions for OnStartNpcConversation were false."); - return SCRIPT_CONTINUE; + return craft_response_prose(new String[] {"s_22", "s_26"}, 8, player, self, barn_ranchhand_tokenTO_barnOwnerName(player, self)); } public int OnNpcConversationResponse(obj_id self, String conversationId, obj_id player, string_id response) throws InterruptedException { @@ -372,17 +188,16 @@ public class barn_ranchhand extends script.base_script { return SCRIPT_CONTINUE; } - obj_id npc = self; int branchId = utils.getIntScriptVar(player, "conversation.barn_ranchhand.branchId"); - if (branchId == 1 && barn_ranchhand_handleBranch1(player, npc, response) == SCRIPT_CONTINUE) + if (branchId == 1 && barn_ranchhand_handleBranch1(player, self, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } - if (branchId == 8 && barn_ranchhand_handleBranch8(player, npc, response) == SCRIPT_CONTINUE) + if (branchId == 8 && barn_ranchhand_handleBranch8(player, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } - chat.chat(npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); + chat.chat(self, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar(player, "conversation.barn_ranchhand.branchId"); return SCRIPT_CONTINUE; } diff --git a/sku.0/sys.server/compiled/game/script/conversation/base/conversation_base.java b/sku.0/sys.server/compiled/game/script/conversation/base/conversation_base.java index fe0e6d65d..341411248 100755 --- a/sku.0/sys.server/compiled/game/script/conversation/base/conversation_base.java +++ b/sku.0/sys.server/compiled/game/script/conversation/base/conversation_base.java @@ -99,4 +99,30 @@ public class conversation_base extends script.base_script return SCRIPT_CONTINUE; } + protected int craft_response_prose(String[] responseStrings, int branchId, obj_id player, obj_id self, String name) throws InterruptedException{ + string_id message = new string_id(c_stringFile, responseStrings[0]); + string_id responses[] = new string_id[responseStrings.length]; + for(int i = 1; i < responseStrings.length; i++){ + responses[i] = new string_id(c_stringFile, responseStrings[i]); + } + if(responses.length > 1){ + utils.setScriptVar(player, conversation + ".branchId", branchId); + prose_package pp = new prose_package(); + pp.stringId = message; + pp.actor.set(player); + pp.target.set(self); + pp.other.set(name); + npcStartConversation(player, self, scriptName, null, pp, responses); + } + else + { + prose_package pp = new prose_package(); + pp.stringId = message; + pp.actor.set(player); + pp.target.set(self); + pp.other.set(name); + chat.chat(self, player, null, null, pp); + } + return SCRIPT_CONTINUE; + } }