Paste #21407: Clucky (just playing with the script I found in an old repo)

Date: 2015/10/23 19:41:45 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# 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
  debug: true
  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: li@melon_seeds|pumpkin_seeds|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 radius:7
    - trigger name:damage state:true

    # Make the NPC so they can be killed by the player. They will respawn 60 seconds later.
    - execute as_player "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_player "npc vulnerable"
    - execute as_player "npc respawn 60"

    # Turn the NPC into a chicken!
    - execute as_player "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:

    - narrate "<red>You have killed <aqua><npc.name><red>!"

"Feed Clucky":
  type: interact
  debug: true
  steps:
    1:
      proximity trigger:
        entry:
          script:
          # On player entering proximity range, run a script called 'Clucky Greet', located just below.
          - ^random {
            - ^narrate "<red>Покорми меня, пожалуйста!"
            - ^narrate "<red>Умираю с голоду!"
            - ^narrate "<red>Два зёрнышка для бедной курочки!"
            }
          - ^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 <npc.constant[Food]> contains <player.item_in_hand.material.name> {
          - take <player.item_in_hand>
          - flag <player> CluckyCount:++
          - run "Clucky Reward Check" }

          else {
            - random {
              - narrate "<red>Курочка горько плачет..."
              - narrate "<red>Курочка вздыхает..."
              }
          }



"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 "<red>Зёрнышки склевала, но не наелась..."
    else if <player.flag[CluckyCount]> == 2 narrate "Курочка повеселела, но просит ещё..."
    else if <player.flag[CluckyCount]> == 3 narrate "<red>Корми, корми, сейчас что-то будет!"
    else if <player.flag[CluckyCount]> == 4 narrate "<red>Почти готово..."
    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>Ура, яичко!"
    - narrate "<red>Снесла курочка яичко!"
    - narrate "<red>Ха-ха, яичко!"
    }