package script.conversation; import script.*; import script.library.*; public class npe_commando extends script.base_script { public npe_commando() { } public static String c_stringFile = "conversation/npe_commando"; public boolean npe_commando_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException { return true; } public boolean npe_commando_condition_wantsCommando(obj_id player, obj_id npc) throws InterruptedException { return npe_commando_condition_isCommandoTemplate(player, npc) && groundquests.isQuestActive(player, "npe_pointer_commando_template"); } public boolean npe_commando_condition_isCommandoTemplate(obj_id player, obj_id npc) throws InterruptedException { String playerTemplate = getSkillTemplate(player); if (playerTemplate.contains("commando")) { return true; } else { return false; } } public boolean npe_commando_condition_fromBrawler(obj_id player, obj_id npc) throws InterruptedException { return groundquests.isTaskActive(player, "npe_commando_tracker", "done"); } public boolean npe_commando_condition_finishFinalTask(obj_id player, obj_id npc) throws InterruptedException { return groundquests.isTaskActive(player, "npe_commando", "final_return"); } public boolean npe_commando_condition_finishedFirstTask(obj_id player, obj_id npc) throws InterruptedException { return groundquests.isTaskActive(player, "npe_commando", "return1"); } public boolean npe_commando_condition_finishedSecondTask(obj_id player, obj_id npc) throws InterruptedException { return groundquests.isTaskActive(player, "npe_commando", "return2"); } public boolean npe_commando_condition_isOnTask(obj_id player, obj_id npc) throws InterruptedException { return (groundquests.isTaskActive(player, "npe_commando", "elevator_toDroid") || groundquests.isTaskActive(player, "npe_commando", "elevator_toData") || groundquests.isTaskActive(player, "npe_commando", "defuse") || groundquests.isTaskActive(player, "npe_commando", "thugs") || groundquests.isTaskActive(player, "npe_commando", "get_data")); } public boolean npe_commando_condition_defusedBomb(obj_id player, obj_id npc) throws InterruptedException { return true; } public boolean npe_commando_condition_finishedAll(obj_id player, obj_id npc) throws InterruptedException { return groundquests.hasCompletedQuest(player, "npe_commando"); } public boolean npe_commando_condition_hasFinishedInaldraLt(obj_id player, obj_id npc) throws InterruptedException { return (groundquests.hasCompletedQuest(player, "npe_side_smuggle") && groundquests.hasCompletedQuest(player, "npe_side4") && groundquests.hasCompletedQuest(player, "npe_brawler_4a") && groundquests.hasCompletedQuest(player, "npe_side_hutt_slicers") && groundquests.hasCompletedQuest(player, "npe_scout_1") && groundquests.hasCompletedQuest(player, "npe_side3") && groundquests.hasCompletedQuest(player, "npe_side5") && space_quest.hasWonQuest(player, "escort", "npe_training_3") && space_quest.hasCompletedQuestRecursive(player, "patrol", "npe_easy_main_4") && space_quest.hasWonQuest(player, "destroy", "npe_med_main_4") && space_quest.hasWonQuest(player, "destroy", "npe_hard_main_3") && groundquests.hasCompletedQuest(player, "npe_side2") && groundquests.hasCompletedQuest(player, "npe_side_jolka") && groundquests.hasCompletedQuest(player, "npe_inaldra_quest") && groundquests.hasCompletedQuest(player, "npe_side_dungeon_soldier") && groundquests.hasCompletedQuest(player, "npe_side_dungeon_dna") && groundquests.hasCompletedQuest(player, "npe_frelka_transition") && (groundquests.hasCompletedQuest(player, "npe_imperial_1") || groundquests.hasCompletedQuest(player, "npe_rebel_2"))); } public void npe_commando_action_giveInaldraPointer(obj_id player, obj_id npc) throws InterruptedException { groundquests.grantQuest(player, "npe_pointer_secretary"); } public void npe_commando_action_giveCommandoQuest(obj_id player, obj_id npc) throws InterruptedException { npe.giveGrenadePopUp(player, npc); groundquests.grantQuest(player, "npe_commando"); groundquests.sendSignal(player, "npe_commando_done"); groundquests.sendSignal(player, "found_commando"); if (!hasObjVar(player, npe.QUEST_REWORK_VAR)) { setObjVar(player, npe.QUEST_REWORK_VAR, npe.QUEST_ENUMERATION); } boolean hasItem = false; obj_id[] playerStuff = getInventoryAndEquipment(player); for (obj_id obj_id : playerStuff) { String templateName = static_item.getStaticItemName(obj_id); if (templateName != null) { if (templateName.equals("weapon_grenade_fragmentation_01_01")) { hasItem = true; newbieTutorialSetToolbarElement(player, 5, obj_id); newbieTutorialHighlightUIElement(player, "/GroundHUD.Toolbar.volume.5", 5.0f); } } } if (hasItem == false) { obj_id grenade = static_item.createNewItemFunction("weapon_grenade_fragmentation_01_01", player); newbieTutorialSetToolbarElement(player, 5, grenade); obj_id[] items = new obj_id[1]; items[0] = grenade; showLootBox(player, items); dictionary dic = new dictionary(); dic.put("player", player); dic.put("location", 5); dic.put("time", 5.0f); messageTo(player, "makeUiElementAnimate", dic, 0.25f, true); } } public void npe_commando_action_giveFirstSignal(obj_id player, obj_id npc) throws InterruptedException { groundquests.sendSignal(player, "npe_grenade_done"); } public void npe_commando_action_giveSecondSignal(obj_id player, obj_id npc) throws InterruptedException { groundquests.sendSignal(player, "npe_datapad_done"); } public void npe_commando_action_facePlayer(obj_id player, obj_id npc) throws InterruptedException { faceTo(npc, player); } public void npe_commando_action_giveReward(obj_id player, obj_id npc) throws InterruptedException { groundquests.sendSignal(player, "final_return"); setObjVar(player, "npe.finishedTemplate", 1); } public void npe_commando_action_giveHanPointer(obj_id player, obj_id npc) throws InterruptedException { groundquests.grantQuest(player, "npe_job_pointer_han"); } public int npe_commando_handleBranch2(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_64")) { if (npe_commando_condition__defaultCondition(player, npc)) { npe_commando_action_giveInaldraPointer(player, npc); string_id message = new string_id(c_stringFile, "s_84"); utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } if (response.equals("s_69")) { if (npe_commando_condition__defaultCondition(player, npc)) { npe_commando_action_giveHanPointer(player, npc); string_id message = new string_id(c_stringFile, "s_88"); utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch5(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_46")) { if (npe_commando_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_48"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_67"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 6); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch6(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_67")) { if (npe_commando_condition__defaultCondition(player, npc)) { npe_commando_action_giveReward(player, npc); string_id message = new string_id(c_stringFile, "s_68"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_42"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 7); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch7(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_42")) { if (npe_commando_condition__defaultCondition(player, npc)) { npe_commando_action_giveHanPointer(player, npc); string_id message = new string_id(c_stringFile, "s_47"); utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch9(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_36")) { doAnimationAction(player, "salute1"); if (npe_commando_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_43"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_45"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 10); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch10(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_45")) { if (npe_commando_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_49"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_53"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 11); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch11(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_53")) { if (npe_commando_condition__defaultCondition(player, npc)) { npe_commando_action_giveFirstSignal(player, npc); string_id message = new string_id(c_stringFile, "s_57"); utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch13(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_56")) { if (npe_commando_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_60"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_63"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 14); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch14(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_63")) { if (npe_commando_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_70"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_72"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 15); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.npe_commando.branchId"); npcEndConversationWithMessage(player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int npe_commando_handleBranch15(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_72")) { if (npe_commando_condition__defaultCondition(player, npc)) { npe_commando_action_giveCommandoQuest(player, npc); string_id message = new string_id(c_stringFile, "s_74"); utils.removeScriptVar(player, "conversation.npe_commando.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.npe_commando"); } setCondition(self, CONDITION_CONVERSABLE); setInvulnerable(self, true); ai_lib.setCustomIdleAnimation(self, "npc_imperial"); setName(self, "Sergeant Snopel (Commando)"); return SCRIPT_CONTINUE; } public int OnAttach(obj_id self) throws InterruptedException { setCondition(self, CONDITION_CONVERSABLE); setInvulnerable(self, true); ai_lib.setCustomIdleAnimation(self, "npc_imperial"); setName(self, "Sergeant Snopel (Commando)"); 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.npe_commando"); 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 (npe_commando_condition_isOnTask(player, npc)) { npe_commando_action_facePlayer(player, npc); string_id message = new string_id(c_stringFile, "s_31"); chat.chat(npc, player, message); return SCRIPT_CONTINUE; } if (npe_commando_condition_finishedAll(player, npc)) { string_id message = new string_id(c_stringFile, "s_65"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (!npe_commando_condition_hasFinishedInaldraLt(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (npe_commando_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_64"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_69"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 2); prose_package pp = new prose_package(); pp.stringId = message; pp.actor.set(player); pp.target.set(npc); npcStartConversation(player, npc, "npe_commando", 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 (npe_commando_condition_finishFinalTask(player, npc)) { npe_commando_action_facePlayer(player, npc); string_id message = new string_id(c_stringFile, "s_44"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_46"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 5); npcStartConversation(player, npc, "npe_commando", message, responses); } else { chat.chat(npc, player, message); } return SCRIPT_CONTINUE; } if (npe_commando_condition_finishedFirstTask(player, npc)) { npe_commando_action_facePlayer(player, npc); string_id message = new string_id(c_stringFile, "s_34"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_36"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 9); npcStartConversation(player, npc, "npe_commando", message, responses); } else { chat.chat(npc, player, message); } return SCRIPT_CONTINUE; } if (npe_commando_condition_wantsCommando(player, npc)) { npe_commando_action_facePlayer(player, npc); string_id message = new string_id(c_stringFile, "s_52"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (npe_commando_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_56"); } utils.setScriptVar(player, "conversation.npe_commando.branchId", 13); npcStartConversation(player, npc, "npe_commando", message, responses); } else { chat.chat(npc, player, message); } return SCRIPT_CONTINUE; } if (npe_commando_condition__defaultCondition(player, npc)) { npe_commando_action_facePlayer(player, npc); string_id message = new string_id(c_stringFile, "s_76"); 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("npe_commando")) { return SCRIPT_CONTINUE; } obj_id npc = self; int branchId = utils.getIntScriptVar(player, "conversation.npe_commando.branchId"); if (branchId == 2 && npe_commando_handleBranch2(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 5 && npe_commando_handleBranch5(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 6 && npe_commando_handleBranch6(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 7 && npe_commando_handleBranch7(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 9 && npe_commando_handleBranch9(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 10 && npe_commando_handleBranch10(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 11 && npe_commando_handleBranch11(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 13 && npe_commando_handleBranch13(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 14 && npe_commando_handleBranch14(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 15 && npe_commando_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.npe_commando.branchId"); return SCRIPT_CONTINUE; } }