// ====================================================================== // // imperial_title_grant.script // Copyright 2004, Sony Online Entertainment // All Rights Reserved. // // Created with SwgConversationEditor 1.37 - DO NOT EDIT THIS AUTO-GENERATED FILE! // // ====================================================================== // ====================================================================== // Library Includes // ====================================================================== include library.ai_lib; include library.badge; include library.chat; include library.conversation; include library.factions; include library.money; include library.utils; // ====================================================================== // Script Constants // ====================================================================== string c_stringFile = "conversation/imperial_title_grant"; // ====================================================================== // Script Conditions // ====================================================================== boolean imperial_title_grant_condition__defaultCondition (obj_id player, obj_id npc) { return true; } // ---------------------------------------------------------------------- boolean imperial_title_grant_condition_isImperialPlayer (obj_id player, obj_id npc) { return factions.isImperial(player); } // ---------------------------------------------------------------------- boolean imperial_title_grant_condition_isRebelPlayer (obj_id player, obj_id npc) { return factions.isRebel(player); } // ---------------------------------------------------------------------- boolean imperial_title_grant_condition_hasMillionCredits (obj_id player, obj_id npc) { return money.hasFunds(player, money.MT_TOTAL, money.MILLION); } // ---------------------------------------------------------------------- boolean imperial_title_grant_condition_hasTitle (obj_id player, obj_id npc) { return hasCompletedCollectionSlot(player, "imp_million_title"); } // ====================================================================== // Script Actions // ====================================================================== void imperial_title_grant_action_grantTitle (obj_id player, obj_id npc) { utils.moneyOutMetric(player, "IMPERIAL_TITLES", money.MILLION); if(money.requestPayment(player, npc, money.MILLION, "pass_fail", null, true)) { CustomerServiceLog("title_grant", getFirstName(player) + "(" + player + ") Just purchased the title (collection slot) 'imp_million_title' for " + money.MILLION + " credits."); //modifyCollectionSlotValue(player, "imp_million_title", 1); badge.grantBadge(player, "imp_million_title"); } else CustomerServiceLog("title_grant", getFirstName(player) + "(" + player + ") Just FAILED to purchase the title (collection slot) 'imp_million_title' for " + money.MILLION + " credits."); } // ====================================================================== // Script %TO Tokens // ====================================================================== // ====================================================================== // Script %DI Tokens // ====================================================================== // ====================================================================== // Script %DF Tokens // ====================================================================== // ====================================================================== // handleBranch Functions // ====================================================================== int imperial_title_grant_handleBranch2 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Welcome! I am Major Caleb Knolar. Are you here to make a monetary donation to the war effort? //-- [RESPONSE NOTE] //-- PLAYER: What kind of donation? if (response == "s_7") { //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: By order of Emperor Palpatine, we are allowing loyal Imperial citizens to donate to the cause. string_id message = new string_id (c_stringFile, "s_9"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: What do I get out of it? boolean hasResponse0 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: How much do I need to donate? boolean hasResponse1 = false; if (imperial_title_grant_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_11"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_18"); utils.setScriptVar (player, "conversation.imperial_title_grant.branchId", 3); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: What do I get out of it? if (response == "s_35") { //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Besides the Gratitude of the Emperor? You receive the official title of 'Patron of The Empire'. string_id message = new string_id (c_stringFile, "s_13"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: How much do I need to donate? boolean hasResponse0 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: No thanks. boolean hasResponse1 = false; if (imperial_title_grant_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_27"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_28"); utils.setScriptVar (player, "conversation.imperial_title_grant.branchId", 4); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int imperial_title_grant_handleBranch3 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: By order of Emperor Palpatine, we are allowing loyal Imperial citizens to donate to the cause. //-- [RESPONSE NOTE] //-- PLAYER: What do I get out of it? if (response == "s_11") { //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Besides the Gratitude of the Emperor? You receive the official title of 'Patron of The Empire'. string_id message = new string_id (c_stringFile, "s_13"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: How much do I need to donate? boolean hasResponse0 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: No thanks. boolean hasResponse1 = false; if (imperial_title_grant_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_27"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_28"); utils.setScriptVar (player, "conversation.imperial_title_grant.branchId", 4); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: How much do I need to donate? if (response == "s_18") { //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: One million credits. string_id message = new string_id (c_stringFile, "s_20"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: Sounds reasonable, I'll do it. boolean hasResponse0 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: What do I get out of it? boolean hasResponse1 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } //-- PLAYER: Wow that's a lot of credits! I don't think I am interested. boolean hasResponse2 = false; if (imperial_title_grant_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_22"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_26"); if (hasResponse2) responses [responseIndex++] = new string_id (c_stringFile, "s_33"); utils.setScriptVar (player, "conversation.imperial_title_grant.branchId", 6); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int imperial_title_grant_handleBranch4 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Besides the Gratitude of the Emperor? You receive the official title of 'Patron of The Empire'. //-- [RESPONSE NOTE] //-- PLAYER: How much do I need to donate? if (response == "s_27") { //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: One million credits. string_id message = new string_id (c_stringFile, "s_20"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: Sounds reasonable, I'll do it. boolean hasResponse0 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: What do I get out of it? boolean hasResponse1 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } //-- PLAYER: Wow that's a lot of credits! I don't think I am interested. boolean hasResponse2 = false; if (imperial_title_grant_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_22"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_26"); if (hasResponse2) responses [responseIndex++] = new string_id (c_stringFile, "s_33"); utils.setScriptVar (player, "conversation.imperial_title_grant.branchId", 6); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: No thanks. if (response == "s_28") { //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Humph, your choice. You can give it freely now, or we can requisition it later. string_id message = new string_id (c_stringFile, "s_29"); utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int imperial_title_grant_handleBranch6 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: One million credits. //-- [RESPONSE NOTE] //-- PLAYER: Sounds reasonable, I'll do it. if (response == "s_22") { //-- [NOTE] if (!imperial_title_grant_condition_hasMillionCredits (player, npc)) { //-- NPC: You had best go get those credits now. string_id message = new string_id (c_stringFile, "s_30"); utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { imperial_title_grant_action_grantTitle (player, npc); //-- NPC: Great! On behalf of the Emperor, I hereby grant you the title 'Patron of The Empire'. string_id message = new string_id (c_stringFile, "s_32"); utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: What do I get out of it? if (response == "s_26") { //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Besides the Gratitude of the Emperor? You receive the official title of 'Patron of The Empire'. string_id message = new string_id (c_stringFile, "s_13"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: How much do I need to donate? boolean hasResponse0 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: No thanks. boolean hasResponse1 = false; if (imperial_title_grant_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_27"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_28"); utils.setScriptVar (player, "conversation.imperial_title_grant.branchId", 4); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: Wow that's a lot of credits! I don't think I am interested. if (response == "s_33") { //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Humph, your choice. You can give it freely now, or we can requisition it later. string_id message = new string_id (c_stringFile, "s_29"); utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- // ====================================================================== // User Script Triggers // ====================================================================== trigger OnInitialize () { if ((!isTangible (self)) || (isPlayer (self))) detachScript(self, "conversation.imperial_title_grant"); 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.imperial_title_grant"); 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 (imperial_title_grant_condition_hasTitle (player, npc)) { //-- NPC: I see you have already contributed to the cause. Thank you. string_id message = new string_id (c_stringFile, "s_39"); chat.chat (npc, player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (imperial_title_grant_condition_isImperialPlayer (player, npc)) { //-- NPC: Welcome! I am Major Caleb Knolar. Are you here to make a monetary donation to the war effort? string_id message = new string_id (c_stringFile, "s_5"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: What kind of donation? boolean hasResponse0 = false; if (imperial_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: What do I get out of it? boolean hasResponse1 = false; if (imperial_title_grant_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_7"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_35"); utils.setScriptVar (player, "conversation.imperial_title_grant.branchId", 2); npcStartConversation (player, npc, "imperial_title_grant", message, responses); } else { chat.chat (npc, player, message); } return SCRIPT_CONTINUE; } //-- [NOTE] if (imperial_title_grant_condition_isRebelPlayer (player, npc)) { //-- NPC: Begone before I call the Authorities! string_id message = new string_id (c_stringFile, "s_37"); chat.chat (npc, player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (imperial_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Greetings citizen. At this time I only deal with patriots. 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 != "imperial_title_grant") return SCRIPT_CONTINUE; obj_id npc = self; int branchId = utils.getIntScriptVar (player, "conversation.imperial_title_grant.branchId"); if (branchId == 2 && imperial_title_grant_handleBranch2 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 3 && imperial_title_grant_handleBranch3 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 4 && imperial_title_grant_handleBranch4 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 6 && imperial_title_grant_handleBranch6 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; chat.chat (npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar (player, "conversation.imperial_title_grant.branchId"); return SCRIPT_CONTINUE; } // ======================================================================