var intro = 0;
var newspapervalue = 0;
var slippery = 0;
var phonevalue = 0;
var roachfarm = 0;
var usedGrabber = 0;

sub inoffice () {
	addOverlay ('inoffice/room.tga', 0, 0);
	setFloor ('inoffice/room.flo');
        setLightMap ('inoffice/lightmap.tga', HOTSPOT);
	setScale (-400, 1000);
	setZBuffer ('inoffice/room.zbu');
        addScreenRegion (outtostreet, 0, 196, 65, 387, 70, 410, WEST);
        addScreenRegion (tv, 354, 197, 470, 304, 320, 379, EAST);
        addScreenRegion (newspaper, 427, 313, 538, 388, 371, 435, EAST);
        addScreenRegion (drawer, 506, 286, 594, 369, 565, 339, SOUTH);
        addScreenRegion (dartboard, 504, 98, 559, 206, 478, 300, EAST);
        addScreenRegion (telescope, 513, 223, 599, 269, 502, 313, NORTH);
        addScreenRegion (closet, 716, 180, 798, 527, 711, 511, EAST);
        addScreenRegion (pictures, 131, 120, 445, 214, 319, 308, NORTH);
      if (roachfarm == 0) {
        addCharacter (roaches, 229, 260, costume (
             anim ('iface/act1-1.duc', 22), NULL, NULL));
      }
      else if (roachfarm == 1) {
        addCharacter (roaches, 229, 260, costume (
             anim ('iface/act1-1.duc', 21), NULL, NULL));
     }
        addCharacter (police, 39, 482, costume (
           anim ('iface/act1-1.duc', 14), NULL, anim ('iface/act1-1.duc', 14)));
        setCharacterExtra (police, FIXEDSIZE + NOZBUFFER + FRONT);
	addCharacter (sam, 40, 419, makeEgoAnim ());
        addCharacter (max, 40, 416, makeMaxAnim ());
        turnCharacter (max, EAST);
        moveCharacter (sam, 320, 384);
     if (intro == 0) {
        moveCharacter (sam, 371, 435);
        turnCharacter (sam, EAST);
        Say (sam, "Hey!  It's the morning paper!");
        Say (sam, "And it says, 'Freelance Police No More.'");
        Say (sam, "This is peculiarly false.");
        Say (max, "Must be affiliated with the National Confuser.");
        Say (sam, "Good point...let's see what else it says...");
        Say (sam, "'The dynamic duo disappeared several months ago during a mission at an old warehouse.");
        Say (sam, "'Their licenses as police officers have since expired, and no one knows their whereabouts.'");
        Say (sam, "Oops... I guess we were underground a bit longer than I thought.");
        Say (sam, "Gee, I wish the commissioner were hear to explain...");
        setCostume (police, costume (
           anim ('iface/act1-1.duc', 14, 14, 15, 15, 16, 16, 15, 15), NULL, NULL));
        think (max, "Here's where the phone chase animation will go...");
        setCostume (police, costume (
           anim ('iface/act1-1.duc', 17), NULL, NULL));
        jumpCharacter (sam, 161, 517);
        jumpCharacter (max, 426, 505);
        turnCharacter (max, WEST);
        turnCharacter (sam, WEST);
        Say (sam, "Yes.. Yes..");
        Say (sam, "And then? No..");
        Say (sam, "NO!");
        Say (sam, "Okay. Bye.");
        setCostume (police, costume (
           anim ('iface/act1-1.duc', 14), NULL, NULL));
        Say (max, "What did the commissioner want?");
        turnCharacter (sam, EAST);
        Say (sam, "It wasn't the commissioner.");
        Say (max, "Huh?");
        Say (sam, "It was a telemarketer selling festive sombrero-shaped cheese molds.");
        Say (sam, "He somehow talked me into buying a couple hundred boxes.");
        Say (sam, "I hate that.  I need to shoot someone.");
        Say (max, "Sam, you should let out your anger in a more constructive manner!");
        Say (max, "So let's chuck furniture out the window at passing pedestrians instead.");
        Say (sam, "Maybe later, Max.");
        Say (sam, "Right now, we've got some important spare time to kill...");
        Say (sam, "...what with no job and no case to get right on...");
        Say (max, "Well then, what are we supposed to get right on?");
        Say (sam, "Hmmm...");
        Say (sam, "...well, they have a new 25 cent mechanical ferret that you can ride...");
        Say (sam, "...right outside of Ma and Pa's Corner Grocery and Stick-em-Up Emporium!");
        Say (max, "Oboy!  Let's hurry before it loses that factory-fresh burning oil smell!");
        Say (sam, "You're an adorable little psychopath, Max.");
        intro = 1;
     }
}

objectType outtostreet ("to the next room") {
 	event oneCursor = arrowEast;
	event onlyAction {
            gotoRoom (officehallway);
	}
}

var lookTV = 0;
var watchTV = 0;

objectType tv ("TV") {
      event lookAt {
        if (lookTV == 0) {
          Say (sam, "It's my beat-up, slightly shell-shocked TV.");
          lookTV = 1;
          return;
        }
        else {
          Say (sam, "My TV.");
        }
      }
      event use {
        if (watchTV == 0) {
         Say (sam, "I love this TV, but I really don't think now is the time to watch the madness-filled carnage of the American television networks."); 
         Say (max, "But I like carnage!");
         watchTV = 1;
         return;
        }
        else {
         Say (sam, "There's nothing good on.");
        }
      }
      event verbRename {
        rename (use, "Watch ");
      }
}

var burnpaper = 0;

objectType newspaper ("newspapers") {
     event lookAt {
       if (newspapervalue == 1) {
         Say (sam, "It's a lie-filled, biased newspaper.");
         Say (sam, "The main headline reads 'Freelance Police No More.'");
         newspapervalue = 2;
       }
       else if (newspapervalue == 0) {
         Say (sam, "The headline reads 'Freelance Police No More.'");
         Say (sam, "Geez, that's not good, is it, little buddy?");
         Say (max, "But Sam, if we've lost our jobs, can't we still go around causing wanton chaos and pain?");
         Say (sam, "That is a good point, but first we should use our newfound anonymousness to fight crime and be cool!"); 
         Say (max, "Sam, you're so old-fashioned.");
         newspapervalue = 1;
       }
       else {
         Say (sam, "The next headline reads:");
         Say (sam, pickOne ("'Contestant Sues Japanese Gameshow for 44 Compound Fractures Caused by Suspended Rolling Logs.'", "'I Married a Sea Bear.'", "'Motel Closed for Dumping Toxic Sludge.'", "'Elvis Discovered Frozen in Carnival!'", "'Robo-Rodent Terrorizes Manhattan - 40,000 Dead, Countless Wounded'", "'Two Music Singers Drive through Supermarket on Holy Mission.'"));
         Say (sam, "Sure.");
       }
     }
 event use {
    if (burnpaper == 0) { 
       Say (sam, "It's a good idea, but we really can't afford to get in trouble with the city's heroic fire department again."); 
       Say (max, "Spoilsport...");
       burnpaper = 1;
       return;
    }
    else {
       Say (sam, "No way!");
    }
}
 event verbRename {
      rename (lookAt, "Read ");
      rename (use, "Burn ");
 }
}

var lookDrawer = 0;
var samsAdvice = 0;

objectType drawer ("desk drawer") {
   event lookAt {
     if (lookDrawer == 0) {
      Say (sam, "It's a drawer, genius!");
      Say (max, "Really? I always thought it was some kind of fold-out bed!");
      lookDrawer = 1;
      return;
     }
     else {
      Say (sam, "It's a desk drawer.");
     }
   }
   event use {
     if (slippery < 2) {
      Say (sam, "It won't budge."); 
      Say (sam, "I think it needs to be greased.");
     }
     else {
      Say (sam, "There's nothing else in the drawer.");
     }
   }
   event invmax {
      if (slippery == 0) {
         Say (sam, "While Max's ears could loosen the drawer, they just aren't greasy enough right now.");
      }
      else if (slippery == 1) {
         Say (sam, "Max, get your greased-up carcass over here.");
         moveCharacter (max, 557, 349);
         hideCharacter (max);
         addCharacter (draweranim, 510, 332, costume (
            anim ('iface/act1-1.duc', 1),
            anim ('iface/act1-1.duc', 1),
            NULL));
         setCharacterExtra (draweranim, FIXEDSIZE + FRONT);
         forceCharacter (draweranim, 555, 332);
         Say (sam, "Ah, the satisfying squelch of an overly greasy drawer...");
         Say (sam, "Oh, so this is the long lost office supplies cabinet!");
         Say (max, "Office supplies! Who needs them?");
         Say (sam, "Apparently not us, little buddy...");
         Say (sam, "...although, in games like this, there's always some use for the useless.");
         Say (max, "So painfully true...");
         forceCharacter (draweranim, 510, 332);
         removeCharacter (draweranim);
         pushToStack (inventory, scissors);
         pushToStack (inventory, pen);
         showCharacter (max);
         slippery = 2;
      }
      else {
         Say (sam, "Nothing in there.");
      }
   }
   event invGrease {
       Say (sam, "I don't think that will work.");
       Say (sam, "I need something to wipe the grease on the inside of the drawer...");
       Say (sam, "...like Max's disturbingly flexible head.");
       samsAdvice = 1;
   }
   event verbRename {
      rename (use, "Open ");
   }
}

objectType dartboard ("dartboard") {
     event lookAt {
        Say (sam, "It's our cleverly-designed hanging enemies list.");
        Say (max, "Our most recent addition is an evil businessman from our last case who went back on his deal.");
        Say (sam, "You can't trust anyone.");
     }
     event use {
        Say (sam, "We have a strange lack of sharp objects around the office since Max's little 'Homicidal Rampage' escapade.");
     }
   event verbRename {
      rename (use, "Throw darts at ");
   }

}

objectType telescope ("telescope") {
     event lookAt {
        Say (sam, "It's one of Max's little used birthday presents.");
        Say (sam, "I'll look inside it.");
        pause (40);
        Say (sam, pickOne ("Looks like no crime today....", "Oh, look at the size of that one!", "Why am I looking through this thing?", "AHHHHHHH!", "This is boring.", "I didn't think they could do that!", "Max, have you been drooling in the lens again?", "Let's shoot that shady character standing across the street."));
     }
     event use {
        callEvent (lookAt, telescope);
    }
     event invmax {
        Say (max, "Sam, this is the second-worst present you've ever given me.");
        Say (max, "Wait, no. This is the worst present.");
    }
   event verbRename {
      rename (lookAt, "Look inside ");
   }
}

var lookCloset = 0;

objectType closet ("closet") {
    event lookAt {
      if (lookCloset == 0) {
       Say (sam, "It's our closet, a dark place filled with the greatest inanimate horrors ever to grace the Earth.");
       Say (max, "And it has some animate horrors as well!");
       lookCloset = 1;
       return;
      }
      else {
       Say (sam, "It's a closet full of almost useless junk.");
      }
}
    event use { #USE becomes #SEARCH
       Say (sam, "Never! That place is scary!");
       Say (sam, "If I had twelve-foot long arms, then sure...");
       Say (max, "Now where the heck are we going to get twelve-foot long arms?");
       Say (sam, "That's what I like about you Max - you always approach these inane and ridiculous problems head on.");
    }
    event invmax {
       Say (max, "No way, Sam. I don't want to have to see your record collection ever again.");
       Say (max, "Ohhhh the horrors.....");
    }
    event golfgrabber {
      if (usedGrabber == 0) {
       say (sam, "Insert animation here.");
       say (max, "Cheapskate.");
       Say (sam, "Hey, there's a beer bottle in here.");
       Say (sam, "So that's where my booze went...");
       Say (max, "What a model for the innocent children audience you are, Sam.");
       Say (sam, "Shut up, Sam...I mean Max.");
       pushToStack (inventory, beerbottle);
       usedGrabber = 1;
      }
      else {
       Say (sam, "I'm sure there's nothing else important in there.");
       turnCharacter (sam, SOUTH);
       Say (sam, "Very sure.  Okay?");
      }
    }
   event verbRename {
      rename (use, "Search the ");
   }
}

objectType pictures ("pictures") {
    event lookAt {
      Say (sam, "Ahhh...the memories...");
    }
    event pickUp {
      Say (sam, "These are completely useless.  Stop trying.");
    }
}

var lookPhone = 0;

objectType police ("phone") {
  speechColour 100, 100, 255;
  speechGap 43;
    event lookAt {
      if (lookPhone == 0) {
        Say (sam, "Max and I have suffered so many cartoon injuries over this little box of noise...");
        lookPhone = 1;
        return;
      }
      else {
        Say (sam, "It's our patented telemarketer insulter.");
      }
    }
    event use { #USE becomes CALL
      if (phonevalue < 3) {
        Say (sam, "I wonder how our old friends at 911 are doing?");
        moveCharacter (sam, 161, 517);
        setCostume (police, costume (
           anim ('iface/act1-1.duc', 17), NULL, anim ('iface/act1-1.duc', 14)));
        Say (sam, "Hi guys!");
        Say (police, "Who is this?");
        Say (sam, "It's Sam, the debatable leader of the Freelance Police!");
        Say (police, pickOne ("Who?  Go away!", "Get lost, jerk.", "Stop bothering us!"));
        pause (30);
        Say (sam, "Those ungrateful slobs...");
        phonevalue += 1;
        setCostume (police, costume (
           anim ('iface/act1-1.duc', 14), NULL, NULL));
        return;
      }
      else {
        moveCharacter (sam, 161, 517);
        setCostume (police, costume (
           anim ('iface/act1-1.duc', 17), NULL, NULL));
      if (thugCard > 0) {
        Say (sam, "There's no dial tone.");
        Say (sam, "They've disconnected our phone, all right.");
        Say (sam, "Rats.  We need to find another phone if we're gonna try out this ID card's phone number.");
      }
      else {
        Say (sam, "I'm not hearing anything at all.");
        Say (sam, "We must have been disconnected.");
        Say (max, "The phone company is quite efficient in getting rid of phone lines of nonexistent people, Sam.");
        Say (sam, "Or maybe aliens have taken over the phone company simply to annoy us.");
      }
        setCostume (police, costume (
           anim ('iface/act1-1.duc', 14), NULL, NULL));
      }
    }
   event verbRename {
      rename (use, "Dial ");
   }
}

var lookRoachFarm = 0;

objectType roaches ("roach farm") {
    event lookAt {
      if (roachfarm == 0) {
       if (lookRoachFarm == 0) {
         Say (sam, "It's a disgusting old roach farm with a definite tuna sandwich smell about it.");
         Say (max, "It contains the sandwich we sacrificed on our last pixel-induced escapade!");
         Say (sam, "Oh yeah.");
         lookRoachFarm = 1;
         return;
       }
       else {
         Say (sam, "It's a roach farm with a lingering tuna smell.");
       }
      }
      else {
       Say (sam, "Roaches are always fun to watch.");
       Say (max, "And throw hammers at.");
      }
    }
    event pickUp {
      if (roachfarm == 0) {
       moveCharacter (sam, 232, 332);
       setCostume (roaches, costume (
            anim ('iface/act1-1.duc', 21), NULL, NULL));
       Say (sam, "Whew!  This thing reeks!");
       Say (sam, "Let's feed it to people we don't like.");
       Say (max, "Who needs nuclear weapons when you've got something twice as powerful in terms of instant death?");
       Say (sam, "The government, obviously.");
       pushToStack (inventory, sandwich);
       roachfarm = 1;
      }
      else {
        Say (sam, "I'm not gonna carry a bunch of roaches around.");
      }
    }
   event talkTo {
      Say (sam, "Hello little roach!  What's your name?");
      pause (30);
      Say (sam, "Oh dear.  I think I killed him.");
   }
   event invmax {
      Say (max, "I'm hungry!");
      moveCharacter (max, 229, 260);
       setCostume (roaches, costume (
            anim ('iface/act1-1.duc', 21), NULL, NULL));
       pushToStack (inventory, sandwich);
       roachfarm = 1;
      Say (sam, "Ew, Max! Give that to me!");
      Say (sam, "In your hands, I see it as a deadly weapon.");
   }
   event verbRename {
     if (roachfarm == 0) {
      rename (pickUp, "Get sandwich from ");
     }
   }
}

objectType draweranim ("") {}
objectType deskGolfGrabber ("") {}

#Things still missing:
#1:  The phone chase
#2:  Sam using Max on the desk drawer
#3:  The golf grabber animation

sub musicOffice () {
  cacheSound ('inoffice/lounging.mp3');
  playSound ('inoffice/loungingOpening.mp3');
  pause (211);
  loopSound ('inoffice/lounging.mp3');
}