var firstTime = 0;
var mailboxCheck = 0;
var talkToJanitor1 = 0;
var talkToJanitor2 = 0;
var talkToJanitor3 = 0;
var talkToJanitor4 = 0;
var drugJanitor = 0;
var littleGirl = 0;
var flintPicture = 0;
var thugCard = 0;

sub officehallway () {
        thisRoom = 0;
        setSceneDimensions (800, 600);
	addOverlay ('officehallway/room.tga', 0, 0);
	setFloor ('officehallway/room.flo');
        setLightMap ('officehallway/lightmap.tga', HOTSPOT);
	setScale (-450, 1000);
	setZBuffer ('officehallway/room.zbu');
        addCharacter (doornote, 519, 67, costume (
             anim ('iface/act1-1.duc', 13), NULL, NULL));
        addScreenRegion (backtooffice, 672, 2, 782, 166, 690, 174, WEST);
        addScreenRegion (tooutside, 539, 229, 628, 397, 570, 426, NORTH);
        addScreenRegion (flintdoor, 456, 20, 581, 170, 529, 183, NORTH);
        addScreenRegion (greenPuddle, 191, 497, 325, 557, 166, 526, EAST);
    if (flintPicture == 0) { addCharacter (flintpicture, 288, 214, costume (anim ('iface/act1-1.duc', 19), NULL, NULL)); }
        addScreenRegion (snmpicture, 209, 0, 367, 138, 293, 205, NORTH);
        addScreenRegion (locker, 67, 220, 153, 387, 131, 481, NORTH);
       if (mailboxCheck == 0) {
        addCharacter (mailbox, 626, 103, costume (
           anim ('iface/act1-1.duc', 6), NULL, NULL));
       }
       if (mailboxCheck > 0) {
        addCharacter (mailbox, 626, 103, costume (
           anim ('iface/act1-1.duc', 10), NULL, NULL));
       }
        setCharacterExtra (mailbox, FIXEDSIZE);

      if (drugJanitor == 0) {
        addCharacter (mopbackdrop, 434, 510, costume (
            anim ('iface/act1-1.duc', 11), NULL, NULL));
        addCharacter (janitor, 262, 480, costume (
                  anim ('officehallway/janitor.duc', wait (2, 5), wait (3, 5), wait (4, 5), wait (3, 5), wait (2, 5), wait (5, 5)), NULL, anim ('officehallway/janitor.duc', wait (9, 4), wait (10, 4), wait (9, 4), wait (11, 4), wait (10, 4), wait (12, 4))));
      }
      if (drugJanitor == 1) {
        addCharacter (mopbackdrop, 434, 510, costume (
            anim ('iface/act1-1.duc', 12), NULL, NULL));
        addCharacter (janitor, 262, 480, costume (anim ('officehallway/janitor.duc', wait (20, 8), wait (21, 8), wait (22, 8), wait (21, 8)), NULL, NULL));
      }
      if (drugJanitor == 2) {
        addCharacter (mopbackdrop, 434, 510, costume (
            anim ('iface/act1-1.duc', 11), NULL, NULL));
        addCharacter (janitor, 262, 480, costume (anim ('officehallway/janitor.duc', wait (20, 8), wait (21, 8), wait (22, 8), wait (21, 8)), NULL, NULL));
      }
      if (gotJanitorKeys == 0) {
          if (drugJanitor > 0) {
            addCharacter (fallenKeys, 250, 520, costume (
             anim ('iface/act1-1.duc', 72),
             anim ('iface/act1-1.duc', 71), NULL));
          }
      }
        setCharacterExtra (mopbackdrop, FIXEDSIZE);
        setCharacterExtra (doornote, FIXEDSIZE);

     if (lastRoom == inoffice) { addCharacter (sam, 690, 174, makeEgoAnim ()); addCharacter (max, 690, 174, makeMaxAnim ());}
     if (lastRoom == outoffice) {addCharacter (sam, 562, 411, makeEgoAnim ()); addCharacter (max, 562, 410, makeMaxAnim ());}
     if (firstTime == 0) {
        turnCharacter (sam, WEST);
        moveCharacter (max, 299, 210);
        turnCharacter (max, EAST);
        Say (max, "Hurry Sam!");
        Say (sam, "Wait!  Something's not right here...");
        Say (max, "I know!");
        Say (max, "We have a chance to ride the ferret and you're taking your precious time.");
        Say (sam, "No, it seems rather quiet over at Flint Paper's.");
        Say (max, "Yeah, well...I guess we could take a quick look-see.");
        Say (max, "A REALLY quick one.");
        Say (sam, "Let's.");
        firstTime = 1;
                        }
}

objectType backtooffice ("to the office") {
 	event oneCursor = arrowEast;
	event onlyAction {
            gotoRoom (inoffice);
	}
}

objectType tooutside ("go outside") {
 	event oneCursor = arrowEast;
	event onlyAction { gotoRoom (outoffice); }
}

var openFlintDoor = 0;

objectType flintdoor ("Flint Paper's door") {
       event lookAt {
         if (firstTime == 1) {
        moveCharacter (sam, 529, 183);
	turnCharacter (sam, NORTH);
        moveCharacter (max, 456, 190);
        turnCharacter (max, NORTH);
        pause (10);
        Say (sam, "WOW!! Completely empty.");
        Say (sam, "Usually Friday is the day when they interrogate the illiterate eye witness...");
        Say (sam, "...and he gets the everloving teeth pistol whipped outta his mouth!");
        Say (max, "What a life they live!");
        Say (max, "There's a note on the door.");
        Say (sam, "Way to point out the obvious, Max.");
        pause (20);
        Say (max, "The note reads, 'We're gone, we won't back for a while.'");
        turnCharacter (sam, SOUTH);
        Say (sam, "I smell something fishy.");
        Say (max, "Probably that golf ball retriever from Gator Golf....");
        pause (5);
        Say (max, "...cheater...");
        turnCharacter (max, EAST);
        turnCharacter (sam, WEST);
        Say (sam, "All's fair in love and phonecalls.");
        Say (max, "Don't change old sayings in such a cliche fashion.");
        Say (sam, "Can do."); 
        firstTime = 2;
        }
          else {
           Say (sam, "It's the office of our good friend, Flint Paper.");
          }
       } 
       event use { #USE becomes #OPEN
         if (openFlintDoor == 0) {
           Say (sam, "There's something blocking the door from the inside.");
           Say (sam, "Probably a dead body.");
           openFlintDoor = 1;
           return;
         }
         else {
           Say (sam, "I can't get in there.");
         }
       }
       event verbRename {
           rename (lookAt, "Look into ");
           rename (use, "Open ");
       }
}

var lookSnmpicture = 0;

objectType snmpicture ("picture of Sam & Max") {
      event lookAt {
       if (lookSnmpicture == 0) {
        Say (sam, "Yup, that's us, in all our majestic beauty.");
        Say (sam, "Not counting Max, who looks like a constipated squirrel.");
        Say (max, "Shut up, Sam.");
        lookSnmpicture = 1;
        return;
       }
       else {
        Say (sam, "A picture of us. Bow.");
       }
      }
      event pickUp { #GET becomes CARRY
        Say (sam, "How on earth would I carry that thing around with me?");
	Say (max, "A forklift?");
	Say (sam, "Don't encourage the player, Max.");
      }
       event verbRename {
           rename (lookAt, "Admire ");
           rename (pickUp, "Carry ");
       }
}

var openLocker = 0;
var gotGrease = 0;

objectType locker ("janitor's locker") {
     event lookAt {
        Say (sam, "It's the janitor's impromptu supply closet.");
     }
     event use { #USE becomes OPEN
       if (openLocker == 0) {
        Say (sam, "It's locked. Mr. Johnson is really paranoid about people stealing toilet cleaner.");
        Say (max, "With good reason!");
        Say (max, "Didn't you ever wonder how he keeps the toilet so sparkling fresh and shiny?");
        Say (sam, "Wonder where the key is?");
        openLocker = 1;
        return;
       }
       else { 
         Say (sam, "It's locked.");
       }
     }
     event invJanitorKeys {
      if (gotGrease == 1) {
         Say (sam, "I already have some grease.");
         return;
      }
       forceCharacter (sam, 115, 414);
       #Add open door sprite.
       Say (max, "Now I won't even have to pick the lock with my teeth to gain access to free house-hold cleaning tools!");
       Say (sam, "Possibly, but it seems all the janitor uses to clean is grease.");
       Say (max, "Touche.");
       Say (sam, "No one will miss this one tub...");
       pushToStack (inventory, invGrease);
       gotGrease = 1;
       forceCharacter (sam, 153, 514);
       #Remove door sprite.
     }
       event verbRename {rename (use, "Bust open ");}
}

objectType mailbox ("mailbox") {
     event lookAt {
        Say (sam, "It's our trusty old mailbox, the one that relieved Mailman Jenkins of his hand back in '93.");
        Say (max, "Good times...good times...");
     }
     event use { #USE becomes CHECK
        if (mailboxCheck == 0) {
           moveCharacter (sam, 620, 182);
           turnCharacter (sam, NORTH);
           setCostume (mailbox, costume (
                anim ('iface/act1-1.duc', 6, 6, 7, 7, 8, 8, wait (9, 50)), NULL, NULL));
           pause (30);
           setCostume (mailbox, costume (
                anim ('iface/act1-1.duc', 9), NULL, NULL));
           Say (sam, "Let's see.... junk, junk...");
           Say (sam, "...more junk...ooh!");
           Say (sam, "Uber junk!");
           Say (max, "Sounds good enough for my tastes!  Let me see!");
           Say (sam, "Well, it seems that we've been selected as possible contestants for that hip new gameshow...");
           Say (sam, "Who Doesn't Want To Be a Billionare??!?");
           Say (max, "Wow! And to think we had only had a 98 out of 100 chance of getting sent this particular chunk of card!");
           Say (sam, "Yeah, and all we have to do is fill it out with our names, ages, and credit card information...");
           Say (sam, "...and we can send it back!");
           Say (max, "Cool!!  That sounds like something constructive to kill time with!");
           if (thugCard == 2) {
              Say (sam, "And as a double bonus, I seem to recollect that this is the location where the gangsters who kidnapped Flint are supposed to meet.");
              Say (sam, "Now we can go in there are arrest random bad guys without breaking any doors down!");
              Say (max, "Yeah, but we should still break a door down sometime before today is out.");
              Say (sam, "And I need to find a pen somewhere to fill this foolscap out.");
              Say (max, "Foolscap?");
           }
           setCostume (mailbox, costume (
                anim ('iface/act1-1.duc', 10), NULL, NULL));
           Say (sam, "I'll toss the rest of this mail.");
           turnCharacter (max, EAST);
           pushToStack (inventory, entryformnosign);
           pause (30);
           Say (max, "Hey Sam, you missed something.");
           Say (sam, "Huh?");
           Say (max, "There's still something in the mailbox.");
           mailboxCheck = 1;
           return;
        }
        if (mailboxCheck == 1) {
           moveCharacter (sam, 620, 182);
           turnCharacter (sam, NORTH);
           Say (sam, "Hey, there's an empty envelope in here.");
           Say (sam, "That's the third time this week.");
           Say (sam, "Look's like Mr. Jenkins the mailman is stealing my coupons for Big Billy Joe Bob's Meat-O-Rama.");
           Say (max, "And we could have used those!");
           Say (max, "Maybe it's time we put another bear trap in here...");
           Say (sam, "Oh well.  Free envelope.");
           Say (sam, "We can use it for our entry form for the gameshow as soon as we fill it out.");
           pushToStack (inventory, envelope);
           mailboxCheck = 2;
           return;
        }
        if (mailboxCheck > 1) {
           moveCharacter (sam, 620, 182);
           turnCharacter (sam, NORTH);
           Say (sam, pickOne ("It's empty all right.", "Empty as could be.", "This is the emptiest mailbox I've seen, and that's saying a lot.", "Empty again."));
        }
     }
    event pickUp {
       Say (sam, "Sure, why not?");
    }
    event verbRename {
       rename (use, "Check ");
    }
}


objectType mopbackdrop ("janitorial tools") {
   event lookAt {
       Say (sam, "It's Johnson's trusty bucket.");
     if (drugJanitor > 0) {
       Say (sam, "The mop's lower section seems to be covered in some kind of semi-transparent goo.");
     }
     else {
       Say (sam, "The mop is being used right now, though.");
     }
   }
   event pickUp { #PICK UP becomes SNATCH
      if (drugJanitor == 0) {
         Say (sam, "He's probably using the mop.");
      }
      else if (drugJanitor == 1) {
         moveCharacter (sam, 472, 444);
         turnCharacter (sam, SOUTH);
         Say (sam, "I don't think Mr. J will need this sticky mop.");
         drugJanitor = 2;
         setCostume (mopbackdrop, costume (anim ('iface/act1-1.duc', 11), NULL, NULL));
         pushToStack (inventory, invStickyMop);
         return;
      }
      else {
         Say (sam, "I don't want the bucket.");
      }
   }
    event verbRename {
       rename (pickUp, "Snatch ");
    }
}

var takeDoorNote = 0;

objectType doornote ("message") {
    event lookAt {
       if (firstTime == 1) {
        callEvent (lookAt, flintdoor);
        return;
       }
       else {
        moveCharacter (sam, 529, 185);
        turnCharacter (sam, NORTH);
        Say (sam, "'We're gone, we won't be back for a while.'");
        Say (sam, "It's not in Flint's handwriting.");
        Say (sam, "Overly suspicious if you ask me.");
       }
    }
   event pickUp {
        moveCharacter (sam, 529, 185);
        turnCharacter (sam, NORTH);
     if (takeDoorNote == 0) {
        Say (sam, "We should run a fingerprint scan on this thing.");
        Say (max, "Sam, either you've gone mad or I have.");
        Say (max, "The most high-tech piece of equipment we have around the office is that corkscrew shaped like a rabbit.");
        takeDoorNote = 1;
     }
     else {
        Say (sam, "I don't want the note.");
        Say (sam, "I'll leave it where it is for reference.");
     }
   }
       event verbRename {
           rename (lookAt, "Read ");
       }
}

var lookFlintPicture = 0;

objectType flintpicture ("picture") {
   event lookAt {
     if (lookFlintPicture == 0) {
      moveCharacter (sam, 352, 202);
      Say (sam, "It's a picture of me, Max, and Flint, having a good time at the beach.");
      Say (sam, "It looks like somebody's unconscious hand dropped it here on the floor.");
      lookFlintPicture = 1;
     }
     else {
      Say (sam, "It's a photo.");
     }
   }
   event pickUp {
      moveCharacter (sam, 352, 202);
      turnCharacter (sam, WEST);
      flintPicture = 1;
      removeCharacter (flintpicture);
      Say (sam, "Got it.");
      pushToStack (inventory, invflintpic);
   }
}

var lookAtPuddle = 0;
var gotJanitorKeys = 0;

objectType greenPuddle ("puddle") {
    event lookAt {
      if (lookAtPuddle == 0) {
        Say (sam, "It looks sticky and highly toxic.");
        Say (sam, "Like some kind of radioactive grade-school art class paste.");
        Say (max, "I tried it. Tastes like chicken.");
        lookAtPuddle = 1;
      }
      else { Say (sam, "Eww.."); }
    }
    event pickUp {
       if (drugJanitor > 0) {
           if (gotJanitorKeys == 0) {
             Say (sam, "No way! I'm not getting my hands covered in radioactive chicken glue!");
       }}
    }
    event invmax {
        Say (max, "Mmm...Chicken!");
        moveCharacter (max, 254, 569);
        turnCharacter (max, NORTH);
        removeCharacter (fallenKeys);
        pushToStack (inventory, invJanitorKeys);
        gotJanitorKeys = 1;
    }
    event verbRename {
       if (drugJanitor > 0) {
          if (gotJanitorKeys == 0) {
            rename (pickUp, "Get keys out of ");
          }
       }
    }
}

objectType fallenKeys ("") {}