// ====================================================================== // // neutral_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/neutral_title_grant"; // ====================================================================== // Script Conditions // ====================================================================== boolean neutral_title_grant_condition__defaultCondition (obj_id player, obj_id npc) { return true; } // ---------------------------------------------------------------------- boolean neutral_title_grant_condition_hasMillionCredits (obj_id player, obj_id npc) { return money.hasFunds(player, money.MT_TOTAL, money.MILLION); } // ---------------------------------------------------------------------- boolean neutral_title_grant_condition_hasTitles (obj_id player, obj_id npc) { return hasCompletedCollectionSlot(player, "neut_million_title") && hasCompletedCollectionSlot(player, "neut_billion_title"); } // ---------------------------------------------------------------------- boolean neutral_title_grant_condition_hasMillionTitle (obj_id player, obj_id npc) { return hasCompletedCollectionSlot(player, "neut_million_title"); } // ---------------------------------------------------------------------- boolean neutral_title_grant_condition_hasBillionTitle (obj_id player, obj_id npc) { return hasCompletedCollectionSlot(player, "neut_billion_title"); } // ---------------------------------------------------------------------- boolean neutral_title_grant_condition_hasHundredMillionCredits (obj_id player, obj_id npc) { return money.hasFunds(player, money.MT_TOTAL, money.HUNDRED_MILLION); } // ====================================================================== // Script Actions // ====================================================================== void neutral_title_grant_action_grantMillionTitle (obj_id player, obj_id npc) { utils.moneyOutMetric(player, "NEUTRAL_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) 'neut_million_title' for " + money.MILLION + " credits."); //modifyCollectionSlotValue(player, "neut_million_title", 1); badge.grantBadge(player, "neut_million_title"); } else CustomerServiceLog("title_grant", getFirstName(player) + "(" + player + ") Just failed to purchase the title (collection slot) 'neut_million_title' for " + money.MILLION + " credits."); } // ---------------------------------------------------------------------- void neutral_title_grant_action_transferHundredMillion (obj_id player, obj_id npc) { utils.moneyOutMetric(player, "NEUTRAL_TITLES", money.HUNDRED_MILLION); if(money.requestPayment(player, npc, money.HUNDRED_MILLION, "pass_fail", null, true)) { CustomerServiceLog("title_grant", getFirstName(player) + "(" + player + ") Just purchased an update to the slot 'neut_billion_title' for " + money.HUNDRED_MILLION + " credits."); if(getCollectionSlotValue(player, "neut_billion_title") >= 9) { badge.grantBadge(player, "neut_billion_title"); } else modifyCollectionSlotValue(player, "neut_billion_title", 1); CustomerServiceLog("title_grant", getFirstName(player) + "(" + player + ")'s slot count is now "+getCollectionSlotValue(player, "neut_billion_title")+"."); } else CustomerServiceLog("title_grant", getFirstName(player) + "(" + player + ") Just FAILED to purchase an update to the slot 'neut_billion_title' for " + money.HUNDRED_MILLION + " credits."); } // ====================================================================== // Script %TO Tokens // ====================================================================== // ====================================================================== // Script %DI Tokens // ====================================================================== // ====================================================================== // Script %DF Tokens // ====================================================================== // ====================================================================== // handleBranch Functions // ====================================================================== int neutral_title_grant_handleBranch2 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Welcome! I am Ozzmos Roberts. Are you here to purchase your official title? //-- [RESPONSE NOTE] //-- PLAYER: What titles? if (response == "s_7") { //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: The InterGalactic Banking Clan has decreed that if you open a savings account with them, they will give you an official title based on the amount you transfer. string_id message = new string_id (c_stringFile, "s_9"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: What are the titles? boolean hasResponse0 = false; if (neutral_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: How much do I need to transfer for these? boolean hasResponse1 = false; if (neutral_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.neutral_title_grant.branchId", 3); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int neutral_title_grant_handleBranch3 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: The InterGalactic Banking Clan has decreed that if you open a savings account with them, they will give you an official title based on the amount you transfer. //-- [RESPONSE NOTE] //-- PLAYER: What are the titles? if (response == "s_11") { //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Millionaire and Billionaire. string_id message = new string_id (c_stringFile, "s_13"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: How much do I need to transfer for these? boolean hasResponse0 = false; if (neutral_title_grant_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: No thanks. boolean hasResponse1 = false; if (neutral_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.neutral_title_grant.branchId", 4); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: How much do I need to transfer for these? if (response == "s_18") { //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Fairly self explanatory. One million credits for the Millionaire title, and one billion credits for the Billionaire title. string_id message = new string_id (c_stringFile, "s_20"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: I will take the Millionaire title please. boolean hasResponse0 = false; if (!neutral_title_grant_condition_hasMillionTitle (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: Do I transfer all one billion now? boolean hasResponse1 = false; if (!neutral_title_grant_condition_hasBillionTitle (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 (neutral_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_42"); if (hasResponse2) responses [responseIndex++] = new string_id (c_stringFile, "s_40"); utils.setScriptVar (player, "conversation.neutral_title_grant.branchId", 6); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int neutral_title_grant_handleBranch4 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Millionaire and Billionaire. //-- [RESPONSE NOTE] //-- PLAYER: How much do I need to transfer for these? if (response == "s_27") { //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Fairly self explanatory. One million credits for the Millionaire title, and one billion credits for the Billionaire title. string_id message = new string_id (c_stringFile, "s_20"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: I will take the Millionaire title please. boolean hasResponse0 = false; if (!neutral_title_grant_condition_hasMillionTitle (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: Do I transfer all one billion now? boolean hasResponse1 = false; if (!neutral_title_grant_condition_hasBillionTitle (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 (neutral_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_42"); if (hasResponse2) responses [responseIndex++] = new string_id (c_stringFile, "s_40"); utils.setScriptVar (player, "conversation.neutral_title_grant.branchId", 6); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: No thanks. if (response == "s_28") { //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Okay, come back any time if you change your mind. string_id message = new string_id (c_stringFile, "s_29"); utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int neutral_title_grant_handleBranch6 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Fairly self explanatory. One million credits for the Millionaire title, and one billion credits for the Billionaire title. //-- [RESPONSE NOTE] //-- PLAYER: I will take the Millionaire title please. if (response == "s_22") { //-- [NOTE] if (!neutral_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.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { neutral_title_grant_action_grantMillionTitle (player, npc); //-- NPC: Great! On behalf of the InterGalactic Banking Clan, I hereby grant you the title 'Millionaire'. string_id message = new string_id (c_stringFile, "s_32"); utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: Do I transfer all one billion now? if (response == "s_42") { //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: No, we ask that you transfer one-hundred million at a time. This will help prevent fraudulent slicing. Once you have transferred all one billion credits you will receive the title. string_id message = new string_id (c_stringFile, "s_35"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: Alright, I am ready to transfer the credits. boolean hasResponse0 = false; if (neutral_title_grant_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.neutral_title_grant.branchId", 9); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.neutral_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_40") { //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Okay, come back any time if you change your mind. string_id message = new string_id (c_stringFile, "s_29"); utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int neutral_title_grant_handleBranch9 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: No, we ask that you transfer one-hundred million at a time. This will help prevent fraudulent slicing. Once you have transferred all one billion credits you will receive the title. //-- [RESPONSE NOTE] //-- PLAYER: Alright, I am ready to transfer the credits. if (response == "s_36") { //-- [NOTE] if (!neutral_title_grant_condition_hasHundredMillionCredits (player, npc)) { //-- NPC: You had best go get those credits now. string_id message = new string_id (c_stringFile, "s_38"); utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { neutral_title_grant_action_transferHundredMillion (player, npc); //-- NPC: Great! On behalf of the InterGalactic Banking Clan, I thank you for your patronage. string_id message = new string_id (c_stringFile, "s_41"); utils.removeScriptVar (player, "conversation.neutral_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.neutral_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.neutral_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 (neutral_title_grant_condition_hasTitles (player, npc)) { //-- NPC: I see you have already purchased all the titles available. string_id message = new string_id (c_stringFile, "s_39"); chat.chat (npc, player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (neutral_title_grant_condition__defaultCondition (player, npc)) { //-- NPC: Welcome! I am Ozzmos Roberts. Are you here to purchase your official title? string_id message = new string_id (c_stringFile, "s_5"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: What titles? boolean hasResponse0 = false; if (neutral_title_grant_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_7"); utils.setScriptVar (player, "conversation.neutral_title_grant.branchId", 2); npcStartConversation (player, npc, "neutral_title_grant", message, responses); } else { 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 != "neutral_title_grant") return SCRIPT_CONTINUE; obj_id npc = self; int branchId = utils.getIntScriptVar (player, "conversation.neutral_title_grant.branchId"); if (branchId == 2 && neutral_title_grant_handleBranch2 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 3 && neutral_title_grant_handleBranch3 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 4 && neutral_title_grant_handleBranch4 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 6 && neutral_title_grant_handleBranch6 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 9 && neutral_title_grant_handleBranch9 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; chat.chat (npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar (player, "conversation.neutral_title_grant.branchId"); return SCRIPT_CONTINUE; } // ======================================================================