// THIS ACTIONSCRIPT WAS WRITTEN BY MATT FARGO FOR FREE FOR BOB CLARK // MATT FARGO GIVES ALL INTELLECTUAL RIGHTS FOR THESE SCRIPTS TO BOB CLARK // BECAUSE BOB CLARK'S GAME IS GOING TO BE EXTREMELY ENGAGING. include("KeyDetection.as"); var cnt = 0; var lives = 18; var lifeArr = new Array(); var currentRate = 0; var npclives = 18; var npclifeArr = new Array(); var girlsSaved = 0; var girlsKilled = 0; var narXML = new XML; var nodes; var timeType = 0; var talkAmmo = 0; var numKeysPressed = 0; var pressedStr = ""; var questionType = 0; var speakerType = 3; /*textBox.vScrollPolicy = "on"; textBox.setStyle("color", "white"); textBox.setStyle("backgroundColor", "black"); textBox.setStyle("fontSize", "14"); textBox.setStyle("autoScroll"); */ loadNewXML("OffWithHerHeadIntro.xml"); //var questionType=Number(nodes[cnt].firstChild.attributes.qt); function resetLives() { lives = 18; for (var i = 1; i < 19; i++) { setProperty("light"+i, _visible, true); } } function resetNPCLives() { npclives = 18; for (var i = 1; i < 19; i++) { setProperty("npclight"+i, _visible, true); } } function resetGirlLives() { girlsSaved = 0; girlsKilled = 0; } function stopTime() { //function subtractLife():Void{ trace("Time"); clearInterval(timerKill); //}; } function doTime() { //if (Number(speakerType) == 2 ) { //if (lives >= 1) { if (Number(currentRate) <= 0){ timerKill = setInterval(subtractLife, 1000); trace("Rate=0"); } else if (Number(currentRate) == 1){ timerKill = setInterval(subtractLife, 900); trace("Rate=1"); } else if (Number(currentRate) == 2){ timerKill = setInterval(subtractLife, 700); trace("Rate=2"); } else if (Number(currentRate) == 3){ timerKill = setInterval(subtractLife, 600); trace("Rate=3"); } else if (Number(currentRate) == 4){ timerKill = setInterval(subtractLife, 500); trace("Rate=4"); } else if (Number(currentRate) == 5){ timerKill = setInterval(subtractLife, 400); trace("Rate=5"); } else if (Number(currentRate) == 6){ timerKill = setInterval(subtractLife, 300); trace("Rate=6"); } else if (Number(currentRate) == 7){ timerKill = setInterval(subtractLife, 200); trace("Rate=7"); } else if (Number(currentRate) == 8){ timerKill = setInterval(subtractLife, 100); trace("Rate=8"); } //} } // } else { //trace("No Time"); // } function subtractLife() { pressedStr=""; if (npclives > 0) { if (lives > 1) { trace("Subtracting Life"); setProperty("light"+lives, _visible, false); lives--; } else if (lives == 1){ trace("Subtracting Life"); setProperty("light"+lives, _visible, false); lives--; if ((Number(girlsSaved) < Number(girlsKilled))){ loadNewXML("OffWithHerHeadBadEnd.xml"); } if ((Number(girlsSaved) > Number(girlsKilled))){ loadNewXML("OffWithHerHeadGoodEnd.xml"); } else if ((Number(girlsSaved) <= Number(girlsKilled))){ loadNewXML("OffWithHerHeadBadEnd.xml"); } } } else if (lives == 0){ null } } function addLife() { if (lives < 18) { lives++; trace("Adding My Life"); setProperty("light"+lives, _visible, true); }; } function resetCurrentRate(){ currentRate = 0; } function increaseRate(){ if (Number(currentRate) < 8){ currentRate += 1; } else { null } } function decreaseRate(){ if (Number(currentRate) > 0){ currentRate -= 1; } else { null } } function saveGirl(){ resetCurrentRate(); girlsSaved += 1; trace("Girl is Saved"); if (Number(girlsSaved) == 10){ loadNewXML("OffWithHerHeadWinEnd.xml"); } } function killGirl(){ resetCurrentRate(); girlsKilled += 1; trace("Girl is Dead"); } function killGame(){ if (Number(girlsSaved) == 5){ resetGirlLives(); loadNewXML("OffWithHerHeadWinEnd.xml"); } else if (Number(girlsKilled) == 5){ resetGirlLives(); loadNewXML("OffWithHerHeadLoseEnd.xml"); } else { null } } function subtractNPCLife() { pressedStr=""; if (lives > 0) { if (npclives > 1) { trace("Subtracting NPC Life"); setProperty("npclight"+npclives, _visible, false); npclives--; } else { trace("Subtracting NPC Life"); setProperty("npclight"+npclives, _visible, false); npclives--; switchScene(1) saveGirl(); }; } } function addNPCLife() { if (npclives < 18) { npclives++; trace("Adding NPC Life"); setProperty("npclight"+npclives, _visible, true); }; } function loadNewXML(XMLName) { cnt = 0; if (Number(lives == 0)){ resetGirlLives(); } resetLives(); lifeArr = []; resetNPCLives(); npclifeArr = []; nodes = ""; hypoFlag = 0; talkAmmo = 0; numKeysPressed = 0; pressedStr = ""; questionType = 0; narXML.ignoreWhite = true; narXML.onLoad = narLoaded; narXML.load(XMLName); // change me } function narLoaded() { nodes = this.firstChild.childNodes; trace( "nodes: " + nodes[0].firstChild.firstChild); var tmp = String(nodes[cnt].firstChild.firstChild); doTyping(tmp.split("'").join("'")); } ///////// Button Presses ////////// var typeStr = new String; var typeCount = 0; var typeInt; function typeInterval(){ var tempStr = textBox.text; tempStr+=_root.typeStr.charAt(typeCount); textBox.text=tempStr; typeCount++; if (textBox.text.length < typeStr.length){ stopTime(); CtrlBtn.play(4); if(Number(speakerType) == 2){ ColorBox.gotoAndStop(2); } else if(Number(speakerType) == 1){ ColorBox.gotoAndStop(1); } else if (Number(speakerType) == 3){ ColorBox.gotoAndStop(3); } } if (typeCount >=_root.typeStr.length){ typeCount=0; clearInterval(typeInt); resetButtons(); } } function doTyping (newStr:String){ _root.textBox.text = ""; _root.typeStr = newStr; typeCount=0; clearInterval(typeInt); typeInt = setInterval (typeInterval,50); } // doTyping(""); stop(); ///////// SWITCH SCENES ///////////// function switchScene(sceneNum) { if(Number(questionType) == 0){ stopTime(); } if (Number(deadGirl) == 1){ killGirl(); } resetButtons(); if (Number(sceneNum) > -1) { cnt = Number(sceneNum); trace("Scene " + sceneNum); trace("QuestionType " + questionType); if(nodes[cnt].lastChild.firstChild != null) { trace("img: " + nodes[cnt].lastChild.firstChild); //imgLoader.contentPath = String(nodes[cnt].lastChild.firstChild); imgLoader._visible = true; imgLoader.load(String(nodes[cnt].lastChild.firstChild)); } else { imgLoader._visible = false; } var tmp = String(nodes[cnt].firstChild.firstChild); trace("TMP:" + tmp); doTyping(tmp.split("'").join("'")); if (nodes[cnt].firstChild.attributes.death) { deadGirl=Number(nodes[cnt].firstChild.attributes.death); } if (nodes[cnt].firstChild.attributes.speaker) { speakerType=Number(nodes[cnt].firstChild.attributes.speaker); } if (nodes[cnt].firstChild.attributes.tt) { timeType=Number(nodes[cnt].firstChild.attributes.tt); } if (nodes[cnt].firstChild.attributes.qt) { questionType=Number(nodes[cnt].firstChild.attributes.qt); } /*else { CtrlBtn.gotoAndStop(2); }*/ trace(">>>>QuestionType " + questionType); //var points=Number(nodes[cnt].firstChild.attributes.pt); trace(">>>>" + nodes[cnt].firstChild.attributes.newlev); if (nodes[cnt].firstChild.attributes.newlev != null) { trace("I GOT" + nodes[cnt].firstChild.attributes.newlev); loadNewXML(nodes[cnt].firstChild.attributes.newlev); } } } //onscreen buttons leftBtn.onPress = function() { stopTime(); if (textBox.text.length == typeStr.length){ if (Number(questionType) > 0){ increaseRate(); if (Number(girlsSaved) == 0){ subtractNPCLife(); } else if (Number(girlsSaved) == 1){ subtractNPCLife(); subtractNPCLife(); } else if (Number(girlsSaved) == 2){ subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); } else if (Number(girlsSaved) == 3){ subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); } else if (Number(girlsSaved) == 4){ subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); } _root.textBox2.text = "Question"; switchScene(nodes[cnt].firstChild.attributes.Q); //LeftBtn.gotoAndStop(4); RightBtn.gotoAndStop(1); UpBtn.gotoAndStop(1); DownBtn.gotoAndStop(1); ColorBox.gotoAndStop(1); if (textBox.text.length == typeStr.length) { resetButtons(); } else{ null } } } } rightBtn.onPress = function() { stopTime(); if (textBox.text.length == typeStr.length){ if (Number(questionType) > 0){ if (Number(questionType)== 1){ subtractLife(); } if (Number(questionType)== 2){ subtractLife(); } if (Number(questionType)== 3){ //decreaseRate(); resetLives(); } if (Number(questionType)== 4){ subtractLife(); } if (Number(questionType)== 5){ resetLives(); resetNPCLives(); } if (Number(questionType)== 6){ subtractLife(); } _root.textBox2.text = "Answer"; switchScene(nodes[cnt].firstChild.attributes.A); RightBtn.gotoAndStop(4); LeftBtn.gotoAndStop(1); UpBtn.gotoAndStop(1); DownBtn.gotoAndStop(1); ColorBox.gotoAndStop(1); if (textBox.text.length == typeStr.length) { resetButtons(); } else{ null } } } } upBtn.onPress = function() { stopTime(); if (textBox.text.length == typeStr.length){ if (Number(questionType) > 0){ if (Number(questionType)== 1){ resetLives(); } if (Number(questionType)== 2){ decreaseRate(); subtractLife(); } if (Number(questionType)== 3){ subtractLife(); } if (Number(questionType)== 4){ subtractLife(); addNPCLife(); } if (Number(questionType)== 5){ subtractLife(); } if (Number(questionType)== 6){ addLife(); } _root.textBox2.text = "Yes"; switchScene(nodes[cnt].firstChild.attributes.Y); UpBtn.gotoAndStop(4); RightBtn.gotoAndStop(1); LeftBtn.gotoAndStop(1); DownBtn.gotoAndStop(1); ColorBox.gotoAndStop(1); if (textBox.text.length == typeStr.length) { resetButtons(); } else{ null } } } } downBtn.onPress = function() { stopTime(); if (textBox.text.length == typeStr.length){ if (Number(questionType) > 0){ if (Number(questionType)== 1){ decreaseRate(); subtractLife(); } if (Number(questionType)== 2){ resetLives(); } if (Number(questionType)== 3){ subtractLife(); } if (Number(questionType)== 4){ addLife(); } if (Number(questionType)== 5){ subtractLife(); } if (Number(questionType)== 6){ subtractLife(); addNPCLife(); } _root.textBox2.text = "No"; switchScene(nodes[cnt].firstChild.attributes.N); DownBtn.gotoAndStop(4); RightBtn.gotoAndStop(1); UpBtn.gotoAndStop(1); LeftBtn.gotoAndStop(1); ColorBox.gotoAndStop(1); if (textBox.text.length == typeStr.length) { resetButtons(); } else{ null } } } } ctrlBtn.onRelease = function() { resetButtons(); if(Number(speakerType) == 2){ ColorBox.gotoAndStop(2); } else if(Number(speakerType) == 1){ ColorBox.gotoAndStop(1); } else if(Number(speakerType) == 3){ ColorBox.gotoAndStop(3); } //if(Number(questionType)>0){ if (textBox.text.length < typeStr.length) { clearInterval(typeInt); typeCount=0; textBox.text = typeStr; break; //} } else { //CtrlBtn.gotoAndStop(2); switchScene(nodes[cnt].firstChild.attributes.controlkey); break; } } // r39 l37 u38 d40 space32 var keyDet = new KeyDetection(); keyDet.addCombination("left", Key.LEFT); keyDet.addCombination("right", Key.RIGHT); keyDet.addCombination("up", Key.UP); keyDet.addCombination("down", Key.DOWN); keyDet.addCombination("control", Key.CONTROL); keyDet.addCombination("control", Key.ENTER); // ADD ANY MORE KEY COMBOS YOU WANT IN THE ABOVE MANNER! myObj = new Object(); myObj.onKeyCombination = function(name:String) { if (isReleased == false) { firstKey = 0; clearInterval(singleKeyInterval); isReleased = true; keyInterval = setInterval(keyWait, 100); trace("NAME: " + name); switch (name) { case "left" : stopTime(); if (textBox.text.length == typeStr.length){ if (Number(questionType) > 0){ increaseRate(); if (Number(girlsSaved) == 0){ subtractNPCLife(); } else if (Number(girlsSaved) == 1){ subtractNPCLife(); subtractNPCLife(); } else if (Number(girlsSaved) == 2){ subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); } else if (Number(girlsSaved) == 3){ subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); } else if (Number(girlsSaved) == 4){ subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); subtractNPCLife(); } _root.textBox2.text = "Question"; switchScene(nodes[cnt].firstChild.attributes.Q); LeftBtn.gotoAndStop(4); RightBtn.gotoAndStop(1); UpBtn.gotoAndStop(1); DownBtn.gotoAndStop(1); ColorBox.gotoAndStop(1); if (textBox.text.length == typeStr.length) { resetButtons(); } else{ null } } } break; case "right" : stopTime(); if (textBox.text.length == typeStr.length){ if (Number(questionType) > 0){ if (Number(questionType)== 1){ subtractLife() } if (Number(questionType)== 2){ subtractLife(); } if (Number(questionType)== 3){ //decreaseRate(); resetLives(); } if (Number(questionType)== 4){ subtractLife(); } if (Number(questionType)== 5){ resetLives(); resetNPCLives(); } if (Number(questionType)== 6){ subtractLife(); } _root.textBox2.text = "Answer"; switchScene(nodes[cnt].firstChild.attributes.A); RightBtn.gotoAndStop(4); LeftBtn.gotoAndStop(1); UpBtn.gotoAndStop(1); DownBtn.gotoAndStop(1); ColorBox.gotoAndStop(1); if (textBox.text.length == typeStr.length) { resetButtons(); } else{ null } } } break; case "up" : stopTime(); if (textBox.text.length == typeStr.length){ if (Number(questionType) > 0){ if (Number(questionType)== 1){ resetLives(); } if (Number(questionType)== 2){ decreaseRate(); subtractLife(); } if (Number(questionType)== 3){ subtractLife(); } if (Number(questionType)== 4){ subtractLife(); addNPCLife(); } if (Number(questionType)== 5){ subtractLife(); } if (Number(questionType)== 6){ addLife(); } _root.textBox2.text = "Yes"; switchScene(nodes[cnt].firstChild.attributes.Y); UpBtn.gotoAndStop(4); RightBtn.gotoAndStop(1); LeftBtn.gotoAndStop(1); DownBtn.gotoAndStop(1); ColorBox.gotoAndStop(1); if (textBox.text.length == typeStr.length) { resetButtons(); } else{ null } } } break; case "down" : stopTime(); if (textBox.text.length == typeStr.length){ if (Number(questionType) > 0){ if (Number(questionType)== 1){ decreaseRate(); subtractLife(); } if (Number(questionType)== 2){ resetLives(); } if (Number(questionType)== 3){ subtractLife(); } if (Number(questionType)== 4){ addLife(); } if (Number(questionType)== 5){ subtractLife(); } if (Number(questionType)== 6){ subtractLife(); addNPCLife(); } _root.textBox2.text = "No"; switchScene(nodes[cnt].firstChild.attributes.N); DownBtn.gotoAndStop(4); RightBtn.gotoAndStop(1); UpBtn.gotoAndStop(1); LeftBtn.gotoAndStop(1); ColorBox.gotoAndStop(1); if (textBox.text.length == typeStr.length) { resetButtons(); } else{ null } } } break; case "control" : _root.textBox2.text = ""; killGame(); if (textBox.text.length < typeStr.length) { resetButtons(); } else if (textBox.text.length == typeStr.length){ null } if(Number(speakerType) == 2){ ColorBox.gotoAndStop(2); } else if(Number(speakerType) == 1){ ColorBox.gotoAndStop(1); } else if(Number(speakerType) == 3){ ColorBox.gotoAndStop(3); } //if(Number(questionType)>0){ if (textBox.text.length < typeStr.length) { clearInterval(typeInt); typeCount=0; textBox.text = typeStr; //} } else { //CtrlBtn.gotoAndStop(2); switchScene(nodes[cnt].firstChild.attributes.controlkey); } } } }; function resetButtons() { _root.textBox2.text = ""; stopTime(); RightBtn.gotoAndStop(1); LeftBtn.gotoAndStop(1); UpBtn.gotoAndStop(1); DownBtn.gotoAndStop(1); //ColorBox.gotoAndStop(2); CtrlBtn.gotoAndStop(4); if (Number(questionType) > 0){ doTime(); LeftBtn.gotoAndStop(4); RightBtn.gotoAndStop(4); UpBtn.gotoAndStop(4); DownBtn.gotoAndStop(4); CtrlBtn.gotoAndStop(1); //ColorBox.gotoAndStop(2); } else if (Number(questionType) == 0){ stopTime(); LeftBtn.gotoAndStop(1); RightBtn.gotoAndStop(1); UpBtn.gotoAndStop(1); DownBtn.gotoAndStop(1); CtrlBtn.gotoAndStop(4); if (Number(speakerType) == 2){ ColorBox.gotoAndStop(2); } else if (Number(speakerType)==1){ ColorBox.gotoAndStop(1); } else if(Number(speakerType) == 3){ ColorBox.gotoAndStop(3); } } else if (textBox.text.length > typeStr.length){ if(Number(speakerType) == 2){ ColorBox.gotoAndStop(2); } else if(Number(speakerType) == 1){ ColorBox.gotoAndStop(1); } else if(Number(speakerType) == 3){ ColorBox.gotoAndStop(3); } } else { if(Number(speakerType) == 2){ ColorBox.gotoAndStop(2); } else if(Number(speakerType) == 1){ ColorBox.gotoAndStop(1); } else if(Number(speakerType) == 3){ ColorBox.gotoAndStop(3); } CtrlBtn.gotoAndStop(1); } } keyDet.addListener(myObj); var keyInterval; var isReleased = false; function keyWait() { isReleased = false; clearInterval(keyInterval); checkingFirst = false; } stop();