package script.conversation; import script.*; import script.library.*; public class nexus_travel extends script.base_script { public nexus_travel() { } public static String c_stringFile = "conversation/nexus_travel"; public boolean nexus_travel_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException { return true; } public boolean nexus_travel_condition_isEligible(obj_id player, obj_id npc) throws InterruptedException { return township.isTownshipEligible(player); } public boolean nexus_travel_condition_hasMet(obj_id player, obj_id npc) throws InterruptedException { if (hasObjVar(player, "towship.metTravel") && nexus_travel_condition_isEligible(player, npc)) { return true; } return false; } public boolean nexus_travel_condition_hasFoundAurillia(obj_id player, obj_id npc) throws InterruptedException { return groundquests.hasCompletedQuest(player, "travel_found"); } public boolean nexus_travel_condition_canAffordPay(obj_id player, obj_id npc) throws InterruptedException { return money.hasFunds(player, money.MT_TOTAL, township.TRAVEL_COST); } public void nexus_travel_action_travelAurillia(obj_id player, obj_id npc) throws InterruptedException { String prompt = utils.packStringId(new string_id("nexus", "shuttle_to_aurillia_prompt")); String title = utils.packStringId(new string_id("nexus", "shuttle_to_aurillia_title")); location npcLoc = getLocation(npc); utils.setScriptVar(player, "nexus.travel.npc_loc", npcLoc); utils.setScriptVar(player, "nexus.travel.pid", true); int pid = sui.msgbox(npc, player, prompt, sui.OK_CANCEL, title, 0, "nexusTravelAurillia"); } public void nexus_travel_action_setMet(obj_id player, obj_id npc) throws InterruptedException { setObjVar(player, "towship.metTravel", true); } public int nexus_travel_tokenDI_travelCost(obj_id player, obj_id npc) throws InterruptedException { return township.TRAVEL_COST; } public int nexus_travel_handleBranch1(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_27")) { if (nexus_travel_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_28"); utils.removeScriptVar(player, "conversation.nexus_travel.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int nexus_travel_handleBranch3(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_9")) { if (!nexus_travel_condition_canAffordPay(player, npc)) { string_id message = new string_id(c_stringFile, "s_24"); utils.removeScriptVar(player, "conversation.nexus_travel.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } if (nexus_travel_condition__defaultCondition(player, npc)) { nexus_travel_action_travelAurillia(player, npc); string_id message = new string_id(c_stringFile, "s_12"); utils.removeScriptVar(player, "conversation.nexus_travel.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int nexus_travel_handleBranch6(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_16")) { if (nexus_travel_condition__defaultCondition(player, npc)) { nexus_travel_action_setMet(player, npc); string_id message = new string_id(c_stringFile, "s_18"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (nexus_travel_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (nexus_travel_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_22"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_23"); } utils.setScriptVar(player, "conversation.nexus_travel.branchId", 7); prose_package pp = new prose_package(); pp.stringId = message; pp.actor.set(player); pp.target.set(npc); pp.digitInteger = nexus_travel_tokenDI_travelCost(player, npc); npcSpeak(player, pp); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.nexus_travel.branchId"); prose_package pp = new prose_package(); pp.stringId = message; pp.actor.set(player); pp.target.set(npc); pp.digitInteger = nexus_travel_tokenDI_travelCost(player, npc); npcEndConversationWithMessage(player, pp); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int nexus_travel_handleBranch7(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_22")) { if (!nexus_travel_condition_canAffordPay(player, npc)) { string_id message = new string_id(c_stringFile, "s_24"); utils.removeScriptVar(player, "conversation.nexus_travel.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } if (nexus_travel_condition__defaultCondition(player, npc)) { nexus_travel_action_travelAurillia(player, npc); string_id message = new string_id(c_stringFile, "s_12"); utils.removeScriptVar(player, "conversation.nexus_travel.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } if (response.equals("s_23")) { if (nexus_travel_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_26"); utils.removeScriptVar(player, "conversation.nexus_travel.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int nexusTravelAurillia(obj_id self, dictionary params) throws InterruptedException { int btn = sui.getIntButtonPressed(params); obj_id player = sui.getPlayerId(params); location npcLoc = utils.getLocationScriptVar(player, "nexus.travel.npc_loc"); location playerLoc = getLocation(player); if (btn == sui.BP_OK) { if (!npcLoc.area.equals(playerLoc.area)) { sendSystemMessage(self, new string_id("nexus", "travel_too_far")); utils.removeScriptVarTree(player, "nexus.travel"); return SCRIPT_CONTINUE; } if (getDistance(npcLoc, playerLoc) < 10) { dictionary d = new dictionary(); d.put("price", township.TRAVEL_COST); d.put("player", player); d.put("npc", self); if (transition.hasPermissionForZone(player, "aurillia_township", "initialRequiredFlag")) { if (money.requestPayment(player, "aurillia_travel", township.TRAVEL_COST, "handleTransaction", d, true)) { transition.zonePlayerNoGate("aurillia_township", player, true); } } else { transition.notifyPlayerOfInvalidPermission(player, "aurillia_township"); } } else { sendSystemMessage(self, new string_id("nexus", "travel_too_far")); } utils.removeScriptVarTree(player, "nexus.travel"); } if (btn == sui.BP_CANCEL) { utils.removeScriptVarTree(player, "nexus.travel"); } utils.removeScriptVarTree(player, "nexus.travel"); return SCRIPT_CONTINUE; } public int handleTransaction(obj_id self, dictionary params) throws InterruptedException { if (params == null || params.isEmpty()) { return SCRIPT_CONTINUE; } obj_id player = params.getObjId("player"); int price = params.getInt("price"); if (!isIdValid(player) || price < 1) { return SCRIPT_CONTINUE; } if (params.getInt(money.DICT_CODE) == money.RET_FAIL) { chat.chat(self, player, new string_id("spam", "no_money")); return SCRIPT_CONTINUE; } return SCRIPT_CONTINUE; } public int OnInitialize(obj_id self) throws InterruptedException { if ((!isTangible(self)) || (isPlayer(self))) { detachScript(self, "conversation.nexus_travel"); } setCondition(self, CONDITION_CONVERSABLE); return SCRIPT_CONTINUE; } public int OnAttach(obj_id self) throws InterruptedException { setCondition(self, CONDITION_CONVERSABLE); 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.nexus_travel"); 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)) { return SCRIPT_OVERRIDE; } if (!nexus_travel_condition_hasFoundAurillia(player, npc)) { string_id message = new string_id(c_stringFile, "s_19"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (nexus_travel_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_27"); } utils.setScriptVar(player, "conversation.nexus_travel.branchId", 1); npcStartConversation(player, npc, "nexus_travel", message, responses); } else { chat.chat(npc, player, message); } return SCRIPT_CONTINUE; } if (nexus_travel_condition_hasMet(player, npc)) { string_id message = new string_id(c_stringFile, "s_7"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (nexus_travel_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_9"); } utils.setScriptVar(player, "conversation.nexus_travel.branchId", 3); prose_package pp = new prose_package(); pp.stringId = message; pp.actor.set(player); pp.target.set(npc); npcStartConversation(player, npc, "nexus_travel", null, pp, responses); } else { prose_package pp = new prose_package(); pp.stringId = message; pp.actor.set(player); pp.target.set(npc); chat.chat(npc, player, null, null, pp); } return SCRIPT_CONTINUE; } if (nexus_travel_condition_isEligible(player, npc)) { string_id message = new string_id(c_stringFile, "s_14"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (nexus_travel_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_16"); } utils.setScriptVar(player, "conversation.nexus_travel.branchId", 6); npcStartConversation(player, npc, "nexus_travel", message, responses); } else { chat.chat(npc, player, message); } return SCRIPT_CONTINUE; } if (nexus_travel_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_30"); chat.chat(npc, player, message); return SCRIPT_CONTINUE; } chat.chat(npc, "Error: All conditions for OnStartNpcConversation were false."); return SCRIPT_CONTINUE; } public int OnNpcConversationResponse(obj_id self, String conversationId, obj_id player, string_id response) throws InterruptedException { if (!conversationId.equals("nexus_travel")) { return SCRIPT_CONTINUE; } obj_id npc = self; int branchId = utils.getIntScriptVar(player, "conversation.nexus_travel.branchId"); if (branchId == 1 && nexus_travel_handleBranch1(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 3 && nexus_travel_handleBranch3(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 6 && nexus_travel_handleBranch6(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 7 && nexus_travel_handleBranch7(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } chat.chat(npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar(player, "conversation.nexus_travel.branchId"); return SCRIPT_CONTINUE; } }