// ****************************************************************************
//
// Logic 29: Coastal Village
//
// ****************************************************************************

#include "defines.txt"

if (new_room) {
  load.pic(room_no);
  draw.pic(room_no);
  discard.pic(room_no);
  set.horizon(37);


// Check what room the player came from and position them on the
// screen accordingly here, e.g:
// if (prev_room_no == 5) {
//   position(ego,12,140);
// }
  load.view(101);
  set.view(ego,101);
  if (prev_room_no == 88) {
      position(ego, 59,116);
      }
  if (prev_room_no == 22) {
      position(ego,20,40);
      }

  draw(ego);
  show.pic();

  animate.obj(o1);    //woman
  load.view(106);
  set.view(o1,106);
  position(o1, 100,50);
  wander(o1);
  draw(o1);

  animate.obj(o2);    //woman
  set.view(o2,106);
  position(o2, 120,50);
  wander(o2);
  draw(o2);

  animate.obj(o3);  //juice barista
  load.view(110);
  set.view(o3,110);
  position(o3,87,132);
  draw(o3);

  animate.obj(o4); //Torches on hounfour
  animate.obj(o5);
  load.view(11);
  set.view(o4,11);
  set.view(o5, 11);
  position(o4, 50, 80);
  position(o5, 72,79);
  set.priority(o4, 15);
  set.priority(o5,15);
  draw(o4);
  draw(o5);

  load.sound(21);
  sound(21,sound_flag);
}

if ((ego_edge_code == horizon_edge ||
     ego_edge_code == left_edge)) {  // ego touching horizon
  load.view(0);
  set.view(ego,0);
  ego_dir=7;
  new.room(22);
}

if (obj.in.box(ego,25,144,40,155) &&
    !hut_flag) {
    set(hut_flag);
    if (has("purple slime")){
        print("Hey, you got purple slime!  You can make a great drink out of that!");
        }
    if (has("vile chug")){
        print("Vile chug!  Yeah, that's some good stuff!");
        print("Can I have some?");
        get.string(s1,m4,80,20,1);
        set.string(s2,m5);
        if (compare.strings(s1,s2)) {
            print("Great!");
            drop("vile chug");
            if (!has("fishing rod")) {
                get("fishing rod");
                print("Here, have my old fishing rod!");
                score++;
                }
            else {
                print("I appreciate the free drink.");
                }
            }
       }
    if (!has("purple slime") && !has("vile chug")) {
        print("Oh, hi, Voodoo Girl!  I was just about ready to go fishing...");
        }
    }


if (obj.in.box(ego,93,142,114,163)) {

    if ((said("give","man","coconut") ||
         said("give","coconut") ||
         said("give","coconut","man"))) {
              if (has("coconut")){
                if (!has("empty coconut") &&
                    !has("sleep bombs") &&
                    !guards_asleep) {
                  print("Mr. Juice: \"Coconut juice...  coming right up.\"");
                  print("Mr. Juice: \"Here's the empty shells.\"");
                  get("empty coconut");
                  score++;
                  }
                else {
                  print("If you drink too much lime and coconut, you'll get a bellyache.");
                  }
                }
              else {
                  print("You don't have a coconut.");
                  }
              }

    if ((said("give","man","blowfish") ||
         said("give","blowfish") ||
         said("give","blowfish","man"))) {
              if (has("blowfish")) {
                  print("Mr. Juice: \"Blowfish Juice?!  err...  coming right up.\"");
                  drop("blowfish");
                  get("blowfish venom");
                  score++;
                  }
              else {
                  print("You don't have a blowfish.");
                  }
              }

   if ((said("give","anyword") ||
        said("give","man","anyword") ||
        said("give","anyword","man"))) {
             print("Mr. Juice: \"I'm afraid I can't make juice of that sort.\"");
             }


    if ((said("talk","man") ||        //request
         said("make","juice") ||
         said("get","juice") ||
         said("buy","juice") ||
         said("ask","juice"))) {
             print("Mr. Juice: \"What kind of juice do you want?\"");
             get.string(s1,m7,80,20,12);
             set.string(s2,m6);
             if (compare.strings(s1,s2)) {
                 if (has("blowfish")) {
                 print("Mr. Juice\"Coming right up!\"");
                 drop("blowfish");
                 get("blowfish venom");
                 score++;
                 new.room(29);
                 }
                }
                 else {
                     set.string(s2,m8);
                     if(compare.strings(s1,s2)) {
                        if (has("coconut")) {
                          if (!has("empty coconut") &&
                              !has("sleep bombs") &&
                              !guards_asleep) {
                            print("Coming right up!");
                            get("empty coconut");
                            score++;
                            new.room(29);
                            }
                          else {
                             print("Too much lime and coconut will give you a bellyache.");
                             }
                           }
                        else {
                            print("Mr. Juice: \"I'm afraid I don't have that in stock.\"");
                            }
                        }

                 }
             else {
                 print("Mr. Juice: \"I'm afraid not...  sorry.\"");
                 }
             }
         }

if (!obj.in.box(ego,25,144,40,155)) {
     reset(hut_flag);
     }

if (said("look")) {
    print("This is the main village.  Some huts are here, as well as the temple, or hounfour.  On the beach is the juice bar.");
    }

if (said("look","hut")) {
    print("The hut to the southwest has an open front door.");
    }

if (said("look","hounfour")) {
    print("This is a place where holy ceremonies are recreated.");
    }

if (said("look","juice bar")) {
    print("You can make almost any kind of juice at the juice bar.  Talk to the man and see if he can make your favorite juice.");
    }

if (said("talk","man")) {
    print("He's busy running the juice bar.  Mainly, he only talks to people on the customer side of his wooden stand.");
    }

if (said("talk","woman")) {
    print("All the women of Coastal Village are busy about their daily errands.");
    }

if (said("look","man")) {
    print("He's just this guy who makes juice, y'know.");
    }

if (said("look","women")) {
    print("All the pretty young women are running around, going about their errands.");
    }

if (said("look","people")) {
    print("Despite the lack of money, the people make do with what they have.");
    }

if (said("get","sand")) {
    print("The sand is clumped together with sea water, but if you put it in your pocket, your pants will get all gritty.");
    }

if (said("look","beach")) {
    print("This is a rather plain shoulder of beach-front.  The sand is rather smooth, as if they hardly ever have any driftwood or anything else wash up.");
    }

if ((said("look","flower") ||
     said("get","flower"))) {
         print("They are lovely, but you have better things to do than pick flowers.");
         }

if (said("look","water")) {
    print("Ah, the ocean stretches out as far as the eye can sea. :D");
    }

if (said("drink","water")) {
    print("Oh, no.  Ocean water is too salty.  You'd get a stomach ache.");
    }

if (obj.in.box(ego,42,85,72,107)) {
    new.room(88); //Inside the hounfour
    }

if (sound_flag) {
    sound(21,sound_flag);
   }

return();

#message 4 "y/n?"
#message 5 "y"
#message 6 "blowfish"
#message 7 "I want..."
#message 8 "coconut"