# Barkeep # # The barkeep will sell a player a selection of bar drinks and food from # the bar menu of which each have a different effect on the player, but # there is a limit to the number of drinks the player can consume. When # the drink limit has been reached the player will become violently ill # and will lose reputation. # After buying an item from the bar the player can tip the barkeep and # earn some reputation. # The bartender can be attacked and will attack back, and after a short # period of time the bartender will cool off. # If the barkeep is killed he will respawn, attack the player, and # the player will lose reputation. # If the player is killed the barkeep will cool off. # Use the NPC name "BarkeepNPC" if you want it has a bartender skin. # I created it for this script or any other bartender script. # # Todo # - Maybe refuse to serve people if they are below a certain rep. # DONE - Add an option for the barkeep to describe the menu items. # - If the player has high enough reputation a quest will be opened. # - Create a questing option if the player tips the barkeep, maybe search # for menu ingredients # - Randomize the quests # DONE (but need to test further) - Engage and disengage NPC during attack. Makes no sense to be # attacking and serving drinks. # # # Date Aug10-2013 # Author: PrimerBlock # # Attacking timeouts # Player damages NPC - NPC attacks for 60 seconds # Player kills NPC - NPC responds and attacks for 3600 seconds (1 hour) # Player damages NPC and runs away - NPC - NPC attacks for 60 seconds "The Bar Keep": type: assignment interact scripts: - 10 First visit to the barkeep - 20 Welcome back to the bar - 30 Describe a menu item - 40 Buy a bar item - 50 Barkeep on the attack default constants: # This is the starting point for the NPC # set it with the command /npc anchor --save BarkeepStart BarkeepStart: DrinkLimit: 6 DrinkLimitWarn: 4 BarName: "The Vrovonic Bar" NPCclr: "" # Change this to whatever you want to sell as a drink item 5 is food # Remember you can use constants to change per-npc # /npc cons --set "MenuItem1" --value "Squirrel Blood" MenuItem1: "Zombie Mead" MenuItem1Price: 5 MenuItem1Desc: "Zombie Mead is a jigger of fermented zombie drool poured into a dirty glass." MenuItem2: "Apple Cider" MenuItem2Price: 10 MenuItem2Desc: "Apple Cider contains freshly pressed digital apples. It may have side effects!" MenuItem3: "Squid Juice" MenuItem3Price: 15 MenuItem3Desc: "Squid ink topped with a layer of milled coco beans. Yum!" MenuItem4: "Squirrel Milk" MenuItem4Price: 15 MenuItem4Desc: "Fresh squirrel milk shaken with a dollop of fermented spider eye jelly over ice. It<&sq>s a house speciality" MenuItem5: "Ham Sandwich" MenuItem5Price: 20 MenuItem5Desc: "Zombie Pigman flank, thinly sliced on freshly baked bread." actions: on assignment: - if '' matches location runtask "script:Barkeep Init" instant else runtask 'script:Template Invalid Init' instant - if true - narrate "NPC Template '' is ready to go!" on assignment: - runtask "script:Barkeep Init" instant on spawn: - runtask "script:Barkeep Init" instant "First visit to the barkeep": type: interact requirements: Mode: All List: - -flagged player "BarVisited:true" steps: 'WelcomeFirstVisitToBar*': click trigger: script: - chat "I don<&sq>t think I have seen you in here before." - narrate "Well, welcome visitor to the . What will ya have today?" - narrate "<&lb>Hint <&co> menu, describe, buy<&rb>" - flag player "BarVisited:true" proximity trigger: entry radius: 6 entry: script: - random 3 - chat "Welcome, come on in!" - chat "We<&sq>re open, have a seat." - chat "Welcome visitor, best grub in town." - ^attack stop - ^disengage "Welcome back to the bar": type: interact requirements: Mode: All List: - flagged player "BarVisited:true" steps: 'VisitingTheBarkeep*': click trigger: script: - random 6 - chat "What can I do ya?" - chat "How<&sq>s it going?" - chat "Lil<&sq> hair o<&sq> the squirrel?" - chat "Hey ! What will ya have?" - chat "I don<&sq>t think I<&sq>ve seen you in here before??? Ah, I<&sq>m kidding . I know who you are." - chat "How<&sq>s it going ? What will you have today?" - narrate "<&lb>Hint <&co> menu, describe, buy<&rb>" proximity trigger: entry radius: 6 exit radius: 9 entry: script: - lookclose toggle:true - random 3 - chat "Hey , come on in!" - chat "Have a seat ." - chat "Welcome back ." exit: script: - random 3 - chat "See you later ." - chat "Good seeing ya ." - chat "Take it easy ." - lookclose toggle:false - flag player BuyABarItem:! - flag player barkeepTip:! - flag player TotalBarTab:! - walkto location: chat trigger: 'bar menu': trigger: "What<&sq>s on the /menu/?" script: - chat "Here have a look." - runtask "script:Bar Menu" - chat "Let me know when you want to buy a menu item." - narrate "<&lb>Hint <&co> menu, describe, buy<&rb>" 'buy from bar': trigger: "I<&sq>m ready to /buy/ from the menu." script: - chat "Sure, just choose from the menu." - runtask "script:Bar Menu" - narrate "<&lb>Hint <&co> 1 - 5<&rb>" - flag player "BuyABarItem:true" duration:300 'describe menu items': trigger: "Can you /describe/ one of the menu items for me?" script: - chat "OK, just tell me the item number you want to know more about." - runtask "script:Bar Menu" - narrate "<&lb>Hint <&co> 1 - 5<&rb>" - flag player "DescribeBarMenuItem:true" duration:300 'tip barkeep': trigger: "Thanks for the service! Here<&sq>s a /tip/ for you." script: - if == true runtask "script:Calc Bar Tip" - if ! == true narrate "You need to buy something before you tip. If you walked away before leaving a tip your bar tab total was forgotten." else if <= 0 narrate "Oops! Your broke, you don<&sq>t have enough to leave a tip!" else if < narrate "Nice gesture, but your broke. You only have ." else runtask "script:Give a tip to the barkeep" ## Working on enabling the barkeep to search for and use a chest as an ice-chest to pull drinks from. ## I think this may be too resource intensive so the search should be a one time event such as when assigning the script. 'What is your location Barkeep': trigger: "What is your /location/ barkeep?" script: - narrate " Debug code... remove before release" - chat "My starting point is " - walkto location: # standing_on now show location instead of materials #- chat "I<&sq>m standing on " - chat "I<&sq>m standing at " - chat "I<&sq>m standing at X " - chat "I<&sq>m standing at Y " - chat "I<&sq>m standing at Z " - chat "].from[1].to[4]>" - chat "I<&sq>m standing in world " #- chat "" #- chat "" #- chat "" #- chat "" - chat "Barkeep is standing on material ].block.material>" 'I cant understand you': trigger: /REGEX:\w+/ script: - chat "Sorry, I don<&sq>t understand . Why don<&sq>t you just buy something?" - narrate "<&lb>Hint <&co> menu, describe, buy<&rb>" "Calc Bar Tip": type: task script: - flag player barkeepTip: - flag player barkeepTip:*:0.1 "Describe a menu item": type: interact requirements: mode: all list: - flagged player "BarVisited:true" - flagged player "DescribeBarMenuItem:true" steps: 'BarkeepDescribesItems*': click trigger: script: - chat " just tell me what item you want to know more about." - runtask "script:Bar Menu" - narrate "<&lb>Hint <&co> 1 - 5<&rb>" chat trigger: 'Menu Item 1': trigger: "What is in item /1/?" script: - chat " " - ^flag player "DescribeBarMenuItem:!" 'Menu Item 2': trigger: "Number /2/ looks good. Tell me about it?" script: - chat " " - ^flag player "DescribeBarMenuItem:!" 'Menu Item 3': trigger: "Item /3/, " script: - chat " " - ^flag player "DescribeBarMenuItem:!" 'Menu Item 4': trigger: "Item /4/ looks interesting." script: - chat " " - ^flag player "DescribeBarMenuItem:!" 'Menu Item 5': trigger: "What is item /5/?" script: - chat " " - ^flag player "DescribeBarMenuItem:!" 'We dont serve that': trigger: /REGEX:\w+/ script: - chat "Sorry, we don<&sq>t serve ." - narrate "<&lb>Hint <&co> menu, describe, buy<&rb>" - ^flag player "DescribeBarMenuItem:!" "Buy a bar item": type: interact requirements: Mode: All list: - flagged player "BarVisited:true" - flagged player "BuyABarItem:true" steps: 'OrderFromTheBarMenu*': click trigger: script: - chat "You didn<&sq>t get a menu? Well, here you go ." - runtask "script:Bar Menu" - narrate "<&lb>Hint <&co> 1 - 5<&rb>" chat trigger: 'Menu Item 1': trigger: I<&sq>ll have a number /1/ for script: - ^flag player BarItemPrice: duration:300 - ^flag player BarItemName: duration:300 - ^flag player DrinkEffect:->:confusion - ^flag player DrinkEffect:->:hunger - ^flag player DrinkEffect:->:night_vision - ^if > runtask script:CompleteMenuDrinkOrder else if = runtask script:CompleteMenuDrinkOrder else chat "You don<&sq>t have enough for . You need and you only have ." - ^flag player "BarItemPrice:!" - ^flag player "BarFoodItem:!" - ^flag player "BarItemName:!" - ^flag player "DrinkEffect:!" - chat "Do you want anything else?" - narrate "<&lb>Hint <&co> yes, no, 1 - 5, tip<&rb>" - ^equip hand:0 chest:0 boots:0 head:0 legs:0 'Menu Item 2': trigger: I<&sq>ll have a number /2/ for script: - flag player BarItemPrice: duration:300 - flag player BarItemName: duration:300 - flag player DrinkEffect:->:confusion - flag player DrinkEffect:->:heal - flag player DrinkEffect:->:blindness - if > runtask script:CompleteMenuDrinkOrder else if = runtask script:CompleteMenuDrinkOrder else chat "You don<&sq>t have enough for . You need and you only have ." - ^flag player "BarItemPrice:!" - ^flag player "BarFoodItem:!" - ^flag player "BarItemName:!" - ^flag player "DrinkEffect:!" - chat "Do you want anything else?" - narrate "<&lb>Hint <&co> yes, no, 1 - 5, tip<&rb>" - ^equip hand:0 chest:0 boots:0 head:0 legs:0 'Menu Item 3': trigger: I<&sq>ll have a number /3/ for script: - flag player BarItemPrice: duration:300 - flag player BarItemName: duration:300 - flag player DrinkEffect:->:confusion - flag player DrinkEffect:->:heal - flag player DrinkEffect:->:poison - if > runtask script:CompleteMenuDrinkOrder else if = runtask script:CompleteMenuDrinkOrder else chat "You don<&sq>t have enough for . You need and you only have ." - ^flag player "BarItemPrice:!" - ^flag player "BarFoodItem:!" - ^flag player "BarItemName:!" - ^flag player "DrinkEffect:!" - chat "Do you want anything else?" - narrate "<&lb>Hint <&co> yes, no, 1 - 5, tip<&rb>" - ^equip hand:0 chest:0 boots:0 head:0 legs:0 'Menu Item 4': trigger: I<&sq>ll have a number /4/ for script: - flag player BarItemPrice: duration:300 - flag player BarItemName: duration:300 - flag player DrinkEffect:->:confusion - flag player DrinkEffect:->:jump - flag player DrinkEffect:->:regeneration - if > runtask script:CompleteMenuDrinkOrder else if = runtask script:CompleteMenuDrinkOrder else chat "You don<&sq>t have enough for . You need and you only have ." - ^flag player "BarItemPrice:!" - ^flag player "BarFoodItem:!" - ^flag player "BarItemName:!" - ^flag player "DrinkEffect:!" - chat "Do you want anything else?" - narrate "<&lb>Hint <&co> yes, no, 1 - 5, tip<&rb>" - ^equip hand:0 chest:0 boots:0 head:0 legs:0 'Menu Item 5': trigger: I<&sq>ll have a number /5/ - for script: - flag player BarItemPrice: duration:300 - flag player BarItemName: duration:300 - flag player BarFoodItem:->:320 duration:300 - flag player BarFoodItem:->:297 duration:300 - if > runtask script:CompleteMenuFoodOrder else if = runtask script:CompleteMenuFoodOrder else chat "You don<&sq>t have enough for . You need and you only have ." - flag player "BarItemPrice:!" - ^flag player "BarFoodItem:!" - ^flag player "BarItemName:!" - chat "Do you want anything else?" - narrate "<&lb>Hint <&co> yes, no, 1 - 5, tip<&rb>" - ^equip hand:0 chest:0 boots:0 head:0 legs:0 'Still ordering from the bar': trigger: "/Yes/, I want something else from the menu." script: - chat "OK, here you go." - runtask "script:Bar Menu" - narrate "<&lb>Hint <&co> yes, no, 1 - 5, tip<&rb>" 'Im done ordering from the bar': trigger: /no/ script: - equip HAND item:0 - flag player "BuyABarItem:!" - chat "OK just let me know when you are ready" - narrate "<&lb>Hint <&co> menu, describe, buy<&rb>" - ^zap "step:VisitingTheBarkeep" "script:Welcome back to the bar" 'Cant order that from the menu': trigger: /REGEX:\w+/ script: - chat "Sorry, I don<&sq>t have on the menu." - narrate "<&lb>Hint <&co> yes, no, 1 - 5, tip<&rb>" 'tip barkeep': trigger: "Thanks for the service! Here<&sq>s a /tip/ for you." script: - flag player barkeepTip: - flag player barkeepTip:*:0.1 # need to first determine if player bought anything and check that they have enough money to tip - if >= 0 && >= runtask "script:Give a tip to the barkeep" else narrate "Oops! you don<&sq>t have enough or you have not bought anything yet. Try buying something first." # later this may be replaced with paying bar tab script - narrate "<&lb>Hint <&co> yes, no, 1 - 5, tip<&rb>" "Give a tip to the barkeep": type: task script: - chat "Hey thanks!" - ^narrate "Current bar tab paid<&co> ." - ^narrate "Tip given to <&co> . Your rep has gone up!" - flag player TotalBarTab:! - flag player barkeepTip:! - flag player reputation:+:1 - execute as_server "denizen save" "Barracho": type: task script: - chat "Hey buddy! You<&sq>re turning green. Don<&sq>t get sick in here!" - cast confusion - narrate "You begin to feel violently ill as your stomach begins to turn!" - cast blindness - cast poison duration:10 power:1 - ^flag player reducedRep: - ^flag player reducedRep:-:10 - ^if <= 0 flag player reputation:0 else flag player reputation: - narrate "Getting sick in public does not look good! You lost some reputation." - ^execute as_server "denizen save" "CompleteMenuFoodOrder": type: task script: - equip hand:297 - chat "Here<&sq>s your ." - equip hand:0 - ^runtask 'loop through' "context:ServingBarFood|BarFoodItem|player" - ^take money "qty:" - ^narrate " have been removed from your account." - ^flag player TotalBarTab:+: - ^chat "Item Price " - ^narrate "Paid bar tab total<&co> " "ServingBarFood": type: task context: yumbarfood script: - give item: qty:1 "CompleteMenuDrinkOrder": type: task script: - equip hand:384 - wait 1 - chat "Here<&sq>s your ." - equip hand:374 - ^runtask 'loop through' "context:ServingBarDrink|DrinkEffect|player" - ^take money "qty:" - ^narrate " have been removed from your account." - ^flag player TotalBarTab:+: - ^flag player TotalDrinksConsumed:+:1 duration:3600 - ^if >= runtask "script:Barracho" else if >= - chat "Are you getting sick? Maybe you should quit?" else chat "Enjoy ." "ServingBarDrink": type: task context: BarDrinkItem script: - cast duration:20 power:1 "Bar Menu": type: task script: - ^narrate " Menu" - ^narrate "==========================" - ^narrate "1 - -- " - ^narrate "2 - -- " - ^narrate "3 - -- " - ^narrate "4 - -- " - ^narrate "5 - -- " "Barkeep Init": type: task script: trigger name:chat toggle:true radius:5 trigger name:click toggle:true radius:5 trigger name:proximity toggle:true trigger name:damage toggle:false - vulnerable toggle:false - execute as_npc "npc select " - execute as_npc "npc health --respawndelay 30s" - health 50 - walkto location: "Barkeep Invalid Init": type: task script: - narrate "[X] Oops! Barkeep failed to initialize<&cm>" - narrate "Assignment removed." - assignment remove - flag npc loaded:false