package script.conversation; import script.library.ai_lib; import script.library.chat; import script.library.utils; import script.*; public class som_pei_yi extends script.base_script { public som_pei_yi() { } public static String c_stringFile = "conversation/som_pei_yi"; public boolean som_pei_yi_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException { return true; } public boolean som_pei_yi_condition_isEntertainer(obj_id player, obj_id npc) throws InterruptedException { int level = getLevel(player); return (utils.isProfession(player, utils.ENTERTAINER) && level >= 46); } public boolean som_pei_yi_condition_isDancer(obj_id player, obj_id npc) throws InterruptedException { return hasSkill(player, "social_dancer_novice"); } public boolean som_pei_yi_condition_hasDance(obj_id player, obj_id npc) throws InterruptedException { return hasCommand(player, "startDance+peiyi"); } public void som_pei_yi_action_grantDance(obj_id player, obj_id npc) throws InterruptedException { sendSystemMessage(player, new string_id("som/som_quest", "grant_dance")); grantCommand(player, "startDance+peiyi"); } public int som_pei_yi_handleBranch1(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_44")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_47"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } boolean hasResponse2 = false; if (som_pei_yi_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_48"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_49"); } if (hasResponse2) { responses[responseIndex++] = new string_id(c_stringFile, "s_50"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 2); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_45")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_46"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch2(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_48")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_53"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } if (response.equals("s_49")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_52"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } if (response.equals("s_50")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_51"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch7(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_17")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_19"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_21"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_25"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 8); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_29")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_31"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_33"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_82"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 11); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_86")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_88"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch8(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_21")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_23"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_33"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_82"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 11); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_25")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_27"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch9(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_33")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_35"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_37"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_78"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 12); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_82")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_84"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch11(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_33")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_35"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_37"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_78"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 12); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_82")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_84"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch12(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_37")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_39"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_41"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_74"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 13); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_78")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_80"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch13(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_41")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_54"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition_isEntertainer(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_56"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_70"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 14); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_74")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_76"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch14(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_56")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_58"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_60"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_66"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 15); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } if (response.equals("s_70")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_72"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int som_pei_yi_handleBranch15(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_60")) { if (som_pei_yi_condition_isEntertainer(player, npc)) { som_pei_yi_action_grantDance(player, npc); string_id message = new string_id(c_stringFile, "s_62"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_64"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } if (response.equals("s_66")) { if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_68"); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int OnInitialize(obj_id self) throws InterruptedException { if ((!isMob(self)) || (isPlayer(self))) { detachScript(self, "conversation.som_pei_yi"); } 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.som_pei_yi"); 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 (som_pei_yi_condition_hasDance(player, npc)) { string_id message = new string_id(c_stringFile, "s_42"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_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_44"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_45"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 1); npcStartConversation(player, npc, "som_pei_yi", message, responses); } else { chat.chat(npc, player, message); } return SCRIPT_CONTINUE; } if (som_pei_yi_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_15"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (som_pei_yi_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } boolean hasResponse2 = false; if (som_pei_yi_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_17"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_29"); } if (hasResponse2) { responses[responseIndex++] = new string_id(c_stringFile, "s_86"); } utils.setScriptVar(player, "conversation.som_pei_yi.branchId", 7); npcStartConversation(player, npc, "som_pei_yi", 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("som_pei_yi")) { return SCRIPT_CONTINUE; } obj_id npc = self; int branchId = utils.getIntScriptVar(player, "conversation.som_pei_yi.branchId"); if (branchId == 1 && som_pei_yi_handleBranch1(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 2 && som_pei_yi_handleBranch2(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 7 && som_pei_yi_handleBranch7(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 8 && som_pei_yi_handleBranch8(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 9 && som_pei_yi_handleBranch9(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 11 && som_pei_yi_handleBranch11(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 12 && som_pei_yi_handleBranch12(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 13 && som_pei_yi_handleBranch13(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 14 && som_pei_yi_handleBranch14(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 15 && som_pei_yi_handleBranch15(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } chat.chat(npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar(player, "conversation.som_pei_yi.branchId"); return SCRIPT_CONTINUE; } }