package script.conversation; import script.library.ai_lib; import script.library.chat; import script.library.utils; import script.*; public class village_elder_2 extends script.base_script { public village_elder_2() { } public static String c_stringFile = "conversation/village_elder_2"; public boolean village_elder_2_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException { return true; } public boolean village_elder_2_condition_needCrystal(obj_id player, obj_id npc) throws InterruptedException { if (utils.playerHasItemByTemplateInBankOrInventory(player, "object/tangible/loot/quest/force_sensitive/force_crystal.iff")) { return false; } return true; } public void village_elder_2_action_giveCrystal(obj_id player, obj_id npc) throws InterruptedException { createObjectInInventoryAllowOverload("object/tangible/loot/quest/force_sensitive/force_crystal.iff", player); return; } public int OnInitialize(obj_id self) throws InterruptedException { if ((!isMob(self)) || (isPlayer(self))) { detachScript(self, "npc.conversation.village_elder_2"); } 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, "npc.conversation.village_elder_2"); 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 { if (ai_lib.isInCombat(self) || ai_lib.isInCombat(player)) { return SCRIPT_OVERRIDE; } if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_5d7558d4"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } boolean hasResponse2 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse2 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_8caad960"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_5e0af20b"); } if (hasResponse2) { responses[responseIndex++] = new string_id(c_stringFile, "s_9dc8bf5d"); } setObjVar(player, "conversation.village_elder_2.branchId", 1); npcStartConversation(player, self, "village_elder_2", message, responses); } else { chat.chat(self, player, message); } return SCRIPT_CONTINUE; } chat.chat(self, "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("village_elder_2")) { return SCRIPT_CONTINUE; } int branchId = getIntObjVar(player, "conversation.village_elder_2.branchId"); if (branchId == 1 && response.equals("s_8caad960")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_96bf47c1"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++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_cc6522f9"); } setObjVar(player, "conversation.village_elder_2.branchId", 2); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Thanks for those supplies. They really are coming in handy.' were false."); return SCRIPT_CONTINUE; } if (branchId == 1 && response.equals("s_5e0af20b")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_bd4cef4a"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } boolean hasResponse2 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse2 = true; } boolean hasResponse3 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++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_4ecdf473"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_1607b22e"); } if (hasResponse2) { responses[responseIndex++] = new string_id(c_stringFile, "s_5bdbe99a"); } if (hasResponse3) { responses[responseIndex++] = new string_id(c_stringFile, "s_c7c2a3b0"); } setObjVar(player, "conversation.village_elder_2.branchId", 10); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Thanks for those supplies. They really are coming in handy.' were false."); return SCRIPT_CONTINUE; } if (branchId == 1 && response.equals("s_9dc8bf5d")) { if (village_elder_2_condition_needCrystal(player, self)) { village_elder_2_action_giveCrystal(player, self); string_id message = new string_id(c_stringFile, "s_bdd3bae5"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } if (!village_elder_2_condition_needCrystal(player, self)) { string_id message = new string_id(c_stringFile, "s_199fe2af"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Thanks for those supplies. They really are coming in handy.' were false."); return SCRIPT_CONTINUE; } if (branchId == 2 && response.equals("s_cc6522f9")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_c3add11e"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++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_9940e942"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_70509760"); } setObjVar(player, "conversation.village_elder_2.branchId", 3); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Oh, excuse me then. There's been so many coming and going lately I have lost track. We're rebuilding after a recent attack.' were false."); return SCRIPT_CONTINUE; } if (branchId == 3 && response.equals("s_9940e942")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_d6a8b96b"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++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_4ecdf473"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_1607b22e"); } setObjVar(player, "conversation.village_elder_2.branchId", 4); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'A gang called the Sith Shadows. They are still out there, planning their next attack I am sure.' were false."); return SCRIPT_CONTINUE; } if (branchId == 3 && response.equals("s_70509760")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_1414eb3a"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (village_elder_2_condition__defaultCondition(player, self)) { ++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_5bdbe99a"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_c7c2a3b0"); } setObjVar(player, "conversation.village_elder_2.branchId", 7); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'A gang called the Sith Shadows. They are still out there, planning their next attack I am sure.' were false."); return SCRIPT_CONTINUE; } if (branchId == 4 && response.equals("s_4ecdf473")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_7471e00a"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'That's an excellent idea. Perhaps if we attack them directly we can take some of their attention away from their attacks on our supply convoys. They have been either destroying or turning back all of the convoys that have been headed to us.' were false."); return SCRIPT_CONTINUE; } if (branchId == 4 && response.equals("s_1607b22e")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_70a99316"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'That's an excellent idea. Perhaps if we attack them directly we can take some of their attention away from their attacks on our supply convoys. They have been either destroying or turning back all of the convoys that have been headed to us.' were false."); return SCRIPT_CONTINUE; } if (branchId == 7 && response.equals("s_5bdbe99a")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_57c6f33"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'It sure couldn't hurt. Thank you for your help. We need both craftsmen and supplies. What would you prefer to do?' were false."); return SCRIPT_CONTINUE; } if (branchId == 7 && response.equals("s_c7c2a3b0")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_c8f614a1"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'It sure couldn't hurt. Thank you for your help. We need both craftsmen and supplies. What would you prefer to do?' were false."); return SCRIPT_CONTINUE; } if (branchId == 10 && response.equals("s_4ecdf473")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_2f1f1ed"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Yes, please. That Sith Shadow gang is still trying to destroy us. We're running low on supplies because our convoys can't get through, and we're sitting ducks right now if they decide to attack.' were false."); return SCRIPT_CONTINUE; } if (branchId == 10 && response.equals("s_1607b22e")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_a60bdc2c"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Yes, please. That Sith Shadow gang is still trying to destroy us. We're running low on supplies because our convoys can't get through, and we're sitting ducks right now if they decide to attack.' were false."); return SCRIPT_CONTINUE; } if (branchId == 10 && response.equals("s_5bdbe99a")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_a601e626"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Yes, please. That Sith Shadow gang is still trying to destroy us. We're running low on supplies because our convoys can't get through, and we're sitting ducks right now if they decide to attack.' were false."); return SCRIPT_CONTINUE; } if (branchId == 10 && response.equals("s_c7c2a3b0")) { if (village_elder_2_condition__defaultCondition(player, self)) { string_id message = new string_id(c_stringFile, "s_278134b4"); removeObjVar(player, "conversation.village_elder_2.branchId"); npcSpeak(player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Yes, please. That Sith Shadow gang is still trying to destroy us. We're running low on supplies because our convoys can't get through, and we're sitting ducks right now if they decide to attack.' were false."); return SCRIPT_CONTINUE; } chat.chat(self, "Error: Fell through all branches and responses for OnNpcConversationResponse."); removeObjVar(player, "conversation.village_elder_2.branchId"); return SCRIPT_CONTINUE; } }