Description:
Feed the chicken some seeds (grass, melon or pumpkin) and she will lay an egg eventually. You can change what she eats by editing the 'Food' list, the number of times she need to be fed and how many eggs she will lay.
This script demonstrates how it compares what the player is holding in their hand to a list of items, if nothing matches a random dialog showing the chicken's disappointment is displayed. Every time you feed it, it adds 1 to the counter and takes the seed from the player's hand. It then run a little task to check if the player has given the chicken all of the necessary seeds for it to lay an egg.
# Clucky the Awkward Chicken# Citizens Build #992# Denizen Build #1352## Description:# Feed the chicken some seeds (grass, melon or pumpkin) and she will lay an egg.## NOTE: If you change the SeedQty, make sure to modify the number of narrates in the # 'Clucky Reward Check' script.### Once you created the NPC, you might want to do "/npc lookclose" to make her look a little # bit more realistic instead of a mini chicken statue.## @author mythanical# @script version 1.0.1# @denizen v0.9.3# @last-updated October 29 2013# @irc EsperNet IRC Network #denizen-dev# @Minecraft Server - minecraft.geek.nz# @Donate Bitcoin: 1Fzacc2gZ5NGRMXg5jWP6NcUkWei34xjzt# @Donate Litecoin: LhsaGa1QzmVLjMYwg4ZPTVnmSgnBDGc75U
"Clucky":
type: assignment
default constants:
# List of items Clucky will eat. Since Clucky is a chicken and not the Tasmanian Devil,# she only eats the following seeds:
Food: i@melon_seeds|i@pumpkin_seeds|i@seeds
# The number of seeds you have to give the chicken to drop an egg
SeedQty: 5# The number of eggs the chicken will drop when fed
EggQty: 1
interact scripts:
- 10 Feed Clucky
actions:
on assignment:
# This enables interaction with NPC via clicking, entering proximity and damage.
- 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 60 seconds later.
- execute as_npc "npc sel <npc.id>"# If you don't want the chicken to take damage or be killed, simply comment the line directly below.
- execute as_npc "npc vulnerable"
- execute as_npc "npc respawn 60"# Turn the NPC into a chicken!
- execute as_npc "npc type chicken"# Make the NPC look at players
- lookclose state:true
on spawn:
# If you uncomment the teleport line below (by removing the hash) then when the chicken is killed, it will return her to this position.# Since she has got vulnerability enabled, it means the chicken can be pushed around by other players.# Usually I would set an NPC path, but using a chicken type NPC doesn't work very well with pathing.## Uncomment and add your own location on the next row where you want the chicken to respawn.#- teleport npc 'location:148,66,265,world'
on death by player:
# This is what it says when a player kills the chicken
- narrate "<red>You have killed <aqua><npc.name><red>. Luckily, she knows how to travel through space and time and will return shortly."
"Feed Clucky":
type: interact
steps:
1:
proximity trigger:
entry:
script:
# On player entering proximity range, run a script called 'Clucky Greet', located just below.
- ^random {
- ^narrate "<aqua><npc.name><red> the chicken looks at you funny..."
- ^narrate "<red>The creepy chicken is eagerly watching your every move.."
- ^narrate "<red>You feel someone or something staring at you.."
- ^narrate "<red>Is this deja vu or have you seen that chicken before?"
- ^narrate "<red>You feel your mind being altered, implanted with an urge to feed that chicken staring at you."
- ^narrate "<red>You notice a chicken, watching you with it's one big eye."
- ^narrate "<red>For some reason, you feel like you are being watched."}
- ^playsound location:<npc.location> sound:chicken_idle
click trigger:
script:
# On right clicking the chicken, it'll go through the following processes:# 1) First, it checks to see if you have melon seeds, if you then add 1 to the counter, take the seed, and# run the task that'll check to see if you've given enough seeds for your reward.# 2) If you do not have enough melon seeds, check to see if you have pumpkin seeds, if not check for normal# seeds.# 3) Else, lastly, if you don't meet any of the first 3 criteria, then run a random dialog option showing# the chickens disappointment.
- ^if <cons:Food> contains <player.item_in_Hand> {
- take <player.item_in_Hand>
- flag <player> CluckyCount:++
- run "Clucky Reward Check"}
else {
- random {
- narrate "<red>A single tear rolls down <aqua><npc.name><red>'s cheek.."
- narrate "<red>You don't have any seeds to feed <aqua><npc.name><red>."
- narrate "<red>Poor <aqua><npc.name><red>, you don't have seeds to feed her. Oh well, it's just a chicken anyway."
- narrate "<red>It's rare that someone approaches <aqua><npc.name><red> without any seeds.. how could you <yellow><player.name><red>?"
- narrate "<red>Another day, another disappointment for poor <aqua><npc.name><red>."
- narrate "<red>You feel disappointed in yourself for not having any seed to feed <aqua><npc.name><red>."
- narrate "<red>You feel ashamed in yourself for being the only person to disappoint <aqua><npc.name><red> in a year."
- narrate "<red>A sudden fear of being attacked..by a chicken, overwhelms you."}}
damage trigger:
script:
# Everytime you hit the chicken, play the 'chicken_hurt' sound effect.
- ^playsound location:<npc.location> sound:chicken_hurt
"Clucky Reward Check":
type: task
speed: 0
script:
# This is where it checks to see the number of times you've fed Clucky. As you feed, the flag counter for "CluckyCount" increments# the value and there is a different narrate for each step. When the number of times fed eventually equal or are more than the seed quantity# you specified at the top of the script it'll run the 'Clucky Reward' script.
- ^if <player.flag[CluckyCount]> == 1 narrate "<aqua><npc.name><red> gobbles up the seeds, but is still hungry.."
else if <player.flag[CluckyCount]> == 2 narrate "<aqua><npc.name><red> seems happier but is eagerly waiting for more.."
else if <player.flag[CluckyCount]> == 3 narrate "<red>Yep, if you keep on feeding <aqua><npc.name><red> she might just.."
else if <player.flag[CluckyCount]> == 4 narrate "<red>Almost..."
else if <player.flag[CluckyCount]> >= <cons:SeedQty> run "Clucky Reward"
"Clucky Reward":
type: task
speed: 0
script:
# This task will then play the sound effect when a chicken lays an egg and drop an egg on the ground next to the NPC. The flag is then# reset using '!' so that the whole process can start from scratch.
- ^playsound location:<npc.location> sound:chicken_egg_pop
- ^drop i@egg qty:1 location:<npc.location>
- ^flag <player> CluckyCount:!
- ^random {
- narrate "<red>Pop, goes the egg!"
- narrate "<red>An Egg!"
- narrate "<red>Oh snap, an egg!"
- narrate "<red>Yes, egg!"
- narrate "<aqua><npc.name><red> lays an egg!"
- narrate "<red>In goes the food, out comes an egg!"}
Love the clean code and well thought out dialogue. It really gives this script a nice, polished feel.
I love this. Thanks!