// ====================================================================== // // trainer_beast_master.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.beast_lib; include library.chat; include library.money; include library.utils; // ====================================================================== // Script Constants // ====================================================================== string c_stringFile = "conversation/trainer_beast_master"; // ====================================================================== // Script Conditions // ====================================================================== boolean trainer_beast_master_condition__defaultCondition (obj_id player, obj_id npc) { return true; } // ---------------------------------------------------------------------- boolean trainer_beast_master_condition_canLearnNextProvoke (obj_id player, obj_id npc) { string bestProvoke = beast_lib.getBestBeastMasterSkill(player, "bm_provoke_1"); if (bestProvoke == "bm_provoke_5") return false; int playerLevel = getLevel(player); if (playerLevel > 72 && !bestProvoke.equals("bm_provoke_5")) { return true; } if (playerLevel > 54 && !bestProvoke.equals("bm_provoke_4")) { return true; } if (playerLevel > 36 && !bestProvoke.equals("bm_provoke_3")) { return true; } if (playerLevel > 18 && !bestProvoke.equals("bm_provoke_2")) { return true; } return false; } // ---------------------------------------------------------------------- boolean trainer_beast_master_condition_hasActiveBeast (obj_id player, obj_id npc) { obj_id activePet = beast_lib.getBeastOnPlayer(player); return (beast_lib.isBeastMaster(player) && isIdValid(activePet) && exists(activePet) && beast_lib.isBeast(activePet)); } // ---------------------------------------------------------------------- boolean trainer_beast_master_condition_canPayFee (obj_id player, obj_id npc) { int balance = getTotalMoney(player); return 5000 <= balance; } // ---------------------------------------------------------------------- boolean trainer_beast_master_condition_knowsProvoke (obj_id player, obj_id npc) { string[] knownSkills = beast_lib.getKnownSkills(player); if (knownSkills == null || knownSkills.length == 0) return false; for (int i=0;i Functions // ====================================================================== int trainer_beast_master_handleBranch1 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Greetings Beast Master, what business do we have today? //-- [RESPONSE NOTE] //-- PLAYER: I am looking to un-train my beast. if (response == "s_6") { //-- [NOTE] if (trainer_beast_master_condition__defaultCondition (player, npc)) { //-- NPC: I can do this for a 5,000 credit fee. Are you sure you wish to retrain your pet? string_id message = new string_id (c_stringFile, "s_8"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: Yes, retrain my pet. boolean hasResponse0 = false; if (trainer_beast_master_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: No boolean hasResponse1 = false; if (trainer_beast_master_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_10"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_16"); utils.setScriptVar (player, "conversation.trainer_beast_master.branchId", 2); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: Is there a way for my beast to keep the attention of our adversaries if (response == "s_20") { //-- [NOTE] if (trainer_beast_master_condition__defaultCondition (player, npc)) { //-- NPC: I can teach you a skill that once trained to your pet will enable him to generate a large amount of threat towards your opponents. We Beast Masters call this skill Provoke. string_id message = new string_id (c_stringFile, "s_22"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: I am in need of this skill. boolean hasResponse0 = false; if (trainer_beast_master_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.trainer_beast_master.branchId", 7); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: I am ready to upgrade my Provoke skill. if (response == "s_28") { //-- [NOTE] if (!trainer_beast_master_condition_canLearnNextProvoke (player, npc)) { //-- NPC: I have nothing more to teach you. string_id message = new string_id (c_stringFile, "s_30"); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (trainer_beast_master_condition__defaultCondition (player, npc)) { trainer_beast_master_action_teachNextProvoke (player, npc); //-- NPC: Use it well. string_id message = new string_id (c_stringFile, "s_32"); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: Now that I think of it, there is nothing I really need. if (response == "s_35") { //-- [NOTE] if (trainer_beast_master_condition__defaultCondition (player, npc)) { //-- NPC: Very well. string_id message = new string_id (c_stringFile, "s_36"); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int trainer_beast_master_handleBranch2 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: I can do this for a 5,000 credit fee. Are you sure you wish to retrain your pet? //-- [RESPONSE NOTE] //-- PLAYER: Yes, retrain my pet. if (response == "s_10") { //-- [NOTE] if (!trainer_beast_master_condition_canPayFee (player, npc)) { //-- NPC: It appears you cannot afford this service. string_id message = new string_id (c_stringFile, "s_12"); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (!trainer_beast_master_condition_hasActiveBeast (player, npc)) { //-- NPC: You must have a beast out in order to revoke its skills. string_id message = new string_id (c_stringFile, "s_39"); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (trainer_beast_master_condition__defaultCondition (player, npc)) { trainer_beast_master_action_clearPetSkills (player, npc); //-- NPC: Your beast is ready to be retrained. string_id message = new string_id (c_stringFile, "s_14"); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: No if (response == "s_16") { //-- [NOTE] if (trainer_beast_master_condition__defaultCondition (player, npc)) { //-- NPC: My services are always available; return anytime. string_id message = new string_id (c_stringFile, "s_18"); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int trainer_beast_master_handleBranch7 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: I can teach you a skill that once trained to your pet will enable him to generate a large amount of threat towards your opponents. We Beast Masters call this skill Provoke. //-- [RESPONSE NOTE] //-- PLAYER: I am in need of this skill. if (response == "s_24") { //-- [NOTE] if (trainer_beast_master_condition__defaultCondition (player, npc)) { trainer_beast_master_action_teachFirstProvoke (player, npc); //-- NPC: You may return to me once you have attained greater skill to learn advanced versions of this ability. string_id message = new string_id (c_stringFile, "s_26"); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- // ====================================================================== // User Script Triggers // ====================================================================== trigger OnInitialize () { if ((!isTangible (self)) || (isPlayer (self))) detachScript(self, "conversation.trainer_beast_master"); setCondition (self, CONDITION_CONVERSABLE); return SCRIPT_CONTINUE; } trigger OnAttach () { setCondition (self, CONDITION_CONVERSABLE); 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.trainer_beast_master"); 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 (trainer_beast_master_condition_hasActiveBeast (player, npc)) { //-- NPC: Greetings Beast Master, what business do we have today? string_id message = new string_id (c_stringFile, "s_4"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: I am looking to un-train my beast. boolean hasResponse0 = false; if (trainer_beast_master_condition_hasSkillsToUnlearn (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: Is there a way for my beast to keep the attention of our adversaries boolean hasResponse1 = false; if (!trainer_beast_master_condition_knowsProvoke (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } //-- PLAYER: I am ready to upgrade my Provoke skill. boolean hasResponse2 = false; if (trainer_beast_master_condition_knowsProvoke (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse2 = true; } //-- PLAYER: Now that I think of it, there is nothing I really need. boolean hasResponse3 = false; if (trainer_beast_master_condition__defaultCondition (player, npc)) { ++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_6"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_20"); if (hasResponse2) responses [responseIndex++] = new string_id (c_stringFile, "s_28"); if (hasResponse3) responses [responseIndex++] = new string_id (c_stringFile, "s_35"); utils.setScriptVar (player, "conversation.trainer_beast_master.branchId", 1); npcStartConversation (player, npc, "trainer_beast_master", message, responses); } else { chat.chat (npc, player, message); } return SCRIPT_CONTINUE; } //-- [NOTE] if (trainer_beast_master_condition__defaultCondition (player, npc)) { //-- NPC: Return to me with a beast so that we might do business. string_id message = new string_id (c_stringFile, "s_38"); 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 != "trainer_beast_master") return SCRIPT_CONTINUE; obj_id npc = self; int branchId = utils.getIntScriptVar (player, "conversation.trainer_beast_master.branchId"); if (branchId == 1 && trainer_beast_master_handleBranch1 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 2 && trainer_beast_master_handleBranch2 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 7 && trainer_beast_master_handleBranch7 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; chat.chat (npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar (player, "conversation.trainer_beast_master.branchId"); return SCRIPT_CONTINUE; } // ======================================================================