package script.conversation; import script.library.ai_lib; import script.library.chat; import script.library.groundquests; import script.library.utils; import script.*; public class ep3_trando_herald extends script.base_script { public ep3_trando_herald() { } public static String c_stringFile = "conversation/ep3_trando_herald"; public boolean ep3_trando_herald_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException { return true; } public boolean ep3_trando_herald_condition_isOnQuest(obj_id player, obj_id npc) throws InterruptedException { int questId1 = questGetQuestId("quest/ep3_trando_herald"); boolean onQuest = questIsQuestActive(questId1, player); return onQuest; } public boolean ep3_trando_herald_condition_questOver(obj_id player, obj_id npc) throws InterruptedException { int questId1 = questGetQuestId("quest/ep3_trando_herald"); boolean onQuest = questIsQuestComplete(questId1, player); return onQuest; } public void ep3_trando_herald_action_giveQuest(obj_id player, obj_id npc) throws InterruptedException { if (!hasScript(player, "event.ep3_trando_herald")) { attachScript(player, "event.ep3_trando_herald"); } int questId = questGetQuestId("quest/ep3_trando_herald"); groundquests.grantQuest(questId, player, npc, true); } public void ep3_trando_herald_action_giveAnotherWp(obj_id player, obj_id npc) throws InterruptedException { if (!hasScript(player, "event.ep3_trando_herald")) { attachScript(player, "event.ep3_trando_herald"); } messageTo(player, "ep3HeraldGiveAnotherWp", null, 3, false); } public int ep3_trando_herald_handleBranch2(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_285")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ep3_trando_herald_action_giveAnotherWp(player, npc); string_id message = new string_id(c_stringFile, "s_286"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int ep3_trando_herald_handleBranch4(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_226")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_228"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (ep3_trando_herald_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_230"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_234"); } utils.setScriptVar(player, "conversation.ep3_trando_herald.branchId", 5); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } if (response.equals("s_254")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_256"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (ep3_trando_herald_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_258"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_278"); } utils.setScriptVar(player, "conversation.ep3_trando_herald.branchId", 12); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } if (response.equals("s_282")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_284"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int ep3_trando_herald_handleBranch5(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_230")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_232"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } if (response.equals("s_234")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_236"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (ep3_trando_herald_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_238"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_250"); } utils.setScriptVar(player, "conversation.ep3_trando_herald.branchId", 7); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int ep3_trando_herald_handleBranch7(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_238")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_240"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (ep3_trando_herald_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_242"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_246"); } utils.setScriptVar(player, "conversation.ep3_trando_herald.branchId", 8); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } if (response.equals("s_250")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_252"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int ep3_trando_herald_handleBranch8(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_242")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ep3_trando_herald_action_giveQuest(player, npc); string_id message = new string_id(c_stringFile, "s_244"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } if (response.equals("s_246")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_248"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int ep3_trando_herald_handleBranch12(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_258")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_260"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (ep3_trando_herald_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_262"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_274"); } utils.setScriptVar(player, "conversation.ep3_trando_herald.branchId", 13); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } if (response.equals("s_278")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_280"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int ep3_trando_herald_handleBranch13(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_262")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_264"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (ep3_trando_herald_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_266"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_270"); } utils.setScriptVar(player, "conversation.ep3_trando_herald.branchId", 14); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } if (response.equals("s_274")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_276"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int ep3_trando_herald_handleBranch14(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_266")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ep3_trando_herald_action_giveQuest(player, npc); string_id message = new string_id(c_stringFile, "s_268"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } if (response.equals("s_270")) { if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_272"); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int OnInitialize(obj_id self) throws InterruptedException { if ((!isMob(self)) || (isPlayer(self))) { detachScript(self, "conversation.ep3_trando_herald"); } 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); faceTo(self, player); return SCRIPT_CONTINUE; } public int OnIncapacitated(obj_id self, obj_id killer) throws InterruptedException { clearCondition(self, CONDITION_CONVERSABLE); detachScript(self, "conversation.ep3_trando_herald"); 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 (ep3_trando_herald_condition_questOver(player, npc)) { string_id message = new string_id(c_stringFile, "s_35"); chat.chat(npc, player, message); return SCRIPT_CONTINUE; } if (ep3_trando_herald_condition_isOnQuest(player, npc)) { string_id message = new string_id(c_stringFile, "s_222"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (ep3_trando_herald_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_285"); } utils.setScriptVar(player, "conversation.ep3_trando_herald.branchId", 2); npcStartConversation(player, npc, "ep3_trando_herald", message, responses); } else { chat.chat(npc, player, message); } return SCRIPT_CONTINUE; } if (ep3_trando_herald_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_224"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } boolean hasResponse2 = false; if (ep3_trando_herald_condition__defaultCondition(player, npc)) { ++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_226"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_254"); } if (hasResponse2) { responses[responseIndex++] = new string_id(c_stringFile, "s_282"); } utils.setScriptVar(player, "conversation.ep3_trando_herald.branchId", 4); npcStartConversation(player, npc, "ep3_trando_herald", message, responses); } else { 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("ep3_trando_herald")) { return SCRIPT_CONTINUE; } obj_id npc = self; int branchId = utils.getIntScriptVar(player, "conversation.ep3_trando_herald.branchId"); if (branchId == 2 && ep3_trando_herald_handleBranch2(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 4 && ep3_trando_herald_handleBranch4(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 5 && ep3_trando_herald_handleBranch5(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 7 && ep3_trando_herald_handleBranch7(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 8 && ep3_trando_herald_handleBranch8(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 12 && ep3_trando_herald_handleBranch12(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 13 && ep3_trando_herald_handleBranch13(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 14 && ep3_trando_herald_handleBranch14(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } chat.chat(npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar(player, "conversation.ep3_trando_herald.branchId"); return SCRIPT_CONTINUE; } }