// ====================================================================== // // npe_medic_wounded.script // Copyright 2004, Sony Online Entertainment // All Rights Reserved. // // Created with SwgConversationEditor 1.36 - DO NOT EDIT THIS AUTO-GENERATED FILE! // // ====================================================================== // ====================================================================== // Library Includes // ====================================================================== include library.ai_lib; include library.chat; include library.groundquests; include library.npe; include library.utils; // ====================================================================== // Script Constants // ====================================================================== string c_stringFile = "conversation/npe_medic_wounded"; // ====================================================================== // Script Conditions // ====================================================================== boolean npe_medic_wounded_condition__defaultCondition (obj_id player, obj_id npc) { return true; } // ---------------------------------------------------------------------- boolean npe_medic_wounded_condition_isFirstToHeal (obj_id player, obj_id npc) { boolean iAmFirst = false; if(groundquests.hasCompletedTask(player, "npe_medic", "npe_medic_heal_1")) { return iAmFirst; } if(groundquests.isQuestActive(player, "npe_medic")) { if(hasObjVar(npc, "quest.taskName")) { string taskName = getStringObjVar(npc, "quest.taskName"); if(taskName.equals("npe_medic_heal_1")) { iAmFirst = true; } } } return iAmFirst; } // ---------------------------------------------------------------------- boolean npe_medic_wounded_condition_wasHealed1 (obj_id player, obj_id npc) { boolean wasHealed = false; string taskName = getStringObjVar(npc, "quest.taskName"); if(taskName.equals("npe_medic_heal_1")) { if(groundquests.hasCompletedTask(player, "npe_medic", "npe_medic_heal_1")) wasHealed = true; } return wasHealed; } // ====================================================================== // Script Actions // ====================================================================== void npe_medic_wounded_action_sendSignalHealed (obj_id player, obj_id npc) { groundquests.sendSignal(player, "npe_medic_heal_worker_1"); return; } // ---------------------------------------------------------------------- void npe_medic_wounded_action_facePlayer (obj_id player, obj_id npc) { faceTo(npc, player); } // ---------------------------------------------------------------------- void npe_medic_wounded_action_giveComm (obj_id player, obj_id npc) { utils.removeScriptVar(player, "npe.heal"); npe.giveHealPopUp(player, npc); } // ====================================================================== // Script %TO Tokens // ====================================================================== // ====================================================================== // Script %DI Tokens // ====================================================================== // ====================================================================== // Script %DF Tokens // ====================================================================== // ====================================================================== // handleBranch Functions // ====================================================================== int npe_medic_wounded_handleBranch1 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Ohh, my hand! I burned it while repairing one of the X-95 starfighters in the hangar. Do you have anything for the pain? //-- [RESPONSE NOTE] //-- PLAYER: I can help you. I have a bactapack. if (response == "s_17") { //-- [NOTE] if (npe_medic_wounded_condition__defaultCondition (player, npc)) { npe_medic_wounded_action_giveComm (player, npc); //-- NPC: Thank you! string_id message = new string_id (c_stringFile, "s_18"); utils.removeScriptVar (player, "conversation.npe_medic_wounded.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int npe_medic_wounded_handleBranch3 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Thank you so much! My hand feels better now. I think I'll rest here for a while, though. //-- [RESPONSE NOTE] //-- PLAYER: That's good to hear. if (response == "s_24") { //-- [NOTE] if (npe_medic_wounded_condition__defaultCondition (player, npc)) { //-- NPC: Thank you. string_id message = new string_id (c_stringFile, "s_26"); utils.removeScriptVar (player, "conversation.npe_medic_wounded.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- // ====================================================================== // User Script Triggers // ====================================================================== trigger OnInitialize () { if ((!isMob (self)) || (isPlayer (self))) detachScript(self, "conversation.npe_medic_wounded"); setCondition (self, CONDITION_CONVERSABLE); setInvulnerable( self, true ); setName( self, "Injured Mechanic"); setPosture(self, POSTURE_SITTING); setAnimationMood(self, "meditating"); return SCRIPT_CONTINUE; } trigger OnAttach () { setCondition (self, CONDITION_CONVERSABLE); setInvulnerable( self, true ); setName( self, "Injured Mechanic"); setPosture(self, POSTURE_SITTING); setAnimationMood(self, "meditating"); return SCRIPT_CONTINUE; } trigger OnObjectMenuRequest (obj_id player, menu_info menuInfo) { 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; } trigger OnIncapacitated (obj_id killer) { clearCondition (self, CONDITION_CONVERSABLE); detachScript (self, "conversation.npe_medic_wounded"); return SCRIPT_CONTINUE; } // ====================================================================== // Script Triggers // ====================================================================== //-- This function should move to base_class.java boolean npcStartConversation(obj_id player, obj_id npc, string convoName, string_id greetingId, prose_package greetingProse, string_id[] responses) { Object[] objects = new Object[responses.length]; System.arraycopy(responses, 0, objects, 0, responses.length); return npcStartConversation(player, npc, convoName, greetingId, greetingProse, objects); } // ---------------------------------------------------------------------- trigger OnStartNpcConversation (obj_id player) { obj_id npc = self; if (ai_lib.isInCombat (npc) || ai_lib.isInCombat (player)) return SCRIPT_OVERRIDE; //-- [NOTE] if (npe_medic_wounded_condition_isFirstToHeal (player, npc)) { //-- NPC: Ohh, my hand! I burned it while repairing one of the X-95 starfighters in the hangar. Do you have anything for the pain? string_id message = new string_id (c_stringFile, "s_10"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: I can help you. I have a bactapack. boolean hasResponse0 = false; if (npe_medic_wounded_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_17"); utils.setScriptVar (player, "conversation.npe_medic_wounded.branchId", 1); npcStartConversation (player, npc, "npe_medic_wounded", message, responses); } else { chat.chat (npc, player, message); } return SCRIPT_CONTINUE; } //-- [NOTE] if (npe_medic_wounded_condition_wasHealed1 (player, npc)) { //-- NPC: Thank you so much! My hand feels better now. I think I'll rest here for a while, though. string_id message = new string_id (c_stringFile, "s_16"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: That's good to hear. boolean hasResponse0 = false; if (npe_medic_wounded_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_24"); utils.setScriptVar (player, "conversation.npe_medic_wounded.branchId", 3); npcStartConversation (player, npc, "npe_medic_wounded", message, responses); } else { chat.chat (npc, player, message); } return SCRIPT_CONTINUE; } //-- [NOTE] if (npe_medic_wounded_condition__defaultCondition (player, npc)) { //-- NPC: Ohh, it hurts... string_id message = new string_id (c_stringFile, "s_40"); chat.chat (npc, player, message); return SCRIPT_CONTINUE; } chat.chat (npc, "Error: All conditions for OnStartNpcConversation were false."); return SCRIPT_CONTINUE; } // ---------------------------------------------------------------------- trigger OnNpcConversationResponse (string conversationId, obj_id player, string_id response) { if (conversationId != "npe_medic_wounded") return SCRIPT_CONTINUE; obj_id npc = self; int branchId = utils.getIntScriptVar (player, "conversation.npe_medic_wounded.branchId"); if (branchId == 1 && npe_medic_wounded_handleBranch1 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 3 && npe_medic_wounded_handleBranch3 (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_medic_wounded.branchId"); return SCRIPT_CONTINUE; } // ======================================================================