Frame 1
function clearScreen() {
removeMovieClip(Player);
removeMovieClip(Interface);
removeMovieClip(Ladder);
removeMovieClip(Student);
var _local1 = 1;
while (_local1 <= 25) {
removeMovieClip("Door" + _local1);
removeMovieClip("Item" + _local1);
_local1++;
}
}
function levelUp() {
SFX.gotoAndPlay("LevelUp");
Interface.gotoAndPlay("LevelUp");
level++;
levelText = "LEVEL " + level;
score = score + (levelBonus * level);
numServed = 0;
numToServe++;
addTime(levelTimeBonus);
if (levelTimeBonus > 5) {
levelTimeBonus = levelTimeBonus - 5;
}
}
function openAllDoors() {
allDoorsOpen = true;
SFX.gotoAndPlay("OpenCupboard");
var _local2 = 1;
while (_local2 <= 25) {
theDoor = _root["Door" + _local2];
if (!theDoor.isOpen) {
theDoor.gotoAndStop("Open");
}
_local2++;
}
}
function closeAllDoors() {
SFX.gotoAndPlay("CloseCupboard");
var _local2 = 1;
while (_local2 <= 25) {
theDoor = _root["Door" + _local2];
if (theDoor.isOpen) {
theDoor.gotoAndStop("Close");
}
_local2++;
}
allDoorsOpen = false;
}
function studentServed() {
score = score + servePoints;
numServed++;
if (numServed == numToServe) {
levelUp();
}
}
function setupShelf() {
var _local4 = 1;
while (_local4 <= 25) {
shelfItems.push(_local4);
_local4++;
}
shuffle(shelfItems);
_local4 = 1;
while (_local4 <= 5) {
var _local3 = 1;
while (_local3 <= 5) {
var _local2 = whatNumber(_local3, _local4);
attachMovie("items", "Item" + _local2, _local2);
theItem = _root["Item" + _local2];
theItem._x = shelfColumns[_local3 - 1];
theItem._y = shelfRows[_local4 - 1];
theItem.myID = shelfItems[_local2 - 1];
theItem.gotoAndStop(theItem.myID);
attachMovie("door", "Door" + _local2, (1000 - (_local4 * 100)) + _local3);
theDoor = _root["Door" + _local2];
theDoor._x = shelfColumns[_local3 - 1];
theDoor._y = shelfRows[_local4 - 1];
if (halfOpen && (theItem.myID <= 12)) {
theDoor.gotoAndStop("Open");
theDoor.alwaysOpen = true;
}
_local3++;
}
_local4++;
}
}
function checkItem(theSlot) {
playerBusy = true;
Player._xscale = 100;
Player.checkingSlot = theSlot;
theDoor = _root["Door" + theSlot];
if (!theDoor.alwaysOpen) {
SFX.gotoAndPlay("OpenCupboard");
theDoor.gotoAndStop("Open");
}
theItem = _root["Item" + theSlot];
Player.itemInSlot = theItem.myID;
if (theItem.myID == requestedItem) {
Player.gotoAndPlay("RightItem");
} else {
Player.gotoAndPlay("WrongItem");
}
}
function giveItem() {
playerBusy = true;
Player.gotoAndPlay("GiveItem");
Student.gotoAndPlay("TakeItem");
}
function addTime(secsAdded) {
minutesLeft = minutesLeft + Math.floor(secsAdded / 60);
secondsLeft = secondsLeft + (secsAdded % 60);
minutesLeft = minutesLeft + Math.floor(secondsLeft / 60);
secondsLeft = secondsLeft % 60;
}
function subtractTime(secsTaken) {
if ((secondsLeft - secsTaken) < 0) {
if (minutesLeft > 0) {
secondsLeft = secondsLeft - secsTaken;
secondsLeft = 60 + secondsLeft;
minutesLeft--;
} else {
secondsLeft = 0;
minutesLeft = 0;
}
} else {
secondsLeft = secondsLeft - secsTaken;
}
}
function movePlayer(moveDir) {
if (moveDir == "Left") {
moveX = -playerMove;
moveY = 0;
} else if (moveDir == "Right") {
moveX = playerMove;
moveY = 0;
} else if (moveDir == "Up") {
moveX = 0;
moveY = -playerMove;
} else if (moveDir == "Down") {
moveX = 0;
moveY = playerMove;
} else if (moveDir == "Idle") {
moveX = 0;
moveY = 0;
Player.Anim.gotoAndStop(1);
}
destX = Player._x + moveX;
destY = Player._y + moveY;
if (moveX != 0) {
if ((Player._y <= bottomEdge) && (Player._y >= (bottomEdge - ladderCling))) {
Player._y = bottomEdge;
Player._x = destX;
Player.gotoAndStop("Walking");
Player.Anim.play();
if (moveX < 0) {
Player._xscale = 100;
} else {
Player._xscale = -100;
}
}
if (destX >= rightEdge) {
Player._x = rightEdge;
} else if (destX <= leftEdge) {
Player._x = leftEdge;
if (playerHasItem) {
giveItem();
}
}
}
if (moveY != 0) {
if ((destY >= topEdge) && (destY <= bottomEdge)) {
var _local1 = 0;
while (_local1 < shelfColumns.length) {
if ((Player._x >= (shelfColumns[_local1] - ladderCling)) && (Player._x <= (shelfColumns[_local1] + ladderCling))) {
Player._x = shelfColumns[_local1];
Player._y = destY;
Player._xscale = 100;
Player.gotoAndStop("Climbing");
Player.Anim.play();
}
_local1++;
}
}
if (destY >= bottomEdge) {
Player._y = bottomEdge;
} else if (destY <= topEdge) {
Player._y = topEdge;
}
}
Ladder._x = Player._x;
}
function decrementTimer() {
if (secondsLeft == 0) {
if (minutesLeft == 0) {
clearInterval(timerCode);
gotoAndPlay ("GameOver");
} else {
secondsLeft = 59;
minutesLeft--;
}
} else {
secondsLeft--;
}
}
function setTimerDigits(theMins, theSecs, theClip) {
minutesText = String(theMins);
secondsText = String(theSecs);
if (minutesText.length < 2) {
theClip.mins1 = "";
theClip.mins2 = minutesText;
} else {
theClip.mins1 = minutesText.substr(0, 1);
theClip.mins2 = minutesText.substr(1, 1);
}
if (secondsText.length < 2) {
theClip.secs1 = "0";
theClip.secs2 = secondsText;
} else {
theClip.secs1 = secondsText.substr(0, 1);
theClip.secs2 = secondsText.substr(1, 1);
}
if ((theMins <= freakOutMins) && (theSecs <= freakOutSecs)) {
SFX.gotoAndPlay("TimerFreakOutStart");
theClip.gotoAndStop("FreakOut");
} else {
SFX.gotoAndPlay("TimerFreakOutStop");
theClip.gotoAndStop("Normal");
}
}
function randInt(num0, num1) {
if (arguments.length == 1) {
return(Math.round(Math.random() * num0));
}
return(Math.round(Math.random() * Math.abs(num0 - num1)) + num0);
}
function whatNumber(theColumn, theRow) {
var _local1 = ((theRow - 1) * shelfWidth) + theColumn;
return(_local1);
}
function whatRow(theTile) {
var _local1 = Math.ceil(theTile / shelfWidth);
return(_local1);
}
function whatColumn(theTile) {
var _local1 = theTile % shelfWidth;
if (_local1 == 0) {
_local1 = shelfWidth;
}
return(_local1);
}
function shuffle(theArray) {
i = 0;
while (i < (theArray.length - 1)) {
var _local2 = Math.round(Math.random() * i);
var _local3 = theArray[i];
theArray[i] = theArray[_local2];
theArray[_local2] = _local3;
i++;
}
return(theArray);
}
stop();
fscommand ("allowscale", false);
funcHITBOX = function (arEvent, arAction) {
lString = ((("javascript: _hbLink ('/flash/" + arEvent.toLowerCase()) + "/") + arAction.toLowerCase()) + "','left','0,0,0,0')";
getURL (lString);
};
Frame 10
stop();
var cheatCodes = ["BENFETCH", "HALFOPEN", "HINTKEY"];
var defaultText = "";
var codeInput = defaultText;
var activeCode = null;
CodeEntry.codeField.restrict = "A-Z 0-9";
HintDialog._visible = false;
Frame 20
stop();
Frame 30
var level = 1;
var levelText = ("LEVEL " + level);
var score = 0;
var numServed = 0;
var numToServe = 5;
var servePoints = 25;
var levelBonus = 250;
var levelTimeBonus = 120;
var gameInPlay = false;
var numOfItems = 25;
var requestedItem = 0;
var playerStartX = 155;
var playerStartY = 390;
var playerMove = 10;
var playerCenterY = -40;
var playerBusy = false;
var playerHasItem = false;
var studentStartX = 0;
var studentStartY = 390;
var leftEdge = 155;
var rightEdge = 500;
var topEdge = 90;
var bottomEdge = 390;
var ladderCling = 15;
var shelfColumns = [220, 290, 360, 430, 500];
var shelfRows = [50, 120, 190, 260, 330];
var shelfCling = 30;
var shelfWidth = 5;
var shelfItems = [];
var minutesLeft = 5;
var secondsLeft = 0;
var freakOutMins = 0;
var freakOutSecs = 20;
var timerUnit = 1000;
var playerClip = "player";
var halfOpen = false;
var hintKey = false;
if (activeCode != null) {
if (activeCode == "BENFETCH") {
playerClip = "benjamin";
} else if (activeCode == "HALFOPEN") {
halfOpen = true;
} else if (activeCode == "HINTKEY") {
hintKey = true;
var hintKeyDelay = 0;
var hintCost = 10;
var hintKeyDelayMax = 50;
var allDoorsOpen = false;
}
}
attachMovie("interface", "Interface", 10000);
attachMovie(playerClip, "Player", 13000);
Player._x = playerStartX;
Player._y = playerStartY;
Player.Item._visible = false;
attachMovie("ladder", "Ladder", 12000);
Ladder._x = playerStartX;
Ladder._y = playerStartY - 10;
attachMovie("student", "Student", 11000);
Student._x = studentStartX;
Student._y = studentStartY;
gotoAndPlay ("Play");
Frame 40
setupShelf();
Student.gotoAndPlay("Enter");
timerCode = setInterval(decrementTimer, timerUnit);
gameInPlay = true;
stop();
Interface.onEnterFrame = function () {
if (gameInPlay) {
setTimerDigits(minutesLeft, secondsLeft, Interface.GameTimer);
if (hintKey) {
if (hintKeyDelay < hintKeyDelayMax) {
hintKeyDelay++;
} else if (allDoorsOpen) {
closeAllDoors();
}
}
}
};
Player.onEnterFrame = function () {
if (gameInPlay) {
if (!playerBusy) {
if (hintKey) {
if (Key.isDown(17)) {
if (hintKeyDelay == hintKeyDelayMax) {
openAllDoors();
hintKeyDelay = 0;
subtractTime(hintCost);
}
}
}
if (Key.isDown(37)) {
_root.movePlayer("Left");
} else if (Key.isDown(39)) {
_root.movePlayer("Right");
} else if (Key.isDown(40)) {
_root.movePlayer("Down");
} else if (Key.isDown(38)) {
_root.movePlayer("Up");
} else {
_root.movePlayer("Idle");
}
if (!playerHasItem) {
if (Key.isDown(32)) {
var _local2 = 1;
while (_local2 <= shelfItems.length) {
var _local3 = _root["Item" + _local2];
if (_local3.hitTest(Player._x, Player._y + playerCenterY, true)) {
checkItem(_local2);
break;
}
_local2++;
}
}
}
}
}
};
Frame 50
gameInPlay = false;
Player.Anim.stop();
clearInterval(timerCode);
stopAllSounds();
Interface.swapDepths(20000);
SFX.gotoAndPlay("GameOver");
Interface.gotoAndPlay("GameOver");
stop();
Symbol 21 MovieClip Frame 1
if (!_root.gameInPlay) {
stop();
}
Symbol 22 MovieClip Frame 1
stop();
Symbol 22 MovieClip Frame 10
stop();
Symbol 38 Button
on (press) {
stopAllSounds();
_root.SFX.gotoAndPlay("Click");
_root.gotoAndStop("Title");
_root.clearScreen();
}
Symbol 39 MovieClip [interface] Frame 1
stop();
Symbol 39 MovieClip [interface] Frame 60
gotoAndStop (1);
Symbol 39 MovieClip [interface] Frame 65
stop();
Symbol 72 MovieClip [items] Frame 1
stop();
Symbol 79 MovieClip [benjamin] Frame 1
stop();
Symbol 79 MovieClip [benjamin] Frame 10
stop();
Anim.gotoAndStop(1);
Item._visible = false;
_root.playerHasItem = false;
Symbol 79 MovieClip [benjamin] Frame 30
Anim.gotoAndStop(1);
Symbol 79 MovieClip [benjamin] Frame 38
var x = _root.randInt(1, 3);
_root.SFX.gotoAndPlay("WrongItem" + x);
BubbleItem.gotoAndStop(itemInSlot);
Symbol 79 MovieClip [benjamin] Frame 50
_root.playerBusy = false;
if (!_root["Door" + checkingSlot].alwaysOpen) {
_root.SFX.gotoAndPlay("CloseCupboard");
_root["Door" + checkingSlot].gotoAndStop("Close");
}
gotoAndStop ("Climbing");
Symbol 79 MovieClip [benjamin] Frame 55
Anim.gotoAndStop(1);
Symbol 79 MovieClip [benjamin] Frame 63
_root.SFX.gotoAndPlay("RightItem");
BubbleItem.gotoAndStop(itemInSlot);
Symbol 79 MovieClip [benjamin] Frame 75
_root.playerHasItem = true;
Item._visible = true;
Item.gotoAndStop(itemInSlot);
_root.playerBusy = false;
if (!_root["Door" + checkingSlot].alwaysOpen) {
_root.SFX.gotoAndPlay("CloseCupboard");
_root["Door" + checkingSlot].gotoAndStop("Close");
}
gotoAndStop ("Climbing");
Symbol 94 MovieClip [player] Frame 1
stop();
Symbol 94 MovieClip [player] Frame 10
stop();
Anim.gotoAndStop(1);
Item._visible = false;
_root.playerHasItem = false;
Symbol 94 MovieClip [player] Frame 30
Anim.gotoAndStop(1);
Symbol 94 MovieClip [player] Frame 38
var x = _root.randInt(1, 3);
_root.SFX.gotoAndPlay("WrongItem" + x);
BubbleItem.gotoAndStop(itemInSlot);
Symbol 94 MovieClip [player] Frame 50
_root.playerBusy = false;
if (!_root["Door" + checkingSlot].alwaysOpen) {
_root.SFX.gotoAndPlay("CloseCupboard");
_root["Door" + checkingSlot].gotoAndStop("Close");
}
gotoAndStop ("Climbing");
Symbol 94 MovieClip [player] Frame 55
Anim.gotoAndStop(1);
Symbol 94 MovieClip [player] Frame 63
_root.SFX.gotoAndPlay("RightItem");
BubbleItem.gotoAndStop(itemInSlot);
Symbol 94 MovieClip [player] Frame 75
_root.playerHasItem = true;
Item._visible = true;
Item.gotoAndStop(itemInSlot);
_root.playerBusy = false;
if (!_root["Door" + checkingSlot].alwaysOpen) {
_root.SFX.gotoAndPlay("CloseCupboard");
_root["Door" + checkingSlot].gotoAndStop("Close");
}
gotoAndStop ("Climbing");
Symbol 103 MovieClip Frame 1
stop();
Symbol 107 MovieClip Frame 1
stop();
Symbol 112 MovieClip [student] Frame 1
stop();
Symbol 112 MovieClip [student] Frame 5
Anim.Head.Eye.gotoAndStop(1);
Anim.Head.gotoAndStop(_root.randInt(1, 4));
Symbol 112 MovieClip [student] Frame 15
_root.SFX.gotoAndPlay("Request");
_root.requestedItem = _root.randInt(1, _root.numOfItems);
BubbleItem.gotoAndStop(_root.requestedItem);
stop();
Symbol 112 MovieClip [student] Frame 20
_root.SFX.gotoAndPlay("TossItem");
Item.gotoAndStop(_root.requestedItem);
Symbol 112 MovieClip [student] Frame 35
_root.studentServed();
_root.playerBusy = false;
Symbol 112 MovieClip [student] Frame 40
_root.SFX.gotoAndPlay("ServeStudent");
Anim.Head.Eye.gotoAndStop(2);
Symbol 112 MovieClip [student] Frame 65
gotoAndPlay ("Enter");
Symbol 115 MovieClip [door] Frame 5
isOpen = false;
stop();
Symbol 115 MovieClip [door] Frame 15
isOpen = true;
stop();
Symbol 119 Button
on (press, keyPress "<Space>") {
_root.SFX.gotoAndPlay("Click");
_root.funcHITBOX("instructions", "view_instructions");
gotoAndPlay ("HowTo");
}
Symbol 124 Button
on (press) {
_root.SFX.gotoAndPlay("Click");
gotoAndPlay ("EnterCode");
}
Symbol 148 MovieClip Frame 1
stop();
Symbol 148 MovieClip Frame 6
gotoAndStop (1);
Symbol 148 MovieClip Frame 16
gotoAndStop (1);
Symbol 148 MovieClip Frame 26
gotoAndStop (1);
Symbol 148 MovieClip Frame 36
gotoAndStop (1);
Symbol 148 MovieClip Frame 46
gotoAndStop (1);
Symbol 148 MovieClip Frame 56
gotoAndStop (1);
Symbol 148 MovieClip Frame 66
gotoAndStop (1);
Symbol 148 MovieClip Frame 76
gotoAndStop (1);
Symbol 148 MovieClip Frame 86
gotoAndStop (1);
Symbol 148 MovieClip Frame 96
gotoAndStop (1);
Symbol 148 MovieClip Frame 106
gotoAndStop (1);
Symbol 148 MovieClip Frame 116
gotoAndStop (1);
Symbol 148 MovieClip Frame 131
gotoAndStop (1);
Symbol 148 MovieClip Frame 146
gotoAndStop (1);
Symbol 150 Button
on (press) {
_root.SFX.gotoAndPlay("Click");
_root.funcHITBOX("play_activity", "play_from_code");
gotoAndPlay ("Start");
}
Symbol 154 Button
on (press) {
_root.SFX.gotoAndPlay("Click");
var match = false;
var i = 0;
while (i < _root.cheatCodes.length) {
var theCode = _root.cheatCodes[i];
if (_root.codeInput == theCode) {
match = true;
break;
}
i++;
}
if (match == true) {
_root.funcHITBOX("misc", "valid_code_" + _root.codeInput);
gotoAndPlay ("Valid");
} else {
gotoAndPlay ("Invalid");
}
}
Symbol 157 MovieClip Frame 1
play();
Symbol 157 MovieClip Frame 2
Selection.setFocus("codeField");
stop();
Symbol 157 MovieClip Frame 10
_root.activeCode = _root.codeInput;
if (_root.activeCode == "HINTKEY") {
_root.HintDialog._visible = true;
}
stop();
Symbol 157 MovieClip Frame 20
_root.activeCode = null;
Symbol 163 Button
on (press, keyPress "<Space>") {
_root.SFX.gotoAndPlay("Click");
_root.funcHITBOX("play_activity", "play_from_instructions");
gotoAndPlay ("Start");
}