// ****************************************************************************
//
// Logic 4: Inside Mama's Hut
//
// ****************************************************************************

#include "defines.txt"

if (new_room) {
  load.pic(room_no);
  draw.pic(room_no);
  discard.pic(room_no);
  set.horizon(1);
  load.view(100);
  set.view(ego,100);

if (prev_room_no == 3) {
  position(ego,6,132);
  }

  ego_dir=0;
  new_ego_x=6;
  new_ego_y=132;
  draw(ego);

  animate.obj(o2); //Mama Hoodoo
  load.view(9);
  set.view(o2,9);
  position(o2,56,120);
  set.loop(o2, 0);
  draw(o2);

  animate.obj(o3); //Torch
  load.view(25);
  set.view(o3,25);
  position(o3,25,46);
  draw(o3);

  animate.obj(o4); //Torch
  set.view(o4,25);
  position(o4,102,49);
  draw(o4);

  load.sound(23);
  sound(23,sound_flag);


  set(done_flag);

  show.pic();


}

  display(1,1,"Press F10 to click");

if (said("look")) {
  print("You are face to face with Mama Hoodoo in the darkness of her hut.  Torches burn, yet illuminate nothing.");
}

if (said("look","hoodoo")) {
  print("Who knows what goes on behind that crazy mask.");
  print("Mama:\"What mask?\"");
  }

if ((said("give","blowfish venom") ||
     said("give","blowfish venom","Mama Hoodoo") ||
     said("give","Mama Hoodoo","blowfish venom"))) {
     venom:
          if (has("blowfish venom")) {
              if (mama_venom) {
                  print("Mama: \"Thank you, Voodoo Girl, but I already have enough.\"");
                  }
              else {
                  print("Mama: \"Good job, Voodoo Girl.  I just need a little bit.\"");
                  print("Mama: \"For your good work, I'm going to give you my old bone rattle.\"");
                  get("bone rattle");
                  score+=5;
                  set(mama_venom);
                  }
              }
         else {
             print("Mama: \"I think maybe you're trying to hard...  your brain seems fried.\"");
             }
        return();
        }

if ((said("give","yellow grave mold") ||
     said("give","yellow grave mold","Mama Hoodoo") ||
     said("give","Mama Hoodoo","yellow grave mold"))) {
     mold:
         if (has("yellow grave mold")) {
             if (mama_mold) {
                 print("Mama: \"That's sweet of you, but I have enough.\"");
                 }
             else {
                 print("Mama: \"Very good.  I'll take a pinch of that.\"");
                 score+=3;
                 set(mama_mold);
                 }
              }
         else {
             print("Mama: \"Are you sure you're all right?\"");
             }
         return();
         }

if ((said("give","coconut") ||
     said("give","coconut","Mama Hoodoo") ||
     said("give","Mama Hoodoo","coconut"))) {
     coco:
         if (has("coconut")) {
             if (mama_coco) {
                 print("Mama: \"You know, I love coconuts, but everything in moderation.\"");
                 }
             else {
                 print("Mama: \"Excellent.  I'll take one of those.\"");
                 score+=3;
                 set(mama_coco);
                 }
              }
         else {
             print("Mama: \"Are you all right, dear?\"");
             }
         return();
         }

if ((said("give","eye of newt") ||
     said("give","eye of newt","Mama Hoodoo") ||
     said("give","Mama Hoodoo","eye of newt"))) {
     eye:
         if (has("eye of newt")) {
             if (mama_newt) {
                 print("Mama: \"Careful now, you don't want to commit genocide.\"");
                 }
             else {
                 print("Mama: \"Why, it's fresh, too!\"");
                 print("Mama: \"They say that newts can see things people can't.\"");
                 print("VG: \"Who says?\"");
                 print("Mama: \"Uh...  you know...  THEY!!\"");
                 drop("eye of newt");
                 set(mama_newt);
                 score+=3;
                 }
              }
         else {
             print("Mama: \"Are you sure you're all right?\"");
             }
         return();
         }

if ((said("give","thorazine") ||
     said("give","thorazine","Mama Hoodoo") ||
     said("give","Mama Hoodoo","thorazine"))) {
     thora:
         if (!mama_thor) {
                 print("Mama: \"Wow, who'd you have to sedate to get this?\"");
                 set(mama_thor);
                 score+=3;
                 }

         else {
             print("Mama: \"You didn't eat any of that before you gave me the bottle, did you?\"");
             }
         return();
         }

if ((said("give","golden cauldron") ||
     said("give","golden cauldron","Mama Hoodoo") ||
     said("give","Mama Hoodoo","golden cauldron"))) {
     gold:
         if (has("golden cauldron")) {
             if (mama_caul) {
                 print("Mama: \"You seem to be suffering from some memory loss.  I'd recommend gingko biloba.\"");
                 }
             else {
                 print("Mama: \"Yes!  It is finally mine!!!\"");
                 print("Mama: \"I'll make you a Golden Dream Brew, but it will take some time.\"");
                 print("Mama: \"I suggest you prepare for the final conflict with the Dream King.\"");
                 drop("golden cauldron");
                 score+=5;
                 set(mama_caul);
                 load.view(0);
                 set.view(ego, 0);
                 new.room(3);
                 }
              }
         else {
             print("Mama: \"Zabadoo?\"");
             }
         return();
         }

if (said("give","rol")) {
    print("Mama:\"Thank you, Voodoo Girl, but I don't need any of that.\"");
    }

if (controller(left_click)){
    if(obj.in.box(ego, 121, 141, 142, 161)){ //Exit
       load.view(0);
       set.view(ego,0);
       new.room(3);
    }
    if(obj.in.box(ego, 3,121, 22,140)) { //sleep moss
       print("Mama:\"This is sleep moss.  Sleep moss can be used to make sleep potions.\"");
       }
    if(obj.in.box(ego, 24,121, 43,140)) { //poison berries
       print("Mama:\"These are poison berries.  They can be distilled into a potent poison.\"");
       }
    if(obj.in.box(ego, 45,121, 64,140)) { //poison
       print("Mama:\"This is the poison distilled from poison berries.  To make it, you'll need a cauldron and a stove.\"");
       }
    if(obj.in.box(ego, 66,121, 85,140)) { //sleep potion
       print("Mama:\"This is a sleep potion.  To make it, you'll need a cauldron and a stove.\"");
       }
    if(obj.in.box(ego, 85,121, 104,140)) {//blue mushroom
       print("Mama:\"These mushrooms are used for dream potions.  They can be found in the maze cave just beyond the river.\"");
       }
    if (obj.in.box(ego, 104,121, 125,140)) {//purple slime
       print("Mama:\"Purple slime is often used for making soda pop.\"");
       }
    if (obj.in.box(ego, 125, 121, 142, 140)) {
        goto(talk);
        }
    if(obj.in.box(ego, 3,142, 22,160)) {//blowfish venom
       if (has("blowfish venom")) {
          goto(venom);
          }
       else {
          print("Mama: \"Blowfish venom is a powerful poison.  It can be used in making potions, but you don't know any recipes that include it.\"");
          }
       }
    if(obj.in.box(ego, 24,142, 43,160)) {//yellow grave mold
       if (has("yellow grave mold")) {
           goto(mold);
           }
       else {
           print("Mama: \"The mysterious yellow grave mold is actually a powerful medicine.\"");
           }
       }
    if (obj.in.box(ego, 45, 142, 64, 160)) { //coconut
       if (has("coconut")) {
           goto(coco);
           }
       else {
           print("Mama: \"In 1863, Voodoo Island successfully defended itself from pirates using nothing more than hollow coconuts filled with different magic potions.\"");
           }
       }
    if (obj.in.box(ego, 66, 142, 85, 160)) { //eye of newt
       if (has("eye of newt")) {
          goto(eye);
          }
       else {
          print("Mama: \"Newts like to spend a lot of time sunning themselves on rocks or sand, but always near water.\"");
          }
       }
    if (obj.in.box(ego, 85, 142, 104, 160)) { //thorazine
       if (has("thorazine")) {
           goto(thora);
           }
       else {
           print("Mama: \"Thorazine is a dangerous medicine often given to the insane to make them docile.\"");
           }
       }
    if (obj.in.box(ego, 104, 142, 125, 160)) { // golden cauldron
        if ((has("golden cauldron") ||
             shattered)) {
             goto(gold);
             }
        else {
            print("Mama: \"The Golden Cauldron is said to give great power to the potions made within.  It is to be found in the Dream World.\"");
            }
        }



}

if (said("talk","hoodoo")) {
  talk:
  if(!shattered) {

    if (mama_mold &&
        mama_coco &&
        mama_newt &&
        mama_thor &&
        mama_caul) {
            print("Mama: \"Finally!  All the elements are complete!  I can now create my Golden Dream Brew!\"");
            print("Mama: \"Here it is!!!  Take it, go home, drink it, and you will be face-to-face with the Dream King!!!\"");
            print("VG: \"Why on Earth would I want to do that?!?!\"");
            print("Mama: \"Oh, yeah, I forgot to tell you...\"");
            print("VG: \"...\"");
            print("Mama: \"Yeah...  erm...  well, since you took the Golden Cauldron from the Dream World, you have to defeat the Dream King or he will give you nightmares for the rest of your days.\"");
            print("VG: \"I find it endlessly amusing all these details you seem to forget.\"");
            print("Mama: \"Really?  You think it's funny?\"");
            print("VG: \"No.\"");
            get("golden brew");

            return();
            }
    if (mama_chat==0) {
        print("Mama: \"Well, Voodoo Girl, do you have any of the supplies I sent you to get?\"");
        mama_chat+=1;
        return();
        }
    if (mama_chat==1) {
        print("Mama: \"You don't remember what you're supposed to get?\"");
          if (!mama_venom) {
               print("\"I need blowfish venom.\"");
               }
          if (!mama_mold) {
               print("\"I need yellow grave mold.\"");
               }
          if (!mama_coco) {
               print("\"I need a coconut.\"");
               }
          if (!mama_newt) {
               print("\"I need an eye of newt.\"");
               }
          if (!mama_thor) {
               print("\"I need some Thorazine.\"");
               }
          if (!mama_caul) {
              print("\"I also need the mythical Golden Cauldron.\"");
              }
        mama_chat+=1;
        return();
        }
    if (mama_chat==2) {
        print("VG: \"Uh, yeah, about that mystical realm of Dream.  How am I supposed to get there?\"");
        print("Mama: \"A dream brew, of course.\"");
        print("VG: \"Of course...  and how am I supposed to make that?\"");
        print("Mama: \"I think you use a blue mushroom and some other stuff.  I really don't have time for all this chit-chat.\"");
        mama_chat=0;
        return();
        }
      }
   else {
        if (golden_caul == 0) {
            print("Mama: \"Oh my, you say the Dream King SHATTERED the Golden Cauldron.  You must find all the pieces!\"");
            print("VG: \"Hold it!!  I've gone all over the island and the Dream World looking for your ingredients.  Give me a break!\"");
            print("Mama: \"All right, don't get your dander up...  I can help you find some of the pieces, I'm sure...  Let me get a fix...\"");
            print(".");
            print("..");
            print("...");
            print("Mama: \"Okay, the first fragment is stuck in a tree...  by a trail...  I can see no more.\"");
            print("VG: \"Thanks.  That was...  helpful.\"");
            golden_caul++;
            }

        if (golden_caul == 1) {
            print("Mama: \"Just remember...  the first fragment is stuck in a tree by a trail.\"");
            }

        if (golden_caul == 2) {
            print("Mama: \"All is dark, and cramped...\"");
            print("Mama: \"But the spirits say there is a quite refreshing breeze.\"");
            }

        if (golden_caul == 3) {
            print("Mama: \"The spirits...  they see...  nothing...\"");
            print("VG: \"Are they broken?\"");
            print("Mama: \"Uhhhh.....  no.\"");
            print("Mama: \"The spirits are definitely working, they just don't see anything.\"");
            print("VG: \"Are you sure the spirits aren't just teasing you or goofing off?\"");
            print("Mama: \"Uhhhh.....  no.\"");
            print("Mama: \"But whatever they're doing, they keep running into walls.\"");
            }

        if (golden_caul == 4) {
            print("Mama: \"I see...\"");
            print("VG: \"Yes?\"");
            print("Mama: \"I see...\"");
            print("VG: \"YES?!\"");
            print("Mama: \"I see nothing...\"");
            print("VG: \"AAAAAUUUUUGHGHGHGH!!\"");
            print("Mama: \"... except for an incredibly twisty maze.\"");
            }

        if (golden_caul==5) {
            print("Mama: \"Water...  Gray walls surrounding...  Darkness...\"");
            print("VG: \"So, are you just making this stuff up, or what?\"");
            }

        if (golden_caul == 6) {
            print("Mama: \"Water...  Gray walls surrounding...  Darkness...\"");
            print("VG: \"Are you getting senile?  You said that before.\"");
            print("Mama: \"Oh, but this is a different place...  it's...  err...  darker and wetter.\"");
            print("VG: \"I think your crystal ball should be taken into the shop for a tune up.\"");
            }

        if (golden_caul == 7) {
            print("Mama: \"I see...  Darkness and filth!!  It is as if the shard has been swallowed up by the refuse of a thousand eons!!\"");
            print("Mama: \"It sits in the place of the lost in a heap of cobwebs and dust bunnies!\"");
            print("Mama: \"I see no more.\"");
            }

        if (golden_caul == 8) {
            print("Mama: \"You found all of the fragments?!\"");
            print("Mama: \"Quick, put it together and give it to me!!\"");
            }
        }

  }



if (ego_dir==3 &&
    done_flag) {
    ego_dir=0;
    if (new_ego_x!=126) {
      temp_x=new_ego_x;
      temp_x+=20;
      position.v(ego,temp_x,new_ego_y);
      new.room(4);
      }
    }

if (ego_dir==1 &&
    done_flag) {
    ego_dir=0;
    if (new_ego_y!=132) {
      temp_y=new_ego_y;
      temp_y-=20;
      position.v(ego,new_ego_x,temp_y);
      new.room(4);
      }
    }

if (ego_dir==5 &&
    done_flag) {
    ego_dir=0;
    if (new_ego_y!=152) {
      temp_y=new_ego_y;
      temp_y+=20;
      position.v(ego,new_ego_x,temp_y);
      new.room(4);
      }
    }

if (ego_dir==7 &&
    done_flag) {
    ego_dir=0;
    if (new_ego_x!=6) {
      temp_x=new_ego_x;
      temp_x-=20;
      position.v(ego,temp_x,new_ego_y);
      new.room(4);
      }
    }

if ((ego_dir==8 ||
     ego_dir==2 ||
     ego_dir==4 ||
     ego_dir==6)) {
        ego_dir=0;
        }



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

if (said("exit")) {
    load.view(0);
    set.view(ego,0);
    new.room(3);
    }

return();