var talkToFBI = 0;
var talkToFBI1 = 0;
var talkToFBI2 = 0;
var talkToFBI3 = 0;
var talkToFBI4 = 0;

sub inwarehouse () {
	addOverlay ('inwarehouse/room.tga', 0, 0);
        setLightMap ('inwarehouse/lightmap.tga', PERPIXEL);
	setFloor ('inwarehouse/room.flo');
	setScale (-200, 900);
	setZBuffer ('inwarehouse/room.zbu');

        addScreenRegion (inwindow, 638, 50, 740, 187, 683, 209, NORTH);
        addScreenRegion (pilestuff, 86, 228, 493, 393, 533, 447, WEST);
        addScreenRegion (pulley, 532, 13, 579, 53, 549, 412, NORTH);
        addCharacter (rubberducky, 308, 164, costume (
                anim ('inwarehouse/fbiguy.duc', 12), NULL, NULL));
        addCharacter (fbiguy, 336, 518, costume (
                anim ('inwarehouse/fbiguy.duc', 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 4, 4, 4, 3, 3, 3, 4, 4, 4),
                NULL,
                anim ('inwarehouse/fbiguy.duc', 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 5, 5, 5, 9, 9, 9, 7, 7, 7, 8, 8, 8, 6, 6, 6)));
	addCharacter (sam, 682, 206, makeEgoAnim ());
        addCharacter (max, 726, 207, makeMaxAnim ());
        setCharacterDrawMode (sam, DARK1);
        setCharacterDrawMode (max, DARK1);
        setCharacterDrawMode (fbiguy, DARK1);
        Say (fbiguy, "Freelance Police!  I'm so glad you're here!");
        Say (fbiguy, "The Rubber Pants Commandos need you to get their laser weapon!");
        Say (fbiguy, "It's for a matter of international security!");
        Say (fbiguy, "Please help!");
        Say (sam, "Well, we haven't got anything better to do.");
	Say (sam, "Let's go, Max.");
}

var lookFBIGuy = 0;

objectType fbiguy ("FBI guy") {
    speechColour 128, 128, 128;
    speechGap 16;
    event lookAt {
       moveCharacter (sam, 436, 518);
       turnCharacter (sam, WEST);
      if (lookFBIGuy == 0) {
       Say (sam, "It's a stereotypical black-suited secret agent.  This one claims he's from the Rubber Pants Commandos.");
       Say (max, "His face sickens me!");
       Say (sam, "Quiet Max.");
       lookFBIGuy = 1;
       return;
      }
      else {
       Say (sam, "It's a stereotypical black-suited secret agent.");
      }
    }
    event talkTo {
       moveCharacter (sam, 436, 518);
       turnCharacter (sam, WEST);
       moveCharacter (max, 540, 520);
       turnCharacter (max, WEST);
       Say (sam, "Hi!");
       Say (fbiguy, "Greetings, Freelance Police.");
       loop {
       if (talkToFBI == 0) {
        if (talkToFBI1 == 0) {
         addSpeechChoice ("How can we help?", 1);
        }
        if (talkToFBI2 == 0) {
         addSpeechChoice ("How are the Rubber Pants Commandos?", 2);
        }
        if (talkToFBI3 == 0) {
         addSpeechChoice ("What's with that rubber ducky?", 3);
        }
        if (talkToFBI4 == 0) {
         addSpeechChoice ("What's up with your head?", 4);
        }
         addSpeechChoice ("Well, bye.", 0);
       }
       if (talkToFBI == 1) {
         addSpeechChoice ("Why don't you get it?", 5);
         addSpeechChoice ("Sure.", 6);
       }
       if (talkToFBI == 2) {
         addSpeechChoice ("Tell me!", 7);
         addSpeechChoice ("Well, fine.", 8);
       }
       if (talkToFBI == 3) {
         addSpeechChoice ("Why you...", 9);
         addSpeechChoice ("You know what, toupee head?", 10);
       }

          var reply = getSpeechChoice (sam);
           if (reply == 0){
              Say (fbiguy, "Whatever.");
              return;
}
          else if (reply == 1) {
              Say (fbiguy, "You have to get us that weapon!  It's urgent!");
              talkToFBI = 1;
}
          else if (reply == 2) {
              Say (fbiguy, "Good, although Sergeant Blip has come down with mild constipation.");
              Say (sam, "Yuck.");
              Say (max, "I am disgusted beyond the bounds of possibility.");
              talkToFBI = 0;
              talkToFBI2 = 1;
}
         else if (reply == 3) {
             Say (fbiguy, "It is of vital importance to our nation's leaders, and it cannot fall into the wrong hands!");
             Say (max, "That rules us out.");
             Say (sam, "Shut it.");
              talkToFBI = 0;
              talkToFBI3 = 1;
}
         else if (reply == 4) {
             Say (max, "Yeah, it's so...hideously deformed!");
             Say (fbiguy, "Look who's talking.");
              talkToFBI = 3;
}
         else if (reply == 5) {
             Say (fbiguy, "This mission is on a need-to-know basis, and you don't need to know.");
             talkToFBI = 2;
}
         else if (reply == 6) {
             talkToFBI = 0;
              talkToFBI1 = 1;
             return;
}
         else if (reply == 7) {
             Say (max, "Can I slice off his legs and use them as oars as we sail down the pirahna-infested waters of the sewers?");
             Say (sam, "Tempting, but now is not the time.");
              talkToFBI1 = 1;
             talkToFBI = 0;
}
         else if (reply == 8) {
             talkToFBI = 0;
              talkToFBI1 = 1;
             return;
}
         else if (reply == 9) {
             Say (max, "I ought to wrap your legs around your face and play baseball with your oversized noggin, you deformed freak!");
             Say (sam, "Now now, Max, play nice.");
             talkToFBI = 0;
              talkToFBI4 = 1;
}
         else {
             Say (fbiguy, "Just get the stupid ducky, okay?");
             talkToFBI = 0;
              talkToFBI4 = 1;
}
       }
    }
}

var lookinWindow = 0;

objectType inwindow ("broken window") {
    event lookAt {
       if (lookinWindow == 0) {
        Say (sam, "Blatant evidence of our act of breaking and entering.");
        lookinWindow = 1;
        return;
       }
       else {
        Say (sam, "A broken window.");
       }
}
    event pickUp {
        Say (sam, "I might cut my poor paws!");
        Say (max, "Sissy.");
}
    event use {
       Say (sam, "We don't need to go out now that we're in!");
}
    event verbRename {
       rename (use, "Climb out the ");
    }
}

var lookpilestuff = 0;

objectType pilestuff ("piles of stuff") {
     event lookAt {
      if (lookpilestuff == 0) {
       Say (sam, "They're tons of storage boxes, filled with complete unusable thingamabobs.");
       lookpilestuff = 1;
       return;
      }
      else {
       Say (sam, "It's a load of useless junk.");
      }
}
      event pickUp {
       Say (sam, "I've seen enough completely unusable thingamabobs in my time...");
      }
    event verbRename {
       rename (pickUp, "Take ");
    }
}

objectType pulley ("pulley") {
    event lookAt {
       Say (sam, "It's a pulley, what do you think it is? The President?");
    }
    event use {
       Say (sam, "I can't touch that! It's greasy!");
    }
    event verbRename {
       rename (use, "Pull ");
    }
}

var lookrubberduck = 0; 

objectType rubberducky ("rubber duck") {
     event lookAt {
      if (lookrubberduck == 0) {
       Say (sam, "It's a cute little rubber ducky with an inviting red button on the side.");
       Say (sam, "For some ungodly reason, that man from the Rubber Pants Commandos wants it."); 
       lookrubberduck = 1;
      }
      else {
       Say (sam, "A potentially dangerous bathtime toy.");
      }
     }
     event pickUp {
       Say (sam, "I can't get it.");
     }
     event golfgrabber {
       moveCharacter (sam, 436, 518);
       turnCharacter (sam, WEST);
       moveCharacter (max, 540, 520);
       turnCharacter (max, WEST);
       say (fbiguy, "INSERT THE ANIMATION OF SAM USING THE GATOR GOLF GRABBER HERE");
       say (sam, "Yeah yeah yeah.");
       removeCharacter (rubberducky);
       pushToStack (inventory, invrubberducky);
       Say (max, "Look Sam!  There's a pulley in the middle of this ducky!");
       Say (max, "Hey, hasn't this been used elsewhere?");
       Say (max, "In a previous career experience, perhaps?");
       Say (sam, "Close, but no Burrito Brittle, Max.");
       Say (fbiguy, "Sam and Max, I thank you.");
       Say (fbiguy, "The Rubber Pants Commandos thank you.");
       Say (fbiguy, "The world thanks you.");
       say (sam, "*salutes, accidentally hitting the button*");
       setCharacterDrawMode (fbiguy, GLOW1);
       setCostume (fbiguy, costume (
                anim ('inwarehouse/fbiguy.duc', 10, 13), NULL, NULL));
       pause (20);
       setCharacterDrawMode (fbiguy, NORMAL);
       setCostume (fbiguy, costume (
                anim ('inwarehouse/fbiguy.duc', wait (14, 20), wait (15, 2), wait (16, 2), wait (17, 2), wait (18, 2), wait (19, 2), wait (20, 2), wait (21, 30)), NULL, NULL));
       pause (40);
       setCostume (fbiguy, costume (
                anim ('inwarehouse/fbiguy.duc', 21), NULL, NULL));
       Say (sam, "Max, I think we've found what we're looking for.");
       Say (max, "Sam, let me play with that rubber ducky.");
       Say (sam, "Over my deliciously dead body, Max.");
       pause (30);
       Say (sam, "Y'know, Max, I'm beginning to think that this Matrix-looking type wasn't a real person at all!");
       Say (max, "Sam, you're right!  Human flesh doesn't incinerate that quickly!");
       Say (max, "Remember that time with the tax collector...");
       pause (30);
       Say (max, "Wait a second...have we been had?");
       blankScreen ();
       playSound ('inwarehouse/metalSlam.wav');
       stopSound ('outwarehouse/music.mp3');       
       hideCharacter (sam);
       hideCharacter (max);
       hideCharacter (fbiguy);
       hideCharacter (inventoryIcon);
       pause (30);
       Say (sam, "Max, I think we've been had.");
       pause (30);
       Say (sam, "Gee, if we're trapped in here, I guess we're gonna run out of air soon.");
       Say (sam, "We'd better tunnel out of here with your cute little steel-reinforced bunny ears.");
       pause (40);
       say (narrator, "It took Sam & Max several months to tunnel out of the warehouse that someone attempted to trap and suffocate them in...");
       say (narrator, "While they were gone, the whole world forgot about Sam & Max, all except for one person - their insane, private eye neighbor...");
       spawnSub (musicOffice);
       showCharacter (inventoryIcon);
       gotoRoom (inoffice);
     }
}

objectType narrator ("") {
  speechColor 7, 128, 255;
}

#Things still missing:
#1:  Sam saluting and accidentally hitting the FBI guy
#2:  Opening credits / Flint Paper's Lament