Frame 1
function onEnterFrame() {
if (this._currentframe == 1) {
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded / bytes_total;
loader._xscale = getPercent * 100;
moneyTree.gotoAndStop(Math.floor(getPercent * 6) + 1);
if (bytes_loaded == bytes_total) {
if (((domain == "armorgames.com") || (domain == "www.armorgames.com")) || (domain == "https://www.armorgames.com")) {
gotoAndStop (2);
} else {
loading._alpha = 0;
pBtn._x = Stage.width / 2;
pBtn.onRollOver = function () {
pBtn._alpha = 50;
};
pBtn.onRollOut = function () {
pBtn._alpha = 100;
};
pBtn.onRelease = function () {
gotoAndStop (2);
};
}
}
}
}
function goToThisURL() {
getURL ("http://armorgames.com/", "_blank");
}
function createContextMenu(menu) {
_root.menu = menu;
}
function __com_mochibot__(swfid, mc, lv, trk) {
var x;
var g;
var s;
var fv;
var sb;
var u;
var res;
var mb;
var mbc;
var pv;
mb = "__mochibot__";
mbc = "mochibot.com";
g = (_global ? (_global) : (_level0._root));
if (g[mb + swfid]) {
return(g[mb + swfid]);
}
s = System.security;
x = mc._root.getSWFVersion;
fv = (x ? (mc.getSWFVersion()) : ((_global ? 6 : 5)));
if (!s) {
s = {};
}
sb = s.sandboxType;
if (sb == "localWithFile") {
return(null);
}
x = s.allowDomain;
if (x) {
s.allowDomain(mbc);
}
x = s.allowInsecureDomain;
if (x) {
s.allowInsecureDomain(mbc);
}
pv = ((fv == 5) ? (getVersion()) : (System.capabilities.version));
u = (((((((((((("http://" + mbc) + "/my/core.swf?mv=8&fv=") + fv) + "&v=") + escape(pv)) + "&swfid=") + escape(swfid)) + "&l=") + lv) + "&f=") + mc) + (sb ? ("&sb=" + sb) : "")) + (trk ? "&t=1" : "");
lv = ((fv > 6) ? (mc.getNextHighestDepth()) : ((g[mb + "level"] ? (g[mb + "level"] + 1) : (lv))));
g[mb + "level"] = lv;
if (fv == 5) {
res = "_level" + lv;
if (!eval (res)) {
loadMovieNum (u, lv);
}
} else {
res = mc.createEmptyMovieClip(mb + swfid, lv);
res.loadMovie(u);
}
return(res);
}
stop();
Color.prototype.setTint = function (r, g, b, amount) {
var _local2 = new Object();
_local2.ra = (_local2.ga = (_local2.ba = 100 - amount));
var _local3 = amount / 100;
_local2.rb = r * _local3;
_local2.gb = g * _local3;
_local2.bb = b * _local3;
this.setTransform(_local2);
};
var myMenu = new ContextMenu();
myMenu.hideBuiltInItems();
var mainItem = new ContextMenuItem("Play More Games", goToThisURL);
myMenu.customItems.push(mainItem);
createContextMenu(myMenu);
urlStart = _url.indexOf("://") + 3;
urlEnd = _url.indexOf("/", urlStart);
domain = _url.substring(urlStart, urlEnd);
LastDot = domain.lastIndexOf(".") - 1;
domEnd = domain.lastIndexOf(".", LastDot) + 1;
domain = domain.substring(domEnd, domain.length);
__com_mochibot__("25e3ac41", this, 10301, true);
if (((domain == "armorgames.com") || (domain == "www.armorgames.com")) || (domain == "https://www.armorgames.com")) {
adBox._x = 2000;
} else {
var CPMStarContentSpotID = "0";
System.security.allowDomain("server.cpmstar.com");
adBox.loadMovie("http://server.cpmstar.com/adviewas2.swf?contentspotid=6493Q827358BF");
}
Instance of Symbol 102 MovieClip in Frame 2
on (release) {
getURL ("http://armorgames.com", "_BLANK");
}
Frame 3
function createNormalHover(button) {
button._alpha = 100;
button.onRollOver = function () {
button._alpha = 75;
};
button.onRollOut = function () {
button._alpha = 100;
};
button.onReleaseOutside = function () {
button._alpha = 100;
};
}
function createMiniScreen() {
miniScreen._x = Stage.width / 2;
createNormalHover(miniScreen.yBtn);
createNormalHover(miniScreen.nBtn);
miniScreen.yBtn.onRelease = function () {
sObject.clear();
resetValues();
miniScreen._x = -300;
};
miniScreen.nBtn.onRelease = function () {
miniScreen._x = -300;
};
}
function aHover(button, num) {
button.onRollOver = function () {
growBig[num - 1] = true;
};
button.onRollOut = function () {
growBig[num - 1] = false;
};
}
function onEnterFrame() {
i = buttons.length - 1;
while (i >= 0) {
button = buttons[i];
if (growBig[i]) {
button._xscale = (button._yscale = button._yscale + ((200 - button._xscale) / 2));
} else {
button._xscale = (button._yscale = button._yscale + ((100 - button._xscale) / 2));
}
i--;
}
characterMovement();
}
function characterMovement() {
if (Key.isDown(39) || (Key.isDown(68))) {
xSpeed = xSpeed + speed;
}
if (Key.isDown(37) || (Key.isDown(65))) {
xSpeed = xSpeed - speed;
}
if (Key.isDown(38) || (Key.isDown(87))) {
if (!justPressed) {
if (!firstJump) {
ySpeed = -20;
firstJump = true;
} else if (!secondJump) {
secondJump = true;
}
justPressed = true;
}
} else {
justPressed = false;
}
ySpeed = ySpeed + gravity;
ySpeed = ySpeed * airFriction;
xSpeed = xSpeed * friction;
if (xSpeed <= 0) {
char._xscale = -100;
} else {
char._xscale = 100;
}
char._x = char._x + xSpeed;
char._y = char._y + ySpeed;
if (level.hitTest(char._x, char._y + 23, true)) {
ySpeed = 0;
firstJump = false;
secondJump = false;
} else {
firstJump = true;
}
while (level.hitTest(char._x, char._y + 23, true)) {
char._y = char._y - 0.05;
}
while (level.hitTest(char._x + (char._width / 2), char._y, true)) {
char._x = char._x - 1;
xSpeed = 0;
}
while (level.hitTest(char._x - (char._width / 2), char._y, true)) {
char._x = char._x + 1;
xSpeed = 0;
}
while (level.hitTest(char._x, char._y - (char._height / 2), true)) {
char._y = char._y + 1;
ySpeed = 0;
}
if ((char._x + 20) >= Stage.width) {
char._x = Stage.width - 20;
xSpeed = 0;
}
if ((char._x - 20) <= 0) {
char._x = 20;
xSpeed = 0;
}
switchBack = false;
if (char._xscale < 0) {
switchBack = true;
}
if ((char._xscale >= 50) && ((_xmouse - char._x) <= 0)) {
char.ina.gun._xscale = -100;
char.ina.gun._rotation = ((Math.atan2(_ymouse - char._y, (_xmouse - char._x) * (char._xscale / 100)) * 180) / Math.PI) + 180;
}
if ((char._xscale >= 50) && ((_xmouse - char._x) > 0)) {
char.ina.gun._xscale = 100;
char.ina.gun._rotation = (Math.atan2(_ymouse - char._y, (_xmouse - char._x) * (char._xscale / 100)) * 180) / Math.PI;
}
if ((char._xscale <= -50) && ((_xmouse - char._x) <= 0)) {
char.ina.gun._xscale = 100;
char.ina.gun._rotation = (Math.atan2(_ymouse - char._y, (_xmouse - char._x) * (char._xscale / 100)) * 180) / Math.PI;
}
if ((char._xscale <= -50) && ((_xmouse - char._x) > 0)) {
char.ina.gun._xscale = -100;
char.ina.gun._rotation = ((Math.atan2(_ymouse - char._y, (_xmouse - char._x) * (char._xscale / 100)) * 180) / Math.PI) + 180;
}
}
function resetValues() {
taskLevel = 1;
tasksCompleted = new Array(false, false, false);
moneyTreeFrame = 1;
highscore = 0;
startingMoney = 0;
gameWon = false;
days = 0;
killsHighscore = 0;
}
function loadGame() {
taskLevel = 1;
tasksCompleted = new Array(false, false, false);
moneyTreeFrame = 1;
highscore = 0;
startingMoney = 0;
gameWon = false;
days = 0;
killsHighscore = 0;
i = 0;
while (i <= tasksCompleted.length) {
if (sObject.data.tasksCompleted[i] != undefined) {
tasksCompleted[i] = sObject.data.tasksCompleted[i];
}
i++;
}
if (sObject.data.taskLevel != undefined) {
taskLevel = sObject.data.taskLevel;
}
if (sObject.data.moneyTreeFrame != undefined) {
moneyTreeFrame = sObject.data.moneyTreeFrame;
}
if (sObject.data.highscore != undefined) {
highscore = sObject.data.highscore;
}
if (sObject.data.startingMoney != undefined) {
startingMoney = sObject.data.startingMoney;
}
if (sObject.data.gameWon != undefined) {
gameWon = sObject.data.gameWon;
}
if (sObject.data.days != undefined) {
days = sObject.data.days;
}
if (sObject.data.killsHighscore != undefined) {
killsHighscore = sObject.data.killsHighscore;
}
if (taskLevel == 0) {
resetValues();
}
}
stop();
theQuestion.gotoAndStop(random(10) + 1);
menuSong.stop();
song.stop();
menuSong = new Sound(this);
menuSong.attachSound("menu.wav");
menuSong.start(0, 100000);
buttons = new Array(playBtn, cg, pmg, cs, mBtn);
growBig = new Array(false, false, false, false, false);
ag.onRollOver = function () {
ag._alpha = 50;
};
ag.onRollOut = function () {
ag._alpha = 100;
};
ag.onRelease = function () {
getURL ("http://armorgames.com/", "_BLANK");
};
playBtn.onRelease = function () {
gotoAndStop (4);
};
cg.onRelease = function () {
gotoAndStop (5);
};
pmg.onRelease = function () {
getURL ("http://armorgames.com/", "_BLANK");
};
cs.onRelease = function () {
createMiniScreen();
};
isMuted = false;
mBtn.onRelease = function () {
isMuted = !isMuted;
if (isMuted) {
mBtn.gotoAndStop(2);
menuSong.setVolume(0);
} else {
mBtn.gotoAndStop(1);
menuSong.setVolume(100);
}
};
i = buttons.length - 1;
while (i >= 0) {
aHover(buttons[i], i + 1);
i--;
}
xSpeed = 0;
ySpeed = 0;
gravity = 1.2;
friction = 0.8;
airFriction = 0.95;
speed = 2;
firstJump = false;
secondJump = false;
char.ina.gun._alpha = 0;
resetValues();
sObject = SharedObject.getLocal("saveFile");
Key.removeListener(keyListener);
loadGame();
Frame 4
function saveGame() {
sObject.data.taskLevel = taskLevel;
sObject.data.tasksCompleted = tasksCompleted;
sObject.data.moneyTreeFrame = moneyTree._currentframe;
sObject.data.highscore = highscore;
sObject.data.startingMoney = startingMoney;
sObject.data.gameWon = gameWon;
sObject.data.days = days;
sObject.data.killsHighscore = killsHighscore;
sObject.flush();
}
function setRingLocation() {
ring._x = random(Stage.width - ring._width) + (ring._width / 2);
ring._y = (random(((Stage.height - ring._height) - lHeight) - 50) + (ring._height / 2)) + 50;
}
function init() {
startNewWave = false;
bulletMissed = false;
tutBox._alpha = 0;
turretAmounts = new Array(0, 0, 0, 0);
windfallModeTimes = 0;
killsInAir = 0;
hitOnDayOne = false;
hasShot = false;
rFlash._x = Stage.width / 2;
rFlash._y = Stage.height / 2;
wFlash._x = Stage.width / 2;
wFlash._y = Stage.height / 2;
health = healthArray[taskLevel - 1];
rings = 0;
if (inTutorial) {
ring._x = -100;
} else {
setRingLocation();
}
framesToGo = times[0] * 30;
gamePause = false;
shopExists = false;
shotDelay = 0;
mDown = false;
gunUsed = 1;
firstJump = false;
secondJump = false;
char.ina.gun._alpha = 100;
ps._alpha = 0;
money = initialGolds[taskLevel - 1] + startingMoney;
kills = 0;
windfallKills = 0;
time = 0;
score = 0;
xp = 0;
char._alpha = 100;
charLevel = 1;
ringsSinceHit = 0;
windTime = 0;
onWave = 1;
levelsUnlocked = 1;
myColor = new Color(char);
tintAmt = 0;
myColor.setTint(255, 255, 255, tintAmt);
isWhite = false;
justPressedSpace = false;
shopStartRemove = false;
giveNotice = true;
xSpeed = 0;
ySpeed = 0;
coinsCollected = 0;
char.ina.gun.gotoAndStop(gunUsed);
bg.play();
char._x = 214;
char._y = 268;
}
function pauseStuff() {
if (playerPause) {
_root._x = 0;
_root._y = 0;
ps2 = attachMovie("pauseScreen", "pauseScreen", 985050);
ps2._x = Stage.width / 2;
ps2._y = Stage.height / 2;
} else {
ps2.removeMovieClip();
}
createNormalHover(ps2.cfs);
ps2.cfs.onRelease = function () {
bClick.start();
health = 0;
clearScreen();
health = healthArray[taskLevel - 1];
gamePause = true;
createTree();
ps2.removeMovieClip();
playerPause = false;
};
createNormalHover(ps2.gtm);
ps2.gtm.onRelease = function () {
ps2.removeMovieClip();
char.removeMovieClip();
tutComplete.removeMovieClip();
clearScreen();
gotoAndStop (3);
};
}
function createTree() {
if (taskLevel > moneyTree._currentframe) {
bg.gotoAndStop(1);
startTreeAnim = true;
} else if ((!gameWon) && (toFinish)) {
char.removeMovieClip();
tutComplete.removeMovieClip();
clearScreen();
saveGame();
gotoAndStop (6);
gameWon = true;
} else {
createLevelFinishScreen();
}
}
function giveTutorialAward(num) {
if (tutorialStage == 5) {
if (!tasksCompleted[num - 1]) {
tasksCompleted[num - 1] = true;
award.gotoAndPlay(2);
award.aname.awardName.htmlText = bold(preTasks[num - 1]);
allTasksCompleted = true;
i = tasksCompleted.length - 1;
while (i >= 0) {
if (!tasksCompleted[i]) {
allTasksCompleted = false;
}
i--;
}
if (allTasksCompleted) {
taskLevelUp();
}
}
}
}
function giveAward(num) {
if (((Math.floor((num - 1) / 3) + 1) == taskLevel) && (!tasksCompleted[(num - 1) % 3])) {
tasksCompleted[(num - 1) % 3] = true;
allTasksCompleted = true;
award.gotoAndPlay(2);
award.aname.awardName.htmlText = bold(tasks[taskLevel - 1][(num - 1) % 3]);
i = tasksCompleted.length - 1;
while (i >= 0) {
if (!tasksCompleted[i]) {
allTasksCompleted = false;
}
i--;
}
if (allTasksCompleted) {
taskLevelUp();
if (onWave >= 3) {
giveAward(8);
}
}
saveGame();
}
}
function taskLevelUp() {
taskLevel = taskLevel + 1;
a1.c1._alpha = 0;
a2.c1._alpha = 0;
a3.c1._alpha = 0;
tasksCompleted = new Array(false, false, false);
if (inTutorial) {
delayToDone = 180;
tutComplete.gotoAndPlay(2);
}
saveGame();
}
function manageStars() {
s = stars.length - 1;
while (s >= 0) {
star = stars[s];
if (star.Type == 1) {
if ((!gamePause) && (!playerPause)) {
star._y = star._y - 3;
star._xscale = (star._yscale = star._yscale - 5);
if (star._xscale <= 0) {
removeStar();
}
}
}
if (star.Type == 2) {
star._x = star._x + star.xSpeed;
star._y = star._y + star.ySpeed;
star.xSpeed = star.xSpeed * 0.95;
star.ySpeed = star.ySpeed * 0.95;
star._xscale = (star._yscale = star._yscale - 5);
if (star._xscale <= 0) {
removeStar();
}
}
s--;
}
}
function removeStar() {
star.removeMovieClip();
stars.splice(s, 1);
}
function onEnterFrame() {
if ((!gamePause) && (!playerPause)) {
characterMovement();
if ((!inTutorial) || (tutorialStage >= 3)) {
shootingManagement();
}
if (mBonus._x != undefined) {
mBonus._x = char._x + 70;
mBonus._y = char._y - 10;
}
bulletMovement();
if (!inTutorial) {
if (!startNewWave) {
ghostManagement();
}
if (startNewWave && (ghosts.length == 0)) {
newWaveDelay = newWaveDelay - 1;
if (newWaveDelay == 10) {
toCreate = false;
j = 0;
while (j < 4) {
if (money >= turretCosts[j][turretAmounts[j]]) {
toCreate = true;
}
j++;
}
if (toCreate) {
createTurretShop();
}
}
if (newWaveDelay == 1) {
onWave = onWave + 1;
ring._x = random(Stage.width - ring._width) + (ring._width / 2);
ring._y = (random(((Stage.height - ring._height) - lHeight) - 50) + (ring._height / 2)) + 50;
startNewWave = false;
newWaveDelay = 0;
dayUp.d1.dTxt.htmlText = bold("DAY " + onWave);
dayUp.gotoAndPlay(2);
framesToGo = times[onWave - 1] * 30;
t2.gotoAndPlay(2);
t1.bar.gotoAndPlay(2);
if ((onWave == 2) && (!hitOnDayOne)) {
giveAward(7);
}
if ((onWave == 3) && (!bulletMissed)) {
giveAward(25);
}
if (onWave == 7) {
giveAward(22);
}
if (onWave == 9) {
giveAward(26);
}
if (onWave >= 3) {
giveAward(8);
}
if (onWave == 2) {
giveAward(1);
}
if ((onWave == 3) && (rings == 0)) {
giveAward(12);
}
if ((onWave == 4) && (gunUsed == 1)) {
giveAward(18);
}
if (onWave == 5) {
giveAward(13);
}
}
}
} else if (tutorialStage == 5) {
tutorialGhostDelay = tutorialGhostDelay - 1;
if (tutorialGhostDelay <= 0) {
createGhost(1);
tutorialGhostDelay = 240;
}
}
ghostMovement();
ghostShotMovement();
turretManagement();
turretBulletManagement();
coinManagement();
hitTesting();
shaker();
if (isWhite) {
tintAmt = tintAmt - 10;
if (tintAmt <= 0) {
isWhite = false;
}
myColor.setTint(255, 255, 255, tintAmt);
}
if (char.ina.g1.hitTest(ring.ina)) {
rings = rings + 1;
if (inTutorial) {
if (rings >= 3) {
tutorialNext(5);
}
}
if ((onWave == 1) && (rings >= 15)) {
giveAward(17);
}
if (rings >= 10) {
giveAward(3);
}
if (rings >= 100) {
giveAward(16);
}
if (rings >= 150) {
giveAward(23);
}
ringsSinceHit = ringsSinceHit + 1;
if (ringsSinceHit == 3) {
mBonus = attachMovie("mBonus", "mBonus", 760600);
mBonus.gotoAndPlay(1);
}
Ring2.start();
Ring2.start();
Ring2.start();
Ring2.start();
Ring2.start();
Ring2.start();
isWhite = true;
tintAmt = 150;
myColor.setTint(255, 255, 255, tintAmt);
r1.bar.gotoAndPlay(2);
r2.gotoAndPlay(2);
while (char.ina.g1.hitTest(ring.ina)) {
if (!startNewWave) {
ring._x = random(Stage.width - ring._width) + (ring._width / 2);
ring._y = (random(((Stage.height - ring._height) - lHeight) - 50) + (ring._height / 2)) + 50;
} else {
ring._x = -200;
}
}
if (inTutorial && (rings >= 3)) {
ring._x = -200;
}
}
if (ringsSinceHit >= 3) {
windTime = windTime + 1;
if (stars.length == 0) {
windfallModeTimes = windfallModeTimes + 1;
if (windfallModeTimes >= 5) {
giveAward(10);
}
}
star = attachMovie("star", "star" + depth, depth++);
star._x = (char._x + random(40)) - 20;
star._y = (char._y + random(40)) - 20;
star.Type = 1;
stars.push(star);
}
bg.gotoAndStop(Math.floor((((times[onWave - 1] * 30) - framesToGo) / (times[onWave - 1] * 30)) * 490));
if (!inTutorial) {
time = time + 1;
framesToGo = framesToGo - 1;
}
if ((framesToGo <= 0) && (!startNewWave)) {
startNewWave = true;
newWaveDelay = newWaveDelayConst;
framesToGo = 0;
}
if (health <= 0) {
health = 0;
explosion = attachMovie("explosion", "explosion" + depth, depth++);
explosion._x = char._x;
explosion._y = char._y;
clearScreen();
health = healthArray[taskLevel - 1];
gamePause = true;
startingMoney = startingMoney + (taskLevel * 10);
createTree();
}
if (Key.isDown(32)) {
if (!justPressedSpace) {
if (money >= weaponCosts[gunUsed]) {
if ((!inTutorial) || (tutorialStage == 5)) {
if (inTutorial) {
giveTutorialAward(3);
}
money = money - weaponCosts[gunUsed];
weaponsOwned[gunUsed] = true;
gunUsed = gunUsed + 1;
if (gunUsed == 4) {
giveAward(15);
}
char.ina.gun.gotoAndStop(gunUsed);
ps.gotoAndStop(31);
}
}
justPressedSpace = true;
}
} else {
justPressedSpace = false;
}
if (dayUp._currentframe != 1) {
dayUp.nextFrame();
}
ps._x = char._x;
ps._y = char._y - 40;
} else if (Key.isDown(32)) {
if (!justPressedSpace) {
shopStartRemove = true;
justPressedSpace = true;
}
} else {
justPressedSpace = false;
}
if (shopStartRemove) {
shop._x = shop._x + (((Stage.width * 1.5) - shop._x) / 4);
if (shop._x >= ((Stage.width * 1.5) - 1)) {
shop.removeMovieClip();
shopStartRemove = false;
}
}
if (award._currentframe != 1) {
award.nextFrame();
}
if (startTreeAnim) {
if (goingDown) {
toWhiteAmt = toWhiteAmt + 2;
ii._alpha = toWhiteAmt;
myColor2.setTint(255, 255, 255, toWhiteAmt);
if (toWhiteAmt >= 100) {
toWhiteAmt = 100;
moneyTree._y = moneyTree._y + theVertSpeed;
theVertSpeed = theVertSpeed + 1;
if ((moneyTree._y - (moneyTree._height / 2)) >= (level._y - (lHeight / 2))) {
goingUp = true;
goingDown = false;
moneyTree.gotoAndStop(moneyTree._currentframe + 1);
saveGame();
}
}
}
if (goingUp) {
moneyTree._y = moneyTree._y - theVertSpeed;
theVertSpeed = theVertSpeed - 1;
if (moneyTree._y <= normalY) {
toWhiteAmt = 0;
ii._alpha = toWhiteAmt;
myColor2.setTint(255, 255, 255, 0);
wFlash.gotoAndPlay(2);
i = 20;
while (i >= 0) {
star = attachMovie("star", "star" + depth, depth++);
star.dir = (Math.random() * Math.PI) * 2;
star.Speed = random(10) + 10;
star._xscale = (star._yscale = 100 + random(100));
star._x = moneyTree._x;
star._y = moneyTree._y + 75;
star.xSpeed = Math.cos(star.dir) * star.Speed;
star.ySpeed = Math.sin(star.dir) * star.Speed;
star._x = star._x + (star.xSpeed * 3);
star._y = star._y + (star.ySpeed * 3);
star.Type = 2;
stars.push(star);
i--;
}
startTreeAnim = false;
if (moneyTree._currentframe < taskLevel) {
startTreeAnim = true;
toWhiteAmt = -100;
} else {
timeToCreateLevelFin = 50;
createLevelFin = true;
}
goingUp = false;
goingDown = true;
moneyTree._y = normalY;
}
}
}
if (turretToPlace != null) {
turretShop._x = turretShop._x + (((Stage.width * 1.5) - turretShop._x) / 4);
if (turretShop._x >= ((Stage.width * 1.5) - 1)) {
turretShop._x = Stage.width * 1.5;
}
turretToPlace._x = _xmouse;
if (turretToPlace._x <= (turretToPlace._width / 2)) {
turretToPlace._x = turretToPlace._width / 2;
}
if (turretToPlace._x >= (Stage.width - (turretToPlace._width / 2))) {
turretToPlace._x = Stage.width - (turretToPlace._width / 2);
}
turretToPlace._y = turretYs[turretToPlaceNum];
} else if (turretShop._x != undefined) {
turretShop._x = turretShop._x + (((Stage.width / 2) - turretShop._x) / 4);
if (turretShop._x < ((Stage.width / 2) + 1)) {
turretShop._x = Stage.width / 2;
}
}
if (inTutorial) {
delayToDone = delayToDone - 1;
if (delayToDone == 60) {
clearScreen();
init();
tutBox.swapDepths(500100);
tutBox.removeMovieClip();
gamePause = true;
bg.gotoAndStop(1);
}
if (delayToDone == 0) {
gamePause = false;
levelTask = 1;
onWave = 1;
inTutorial = false;
tutComplete.removeMovieClip();
setRingLocation();
}
}
tutorialManagement();
levelManager();
manageStars();
lfManage();
achManagement();
shopManagement();
updateStats();
}
function lfManage() {
if (createLevelFin) {
timeToCreateLevelFin = timeToCreateLevelFin - 1;
if (timeToCreateLevelFin <= 0) {
if ((!gameWon) && (toFinish)) {
char.removeMovieClip();
tutComplete.removeMovieClip();
clearScreen();
saveGame();
gotoAndStop (6);
gameWon = true;
} else {
createLevelFin = false;
createLevelFinishScreen();
}
}
}
}
function tutorialManagement() {
if (inTutorial) {
if (inRealTutorial) {
tutBox._alpha = tutBox._alpha + ((100 - tutBox._alpha) / 6);
if (tutBox._alpha >= 99) {
tutBox._alpha = 100;
}
}
if (mDown) {
mDownTime = mDownTime + 1;
if (mDownTime >= 20) {
tutorialNext(4);
}
} else {
mDownTime = 0;
}
}
}
function tutorialNext(num) {
if ((num - 1) == tutorialStage) {
tutorialStage = num;
tutBox.tTxt.htmlText = bold(tutorialDescriptions[tutorialStage - 1]);
if (num == 4) {
setRingLocation();
}
}
}
function levelManager() {
if (levelToCenter && (levelToExit)) {
levelToCenter = false;
}
if (levelToCenter) {
lf._x = lf._x + (((Stage.width / 2) - lf._x) / 4);
if (lf._x <= ((Stage.width / 2) + 1)) {
lf._x = Stage.width / 2;
levelToCenter = false;
}
}
if (levelToExit) {
lf._x = lf._x + (((Stage.width * 1.5) - lf._x) / 4);
if (lf._x >= ((Stage.width * 1.5) - 1)) {
lf.removeMovieClip();
levelToExit = false;
createAchScreen();
}
}
}
function achManagement() {
if (achToExit && (achToCenter)) {
achToCenter = false;
}
if (achToCenter) {
achScreen._x = achScreen._x + (((Stage.width / 2) - achScreen._x) / 4);
if (achScreen._x >= ((Stage.width / 2) - 1)) {
achScreen._x = Stage.width / 2;
achToCenter = false;
}
}
if (achToExit) {
achScreen._x = achScreen._x + (((Stage.width * -0.5) - achScreen._x) / 4);
if (achScreen._x <= ((Stage.width * -0.5) + 1)) {
achScreen.removeMovieClip();
init();
achToExit = false;
}
}
}
function updateStats() {
k1.bar._xscale = (kills / killsMax) * 100;
if (kills >= 1000) {
k1.bar._xscale = 100;
}
k1.iTxt.htmlText = bold(kills);
if (k1.bar._xscale >= 100) {
k1.bar._xscale = 100;
}
r1.bar._xscale = (rings / ringsMax) * 100;
rTxt.htmlText = bold(rings);
if (r1.bar._xscale >= 100) {
r1.bar._xscale = 100;
}
t1.bar._xscale = (Math.floor(time / 30) / timeMax) * 100;
tTxt.htmlText = bold(onWave);
if (t1.bar._xscale >= 100) {
t1.bar._xscale = 100;
}
s1.bar._xscale = (score / scoreMax) * 100;
sTxt.htmlText = bold(score);
if (s1.bar._xscale >= 100) {
s1.bar._xscale = 100;
}
w1.bar._xscale = (xp / goalXPs[charLevel - 1]) * 100;
w1.iTxt.htmlText = bold(xp);
if (w1.bar._xscale >= 100) {
w1.bar._xscale = 100;
}
wTxt.htmlText = bold(((xp + "/") + goalXPs[charLevel - 1]) + "xp");
lTxt.htmlText = bold("Level: " + charLevel);
if (!inTutorial) {
a1.aTxt.htmlText = bold(tasks[taskLevel - 1][0]);
a2.aTxt.htmlText = bold(tasks[taskLevel - 1][1]);
a3.aTxt.htmlText = bold(tasks[taskLevel - 1][2]);
a1.tIcon.gotoAndStop(taskTypes[taskLevel - 1][0]);
a2.tIcon.gotoAndStop(taskTypes[taskLevel - 1][1]);
a3.tIcon.gotoAndStop(taskTypes[taskLevel - 1][2]);
} else {
a1.aTxt.htmlText = bold(preTasks[0]);
a2.aTxt.htmlText = bold(preTasks[1]);
a3.aTxt.htmlText = bold(preTasks[2]);
a1.tIcon.gotoAndStop(taskPreTypes[0]);
a2.tIcon.gotoAndStop(taskPreTypes[1]);
a3.tIcon.gotoAndStop(taskPreTypes[2]);
}
nwTxt.htmlText = bold("Next Weapon: $" + weaponCosts[gunUsed]);
if (tasksCompleted[0]) {
a1.c1._alpha = 100;
}
if (tasksCompleted[1]) {
a2.c1._alpha = 100;
}
if (tasksCompleted[2]) {
a3.c1._alpha = 100;
}
w2Txt.htmlText = bold((Math.floor(windTime / 3) / 10) + "s");
if (Math.floor(windTime / 30) >= 10) {
giveAward(5);
}
if (Math.floor(windTime / 30) >= 30) {
giveAward(11);
}
if (Math.floor(windTime / 30) >= 120) {
giveAward(21);
}
tlTxt.htmlText = bold("Task Level " + moneyTree._currentframe);
hBar._xscale = (health / healthArray[taskLevel - 1]) * 100;
timeTxt.htmlText = bold("TIME: " + (Math.floor(framesToGo / 490) + 1));
ringTxt.htmlText = bold("COMBO: X" + rings);
monTxt.htmlText = bold("$" + money);
if (shop._x != undefined) {
shop.infor.monTxt.htmlText = bold(money);
}
}
function ghostManagement() {
ghostDelay = ghostDelay - 1;
if (ghostDelay <= 0) {
ghostDelay = ghostDelayArray[onWave - 1];
ghostToAdd = random(ghostsAllowedArray[onWave - 1]) + 1;
createGhost(ghostToAdd);
}
}
function createGhost(type) {
ghost = attachMovie(ghostTypes[type - 1], "ghost" + depth, depth++);
ghost.Type = type;
side = random(2) + 1;
ghost.ySpeed = 0;
if (side == 1) {
ghost._x = (-ghost._width) / 2;
ghost.xSpeed = 3;
} else {
ghost._x = Stage.width + (ghost._width / 2);
ghost.xSpeed = -3;
ghost._xscale = -100;
}
ghost.frozen = -1;
ghost.shotDelay = 50;
ghost.attacking = false;
ghost.health = 1;
if (((type == 1) || (type == 3)) || (type == 5)) {
if (type == 3) {
ghost.xSpeed = ghost.xSpeed * 2;
}
if (type == 4) {
ghost.health = 2;
}
if (type == 5) {
ghost.health = 5;
}
ghost._y = (Stage.height - lHeight) - (ghost._height / 2);
}
if ((type == 2) || (type == 4)) {
ghost._y = (((Stage.height - lHeight) - (ghost._height / 2)) - 50) - random(150);
if (type == 4) {
ghost.health = 2;
}
}
ghosts.push(ghost);
}
function ghostMovement() {
g = ghosts.length - 1;
while (g >= 0) {
ghost = ghosts[g];
ghost._x = ghost._x + ghost.xSpeed;
ghost._y = ghost._y + ghost.ySpeed;
ghost.frozen = ghost.frozen - 1;
if (ghost.frozen > 0) {
ghost._x = ghost._x - (ghost.xSpeed * 0.7);
ghost._y = ghost._y - (ghost.ySpeed * 0.7);
}
ghost.shotDelay = ghost.shotDelay - 1;
if (ghost.shotDelay <= 0) {
ghost.shotDelay = 150 + random(50);
createGhostShot(1);
}
if (ghost.Type == 4) {
ghost.xSpeed = Math.cos(Math.atan2(char._y - ghost._y, char._x - ghost._x)) * 3;
ghost.ySpeed = Math.sin(Math.atan2(char._y - ghost._y, char._x - ghost._x)) * 3;
}
if (ghost._x <= (char._x - 10)) {
ghost._xscale = 100;
ghost.xSpeed = Math.abs(ghost.xSpeed);
} else if (ghost._x >= (char._x + 10)) {
ghost._xscale = -100;
ghost.xSpeed = -Math.abs(ghost.xSpeed);
}
if (ghost.hitTest(char.a1)) {
health = health - 10;
if (inTutorial) {
health = health + 10;
}
hitOnDayOne = true;
windTime = 0;
ringsSinceHit = 0;
pHit.start();
pHit.start();
removeGhost(true, g);
rFlash.gotoAndPlay(2);
}
if (ghost.hitTest(tree)) {
}
if (ghost.attacking) {
}
g--;
}
}
function createGhostShot(shotType) {
if (shotType == 1) {
enemyBullet = attachMovie("enemyBullet", "bullet" + depth, depth++);
enemyBullet._x = ghost._x;
enemyBullet._y = ghost._y;
aim = Math.atan2(char._y - ghost._y, char._x - ghost._x) + ((Math.random() * 0.5) - 0.25);
enemyBullet.xSpeed = Math.cos(aim) * 10;
enemyBullet.ySpeed = Math.sin(aim) * 10;
ghostShots.push(enemyBullet);
enemyBullet.alive = true;
enemyBullet.life = 90;
}
}
function ghostShotMovement() {
s = ghostShots.length - 1;
while (s >= 0) {
ghostShot = ghostShots[s];
ghostShot._x = ghostShot._x + ghostShot.xSpeed;
ghostShot._y = ghostShot._y + ghostShot.ySpeed;
if (level.hitTest(ghostShot._x, ghostShot._y, true) && (ghostShot.alive)) {
ghostShot.alive = false;
ghostShot.stop();
ghostShot.xSpeed = 0;
ghostShot.ySpeed = 0;
}
if (!ghostShot.alive) {
ghostShot.life = ghostShot.life - 1;
if (ghostShot.life <= 50) {
ghostShot._alpha = ghostShot.life * 2;
}
if (ghostShot.life <= 0) {
removeGhostShot();
}
}
if (((ghostShot._x != undefined) && (char.a1.hitTest(ghostShot))) && (ghostShot.alive)) {
health = health - 5;
if (inTutorial) {
health = health + 5;
}
hitOnDayOne = true;
windTime = 0;
ringsSinceHit = 0;
pHit.start();
pHit.start();
removeGhostShot();
rFlash.gotoAndPlay(2);
}
if (ghostShot._x != undefined) {
if ((ghostShot._x >= (Stage.width + (ghostShot._width / 2))) || (ghostShot._x <= (-(ghostShot._width / 2)))) {
removeGhostShot();
}
}
s--;
}
}
function removeGhostShot() {
ghostShots[s].removeMovieClip();
ghostShots.splice(s, 1);
}
function createCoin(theGhost, theValue) {
v = theValue;
while (v > 0) {
coin = attachMovie("coin", "coin" + depth, depth++);
coin._x = (theGhost._x + random(40)) - 20;
coin._y = (theGhost._y + random(40)) - 20;
coin.life = 720;
coin.Speed = 10;
coins.push(coin);
v = v - 5;
}
}
function coinManagement() {
c = coins.length - 1;
while (c >= 0) {
coin = coins[c];
dir = Math.atan2(char._y - coin._y, char._x - coin._x);
coin.Speed = coin.Speed + 4;
coin._x = coin._x + (Math.cos(dir) * coin.Speed);
coin._y = coin._y + (Math.sin(dir) * coin.Speed);
while (coin.hitTest(level)) {
coin._y = coin._y - 0.1;
coin.xSpeed = 0;
coin.ySpeed = 0;
}
coin._y = coin._y + 1;
if (coin.hitTest(char) || (Math.abs(coin.Speed) >= 100)) {
money = money + (5 + (taskLevel - 1));
if (money >= 25000) {
giveAward(24);
}
coinsCollected = coinsCollected + 1;
if (coinsCollected >= 100) {
giveAward(4);
}
if (coins.length < 5) {
Ring.start();
}
if (money >= weaponCosts[gunUsed]) {
giveNotice = false;
ps._alpha = 100;
ps.gotoAndPlay(1);
} else {
ps.gotoAndStop(31);
}
coin2 = attachMovie("coin2", "coin" + depth, depth++);
coin2._x = coin._x;
coin2._y = coin._y;
removeCoin();
} else {
coin.life = coin.life - 1;
if (coin.life <= 50) {
coin._alpha = coin.life * 2;
if (coin.life <= 0) {
removeCoin();
}
}
}
c--;
}
}
function removeCoin() {
coin.removeMovieClip();
coins.splice(c, 1);
}
function removeGhost(killed, num) {
if (killed) {
score = score + (((rings + 1) * ghosts[num].Type) + Math.floor((((rings + 1) * ghosts[num].Type) / 5) * (taskLevel - 1)));
if (score >= 1000) {
giveAward(6);
}
if (score >= 20000) {
giveAward(14);
}
if (ringsSinceHit >= 3) {
windfallKills = windfallKills + 1;
if (windfallKills >= 200) {
giveAward(20);
}
}
kills = kills + 1;
if (kills >= 20) {
giveAward(2);
}
if (kills >= 1000) {
giveAward(27);
toFinish = true;
}
if (!level.hitTest(char._x, char._y + 24, true)) {
killsInAir = killsInAir + 1;
if (killsInAir >= 50) {
giveAward(9);
}
}
k1.bar.gotoAndPlay(2);
k2.gotoAndPlay(2);
s1.bar.gotoAndPlay(2);
s2.gotoAndPlay(2);
xp = xp + (((num + 1) * 10) + (((num + 1) * 2) * (taskLevel - 1)));
if (xp >= goalXPs[charLevel - 1]) {
charLevel = charLevel + 1;
xp = 0;
char.ina.gun.gotoAndStop(gunUsed);
}
createExplosion(num);
shake = 1;
shakeDir = bullet._rotation;
if (ringsSinceHit >= 3) {
createCoin(ghosts[num], enemyWorths[ghosts[num].Type - 1] * 2);
} else {
createCoin(ghosts[num], enemyWorths[ghosts[num].Type - 1]);
}
}
ghosts[num].removeMovieClip();
ghosts.splice(num, 1);
}
function createExplosion(num) {
explosion = attachMovie("explosion", "explosion" + depth, depth++);
explosion._x = ghosts[num]._x;
explosion._y = ghosts[num]._y;
}
function characterMovement() {
if (Key.isDown(39) || (Key.isDown(68))) {
xSpeed = xSpeed + speed;
}
if (Key.isDown(37) || (Key.isDown(65))) {
xSpeed = xSpeed - speed;
}
if (Key.isDown(38) || (Key.isDown(87))) {
if (!justPressed) {
if (!firstJump) {
ySpeed = -20;
firstJump = true;
} else if (!secondJump) {
ySpeed = -20;
secondJump = true;
tutorialNext(3);
}
justPressed = true;
}
} else {
justPressed = false;
}
ySpeed = ySpeed + gravity;
ySpeed = ySpeed * airFriction;
xSpeed = xSpeed * friction;
if (xSpeed <= 0) {
char._xscale = -100;
} else {
char._xscale = 100;
}
char._x = char._x + xSpeed;
char._y = char._y + ySpeed;
if (level.hitTest(char._x, char._y + 23, true)) {
ySpeed = 0;
firstJump = false;
secondJump = false;
} else {
firstJump = true;
}
while (level.hitTest(char._x, char._y + 23, true)) {
char._y = char._y - 0.05;
}
while (level.hitTest(char._x + (char._width / 2), char._y, true)) {
char._x = char._x - 1;
xSpeed = 0;
}
while (level.hitTest(char._x - (char._width / 2), char._y, true)) {
char._x = char._x + 1;
xSpeed = 0;
}
while (level.hitTest(char._x, char._y - (char._height / 2), true)) {
char._y = char._y + 1;
ySpeed = 0;
}
if ((char._x + 20) >= Stage.width) {
char._x = Stage.width - 20;
xSpeed = 0;
}
if ((char._x - 20) <= 0) {
char._x = 20;
xSpeed = 0;
}
switchBack = false;
if (char._xscale < 0) {
switchBack = true;
}
if ((char._xscale >= 50) && ((_xmouse - char._x) <= 0)) {
char.ina.gun._xscale = -100;
char.ina.gun._rotation = ((Math.atan2(_ymouse - char._y, (_xmouse - char._x) * (char._xscale / 100)) * 180) / Math.PI) + 180;
}
if ((char._xscale >= 50) && ((_xmouse - char._x) > 0)) {
char.ina.gun._xscale = 100;
char.ina.gun._rotation = (Math.atan2(_ymouse - char._y, (_xmouse - char._x) * (char._xscale / 100)) * 180) / Math.PI;
}
if ((char._xscale <= -50) && ((_xmouse - char._x) <= 0)) {
char.ina.gun._xscale = 100;
char.ina.gun._rotation = (Math.atan2(_ymouse - char._y, (_xmouse - char._x) * (char._xscale / 100)) * 180) / Math.PI;
}
if ((char._xscale <= -50) && ((_xmouse - char._x) > 0)) {
char.ina.gun._xscale = -100;
char.ina.gun._rotation = ((Math.atan2(_ymouse - char._y, (_xmouse - char._x) * (char._xscale / 100)) * 180) / Math.PI) + 180;
}
}
function shootingManagement() {
shotDelay = shotDelay - 1;
if (mDown && (shotDelay <= 0)) {
hasShot = true;
shotDelay = shotDelays[gunUsed - 1];
if (((gunUsed == 1) || (gunUsed == 2)) || (gunUsed == 5)) {
createBullet(0);
AK47.start();
}
if (gunUsed == 3) {
createBullet((Math.random() * 0.5) - 0.25);
createBullet((Math.random() * 0.5) - 0.25);
createBullet((Math.random() * 0.5) - 0.25);
shotgun.start();
}
if (gunUsed == 4) {
createBullet(0);
bullet.gotoAndStop(2);
grenade.start();
}
if (gunUsed == 7) {
electricityShot();
}
if (gunUsed == 6) {
railShot();
}
}
}
function createBullet(exRot) {
bullet = attachMovie("bullet", "bullet" + depth, depth++);
bullet._x = char._x + char.ina._x;
bullet._y = char._y + char.ina._y;
tDir = Math.atan2(_ymouse - char._y, _xmouse - char._x);
bullet.xSpeed = Math.cos(tDir) * 15;
bullet.ySpeed = Math.sin(tDir) * 15;
bullet._x = bullet._x + (bullet.xSpeed * 2);
bullet._y = bullet._y + (bullet.ySpeed * 2);
bullet.Type = gunUsed;
if (xRot != 0) {
tDir = tDir + exRot;
bullet.xSpeed = Math.cos(tDir) * 15;
bullet.ySpeed = Math.sin(tDir) * 15;
}
bullet._rotation = (tDir * 180) / Math.PI;
bullets.push(bullet);
}
function hitTesting() {
b = bullets.length - 1;
while (b >= 0) {
bullet = bullets[b];
g = ghosts.length - 1;
while (g >= 0) {
ghost = ghosts[g];
if (ghost.hitTest(bullet._x, bullet._y, true) && (bullet.Type != 6)) {
ghost.health = ghost.health - 1;
if (ghost.health <= 0) {
if (inTutorial) {
giveTutorialAward(1);
}
poof.start();
poof.start();
removeGhost(true, g);
}
if (bullet.Type == 4) {
ranger = attachMovie("ranger", "ranger" + depth, depth++);
ranger._x = bullet._x;
ranger._y = bullet._y;
v = ghosts.length - 1;
while (v >= 0) {
if (ranger.hitTest(ghosts[v])) {
ghosts[v].health = ghosts[v].health - 1;
if (ghosts[v].health <= 0) {
poof.start();
poof.start();
removeGhost(true, v);
}
}
v--;
}
}
removeBullet();
}
g--;
}
b--;
}
}
function bulletMovement() {
b = bullets.length - 1;
while (b >= 0) {
bullet = bullets[b];
bullet._x = bullet._x + bullet.xSpeed;
bullet._y = bullet._y + bullet.ySpeed;
if (bullet.Type == 4) {
bullet.ySpeed = bullet.ySpeed + 0.5;
bullet._rotation = (Math.atan2(bullet.ySpeed, bullet.xSpeed) * 180) / Math.PI;
}
if (level.hitTest(bullet._x, bullet._y, true) && (bullet._x != undefined)) {
if (bullet.Type == 4) {
ranger = attachMovie("ranger", "ranger" + depth, depth++);
ranger._x = bullet._x;
ranger._y = bullet._y;
v = ghosts.length - 1;
while (v >= 0) {
if (ranger.hitTest(ghosts[v])) {
ghosts[v].health = ghosts[v].health - 1;
if (ghosts[v].health <= 0) {
poof.start();
poof.start();
removeGhost(true, v);
}
}
v--;
}
}
fs = attachMovie("floorShot", "floorShot" + depth, depth++);
fs._x = bullet._x;
fs._y = (Stage.height - lHeight) + 15;
fs._rotation = 270;
fs.gotoAndStop(random(3) + 1);
fs._xscale = (fs._yscale = 200);
removeBullet();
bulletMissed = true;
} else if ((((bullet._x >= (char._x + 2000)) || (bullet._x <= (char._x - 2000))) || (bullet._y >= (char._y + 2000))) || (bullet._y <= (char._y - 2000))) {
removeBullet();
bulletMissed = true;
}
b--;
}
}
function removeBullet() {
bullet.removeMovieClip();
bullets.splice(b, 1);
}
function shaker() {
if (shake == 0) {
if ((_root._x != 0) || (_root._y != 0)) {
_root._x = 0;
_root._y = 0;
}
} else if (shake == 1) {
shake = shake + 1;
_root._x = _root._x + (Math.cos((shakeDir * Math.PI) / 180) * 5);
_root._y = _root._y + (Math.sin((shakeDir * Math.PI) / 180) * 5);
} else if (shake == 2) {
shake = 3;
_root._x = Math.cos((shakeDir * Math.PI) / 180) * 4;
_root._y = Math.sin((shakeDir * Math.PI) / 180) * 4;
} else if (shake == 3) {
shake = 4;
_root._x = Math.cos((shakeDir * Math.PI) / 180) * 3;
_root._y = Math.sin((shakeDir * Math.PI) / 180) * 3;
} else if (shake == 4) {
shake = 0;
_root._x = 0;
_root._y = 0;
}
if (gamePause) {
_root._x = 0;
_root._y = 0;
}
}
function shopManagement() {
if (shopExists && (!shopStartRemove)) {
if (shop.moveLeft) {
shop._x = shop._x + (((Stage.width / 2) - shop._x) / 4);
if (shop._x <= ((Stage.width / 2) + 1)) {
shop._x = Stage.width / 2;
shop.moveLeft = false;
}
}
}
}
function clearScreen() {
g = ghosts.length - 1;
while (g >= 0) {
removeGhost(false, g);
g--;
}
s = ghostShots.length - 1;
while (s >= 0) {
ghostShot = ghostShots[s];
removeGhostShot();
s--;
}
c = coins.length - 1;
while (c >= 0) {
coin = coins[c];
removeCoin();
c--;
}
t = turrets.length - 1;
while (t >= 0) {
turret = turrets[t];
removeTurret();
t--;
}
s = stars.length - 1;
while (s >= 0) {
star = stars[s];
removeStar();
s--;
}
b = bullets.length - 1;
while (b >= 0) {
bullet = bullets[b];
removeBullet();
b--;
}
t = turretBullets.length - 1;
while (t >= 0) {
removeTurretBullet();
t--;
}
mBonus.removeMovieClip();
ring._x = -200;
char._alpha = 0;
ps._alpha = 0;
char._x = Stage.width / 2;
char._y = (Stage.height - lHeight) - (char._height / 2);
}
function createShop(levelWon) {
ps.gotoAndStop(31);
shop.removeMovieClip();
shop = attachMovie("shop", "shop", 800550);
gamePause = true;
shop._x = Stage.width + (Stage.width / 2);
shop.moveLeft = true;
shop._y = Stage.height / 2;
shopExists = true;
if ((onWave == levelsUnlocked) && (levelWon)) {
levelsUnlocked = levelsUnlocked + 1;
}
shopWeaponButtons = new Array(shop.w1, shop.w2, shop.w3, shop.w4, shop.w5, shop.w6);
shopLevelButtons = new Array(shop.l1, shop.l2, shop.l3, shop.l4, shop.l5, shop.l6, shop.l7, shop.l8, shop.l9, shop.l10, shop.l11, shop.l12, shop.l13, shop.l14, shop.l15, shop.l16);
v = shopWeaponButtons.length - 1;
while (v >= 0) {
createWeaponButtons(shopWeaponButtons[v], v);
v--;
}
v = shopLevelButtons.length - 1;
while (v >= 0) {
createLevelButtons(shopLevelButtons[v], v);
v--;
}
}
function createWeaponButtons(button, num) {
createNormalHover2(button, num);
button.gun.gotoAndStop(num + 1);
button.onRelease = function () {
if (money >= weaponCosts[num]) {
bClick.start();
money = money - weaponCosts[num];
giveNotice = true;
weaponsOwned[num] = true;
gunUsed = num + 1;
if (gunUsed == 4) {
giveAward(15);
}
char.ina.gun.gotoAndStop(gunUsed);
}
};
}
function createLevelButtons(button, num) {
if (levelsUnlocked >= (num + 1)) {
createNormalHover(button);
button.numTxt.htmlText = bold(num + 1);
button.onRelease = function () {
shopStartRemove = true;
gamePause = false;
bClick.start();
};
} else {
button.gotoAndStop(2);
}
}
function bold(item) {
return(("<b>" + item) + "</b>");
}
function createNormalHover(button) {
button._alpha = 100;
button.onRollOver = function () {
bHover.start();
button._alpha = 75;
};
button.onRollOut = function () {
button._alpha = 100;
};
button.onReleaseOutside = function () {
button._alpha = 100;
};
}
function createLevelFinishScreen() {
dayUp.gotoAndStop(1);
days = days + 1;
bg.gotoAndStop(1);
clearScreen();
levelToCenter = true;
gamePause = true;
_root._x = 0;
_root._y = 0;
if (score >= highscore) {
highscore = score;
}
if (kills >= killsHighscore) {
killsHighscore = kills;
}
saveGame();
lf = attachMovie("levelFinish", "levelFinish", 958350);
lf._x = Stage.width * 1.5;
lf._y = Stage.height / 2;
lf.taskScreen.d1.htmlText = bold(days + " ATTEMPTS");
lf.taskScreen.t1.htmlText = bold(taskLevel);
lf.taskScreen.b1.htmlText = bold("$" + initialGolds[taskLevel - 1]);
lf.taskScreen.b2.htmlText = bold("+$" + startingMoney);
lf.taskScreen.r1.htmlText = bold(killsHighscore);
lf.taskScreen.r2.htmlText = bold(highscore);
createGenericHover(lf.taskScreen.doneBtn);
lf.taskScreen.doneBtn.onRelease = function () {
bClick.start();
levelToExit = true;
delete lf.taskScreen.doneBtn.onRelease;
};
}
function createAchScreen() {
_root._x = 0;
_root._y = 0;
if (score >= highscore) {
highscore = score;
}
saveGame();
achToCenter = true;
bg.gotoAndStop(1);
achScreen = attachMovie("achScreen", "achScreen", 955350);
achScreen._x = Stage.width * -0.5;
achScreen._y = Stage.height / 2;
achScreen.hTxt.htmlText = bold("HIGHSCORE: " + highscore);
tasksToDo = new Array(achScreen.taskScreen.t1, achScreen.taskScreen.t2, achScreen.taskScreen.t3);
tasksDone = new Array(achScreen.taskScreen.t4, achScreen.taskScreen.t5, achScreen.taskScreen.t6);
tasksToDoA = new Array();
tasksToDoB = new Array();
p = 0;
while (p < tasksCompleted.length) {
if (!tasksCompleted[p]) {
tasksToDoA.push(p + 1);
} else {
tasksToDoB.push(p + 1);
}
p++;
}
t = 0;
while (t < tasksToDo.length) {
if (tasksToDoA.length > t) {
tasksToDo[t].tIcon.gotoAndStop(taskTypes[taskLevel - 1][tasksToDoA[t] - 1]);
tasksToDo[t].nameTxt.htmlText = bold(taskNames[taskTypes[taskLevel - 1][tasksToDoA[t] - 1] - 1]);
tasksToDo[t].descTxt.htmlText = bold(tasks[taskLevel - 1][tasksToDoA[t] - 1]);
} else {
tasksToDo[t]._alpha = 0;
}
t++;
}
t = 0;
while (t < tasksDone.length) {
if (tasksToDoB.length > t) {
tasksDone[t].tIcon.gotoAndStop(taskTypes[taskLevel - 1][tasksToDoB[t] - 1]);
tasksDone[t].nameTxt.htmlText = bold(taskNames[taskTypes[taskLevel - 1][tasksToDoB[t] - 1] - 1]);
tasksDone[t].descTxt.htmlText = bold(tasks[taskLevel - 1][tasksToDoB[t] - 1]);
} else {
tasksDone[t]._alpha = 0;
}
t++;
}
achScreen.taskScreen.l1.htmlText = bold(("Level " + taskLevel) + " Tasks");
achScreen.taskScreen.l2.htmlText = bold(("Level " + taskLevel) + " Tasks Completed");
createGenericHover(achScreen.taskScreen.doneBtn);
achScreen.taskScreen.doneBtn.onRelease = function () {
bClick.start();
achToExit = true;
delete achScreen.taskScreen.doneBtn.onRelease;
};
createGenericHover(achScreen.taskScreen.mgBtn);
achScreen.taskScreen.mgBtn.onRelease = function () {
bClick.start();
getURL ("http://armorgames.com/", "_BLANK");
};
}
function createGenericHover(button) {
button.onRollOver = function () {
button.gotoAndStop(2);
bHover.start();
};
button.onRollOut = function () {
button.gotoAndStop(1);
};
button.onReleaseOutside = function () {
button.gotoAndStop(1);
};
}
function createNormalHover2(button, num) {
button._alpha = 100;
button.onRollOver = function () {
button._alpha = 75;
bHover.start();
shop.infor.gunImg.gotoAndStop(num + 1);
shop.infor.descTxt.htmlText = bold(weaponDescriptions[num]);
shop.infor.costTxt.htmlText = bold(weaponCosts[num]);
};
button.onRollOut = function () {
button._alpha = 100;
};
button.onReleaseOutside = function () {
button._alpha = 100;
};
}
function createTurretShop() {
gamePause = true;
turretShopExists = true;
turretShop = attachMovie("turretShop", "turretShop", 810500);
turretShop._x = Stage.width * 1.5;
turretShop._y = 161.5;
turretButtons = new Array(turretShop.t1, turretShop.t2, turretShop.t3, turretShop.t4);
updateTurretButtons();
}
function updateTurretButtons() {
t = turretButtons.length - 1;
while (t >= 0) {
tb = turretButtons[t];
tb.nTxt.htmlText = bold(turretNames[t]);
tb.dTxt.htmlText = turretDescriptions[t];
tb.mTxt.htmlText = bold("$" + turretCosts[t][turretAmounts[t]]);
tb.tIcon.gotoAndStop(t + 1);
if (((!inTutorial) || (t == 0)) || (t == 2)) {
createTurretButton(tb, t);
} else {
tb._alpha = 20;
tb.mTxt.htmlText = bold("$N/A");
}
t--;
}
}
function createTurretButton(button, num) {
delete button.onRollOver;
delete button.onRollOut;
delete button.onReleaseOutside;
delete button.onRelease;
if (money >= turretCosts[num][turretAmounts[num]]) {
button.onRollOver = function () {
button._alpha = 80;
bHover.start();
};
button.onRollOut = function () {
button._alpha = 100;
};
button.onReleaseOutside = function () {
button._alpha = 100;
};
button.onRelease = function () {
if ((money >= turretCosts[num][turretAmounts[num]]) && (turretToPlace == null)) {
bClick.start();
money = money - turretCosts[num][turretAmounts[num]];
ps.gotoAndStop(31);
turretAmounts[num] = turretAmounts[num] + 1;
turretToPlace = attachMovie(theTurrets[num], theTurrets[num] + depth, depth++);
turretToPlace._x = _xmouse;
turretToPlace._y = turretYs[num];
turretToPlaceNum = num;
readyToPlace = false;
updateTurretButtons();
}
};
} else {
button._alpha = 20;
}
}
function turretManagement() {
t = turrets.length - 1;
while (t >= 0) {
turret = turrets[t];
if (turret.Target._x == undefined) {
turret.Target = null;
}
turret.seekDelay = turret.seekDelay - 1;
if ((turret.seekDelay <= 0) || (turret.Target == null)) {
turret.seekDelay = 10;
smallest = 1000;
ghostChoice = -1;
g = ghosts.length - 1;
while (g >= 0) {
ghost = ghosts[g];
if ((((turret.Type == 3) || (turret.Type == 4)) && (((ghost.Type == 1) || (ghost.Type == 3)) || (ghost.Type == 5))) || (((turret.Type == 1) || (turret.Type == 2)) && ((ghost.Type == 2) || (ghost.Type == 4)))) {
xDist = ghost._x - turret._x;
yDist = ghost._y - turret._y;
ghostDist = Math.sqrt((xDist * xDist) + (yDist * yDist));
if (ghostDist <= smallest) {
smallest = ghostDist;
ghostChoice = g;
}
}
g--;
}
if (ghostChoice != -1) {
turret.Target = ghosts[ghostChoice];
}
}
if (turret.Target != null) {
xDist = turret.Target._x - turret._x;
yDist = turret.Target._y - turret._y;
distFromTurret = Math.sqrt((xDist * xDist) + (yDist * yDist));
framesToHit = ((distFromTurret / turretBulletSpeed) - 3) - 3;
newX = turret.Target._x + (turret.Target.xSpeed * framesToHit);
newY = turret.Target._y + (turret.Target.ySpeed * framesToHit);
turret.cannon._rotation = (Math.atan2(newY - turret._y, newX - turret._x) * 180) / Math.PI;
}
turret.shotDelay = turret.shotDelay - 1;
if ((turret.shotDelay <= 0) && (turret.Target != null)) {
turret.shotDelay = 90 + random(10);
createTurretBullet();
}
t--;
}
}
function removeTurret() {
turret.removeMovieClip();
turrets.splice(t, 1);
}
function createTurretBullet() {
typeHolder = ((turret.Type - 1) % 2) + 1;
if (typeHolder == 1) {
tB = attachMovie("bullet2", "bullet" + depth, depth++);
} else {
tB = attachMovie("bullet", "bullet" + depth, depth++);
}
tB.Type = typeHolder;
tB._x = turret._x;
tB._y = turret._y;
tB._rotation = turret.cannon._rotation;
tB.xSpeed = Math.cos((turret.cannon._rotation * Math.PI) / 180) * turretBulletSpeed;
tB.ySpeed = Math.sin((turret.cannon._rotation * Math.PI) / 180) * turretBulletSpeed;
tB._x = tB._x + (tB.xSpeed * 3);
tB._y = tB._y + (tB.ySpeed * 3);
turretBullets.push(tB);
}
function turretBulletManagement() {
t = turretBullets.length - 1;
while (t >= 0) {
tb = turretBullets[t];
tb._x = tb._x + tb.xSpeed;
tb._y = tb._y + tb.ySpeed;
g = ghosts.length - 1;
while (g >= 0) {
ghost = ghosts[g];
if (tb.hitTest(ghost)) {
if (tb.Type == 1) {
ghost.frozen = 50;
ghost.shotDelay = 1000;
}
if (tb.Type == 2) {
ghost.health = ghost.health - 1;
if (ghost.health <= 0) {
poof.start();
poof.start();
removeGhost(true, g);
}
}
removeTurretBullet();
}
g--;
}
if (level.hitTest(tb._x, tb._y, true) && (tb._x != undefined)) {
fs = attachMovie("floorShot", "floorShot" + depth, depth++);
fs._x = tb._x;
fs._y = (Stage.height - lHeight) + 15;
fs._rotation = 270;
fs.gotoAndStop(random(3) + 1);
fs._xscale = (fs._yscale = 200);
removeTurretBullet();
} else if ((((tb._x >= (char._x + 2000)) || (tb._x <= (char._x - 2000))) || (tb._y >= (char._y + 2000))) || (tb._y <= (char._y - 2000))) {
if (tb._x != undefined) {
removeTurretBullet();
}
}
t--;
}
}
function removeTurretBullet() {
turretBullets[t].removeMovieClip();
turretBullets.splice(t, 1);
}
function railShot() {
rail.start();
laser.removeMovieClip();
createEmptyMovieClip("laser", 900555 + (depth++));
with (laser) {
lineStyle(5, 16777215);
tDir = (Math.atan2(_ymouse - char._y, _xmouse - char._x) * 180) / Math.PI;
xmoveAdd = Math.cos((tDir * Math.PI) / 180) * 10;
ymoveAdd = Math.sin((tDir * Math.PI) / 180) * 10;
currentX = char._x + (xmoveAdd * 4);
currentY = char._y + (ymoveAdd * 4);
holdX = currentX;
holdY = currentY;
moveTo(currentX, currentY);
t = 50;
while (t >= 0) {
currentX = currentX + xmoveAdd;
currentY = currentY + ymoveAdd;
if (t == 0) {
lineStyle(9, 16764108);
lineTo(currentX, currentY);
moveTo(holdX, holdY);
lineStyle(7, 16777215);
lineTo(currentX, currentY);
}
g = ghosts.length - 1;
while (g >= 0) {
ghost = ghosts[g];
if (ghost.hitTest(currentX, currentY, true)) {
ghost.health = ghost.health - 1;
if (ghost.health <= 0) {
if (inTutorial) {
giveTutorialAward(1);
}
poof.start();
poof.start();
removeGhost(true, g);
}
}
g--;
}
t--;
}
}
laser.onEnterFrame = function () {
laser._alpha = laser._alpha - 15;
if (laser._alpha <= 5) {
laser.removeMovieClip();
}
};
}
function hitGhost(num) {
ghost.health = ghost.health - 1;
if (ghost.health <= 0) {
poof.start();
poof.start();
theNum = -1;
g = ghosts.length - 1;
while (g >= 0) {
if (ghosts[g] == ghost) {
theNum = g;
}
g--;
}
removeGhost(true, theNum);
f = num + 1;
while (f <= ghosts.length) {
ghosts[f].Index = ghosts[f].Index - 1;
f++;
}
}
}
function electricityShot() {
if (lGo == 1) {
electricity.start();
}
mainArray = new Array(4);
i = 0;
while (i < 4) {
mainArray[i] = new Array(4);
j = 0;
while (j < 4) {
mainArray[i][j] = new Array();
j++;
}
i++;
}
i = ghosts.length - 1;
while (i >= 0) {
ghost = ghosts[i];
ghost.Index = i;
mainArray[Math.floor(ghost._x / 175)][Math.floor(ghost._y / 100)].push(ghost);
i--;
}
if (lGo == 1) {
bulletMC.removeMovieClip();
lGo = 2;
createEmptyMovieClip("bulletMC", 900555 + (depth++));
with (bulletMC) {
lineStyle(2, 0);
rt = Math.atan2(_ymouse - char._y, _xmouse - char._x);
xmoveAdd = Math.cos(rt) * 15;
ymoveAdd = Math.sin(rt) * 15;
currentX = char._x + (xmoveAdd * 4);
currentY = char._y + (ymoveAdd * 4);
moveTo(currentX, currentY);
t = 35;
while (t >= 0) {
currentX = currentX + xmoveAdd;
currentY = currentY + ymoveAdd;
if (mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)] != undefined) {
i = mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)].length - 1;
while (i >= 0) {
ghost = mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)][i];
if (ghost.hitTest(currentX, currentY, true)) {
t = -5;
hitGhost(ghost.Index);
}
i--;
}
}
lineTo((currentX + (Math.random() * 16)) - 8, (currentY + (Math.random() * 16)) - 8);
t--;
}
}
bulletMC.onEnterFrame = function () {
bulletMC._alpha = bulletMC._alpha - (bulletMC._alpha / 2);
if (bulletMC._alpha <= 5) {
bulletMC.removeMovieClip();
}
};
} else if (lGo == 2) {
bulletMC2.removeMovieClip();
lGo = 3;
createEmptyMovieClip("bulletMC2", 900555 + (depth++));
with (bulletMC2) {
lineStyle(2, 0);
rt = Math.atan2(_ymouse - char._y, _xmouse - char._x);
xmoveAdd = Math.cos(rt) * 15;
ymoveAdd = Math.sin(rt) * 15;
currentX = char._x + (xmoveAdd * 4);
currentY = char._y + (ymoveAdd * 4);
moveTo(currentX, currentY);
t = 35;
while (t >= 0) {
currentX = currentX + xmoveAdd;
currentY = currentY + ymoveAdd;
lineTo((currentX + (Math.random() * 16)) - 8, (currentY + (Math.random() * 16)) - 8);
if (mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)] != undefined) {
i = mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)].length - 1;
while (i >= 0) {
ghost = mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)][i];
if (ghost.hitTest(currentX, currentY, true)) {
t = -5;
hitGhost(ghost.Index);
}
i--;
}
}
t--;
}
}
bulletMC2.onEnterFrame = function () {
bulletMC2._alpha = bulletMC2._alpha - (bulletMC2._alpha / 2);
if (bulletMC2._alpha <= 5) {
bulletMC2.removeMovieClip();
}
};
} else if (lGo == 3) {
bulletMC3.removeMovieClip();
lGo = 1;
createEmptyMovieClip("bulletMC3", 900555 + (depth++));
with (bulletMC3) {
lineStyle(2, 0);
rt = Math.atan2(_ymouse - char._y, _xmouse - char._x);
xmoveAdd = Math.cos(rt) * 15;
ymoveAdd = Math.sin(rt) * 15;
currentX = char._x + (xmoveAdd * 4);
currentY = char._y + (ymoveAdd * 4);
moveTo(currentX, currentY);
t = 35;
while (t >= 0) {
currentX = currentX + xmoveAdd;
currentY = currentY + ymoveAdd;
lineTo((currentX + (Math.random() * 16)) - 8, (currentY + (Math.random() * 16)) - 8);
if (mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)] != undefined) {
i = mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)].length - 1;
while (i >= 0) {
ghost = mainArray[Math.floor(currentX / 175)][Math.floor(currentY / 100)][i];
if (ghost.hitTest(currentX, currentY, true)) {
t = -5;
hitGhost(ghost.Index);
}
i--;
}
}
t--;
}
}
bulletMC3.onEnterFrame = function () {
bulletMC3._alpha = bulletMC3._alpha - (bulletMC3._alpha / 2);
if (bulletMC3._alpha <= 5) {
bulletMC3.removeMovieClip();
}
};
}
}
stop();
times = new Array(20, 30, 40, 50, 60, 70, 80, 90, 150, 250, 350);
goalXPs = new Array(200, 400, 600, 800, 10000000);
enemyWorths = new Array(5, 10, 20, 50, 100, 250);
ringAmounts = new Array(5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70);
healthArray = new Array(60, 70, 80, 90, 100, 120, 140, 160, 200, 250);
initialGolds = new Array(0, 150, 300, 600, 1000, 1500, 2000, 3000, 5000, 8000);
qbtn.onRelease = function () {
if (_quality == "LOW") {
_quality = "MEDIUM";
} else if (_quality == "MEDIUM") {
_quality = "HIGH";
} else {
_quality = "LOW";
}
};
moneyTree.gotoAndStop(moneyTreeFrame);
inTutorial = true;
i = tasksCompleted.length - 1;
while (i >= 0) {
if (tasksCompleted[i]) {
inTutorial = false;
}
i--;
}
if (taskLevel != 1) {
inTutorial = false;
}
lHeight = 100;
init();
if (inTutorial) {
gamePause = true;
tutorial = attachMovie("tutorial", "tutorial", 987300);
tutorial._x = Stage.width / 2;
tutorial._y = Stage.height / 2;
}
if (inTutorial) {
money = 1000;
taskLevel = 0;
}
RING = 1;
DEATH = 2;
STATS = 3;
TIME = 4;
MISC = 5;
MONEY = 6;
WIND = 7;
muted = false;
playerPause = false;
keyListener = new Object();
keyListener.onKeyDown = function () {
num = Key.getAscii();
if (num == 113) {
if (_quality == "LOW") {
_quality = "MEDIUM";
} else if (_quality == "MEDIUM") {
_quality = "HIGH";
} else {
_quality = "LOW";
}
}
if (((num == 112) && (!gamePause)) && (!inTutorial)) {
playerPause = !playerPause;
pauseStuff();
}
if (num == 109) {
muted = !muted;
if (muted) {
song.setVolume(0);
} else {
song.setVolume(100);
}
}
if (num == 101) {
if (turretShopExists) {
turretShop.removeMovieClip();
gamePause = false;
turretShopExists = false;
} else if ((!inTutorial) || (!tasksCompleted[1])) {
if (inTutorial) {
if (tutorialStage == 5) {
createTurretShop();
}
} else {
createTurretShop();
}
}
}
};
Key.addListener(keyListener);
taskNames = new Array("Rings", "Death", "Stats", "Time", "Miscellaneous", "Coins", "Wind");
preTasks = new Array("Kill an enemy by shooting it", "Build a Turret (Press 'E')", "Gun Upgrade Press 'SPACE'");
taskPreTypes = new Array(DEATH, MISC, MISC);
task1s = new Array("Reach day 2", "Kill 20 ghosts", "Collect 10 rings");
task1Types = new Array(TIME, DEATH, RING);
task2s = new Array("Collect 100 coins", "Windfall Mode 10 seconds", "Score 1000");
task2Types = new Array(MONEY, WIND, STATS);
task3s = new Array("Don't get hit on day 1", "Reach day 3", "50 Kills in the air");
task3Types = new Array(MISC, MISC, DEATH);
task4s = new Array("Windfall Mode 5 Times", "Windfall Mode 30 seconds", "First two days no rings");
task4Types = new Array(WIND, WIND, MISC);
task5s = new Array("Reach day 5", "Score 20,000", "Get the 4th Weapon");
task5Types = new Array(TIME, STATS, MISC);
task6s = new Array("Collect 100 rings", "Collect 15 rings day 1", "Reach day 4 w/ pistol");
task6Types = new Array(RING, RING, MISC);
task7s = new Array("Build 7 turrets", "Windfall Mode 200 kills", "Windfall Mode 2 minutes");
task7Types = new Array(MISC, DEATH, WIND);
task8s = new Array("Reach day 7", "Collect 150 rings", "Save up $25,000");
task8Types = new Array(TIME, RING, MONEY);
task9s = new Array("First three levels no missing", "Reach day 9", "Kill 1000 ghosts");
task9Types = new Array(MISC, TIME, DEATH);
task10s = new Array("None", "None", "None");
task10Types = new Array(DEATH, DEATH, DEATH);
tasks = new Array(task1s, task2s, task3s, task4s, task5s, task6s, task7s, task8s, task9s, task10s);
taskTypes = new Array(task1Types, task2Types, task3Types, task4Types, task5Types, task6Types, task7Types, task8Types, task9Types, task10Types);
startTreeAnim = false;
toWhiteAmt = 0;
myColor2 = new Color(moneyTree);
myColor2.setTint(255, 255, 255, toWhiteAmt);
delayToDone = -1;
menuSong.stop();
song = new Sound(this);
song.attachSound("song.wav");
song.start(0, 100000);
var pistol = new Sound();
pistol.attachSound("pistol.wav");
var AK47 = new Sound();
AK47.attachSound("AK47.wav");
var gunshot = new Sound();
gunshot.attachSound("gunshot.wav");
var Ring = new Sound();
Ring.attachSound("Ring.wav");
var Ring2 = new Sound();
Ring2.attachSound("Ring2.wav");
var shotgun = new Sound();
shotgun.attachSound("shotgun.wav");
var grenade = new Sound();
grenade.attachSound("grenade.wav");
var pHit = new Sound();
pHit.attachSound("pHit.wav");
var poof = new Sound();
poof.attachSound("poof.wav");
var bHover = new Sound();
bHover.attachSound("bHover.wav");
var bClick = new Sound();
bClick.attachSound("bClick.wav");
var rail = new Sound();
rail.attachSound("laserShot.wav");
var electricity = new Sound();
electricity.attachSound("electricity.wav");
char.swapDepths(750500);
stars = new Array();
tutComplete.swapDepths(750600);
if (isMuted) {
muted = true;
song.setVolume(0);
}
tutorialGhostDelay = 20;
newWaveDelayConst = 40;
newWaveDelay = 0;
tutorialStage = 0;
tutorialDescriptions = new Array("Welcome, this is a quick tutorial which will familiarize you with the game mechanics...", "You can double jump by pressing the UP or W button TWICE in a row. Try it.", "You can shoot with your mouse. Hold it down for a few seconds for a constant stream of bullets.", "Collecting rings will you give you a bonus to your score. 3 Rings and you will enter windfall mode (Double Money)!", "The goal of the game is to complete tasks, try the ones I put in the bottom right of your screen");
timeToCreateLevelFin = 0;
createLevelFin = false;
mDownTime = 0;
theVertSpeed = 1;
goingDown = true;
goingUp = false;
normalY = 161;
if (!inTutorial) {
dayUp.gotoAndPlay(2);
dayUp.d1.dTxt.htmlText = bold("DAY " + onWave);
}
killsMax = 1000;
ringsMax = 100;
timeMax = 1000;
scoreMax = 10000;
ghosts = new Array();
ghostDelay = 0;
ghostsAllowedArray = new Array(1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5);
ghostDelayArray = new Array(40, 30, 25, 20, 16, 13, 11, 9, 7, 5);
ghostsAllowed = 5;
ghostTypes = new Array("ghost", "ghost2", "ghost3", "ghost4", "ghost5");
ghostShots = new Array();
coins = new Array();
coinsCollected = 0;
toFinish = false;
windfallKills = 0;
shakeDir = 0;
gravity = 1.2;
friction = 0.8;
airFriction = 0.95;
speed = 2;
inRealTutorial = false;
onMouseDown = function () {
if (inTutorial) {
if ((tutorialStage == 1) && (inRealTutorial)) {
tutorialNext(2);
tutBox.ctc._alpha = 0;
}
if (tutorial._currentframe != 5) {
tutorial.gotoAndStop(tutorial._currentframe + 1);
} else {
tutorial.removeMovieClip();
gamePause = false;
inRealTutorial = true;
tutorialNext(1);
}
}
mDown = true;
};
onMouseUp = function () {
if (turretToPlace != null) {
readyToPlace = false;
turretToPlace.Type = turretToPlaceNum + 1;
turretToPlace.seekDelay = 0;
turretToPlace.shotDelay = 0;
turrets.push(turretToPlace);
if (turrets.length >= 7) {
giveAward(19);
}
if (inTutorial) {
giveTutorialAward(2);
turretShop.removeMovieClip();
gamePause = false;
}
turretToPlace.Target = null;
turretToPlace = null;
turretToPlaceNum = -1;
}
mDown = false;
};
shotDelays = new Array(10, 5, 10, 5, 2, 5, 0);
depth = 100;
bullets = new Array();
shake = 0;
weaponsOwned = new Array(true, false, false, false, false, false);
weaponDescriptions = new Array("The Pistol shoots at a slow speed.", "The Ak-47 shoots at a moderate speed.", "The Shotgun shoots bursts of 3 bullets.", "The Grenade Launcher damages surrounding enemies.", "The Chain Gun shoots extremely fast.", "The Rail Gun shoots unstoppable beams.");
weaponCosts = new Array(0, 150, 1000, 2500, 6000, 18000, 50000, 99999999);
levelToCenter = false;
levelToExit = false;
achToCenter = false;
achToExit = false;
turretShopExists = false;
turrets = new Array();
turret1Costs = new Array(200, 1000, 5000, 10000, 20000, 50000, 100000);
turret2Costs = new Array(1000, 5000, 10000, 20000, 50000, 100000);
turret3Costs = new Array(200, 1000, 5000, 10000, 20000, 50000, 100000);
turret4Costs = new Array(1000, 5000, 10000, 20000, 50000, 100000);
turretCosts = new Array(turret1Costs, turret2Costs, turret3Costs, turret4Costs);
turretNames = new Array("Air Freeze", "Air Fire", "Ground Freeze", "Ground Fire");
turretDescriptions = new Array("Freezes Air Enemies", "Shoots Air Enemies", "Freezes Ground Enemies", "Shoots Ground Enemies");
theTurrets = new Array("simpleTurret2", "simpleTurret", "topTurret", "topTurret2");
turretYs = new Array(300, 300, 22, 22);
turretToPlace = null;
turretToPlaceNum = -1;
readyToPlace = false;
turretBulletSpeed = 20;
turretBullets = new Array();
lGo = 1;
Frame 5
function createNormalHover(button) {
button._alpha = 100;
button.onRollOver = function () {
button._alpha = 75;
};
button.onRollOut = function () {
button._alpha = 100;
};
button.onReleaseOutside = function () {
button._alpha = 100;
};
}
createNormalHover(bb);
bb.onRelease = function () {
gotoAndStop (3);
};
createNormalHover(st);
st.onRelease = function () {
getURL ("http://www.sound-tricks.com/", "_BLANK");
};
ag.onRollOver = function () {
ag._alpha = 50;
};
ag.onRollOut = function () {
ag._alpha = 100;
};
ag.onRelease = function () {
getURL ("http://armorgames.com/", "_BLANK");
};
Frame 6
function createNormalHover(button) {
button._alpha = 100;
button.onRollOver = function () {
button._alpha = 75;
};
button.onRollOut = function () {
button._alpha = 100;
};
button.onReleaseOutside = function () {
button._alpha = 100;
};
}
function onEnterFrame() {
}
Key.removeListener(keyListener);
createNormalHover(bb);
bb.onRelease = function () {
gotoAndStop (3);
};
createNormalHover(mg);
mg.onRelease = function () {
getURL ("http://armorgames.com/", "_BLANK");
};
Frame 7
function onEnterFrame() {
}
Symbol 25 MovieClip Frame 10
_parent.gotoAndStop(1);
Symbol 36 MovieClip Frame 11
_parent.gotoAndStop(1);
Symbol 46 MovieClip Frame 8
_parent.gotoAndStop(1);
Symbol 47 MovieClip [gunshots] Frame 1
stop();
Symbol 47 MovieClip [gunshots] Frame 2
stop();
Symbol 71 MovieClip Frame 1
stop();
Symbol 84 MovieClip Frame 1
stop();
Symbol 102 MovieClip Frame 1
_root.stop();
gotoAndPlay (2);
Symbol 102 MovieClip Frame 225
_root.nextFrame();
Symbol 107 MovieClip Frame 1
gotoAndPlay(random(29) + 2);
Symbol 107 MovieClip Frame 31
gotoAndPlay (2);
Symbol 121 MovieClip Frame 1
stop();
Symbol 149 MovieClip Frame 1
stop();
Symbol 163 MovieClip Frame 1
stop();
Symbol 168 MovieClip Frame 1
stop();
Symbol 182 MovieClip Frame 1
stop();
Symbol 284 MovieClip Frame 48
_parent.removeMovieClip();
Symbol 290 MovieClip Frame 30
gotoAndPlay (1);
Symbol 301 MovieClip [bullet] Frame 1
stop();
Symbol 336 MovieClip [ranger] Frame 10
this.removeMovieClip();
Symbol 353 MovieClip Frame 14
_parent.removeMovieClip();
Symbol 367 MovieClip Frame 12
_parent.removeMovieClip();
Symbol 382 MovieClip Frame 14
_parent.removeMovieClip();
Symbol 391 MovieClip [theBar] Frame 1
stop();
Symbol 401 MovieClip Frame 1
stop();
Symbol 406 MovieClip Frame 1
stop();
Symbol 410 MovieClip Frame 1
stop();
Symbol 415 MovieClip Frame 1
stop();
Symbol 419 MovieClip [coin2] Frame 30
this.removeMovieClip();
Symbol 422 MovieClip Frame 1
stop();
Symbol 427 MovieClip Frame 1
stop();
Symbol 427 MovieClip Frame 160
gotoAndStop (1);
Symbol 432 MovieClip Frame 1
stop();
Symbol 447 MovieClip Frame 1
stop();
Symbol 462 MovieClip Frame 1
stop();
Symbol 474 MovieClip Frame 1
stop();
Symbol 488 MovieClip Frame 1
stop();
Symbol 490 MovieClip Frame 1
stop();
Symbol 518 MovieClip [mBonus] Frame 80
this.removeMovieClip();
Symbol 533 MovieClip Frame 1
stop();
Symbol 545 MovieClip [bullet2] Frame 1
stop();
Symbol 571 MovieClip [tutorial] Frame 1
stop();
Symbol 582 MovieClip Frame 1
stop();