// ====================================================================== // // halloween_vendor.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.buff; include library.chat; include library.collection; include library.conversation; include library.factions; include library.static_item; include library.utils; // ====================================================================== // Script Constants // ====================================================================== string c_stringFile = "conversation/halloween_vendor"; // ====================================================================== // Script Conditions // ====================================================================== boolean halloween_vendor_condition__defaultCondition (obj_id player, obj_id npc) { return true; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_costumeLockout (obj_id player, obj_id npc) { if(buff.hasBuff(player, "event_halloween_costume_lockout") || !buff.canApplyBuff(player, "event_halloween_costume_jawa")) return true; return false; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_costumeAlready (obj_id player, obj_id npc) { int[] currentBuffs = buff.getAllBuffs(player); if(currentBuffs != null || currentBuffs.length > 0) { for (int i = 0; i < currentBuffs.length; i++) { string buffName = buff.getBuffNameFromCrc(currentBuffs[i]); if(buffName.startsWith("event_halloween_costume_")) return true; } } return false; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_godMode (obj_id player, obj_id npc) { return(isGod(player)); } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_doesntHaveThree (obj_id player, obj_id npc) { long collectionValue = getCollectionSlotValue(player, "received_halloween_reward"); if (collectionValue < 1) return true; else return false; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_canBuyThree (obj_id player, obj_id npc) { obj_id trickDeviceTwo = utils.getStaticItemInInventory(player, "item_event_halloween_trick_device_02_01"); obj_id[] coins = utils.getAllStaticItemsInPlayerInventory(player, "item_event_halloween_coin"); long collectionValue = getCollectionSlotValue(player, "received_halloween_reward"); if (coins != null && coins.length > 0) { int numberOfCoins = utils.countOfStackedItemsInArray(coins); if (numberOfCoins != 0) { if (isIdValid(trickDeviceTwo) && exists(trickDeviceTwo) && numberOfCoins >= 700 && collectionValue < 1) return true; else return false; } else return false; } else return false; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_hasDevice (obj_id player, obj_id npc) { if(hasCompletedCollectionSlot(player, "received_halloween_reward")) return true; obj_id inventory = utils.getInventoryContainer(player); obj_id[] inventoryContents = getContents(inventory); for(int i = 0; i < inventoryContents.length; i++) { string itemName = getStaticItemName(inventoryContents[i]); if (itemName != null && itemName != "" && itemName.startsWith("item_event_halloween_trick_device_")) { return true; } } return false; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_noBadge (obj_id player, obj_id npc) { if (!hasCompletedCollectionSlot(player, "halloween_badge_09")) return true; else return false; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_canBuyBadge (obj_id player, obj_id npc) { obj_id[] coins = utils.getAllStaticItemsInPlayerInventory(player, "item_event_halloween_coin"); if (coins != null && coins.length > 0) { int numberOfCoins = utils.countOfStackedItemsInArray(coins); if (numberOfCoins != 0) { if (numberOfCoins >= 900 && !hasCompletedCollectionSlot(player, "halloween_badge_09")) return true; else return false; } else return false; } else return false; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_playerStealthed (obj_id player, obj_id npc) { //If player is stealthed, we don't allow them to put on a costume. int stealth = buff.getBuffOnTargetFromGroup(player, "invisibility"); if(stealth != 0) return true; return false; } // ---------------------------------------------------------------------- boolean halloween_vendor_condition_outOfRange (obj_id player, obj_id npc) { location selfLoc = getLocation(npc); location targetLoc = getLocation(player); float fltDistance = getDistance(selfLoc, targetLoc); if (fltDistance > 10.0f) return true; return false; } // ====================================================================== // Script Actions // ====================================================================== void halloween_vendor_action_showTokenVendorUI (obj_id player, obj_id npc) { dictionary d = new dictionary(); d.put("player", player); messageTo(npc, "showInventorySUI", d, 0, false); return; } // ---------------------------------------------------------------------- void halloween_vendor_action_applyCostume (obj_id player, obj_id npc) { //If the player doesn't have a Trick or Treat device, we give him one. obj_id inventory = utils.getInventoryContainer(player); if(!halloween_vendor_condition_hasDevice(player, npc)) { static_item.createNewItemFunction("item_event_halloween_trick_device_01_01", inventory); sendSystemMessage(player, new string_id("event/halloween", "halloween_projector")); } //Apply costume buff. string[] costumes = {"jawa", "toydarian", "hutt_female", "droid", "kowakian"}; if(halloween_vendor_condition_costumeAlready(player, npc)) { int[] currentBuffs = buff.getAllBuffs(player); for (int i = 0; i < currentBuffs.length; i++) { string buffName = buff.getBuffNameFromCrc(currentBuffs[i]); if(buffName.startsWith("event_halloween_costume_")) { int costumeRandom = rand(0, 4); string newCostume = "event_halloween_costume_" + costumes[costumeRandom]; if(newCostume != null && !newCostume.equals("")) { obj_id weapon = getObjectInSlot(player, "hold_r"); obj_id playerInv = utils.getInventoryContainer(player); if (isIdValid(weapon) && isIdValid(playerInv)) putInOverloaded(weapon, playerInv); if(buffName.equals(newCostume)) { halloween_vendor_action_applyCostume(player, npc); } else { int halloweenBuff = buff.getBuffOnTargetFromGroup(player, "shapechange"); if(halloweenBuff !=0) buff.removeBuff(player, halloweenBuff); buff.applyBuff(player, newCostume); buff.applyBuff(player, "event_halloween_costume_lockout"); } } } } } else { //Unequipping weapons since they can cause problems with some costumes. obj_id weapon = getObjectInSlot(player, "hold_r"); obj_id playerInv = utils.getInventoryContainer(player); if (isIdValid(weapon) && isIdValid(playerInv)) putInOverloaded(weapon, playerInv); int costumeRandom = rand(0, 4); string newCostume = "event_halloween_costume_" + costumes[costumeRandom]; buff.applyBuff(player, newCostume); buff.applyBuff(player, "event_halloween_costume_lockout"); } } // ---------------------------------------------------------------------- void halloween_vendor_action_removeLockout (obj_id player, obj_id npc) { if(buff.hasBuff(player, "event_halloween_costume_lockout")) { buff.removeBuff(player, "event_halloween_costume_lockout"); } return; } // ---------------------------------------------------------------------- void halloween_vendor_action_grantProjectorThree (obj_id player, obj_id npc) { if(halloween_vendor_condition_canBuyThree(player, npc)) { obj_id trickDeviceTwo = utils.getStaticItemInInventory(player, "item_event_halloween_trick_device_02_01"); obj_id inventory = utils.getInventoryContainer(player); obj_id[] inventoryContents = getInventoryAndEquipment(player); int tokenCostForReals = 700; for(int i = 0; i < inventoryContents.length; i++) { string itemName = getStaticItemName(inventoryContents[i]); if (itemName != null && itemName != "") { string halloweenCoins = "item_event_halloween_coin"; if(itemName.equals(halloweenCoins) && tokenCostForReals > 0) { if(getCount(inventoryContents[i]) > 1) { int numInStack = getCount(inventoryContents[i]); // Count down on count of physical token until 1. for(int m = 0; m < numInStack-1; m++) { if(tokenCostForReals > 0) { tokenCostForReals--; setCount(inventoryContents[i], getCount(inventoryContents[i]) - 1); if(tokenCostForReals <= 0) { static_item.createNewItemFunction("item_event_halloween_trick_device_03_01", inventory); obj_id trickDeviceThree = utils.getStaticItemInInventory(player, "item_event_halloween_trick_device_03_01"); if (isIdValid(trickDeviceThree) && exists(trickDeviceThree)) { setObjVar(trickDeviceThree, "deviceOwner", player); destroyObject(trickDeviceTwo); modifyCollectionSlotValue(player, "received_halloween_reward", 1); } } } } } if(getCount(inventoryContents[i]) <= 1 && tokenCostForReals > 0) { destroyObject(inventoryContents[i]); tokenCostForReals--; if(tokenCostForReals <= 0) { static_item.createNewItemFunction("item_event_halloween_trick_device_03_01", inventory); obj_id trickDeviceThree = utils.getStaticItemInInventory(player, "item_event_halloween_trick_device_03_01"); if (isIdValid(trickDeviceThree) && exists(trickDeviceThree)) { destroyObject(trickDeviceTwo); modifyCollectionSlotValue(player, "received_halloween_reward", 1); } } } } } } } } // ---------------------------------------------------------------------- void halloween_vendor_action_grantCoins (obj_id player, obj_id npc) { //Get player inventory. obj_id pInv = utils.getInventoryContainer(player); //create the halloween coins in their inventory. obj_id halloweenCoins = utils.getStaticItemInInventory(player, "item_event_halloween_coin"); if (isIdValid(halloweenCoins)) { int currentCoins = getCount(halloweenCoins); setCount(halloweenCoins, currentCoins + 5000); } else obj_id coins = static_item.createNewItemFunction("item_event_halloween_coin", pInv, 5000); } // ---------------------------------------------------------------------- void halloween_vendor_action_removeProjectorLockout (obj_id player, obj_id npc) { if(hasCompletedCollectionSlot(player, "received_halloween_reward")) modifyCollectionSlotValue(player, "received_halloween_reward", -1); } // ---------------------------------------------------------------------- void halloween_vendor_action_badgePurchased (obj_id player, obj_id npc) { obj_id inventory = utils.getInventoryContainer(player); obj_id[] inventoryContents = getInventoryAndEquipment(player); int tokenCostForReals = 900; for(int i = 0; i < inventoryContents.length; i++) { string itemName = getStaticItemName(inventoryContents[i]); if (itemName != null && itemName != "") { string halloweenCoins = "item_event_halloween_coin"; if(itemName.equals(halloweenCoins) && tokenCostForReals > 0) { if(getCount(inventoryContents[i]) > 1) { int numInStack = getCount(inventoryContents[i]); // Count down on count of physical token until 1. for(int m = 0; m < numInStack-1; m++) { if(tokenCostForReals > 0) { tokenCostForReals--; setCount(inventoryContents[i], getCount(inventoryContents[i]) - 1); if(tokenCostForReals <= 0) { badge.grantBadge(player, "halloween_badge_09"); } } } } if(getCount(inventoryContents[i]) <= 1 && tokenCostForReals > 0) { destroyObject(inventoryContents[i]); tokenCostForReals--; if(tokenCostForReals <= 0) { badge.grantBadge(player, "halloween_badge_09"); } } } } } } // ---------------------------------------------------------------------- void halloween_vendor_action_removeDailyLimit (obj_id player, obj_id npc) { if(hasObjVar(player, "galacticCoinCounter.numberOfCoins")) removeObjVar(player, "galacticCoinCounter.numberOfCoins"); if(hasObjVar(player, "galacticCoinCounter.timeStamp")) removeObjVar(player, "galacticCoinCounter.timeStamp"); if(hasObjVar(player, "galacticCoinCounter.startTime")) removeObjVar(player, "galacticCoinCounter.startTime"); if(buff.hasBuff(player, "event_halloween_coin_limit")) buff.removeBuff(player, "event_halloween_coin_limit"); utils.removeScriptVarTree(player, "galacticMoonNpcList"); } // ====================================================================== // Script %TO Tokens // ====================================================================== // ====================================================================== // Script %DI Tokens // ====================================================================== // ====================================================================== // Script %DF Tokens // ====================================================================== // ====================================================================== // handleBranch Functions // ====================================================================== int halloween_vendor_handleBranch1 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Welcome to the Galactic Moon Festival! What can I do for you friend? A costume perhaps? Or some trinkets courtesy of the benevolent Jabba the Hutt? //-- [RESPONSE NOTE] //-- PLAYER: I'd love a costume! if (response == "s_7") { //-- [NOTE] if (halloween_vendor_condition_outOfRange (player, npc)) { doAnimationAction (npc, "shake_head_no"); //-- NPC: You have to come closer if you want a costume %TU. string_id message = new string_id (c_stringFile, "s_69"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } //-- [NOTE] if (halloween_vendor_condition_playerStealthed (player, npc)) { doAnimationAction (npc, "shake_head_no"); //-- NPC: I need to be able to see you to apply a costume %TU. string_id message = new string_id (c_stringFile, "s_67"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } //-- [NOTE] if (halloween_vendor_condition_costumeLockout (player, npc)) { doAnimationAction (npc, "shake_head_no"); //-- NPC: I can't give you another costume right now %TU, I don't have an endless supply of these you know. Come back in a few minutes and I should have more in stock. string_id message = new string_id (c_stringFile, "s_12"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { halloween_vendor_action_applyCostume (player, npc); //-- NPC: Certainly %TU, let me see what I have in stock. string_id message = new string_id (c_stringFile, "s_13"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: What are you selling? if (response == "s_14") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "huge"); halloween_vendor_action_showTokenVendorUI (player, npc); //-- NPC: Take a look at my inventory %TU. string_id message = new string_id (c_stringFile, "s_16"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: How do I Trick or Treat? if (response == "s_63") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "explain"); //-- NPC: All the citizens of Mos Eisley and Moenia gladly agreed to participate in the Galactic Moon Festival, when Jabba asked them. With a townsperson targeted, say 'Trick or Treat'. If they like your costume they will give you Galactic Moon Coins. If not, use your Trick or Treat device and scare them! string_id message = new string_id (c_stringFile, "s_64"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: Is there anything else I can buy? if (response == "s_52") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "nod_head_once"); //-- NPC: Yes for a mere 900 Galactic Moon Coins the benevolent Jabba the Hutt will grant you the badge of Galactic Moon Jester. string_id message = new string_id (c_stringFile, "s_53"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: Sounds great, I have the coins right here! boolean hasResponse0 = false; if (halloween_vendor_condition_canBuyBadge (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: Interesting, thank you. boolean hasResponse1 = false; if (halloween_vendor_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_54"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_55"); utils.setScriptVar (player, "conversation.halloween_vendor.branchId", 8); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: Can I get an even better Trick or Treat Projector? if (response == "s_43") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "nod_head_once"); //-- NPC: Yes I can upgrade a Trick or Treat Projector II to a permanent projector but it will cost you 700 Galactic Moon Coins. string_id message = new string_id (c_stringFile, "s_45"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: Sounds good. I would like to upgrade my projector. boolean hasResponse0 = false; if (halloween_vendor_condition_canBuyThree (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_78"); utils.setScriptVar (player, "conversation.halloween_vendor.branchId", 11); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: I just stopped by to thank you for organizing the festival! if (response == "s_47") { doAnimationAction (player, "celebrate1"); //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "laugh_cackle"); //-- NPC: I thank you on behalf of the generous Jabba the Hutt %TU. Happy Galactic Moon Festival to you! string_id message = new string_id (c_stringFile, "s_49"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: I'm a GM, remove my costume lockout. if (response == "s_51") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { halloween_vendor_action_removeLockout (player, npc); //-- NPC: Done. string_id message = new string_id (c_stringFile, "s_59"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: I'm a GM, give me 5000 coins. if (response == "s_61") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { halloween_vendor_action_grantCoins (player, npc); //-- NPC: Alright. string_id message = new string_id (c_stringFile, "s_65"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: I'm a GM. Remove my third projector lockout. if (response == "s_68") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { halloween_vendor_action_removeProjectorLockout (player, npc); //-- NPC: Very well. string_id message = new string_id (c_stringFile, "s_72"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: I'm a GM, reset my daily limit. if (response == "s_74") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { halloween_vendor_action_removeDailyLimit (player, npc); //-- NPC: Sure. string_id message = new string_id (c_stringFile, "s_76"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int halloween_vendor_handleBranch8 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Yes for a mere 900 Galactic Moon Coins the benevolent Jabba the Hutt will grant you the badge of Galactic Moon Jester. //-- [RESPONSE NOTE] //-- PLAYER: Sounds great, I have the coins right here! if (response == "s_54") { doAnimationAction (player, "thumbs_up"); //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "thumb_up"); halloween_vendor_action_badgePurchased (player, npc); //-- NPC: Excellent, congratulations %TU! string_id message = new string_id (c_stringFile, "s_56"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: Interesting, thank you. if (response == "s_55") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { //-- NPC: Not a problem, Happy Galactic Moon Festival %TU. string_id message = new string_id (c_stringFile, "s_57"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int halloween_vendor_handleBranch11 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Yes I can upgrade a Trick or Treat Projector II to a permanent projector but it will cost you 700 Galactic Moon Coins. //-- [RESPONSE NOTE] //-- PLAYER: Sounds good. I would like to upgrade my projector. if (response == "s_78") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { //-- NPC: Are you sure? It will cost you 700 Galactic Moon Coins to upgrade your Projector II to a class III. It does come with a lifetime warranty though. string_id message = new string_id (c_stringFile, "s_80"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: So it will never disappear? boolean hasResponse0 = false; if (halloween_vendor_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_82"); utils.setScriptVar (player, "conversation.halloween_vendor.branchId", 12); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int halloween_vendor_handleBranch12 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Are you sure? It will cost you 700 Galactic Moon Coins to upgrade your Projector II to a class III. It does come with a lifetime warranty though. //-- [RESPONSE NOTE] //-- PLAYER: So it will never disappear? if (response == "s_82") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { //-- NPC: That is correct. string_id message = new string_id (c_stringFile, "s_84"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: That sounds great, do it! boolean hasResponse0 = false; if (halloween_vendor_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: Maybe later. boolean hasResponse1 = false; if (halloween_vendor_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_86"); if (hasResponse1) responses [responseIndex++] = new string_id (c_stringFile, "s_92"); utils.setScriptVar (player, "conversation.halloween_vendor.branchId", 13); npcSpeak (player, message); npcSetConversationResponses (player, responses); } else { utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- int halloween_vendor_handleBranch13 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: That is correct. //-- [RESPONSE NOTE] //-- PLAYER: That sounds great, do it! if (response == "s_86") { //-- [NOTE] if (halloween_vendor_condition_canBuyThree (player, npc)) { doAnimationAction (npc, "manipulate_medium"); halloween_vendor_action_grantProjectorThree (player, npc); //-- NPC: Excellent %TU! Here you go, enjoy and have fun! string_id message = new string_id (c_stringFile, "s_88"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { //-- NPC: You don't have enough Galactic Moon coins anymore %TU. string_id message = new string_id (c_stringFile, "s_90"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); prose_package pp = new prose_package (); pp.stringId = message; pp.actor.set (player); pp.target.set (npc); npcEndConversationWithMessage (player, pp); return SCRIPT_CONTINUE; } } //-- [RESPONSE NOTE] //-- PLAYER: Maybe later. if (response == "s_92") { //-- [NOTE] if (halloween_vendor_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "nod_head_once"); //-- NPC: I'll be here. string_id message = new string_id (c_stringFile, "s_94"); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- // ====================================================================== // User Script Triggers // ====================================================================== trigger OnInitialize () { if ((!isTangible (self)) || (isPlayer (self))) detachScript(self, "conversation.halloween_vendor"); 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.halloween_vendor"); return SCRIPT_CONTINUE; } trigger OnDetach () { clearCondition (self, CONDITION_CONVERSABLE); 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 (halloween_vendor_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "nod_head_once"); //-- NPC: Welcome to the Galactic Moon Festival! What can I do for you friend? A costume perhaps? Or some trinkets courtesy of the benevolent Jabba the Hutt? string_id message = new string_id (c_stringFile, "s_6"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: I'd love a costume! boolean hasResponse0 = false; if (halloween_vendor_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } //-- PLAYER: What are you selling? boolean hasResponse1 = false; if (halloween_vendor_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } //-- PLAYER: How do I Trick or Treat? boolean hasResponse2 = false; if (halloween_vendor_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse2 = true; } //-- PLAYER: Is there anything else I can buy? boolean hasResponse3 = false; if (halloween_vendor_condition_noBadge (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse3 = true; } //-- PLAYER: Can I get an even better Trick or Treat Projector? boolean hasResponse4 = false; if (halloween_vendor_condition_doesntHaveThree (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse4 = true; } //-- PLAYER: I just stopped by to thank you for organizing the festival! boolean hasResponse5 = false; if (halloween_vendor_condition__defaultCondition (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse5 = true; } //-- PLAYER: I'm a GM, remove my costume lockout. boolean hasResponse6 = false; if (halloween_vendor_condition_godMode (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse6 = true; } //-- PLAYER: I'm a GM, give me 5000 coins. boolean hasResponse7 = false; if (halloween_vendor_condition_godMode (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse7 = true; } //-- PLAYER: I'm a GM. Remove my third projector lockout. boolean hasResponse8 = false; if (halloween_vendor_condition_godMode (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse8 = true; } //-- PLAYER: I'm a GM, reset my daily limit. boolean hasResponse9 = false; if (halloween_vendor_condition_godMode (player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse9 = 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_14"); if (hasResponse2) responses [responseIndex++] = new string_id (c_stringFile, "s_63"); if (hasResponse3) responses [responseIndex++] = new string_id (c_stringFile, "s_52"); if (hasResponse4) responses [responseIndex++] = new string_id (c_stringFile, "s_43"); if (hasResponse5) responses [responseIndex++] = new string_id (c_stringFile, "s_47"); if (hasResponse6) responses [responseIndex++] = new string_id (c_stringFile, "s_51"); if (hasResponse7) responses [responseIndex++] = new string_id (c_stringFile, "s_61"); if (hasResponse8) responses [responseIndex++] = new string_id (c_stringFile, "s_68"); if (hasResponse9) responses [responseIndex++] = new string_id (c_stringFile, "s_74"); utils.setScriptVar (player, "conversation.halloween_vendor.branchId", 1); npcStartConversation (player, npc, "halloween_vendor", 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 != "halloween_vendor") return SCRIPT_CONTINUE; obj_id npc = self; int branchId = utils.getIntScriptVar (player, "conversation.halloween_vendor.branchId"); if (branchId == 1 && halloween_vendor_handleBranch1 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 8 && halloween_vendor_handleBranch8 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 11 && halloween_vendor_handleBranch11 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 12 && halloween_vendor_handleBranch12 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; if (branchId == 13 && halloween_vendor_handleBranch13 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; chat.chat (npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar (player, "conversation.halloween_vendor.branchId"); return SCRIPT_CONTINUE; } // ======================================================================