# The Librarian # Citizens 2 (build #992) # Denizen 0.9.3 (build #1354) # # Description: # # The NPC will ask the player if they want to do a quest to get a book. If the player accepts, # they will need to get paper and leather. Instead of handing it to the NPC, it asks them craft 3 # books instead. It uses a 'listener' to make sure the player did craft them rather than just obtaining # the books another way. # # The NPC then uses 'magic' to fill the book with recipies, but it fails and the words are just gibberish. # It then requires the player to bring the NPC a diamond and redstone. The NPC then tries their magic # again and another book is scribed, this time with formatted custom recipies. # # This then unlocks a couple of other books to be purchased. When a book is purchased, it's added into the # 'LibrarianBooksBought' flag which can be checked later on by another NPC so they will only brew the potions # that are in the books they player bought. # # @author mythanical # @script version 0.9 # @last-updated October 30 2013 # @irc EsperNet IRC Network #denizen-dev # @Minecraft Server - minecraft.geek.nz # @Donate Bitcoin: 1Fzacc2gZ5NGRMXg5jWP6NcUkWei34xjzt # @Donate Litecoin: LhsaGa1QzmVLjMYwg4ZPTVnmSgnBDGc75U "Librarian": type: assignment default constants: # Price for the book containing health and other survival potion recipes. Basic Survival Alchemy: 1000 # Sheets of paper for first quest SheetsOfPaper: 9 # Leather Quantity LeatherQty: 3 # Number of books to be crafted BookQty: 3 # Diamond/s needed for deciphering spell DiamondQty: 1 # Redstone for deciphering spell RedstoneQty: 1 # Price for the books containing offensive splash potions etc Art of War: 2000 # The book that contains all the recipes, survival, defensive and offensive. Alchemist Encyclopedia: 3000 # Name of your town - used in dialogue. Townname: Arrowin interact scripts: - 10 The Right to Learn actions: on assignment: # This enables interaction with NPC via clicking, chatting, proximity and damage. - trigger name:chat toggle:true - trigger name:click toggle:true - trigger name:proximity toggle:true - trigger name:damage toggle:true # Make the NPC so they can be killed by the player. They will respawn a few seconds later. - execute as_npc "npc sel <npc.id>" - execute as_npc "npc vulnerable" - execute as_npc "npc respawn 1200" # Make NPC look at players close by - lookclose state:true "The Right to Learn": type: interact steps: 1: proximity trigger: entry: script: # When the player enters proximity, it will check to see if they are holding any item # in their hand with the word 'sword' in it and run the deny script if so. # Else just chat some random stuff. - if <<player.item_in_hand>.contains[sword]> run "Deny Interaction" else { - random { - ^chat "<yellow>We read to know that we are not alone." - ^chat "<yellow>Never trust anyone who has not brought a book with them." - ^chat "<yellow>If one cannot enjoy reading a book over and over again, there is no use in reading it at all." - ^chat "<yellow>You can never get a cup of tea large enough or a book long enough to suit me." - ^chat "<yellow>A reader lives a thousand lives before he dies. The man who never reads lives only one." - ^chat "<yellow>The books that the world calls immoral are books that show the world its own shame." - ^chat "<yellow>You don<&sq>t have to burn books to destroy a culture. Just get people to stop reading them." - ^chat "<yellow>Until I feared I would lose it, I never loved to read. One does not love breathing." - ^chat "<yellow>Let us read, and let us dance; these two amusements will never do any harm to the world." - ^chat "<yellow>There are worse crimes than burning books. One of them is not reading them." } } click trigger: script: # When the player clicks the NPC, it'll run a script further below that will do some checks # to see what 'quest stage' the player is at and present the relevant dialogue. - ^run "Librarian Quest Stage Check" damage trigger: script: # If you hit the NPC, it will run a script further below with some random dialogue to show # their disgust. - ^run "Librarian Warning" 2: chat trigger: 'Start Questline': Trigger: /Yes/, I am interested. I<&sq>ll start now. script: # If the player responds with 'Yes' to start the quest line, it will flag them as "Stage1" and tell them # to bring some paper and leather. - engage - ^flag <player> LibrarianQuest:Stage1 - chat "<yellow>Great <white><player.name><yellow>, well for your first quest I will need some <white>paper<yellow> and <white>leather<yellow>." - wait 3 - chat "<yellow>Hmm.. I think <white><cons:SheetsOfPaper> sheets of paper<yellow> and <white><cons:LeatherQty> leather<yellow> will do! Come back to me when you<&sq>ve got it." - narrate "<red> Basic Survival Alchemy - Quest Started" - ^disengage 'Deny Questline': Trigger: /No/, I am not interested. script: # If the player says 'No' instead, it plays any one of the 3 lines below and 'zaps' the # interact stage back to "1" above - so it doesn't get stuck in this dialogue. - random { - chat "<yellow>Oh well, I guess literature isn<&sq>t for everyone. You dont reed so gud eh? Haha." - chat "<yellow>That<&sq>s unfortunate, just when I thought you were going to be a great help." - chat "<yellow>Yeah ok, go swing your sword or spill your drink in a tavern. You<&sq>ll fit right in." } - ^zap step:1 click trigger: script: # Same as the click trigger further up. I just put these here again so if the player # missed what was said, then when they click it again it'll show them what is expected. - ^run "Librarian Quest Stage Check" proximity trigger: exit: script: # When the player leaves the NPC proximity it resets the dialogue back to step 1. - ^zap step:1 damage trigger: script: # If you hit the NPC, it will run a script further below with some random dialogue to show # their disgust. - ^run "Librarian Warning" 3: chat trigger: 'Basic Survival Alchemy': Trigger: Can I please buy the Basic /Survival/ Alchemy book? script: # Few things happen here: # 1) Check to see if the player has enough money by comparing the money they've got # with the value of the book set all the way at the top of this script and if not # give some feedback. # 2) If they do have enough, take the money and give them another copy of the book. - ^if <player.money> >= "<cons:Basic Survival Alchemy>" { - take money "qty:<cons:Basic Survival Alchemy>" - narrate "<red> You pay <white><npc.name> <gold><cons:Basic Survival Alchemy> <player.money.currency><red>." - chat "<yellow>Lost your book already? Here is a shiney new <&sq><white>Basic Survival Alchemy<yellow><&sq> book." - if <player.flag[LibrarianBooksBought]> !contains BasicSurvivalAlchemy flag <player> LibrarianBooksBought:->:BasicSurvivalAlchemy - scribe give "script:Basic Survival Alchemy" } else if <player.money> <= 0 narrate "<red>You do not have any money at all. Do some quests or sell items in the shop to earn money." else if <player.money> == 1 narrate "<red>You have just <gold>one <red><player.money.currency>. Do some quests or sell items in the shop to earn more money." else narrate "<red>You have <gold><player.money.asint><red> <player.money.currency>, but need <gold><cons:Basic Survival Alchemy><red> <player.money.currency><red> to buy this book." - ^zap step:1 'Art of War': Trigger: Can I please buy the Art of /War/ alchemy book? script: # Same as above, just a different book. - ^if <player.money> >= "<cons:Art of War>" { - take money "qty:<cons:Art of War>" - narrate "<red> You pay <white><npc.name> <gold><cons:Art of War> <player.money.currency><red>." - if <player.flag[LibrarianBooksBought]> contains ArtofWar chat "<yellow>Lost your book already? Here is a shiney new <&sq><white>Art of War<yellow><&sq> book." else chat "<yellow>Here you go, your own copy of <&sq><white>Art of War<yellow><&sq>!" - if <player.flag[LibrarianBooksBought]> !contains ArtofWar flag <player> LibrarianBooksBought:->:ArtofWar - scribe give "script:Art of War" } else if <player.money> <= 0 narrate "<red>You do not have any money at all. Do some quests or sell items in the shop to earn money." else if <player.money> == 1 narrate "<red>You have just <gold>one <red><player.money.currency>. Do some quests or sell items in the shop to earn more money." else narrate "<red>You have <gold><player.money.asint><red> <player.money.currency>, but need <gold><cons:Art of War><red> <player.money.currency><red> to buy this book." - ^zap step:1 'Alchemist Encyclopedia': Trigger: Can I please buy the complete Alchemist /Encyclopedia/? script: - ^if <player.money> >= "<cons:Alchemist Encyclopedia>" { - take money "qty:<cons:Alchemist Encyclopedia>" - narrate "<red> You pay <white><npc.name> <gold><cons:Alchemist Encyclopedia> <player.money.currency><red>." - if <player.flag[LibrarianBooksBought]> contains AlchemistEncyclopedia chat "<yellow>Lost your book already? Here is a shiney new <&sq><white>Alchemist Encyclopedia<yellow><&sq>." - if <player.flag[LibrarianBooksBought]> !contains AlchemistEncyclopedia flag <player> LibrarianBooksBought:->:AlchemistEncyclopedia - scribe give "script:Alchemist Encyclopedia" } else if <player.money> <= 0 narrate "<red>You do not have any money at all. Do some quests or sell items in the shop to earn money." else if <player.money> == 1 narrate "<red>You have just <gold>one <red><player.money.currency>. Do some quests or sell items in the shop to earn more money." else narrate "<red>You have <gold><player.money.asint><red> <player.money.currency>, but need <gold><cons:Alchemist Encyclopedia><red> <player.money.currency><red> to buy this book." - ^zap step:1 click trigger: script: - ^run "Librarian Quest Stage Check" proximity trigger: exit: script: - ^zap step:1 damage trigger: script: - ^run "Librarian Warning" "Librarian Quest Stage Check": type: task script: # The following task checks the quest progress and respond accordingly. It'll also # flag the player so the next time they interact it'll match the criteria for the next # stage of the quest. # # 1) Check to see if the player is holding a sword, if so run the 'Deny Interaction' script. # 2) Else, if the player has no flag set to indicate they've started the quest line, ask # them if they are interested and 'zap' to step 2 in the script above so it'll activate # the 'Yes' and 'No' chat triggers. # 3) If the player is Stage 1 and have sufficient paper and leather, flag them with 'Stage2' # and ask the player to craft the items into a book. At this point is uses a 'listen' command # that runs in the background and waits for the player to craft a specified quantity of books. # Once they do that, it'll run the 'Librarian Stage Two Complete' # 4) If the player interacts with the NPC and they don't have the required items, it'll tell # them what is needed. # 5) If the it's stage 3 and the player has the books, flag the player with Stage 4, take the # books from the player, run a few effects and give them the 'gibberish' book. Then ask player # to bring diamond and redstone. # 6) If the player comes back with the diamond and redstone, it'll then run the last stage and # give the player the proper deciphered book. # 7) If the player completed the quest and interacts again, it will present them the option to # purchase the books again. - if <<player.item_in_hand>.contains[sword]> run "Deny Interaction" else if <player.flag[LibrarianQuest]> == null { - random { - chat "<yellow>Hello there <white><player.name><yellow>! Are you interested in helping me out with something?" - chat "<yellow>Hey <white><player.name><yellow>, are you keen on buying books for alternative alchemy recipies? Help me first!" - chat "<yellow>Oooh, are you up for an adventure? I do so love an adventure! Help me help you." } - chat "<yellow>I will reward you with a <dark_purple><&sq>Basic Survival Alchemy<&sq><yellow> book if you help me. It contains alternative recipies to potions and <white>Greylocke<yellow>, in the wizard<&sq>s tower, can brew them for you!" - narrate "<red>Say<&co>" - narrate " <blue>Yes<blue> <gray>or<red> No" - ^zap step:2 "s@The Right to Learn" } else if <player.flag[LibrarianQuest]> == Stage1 && <player.inventory.contains[paper].qty[<cons:SheetsOfPaper>]> && <player.inventory.contains[leather].qty[<cons:LeatherQty>]> { - ^flag player LibrarianQuest:Stage2 - ^flag player Alignment:++ - narrate "<gold>Your alignment is<&co> <player.flag[Alignment]>." - chat "<yellow>Fantastic, seems like you<&sq>ve got the <white><cons:SheetsOfPaper> sheets of paper<yellow> and <white><cons:LeatherQty> leather<yellow> that I need." - wait 2 - chat "<yellow>Now, what invites a fickle reader to look at a book.. the cover of course! Show me your love for books by combining the <white>paper<yellow> and <white>leather<yellow> and craft me <white><cons:BookQty> books<yellow>." - ^narrate "<red> Basic Survival Alchemy - Craft <cons:BookQty> Books" - ^listen item type:craft item:book qty:<cons:BookQty> id:CraftingBooks "script:Librarian Stage Two Complete" - ^zap step:1 "s@The Right to Learn" } else if <player.flag[LibrarianQuest]> == Stage1 && <player.inventory.contains[paper].qty[<cons:SheetsOfPaper>]>|<player.inventory.contains[leather].qty[<cons:LeatherQty>]> contains false chat "<yellow>Oh, <white><player.name><yellow>, it seems like you are missing some components. I need <white><cons:SheetsofPaper> sheets of paper<yellow> and <white><cons:LeatherQty> leather<yellow>. Please come back when you have everything I need." else if <player.flag[LibrarianQuest]> == Stage2 chat "<yellow>Hi <white><player.name><yellow>, I<&sq>m still waiting for you to craft me <white><cons:BookQty> books<yellow>." else if <player.flag[LibrarianQuest]> == Stage3 && <player.inventory.contains[book].qty[<cons:BookQty>]> { - ^flag <player> LibrarianQuest:Stage4 - ^flag <player> Alignment:++ - ^take i@book qty:<cons:BookQty> - chat "<yellow>Good work <white><player.name><yellow>! Now it<&sq>s time for the magic to start happening..literally." - narrate "<red><npc.name> takes the <cons:BookQty> books and starts casting a spell over the pages.." - ^cast blindness power:5 duration:10 - ^cast confusion power:5 duration:3 - ^playsound "location:<npc.location>" "sound:portal_travel" volume:2 pitch:3 - ^playsound "location:<npc.location>" "sound:portal_trigger" volume:2 pitch:3 - wait 5 - chat "<yellow>Hmmm.. it didn<&sq>t work as I had hoped. The spell wasn<&sq>t powerful enough to scribe it into a readable format." - wait 5 - chat "<yellow>Ok, I<&sq>ve got an idea. I need you to bring me <white><cons:DiamondQty> diamond<yellow> and <white><cons:RedstoneQty> redstone dust<yellow>. Don<&sq>t worry! I<&sq>ll give the diamond back. I just need a little bit of powder." - wait 3 - ^narrate "<red><npc.name> hands you the failed scribed book. You don<&sq>t have to keep it." - ^scribe give "script:Basic Survival Alchemy Gibberish" - wait 3 - ^narrate "<red> Basic Survival Alchemy - Deciphering the Pages" - ^zap step:1 "s@The Right to Learn" } else if <player.flag[LibrarianQuest]> == Stage3 chat "<yellow>Errm <white><player.name><yellow>, what did you do with the books you crafted? Oh well, you<&sq>ve shown you can craft them so just bring me any <white><cons:BookQty> books<yellow> then." else if <player.flag[LibrarianQuest]> == Stage4 && <player.inventory.contains[diamond].qty[<cons:DiamondQty>]> && <player.inventory.contains[redstone].qty[<cons:RedstoneQty>]> { - ^flag <player> LibrarianQuest:Completed - ^flag <player> Alignment:++ - narrate "<red> You hand <white><npc.name> <white><cons:DiamondQty> diamond<red> and <white><cons:RedstoneQty> redstone dust<red>." - ^take i@diamond qty:<cons:DiamondQty> - ^take i@redstone qty:<cons:RedstoneQty> - chat "<yellow>Ok, let<&sq>s try this again...." - wait 4 - ^cast blindness power:5 duration:10 - ^cast confusion power:5 duration:3 - ^playsound location:<npc.location> sound:portal_travel volume:4 pitch:3 - ^playsound location:<npc.location> sound:portal_trigger volume:4 pitch:3 - wait 6 - chat "<yellow>Excellent, it worked!" - wait 2 - chat "<yellow>Here is the new book with alternative alchemy recipies. Make sure you<&sq>ve got the ingredients the book says and take it to <white>Greylocke<yellow>, in the Wizard<&sq>s Tower, he<&sq>ll be able to create potions for you." - ^give i@diamond qty:<cons:DiamondQty> - wait 3 - ^scribe give "script:Basic Survival Alchemy" - narrate "<white><npc.name><red> hands you the deciphered <dark_purple><&sq>Basic Survival Aclhemy<&sq><red> book and <white><cons:DiamondQty> diamond<red>." - ^zap step:1 "s@The Right to Learn" } else if <player.flag[LibrarianQuest]> == Stage4 && <player.inventory.contains[diamond].qty[<cons:DiamondQty>]>|<player.inventory.contains[redstone].qty[<cons:RedstoneQty>]> contains false chat "<yellow>Oh, <white><player.name><yellow>, it seems like you are missing some components. I need <white><cons:DiamondQty> diamond<yellow> and <white><cons:RedstoneQty> redstone dust<yellow>. Please come back when you have everything I need." else if <player.flag[LibrarianQuest]> == Completed { - ^chat "<yellow>Welcome back <white><player.name><yellow>! If you<&sq>ve lost your <&sq><white>Basic Survival Alchemy<yellow><&sq> book, you can buy it again or buy another book." - ^narrate "<red>Say<&co>" - ^narrate " <blue>[Survival]<blue><gray> - Survival Alchemy (defensive) - <gold><cons:Basic Survival Alchemy> <player.money.currency>." - ^narrate " <blue>[War]<blue><gray> - Art of War (offensive) - <gold><cons:Art of War> <player.money.currency>." - ^narrate " <blue>[Encyclopedia]<blue><gray> - Alchemist (all recipies) - <gold><cons:Alchemist Encyclopedia> <player.money.currency>." - ^zap step:3 "s@The Right to Learn" } "Librarian Warning": type: task script: # When you hit (damage) the NPC, they will respond with one of the following lines. - ^random { - chat "<red>Oucch! <yellow>Why would you do that? If I die, you WILL regret it!" - chat "<red>Aaarrggg! <yellow>What did I ever do to you? Don't hit me again!" - chat "<red>Wha..why are you hurting me? <yellow>Oh, these cuts..they hurt so much." - chat "<red>Please don't hurt me! <yellow>I have never done anything bad to you!" - chat "<red>Owwee! <yellow>Don't do something now that you will regret later.." } "Librarian Stage Two Complete": type: task script: # This runs when the 'listen' command sees the relevant amount of books have been # crafted. - ^flag <player> LibrarianQuest:Stage3 - ^flag <player> Alignment:++ - narrate "<red>You have crafted <white><cons:BookQty> Books<red>. Return to <white><npc.name><red> in the Library with the books." - ^zap step:1 "s@The Right to Learn" # This is an item script, that will create a book when it's used with the 'scribe' command. # The tags, like <npc.name> will be substituted with the proper values. Used that to personalise # the books. Further below I used the player's name, so even when they drop it and someone else # picks it up, they'll know whose book it is. "Basic Survival Alchemy Gibberish": type: book title: "Basic Survival Alchemy - Gibberish" author: <npc.name> text: - Buedaehain ges seist gieneof yauteof moareon noisoin daeceolan peobuohen rieyeiher - sieqeawof cuekuaxeof deuliukan roapen teahan noifaogu liacon. Daogeadan rin xaegiehin - can qeoviof dairin toefoatean rion teiceivean naijaeton riof rain hiakeof weawean. "Basic Survival Alchemy": type: book title: "<player.name><&sq>s Basic Survival Alchemy" author: <npc.name> text: - Dear <player.name>, I am Greylocke, <cons:Townname><&sq>s alchemist. This book has been inscribed with recipies for <bold>defensive<black> potions. Look at the pages and bring me the ingredients for the potions you want. I am located upstairs in the Wizard<&sq>s tower. - <bold>Fire Resistance<black><P> 1 Yellow Wool, 1 sugar and 1 glass vial.<P><bold>Healing potion<P><black>1 Purple Wool, 1 sugar and 1 glass vial. - <bold>Regeneration potion<P><black>1 Magenta Wool, 1 sugar and 1 glass vial. "Art of War": type: book title: "<player.name><&sq>s Art of War" author: <npc.name> text: - Dear <player.name>, I am Greylocke, <cons:Townname><&sq>s alchemist. This book has been inscribed with recipies for <bold>offensive<black> potions. Look at the pages and bring me the ingredients for the potions you want. I am located upstairs in the Wizard<&sq>s tower. - <bold>Strength Potion<P><black>1 Orange Wool, 1 sugar and 1 glass vial. (Deal more damage)<P><bold>Slowness Potion<P><black>1 Gray Wool, 1 sugar and 1 glass vial. - <bold>Harming Potion<P><black>1 Lime Wool, 1 sugar and 1 glass vial. (Splash)<P><bold>Weakness Potion<P><black>1 Light Gray, 1 sugar and 1 glass vial. (Splash) - <bold>Poison Potion<P><black>1 Pink Wool, 1 sugar and 1 glass vial. (Splash) "Alchemist Encyclopedia": type: book title: "<player.name><&sq>s Alchemist Encyclopedia" author: <npc.name> text: - Dear <player.name>, I am Greylocke, <cons:Townname><&sq>s alchemist. This book has been inscribed with recipies for <bold>all<black> my potions. Look at the pages and bring me the ingredients for the potions you want. I am located upstairs in the Wizard<&sq>s tower. - <bold>Fire Resistance<black><P> 1 Yellow Wool, 1 sugar and 1 glass vial.<P><bold>Healing potion<P><black>1 Purple Wool, 1 sugar and 1 glass vial. - <bold>Regeneration potion<P><black>1 Magenta Wool, 1 sugar and 1 glass vial. - <bold>Strength Potion<P><black>1 Orange Wool, 1 sugar and 1 glass vial. (Deal more damage)<P><bold>Slowness Potion<P><black>1 Gray Wool, 1 sugar and 1 glass vial. - <bold>Harming Potion<P><black>1 Lime Wool, 1 sugar and 1 glass vial. (Splash)<P><bold>Weakness Potion<P><black>1 Light Gray, 1 sugar and 1 glass vial. (Splash) - <bold>Poison Potion<P><black>1 Pink Wool, 1 sugar and 1 glass vial. (Splash)
Great script, Where do we find the scripts for Greylocke / Or how do we activate them
"2013-04-28 18:24:47 - ratonacat: Great script, Where do we find the scripts for Greylocke / Or how do we activate them" +1
where is Greylocke script so would like it.
btw this script now works with denizen-0.9.3-SNAPSHOT.jar
found a way combine denizen with alchemist plugin then set denizen to check for flag before allowing use. will post code soon
nevermind that report seems alchemist is bugged and hasnt been updated in a year it wont keep the configs for the potions