:devin_finds_magic_book
  start cutscene

  create villager Devin 10,3,8
  create villager Annie 7,8,8

  js $gameMap.centerCameraOn(4, 4, 3);
  
  speed Devin 2.5
  speed Player 2.5

  wait 60

  Devin "<!>"
  wait 10
  
  Devin "Wow, this book explains how to use the magic power of jewels to create farming tools."
  
  wait 2
  Annie "<!>"
  wait 10
  Devin ".<wait>.<wait>.<wait>"

  move villager Devin 10,4,4
  wait for Devin
  move villager Devin 9,4,2
  wait for Devin
  move villager Devin 9,8,4
  wait 30
  move villager Annie 8,8,6
  
  js $gameMap.centerCameraOn(4, 9, 3);
  wait for Devin

  Devin "Oh, hello Annie."
  Annie "Hello Devin. Is that a magic book you're reading?"
  Devin "Yeah... Just some thing about using \"Elemental Magic Jewels\" to enhance tools."
  Annie "Ah, yes. Those are crystals, they hold the magic power of the elements."
  Devin "Is that so? How do you know? This information was missing from the book."
  Annie "I know a thing or two about magic. I've seen some of those tools in the past too."
  Devin "Really? Do you think I could try to build one myself?"
  Annie "If you have the instructions and you can get the right materials, why not?"
  Devin "You're right. Let me check the list of materials...<wait>"

  move villager Player 9,9,8
  wait 30
  Devin "Man, I'm getting super excited about this."

  wait for Player

  turn Devin down
  turn Annie down

  Devin "<name>! Great timing! Do you think you can help me get some materials for a project?"
  Player "Uhh.. Sure. What do you need?"
  Devin "According to this, I need 4 Iron Ores and one \"Water Magic Crystal\"."
  Annie "That's a regular blue crystal. You can find them on the mountains or places with a lot of copper."
  Player "Yes, I can find those for you, but what kind of project are you going to make?"
  Devin "Something that will be very useful to you: An Automated Irrigation System."
  Player "That sounds perfect. I'm going after those materials right now."
  move villager Player 9,13,2
  wait 45

  switch devinOnAProject ON
  switch playedDevinFindingMagicBook ON
  fade out
  speed Player restore
  teleport to orange_town (18, 39, down)
  abort cutscene
  wait 1
  fade in
  wait 10
  accept automated-irrigation-system

:devin_studies_magic
  start cutscene

  create villager Devin 9,3,8
  create villager Annie 7,8,8

  js $gameMap.centerCameraOn(4, 6, 3);
  
  speed Devin 2.5
  speed Player 2.5

  wait 15

  move villager Devin 9,8,4
  wait for Devin
  turn Annie right
  wait 5
  Devin "Hey Annie, remember when you helped me build that magic sprinkler the other day?"
  move villager Annie 8,8,6
  wait for Annie
  Annie "Sure, what about it?"
  Devin "I've been wondering if I can change the design to make it even more effective."
  Devin "<name> has shipped a much larger blue crystal. If I use one of those I can probably make it a lot stronger."
  Annie "So <he> found a big blue crystal? Those are very powerful. I think it could work."
  Devin "Really? I'll try it then. The only problem is that that big blue crystal was already shipped."
  Annie "Finding another won't be easy, they are very rare."

  switch hidePlayer off
  move villager Player 9,9,8
  
  js $gameMap.centerCameraOn(4, 9, 3);
  turn Devin down
  wait 5
  Devin "<!:async>"
  wait 30
  turn Annie down
  wait for Player
  Devin "<name>! Perfect timing as usual."
  Devin "Remember that <color:important>Big Blue Crystal</color> you shipped? Do you think you can find another one?"
  Devin "If you do, I think I can make a better sprinkler for you."
  Player "The sprinkler you made is super useful already, if you can make it even better, I'll look everywhere for that crystal!"
  Devin "That's my <man>! Other than that, I'll also need a <color:important>ruby gem</color>, alright? This one should not be too hard."
  Annie "I heard the big blue crystal is found on places with a lot of silver. That should narrow your search a bit!"
  Player "That's useful knowledge. Thank you, Annie!"
  move villager Player 9,13,2
  wait 45

  switch devinOnAProject ON
  switch playedDevinKnowsMagic ON
  fade out
  speed Player restore
  teleport to orange_town (18, 39, down)
  wait 1
  abort cutscene
  fade in
  wait 10
  accept super-sprinkler


:devin_complete_sprinkler_quest
  Devin "<name>, I've been waiting for you. Did you get the materials?"
  Player ("4 Iron Ores and a Blue Crystal...", "Here they are", "Hold on", "Hold on")
  if response == "Here they are"
    Devin "Oh thank you, thank you! I'll go work on it right away!"
    js Managers.Items.loseItemId('iron-ore', 4);
    + Managers.Items.loseItemId('blue-crystal', 1);
    + Variables.sprinklersMade = 1;

    Devin "Ah, wait, I just remembered I have to finish some stuff for dad first."
    Devin "Darn, why do I have to do this? I want to work on my project."
    Player "I'll...<wait><wait> check up on you later."
    switch devinFinishingSprinkler ON

    complete automated-irrigation-system
  else
    Devin "Alright, no pressure. I'm just too excited with this project."
  end

:devin_complete_super_sprinkler_quest
  Devin "<name>, I've been waiting for you. Did you get the materials?"
  Player ("A Ruby and a Big Blue Crystal...", "Here they are", "Hold on", "Hold on")
  if response == "Here they are"
    Devin "Oh thank you, thank you! I'll work on it as soon as I can!"
    js Managers.Items.loseItemId('ruby', 1);
    + Managers.Items.loseItemId('big-blue-crystal', 1);
    + Variables.sprinklersMade += 1;

    Devin "I'll leave the new sprinkler on your mailbox when it's finished."
    switch devinFinishingSuperSprinkler ON
    complete super-sprinkler
  else
    Devin "Alright, no pressure. Let me know when you have it."
  end