Frame 1
function makegamevars() {
smd = SharedObject.getLocal("SMD_save_data");
levelnames = new Array("", "Yoshi's Island", "Yoshi's Island 2", "Donut Plains", "Donut Ghost House", "Vanilla Dome", "Red Switch Palace", "Cookie Mountain", "Cheese Bridge", "Butter Bridge", "Butter Bridge 2", "Forest Of Illusion", "Forest Fortress", "Chocolate Island", "Choco-Ghost House", "Valley Of Bowser", "Valley Of Bowser 2", "Star Road", "Valley Fortress", "Valley Fortress 2", "Special Zone");
musictypes = new Array("", 0, 1, 5, 6, 5, 3, 1, 0, 2, 3, 4, 4, 2, 6, 5, 5, 4, 6, 2, 3);
medalnames = new Array("", "Gold", "Silver", "Bronze");
musicnames = new Array("Overworld 1", "Overworld 2", "Underworld", "Underwater", "Forest Of Illusion", "Vanilla Dome", "Bowser's Castle");
diffs = new Array("Easy", "Medium", "Hard", "Extreme");
bgnumbers = new Array(0, 1, 2, 3, 5, 6, 12, 10, 15, 10, 10, 2, 8, 19, 5, 6, 17, 11, 14, 18, 16);
lastmenux = 300;
freeplvl = 1;
freemusic = 0;
freemusicplay = false;
freediff = 0;
gamename = "Super_Mario_Defence";
sentScore = 0;
gotcheats = false;
moneycheat = false;
clickkill = false;
clickboo = false;
holdshell = false;
randomenemies = false;
nolimits = false;
randombgs = false;
loadgamestuff();
}
function loadgamestuff() {
if (smd.data.madedata == undefined) {
level = 1;
passedlevels = new Array();
i = 0;
while (i < 20) {
passedlevels.push(false);
i++;
}
levelscores = new Array();
i = 0;
while (i < 20) {
levelscores.push(0);
i++;
}
levelmedals = new Array();
i = 0;
while (i < 20) {
levelmedals.push(4);
i++;
}
maxlevel = 4;
autowave = false;
particleeffects = true;
enhealths = true;
soundeffects = true;
musicon = true;
quality = 3;
totalscore = 0;
subscores = 3;
cheated = false;
makesavegamevars();
} else if (smd.data.madedata == true) {
level = smd.data.level;
passedlevels = smd.data.passedlevels;
levelscores = smd.data.levelscores;
levelmedals = smd.data.levelmedals;
maxlevel = smd.data.maxlevel;
autowave = smd.data.autowave;
particleeffects = smd.data.particleeffects;
soundeffects = smd.data.soundeffects;
musicon = smd.data.musicon;
quality = smd.data.quality;
totalscore = smd.data.totalscore;
subscores = smd.data.subscores;
cheated = smd.data.cheated;
enhealths = smd.data.enhealths;
}
}
function makesavegamevars() {
if (smd.data.madedata == undefined) {
smd.data.madedata = true;
smd.data.level = 1;
smd.data.passedlevels = new Array();
i = 0;
while (i < 20) {
smd.data.passedlevels.push(false);
i++;
}
smd.data.levelscores = new Array();
i = 0;
while (i < 20) {
smd.data.levelscores.push(0);
i++;
}
smd.data.levelmedals = new Array();
i = 0;
while (i < 20) {
smd.data.levelmedals.push(4);
i++;
}
smd.data.maxlevel = 4;
smd.data.autowave = true;
smd.data.particleeffects = true;
smd.data.soundeffects = true;
smd.data.musicon = true;
smd.data.quality = 3;
smd.data.totalscore = 0;
smd.data.seenstory = false;
smd.data.subscores = 3;
smd.data.cheated = false;
smd.data.enhealths = true;
}
}
function savegame() {
smd.data.level = level;
smd.data.passedlevels = passedlevels;
smd.data.levelscores = levelscores;
smd.data.levelmedals = levelmedals;
smd.data.maxlevel = maxlevel;
smd.data.autowave = autowave;
smd.data.particleeffects = particleeffects;
smd.data.soundeffects = soundeffects;
smd.data.musicon = musicon;
smd.data.quality = quality;
smd.data.totalscore = totalscore;
smd.data.subscores = subscores;
smd.data.cheated = cheated;
smd.data.enhealths = enhealths;
}
function newgame() {
level = 1;
passedlevels = new Array();
i = 0;
while (i < 20) {
passedlevels.push(false);
i++;
}
levelscores = new Array();
i = 0;
while (i < 20) {
levelscores.push(0);
i++;
}
levelmedals = new Array();
i = 0;
while (i < 20) {
levelmedals.push(4);
i++;
}
maxlevel = 4;
autowave = true;
particleeffects = true;
soundeffects = true;
musicon = true;
quality = 3;
totalscore = 0;
subscores = 3;
cheated = false;
enhealths = true;
savegame();
}
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);
}
Stage.showMenu = false;
makegamevars();
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);
if (domain != "flashgamelicense.com") {
}
__com_mochibot__("23ea6ff5", this, 10301, true);
stop();
NewgroundsAPI.connectMovie(5022);
Frame 2
function makevars() {
health = 100;
pressed = false;
skey = 1;
wave = 0;
xspeed = 0;
res = 0.6;
xac = 5;
endtimer = 0;
xsmax = 10;
score = 0;
enemieskilled = 0;
enemiessent = 0;
fadeoutpause = false;
mouseListener = new Object();
scrolltowers = new Object();
pkey = false;
pauseheld = false;
clickvar = false;
scrolltowers.onKeyDown = function () {
if (!gamepaused) {
if (Key.getCode() == 69) {
_root.nexttower();
}
if (Key.getCode() == 81) {
_root.prevtower();
}
}
};
mouseListener.onMouseWheel = function (wheeldir) {
if (!gamepaused) {
xspeed = xspeed + Math.round(wheeldir * 2);
}
};
Mouse.addListener(mouseListener);
Key.addListener(scrolltowers);
enemies = new Array();
towers = new Array();
gcoins = new Array();
bullets = new Array();
parts = new Array();
healthtexts = new Array();
waves = new Array();
costs = new Array(0, 30, 40, 60, 70, 65, 100, 150, 180, 250, 150, 140, 300, 500);
menu.endy = -20;
menu.endx = 670;
bubactive = false;
placeable = true;
enemynames = new Array("noname", "Baby Mario", "Baby Luigi", "Baby Mario on Yoshi", "Baby Luigi on Yoshi", "Mario", "Luigi", "Mario on Yoshi", "Luigi on Yoshi", "Fire Mario", "Fire Luigi", "Giant Mario on Yoshi", "Giant Fire Luigi");
towernames = new Array("noname", "Spring Board", "Bomb-omb Cloud", "Thwomp", "Koopa Pipe", "Ninji Platform", "Hammer Bros.", "Bullet Bill Tower", "Mecha Koopa Pipe", "Mega Mole Hole", "Wiggler Pipe", "Boo Pipe", "Swinging Stone", "Volcano Lotus");
mintower = 1;
itembannerpos = 1;
menulock = true;
updown = false;
shaketime = 0;
shakemag = 0;
obstruct = false;
grouptimer = 0;
groupamaount = 0;
attachMovie("topmenu", "menu", _root.getNextHighestDepth());
menu._x = 300;
menu._y = -30;
attachMovie("rightmenu", "rmenu", _root.getNextHighestDepth());
exclam = attachMovie("exclam", "exclam", _root.getNextHighestDepth());
exclam._x = 550;
exclam._y = 190;
rmenu._x = 670;
rmenu._y = 190;
rmenu.rx = 0;
enemycount = 0;
waveframe = 1;
gamepaused = false;
startbound = -600;
endbound = 600;
countingends = new Array("", "bounces", "bombs dropped", "enemies squashed", "shells fired", "ninjis dropped", "hammers thrown", "bullets fired", "mecha koopas released", "moles freed", "wigglers escaped", "boos released", "enemies hit", "fireballs spit");
if (!randombgs) {
bg.bg1.gotoAndStop(bgframe);
bg.bg2.gotoAndStop(bgframe);
} else {
ranframe = random(19) + 1;
bg.bg1.gotoAndStop(ranframe);
bg.bg2.gotoAndStop(ranframe);
}
t1upgrades = new Array(false, true, false);
t1range = new Array();
t1rangecost = new Array();
t1damage = new Array(1, 2, 4, 6, 10, 15, 20, 25, 30, 40);
t1damagecost = new Array(0, 5, 5, 15, 30, 75, 100, 150, 350, 600);
t1reload = new Array();
t1reloadcost = new Array();
t2upgrades = new Array(true, true, true);
t2range = new Array(250, 300, 350, 450);
t2rangecost = new Array(0, 60, 180, 300);
t2damage = new Array(2, 4, 8, 20, 30, 40);
t2damagecost = new Array(0, 10, 15, 35, 50, 65);
t2reload = new Array(45, 40, 35, 30, 25, 20);
t2reloadcost = new Array(0, 15, 15, 20, 20, 30);
t3upgrades = new Array(true, true, true);
t3range = new Array(50, 100, 150, 200, 250, 300);
t3rangecost = new Array(0, 70, 100, 150, 200, 300);
t3damage = new Array(5, 10, 15, 20, 25, 30, 35, 40, 45, 50);
t3damagecost = new Array(0, 40, 70, 100, 150, 160, 170, 180, 190, 200);
t3reload = new Array(50, 45, 40, 35, 30, 25);
t3reloadcost = new Array(0, 20, 35, 60, 125, 250);
t4upgrades = new Array(true, true, false);
t4range = new Array(500, 525, 550, 575, 600);
t4rangecost = new Array(0, 50, 80, 130, 170);
t4damage = new Array(2, 4, 6, 8, 10, 15, 20);
t4damagecost = new Array(0, 20, 40, 80, 100, 250, 350);
t4reload = new Array();
t4reloadcost = new Array();
t5upgrades = new Array(true, false, true);
t5range = new Array(200, 250, 300, 350);
t5rangecost = new Array(0, 50, 100, 200);
t5damage = new Array();
t5damagecost = new Array();
t5reload = new Array(50, 45, 40, 35, 30);
t5reloadcost = new Array(0, 15, 30, 60, 100);
t6upgrades = new Array(true, true, false);
t6range = new Array(300, 325, 350, 375, 400);
t6rangecost = new Array(0, 40, 75, 150, 250);
t6damage = new Array(4, 6, 8, 10, 12, 14, 16, 18, 20);
t6damagecost = new Array(0, 25, 60, 80, 110, 160, 200, 250, 300);
t6reload = new Array();
t6reloadcost = new Array();
t7upgrades = new Array(false, true, true);
t7range = new Array();
t7rangecost = new Array();
t7damage = new Array(20, 25, 30, 35, 40, 45, 50, 55, 60);
t7damagecost = new Array(0, 35, 60, 75, 100, 140, 200, 270, 350);
t7reload = new Array(46, 44, 42, 40, 38, 36, 34, 32, 30);
t7reloadcost = new Array(0, 10, 30, 55, 70, 100, 150, 250, 300);
t8upgrades = new Array(false, true, true);
t8range = new Array();
t8rangecost = new Array();
t8damage = new Array(20, 22, 24, 26, 28, 30, 35, 40, 50);
t8damagecost = new Array(0, 30, 60, 100, 150, 250, 500, 750, 1000);
t8reload = new Array(60, 57, 54, 51, 48, 45, 40);
t8reloadcost = new Array(0, 50, 80, 100, 150, 210, 400);
t9upgrades = new Array(false, true, true);
t9range = new Array();
t9rangecost = new Array();
t9damage = new Array(2, 3, 4, 5);
t9damagecost = new Array(0, 100, 250, 500);
t9reload = new Array(70, 65, 60);
t9reloadcost = new Array(0, 150, 300);
t10upgrades = new Array(false, true, true);
t10range = new Array();
t10rangecost = new Array();
t10damage = new Array(14, 16, 18, 20, 22, 24, 26, 28, 30, 35, 40, 50);
t10damagecost = new Array(0, 20, 30, 50, 70, 100, 150, 150, 200, 400, 500, 1000);
t10reload = new Array(60, 55, 50, 40);
t10reloadcost = new Array(0, 50, 150, 250);
t11upgrades = new Array(true, true, true);
t11range = new Array(500, 525, 550, 575, 600, 650);
t11rangecost = new Array(0, 40, 80, 100, 130, 180);
t11damage = new Array(1, 2, 3, 4, 5);
t11damagecost = new Array(0, 50, 200, 500, 1000);
t11reload = new Array(100, 95, 90, 85, 80, 75, 50);
t11reloadcost = new Array(0, 25, 40, 70, 100, 200, 350);
t12upgrades = new Array(false, true, false);
t12range = new Array();
t12rangecost = new Array();
t12damage = new Array(1, 2, 3, 4, 5);
t12damagecost = new Array(0, 100, 250, 500, 1000);
t12reload = new Array();
t12reloadcost = new Array();
t13upgrades = new Array(true, true, true);
t13range = new Array(100, 120, 140, 160, 180, 200);
t13rangecost = new Array(0, 50, 100, 200, 250, 300);
t13damage = new Array(10, 15, 20, 25, 30, 35, 40, 45, 50);
t13damagecost = new Array(0, 50, 100, 150, 200, 250, 300, 400, 500);
t13reload = new Array(50, 48, 46, 44, 42, 40, 35, 30);
t13reloadcost = new Array(0, 60, 100, 150, 210, 280, 350, 450);
}
function raisemenus() {
menu.swapDepths(_root.getNextHighestDepth());
rmenu.swapDepths(_root.getNextHighestDepth());
}
function grav(ob, grav) {
if (ob.yspeed == undefined) {
ob.yspeed = 0;
ob.grounded = true;
}
ob.yspeed = ob.yspeed + grav;
ob._y = ob._y + ob.yspeed;
if (ob.grounded) {
while (ground.hitTest(ob._x, ob.getBounds(_root).yMax, true)) {
ob.yspeed = 0;
ob._y--;
}
}
}
function keepstationary(ob, variable) {
if (!variable) {
if (ob.startx == undefined) {
ob.startx = ob._x;
}
ob._x = ob.startx - _root._x;
} else {
if (ob.startx == undefined) {
ob.startx = ob._x;
ob.rx = 0;
}
ob._x = (ob.startx - _root._x) + ob.rx;
}
}
function moveground() {
if ((bg._x + _x) > 600) {
bg.rx = bg.rx - 600;
}
if ((bg._x + _x) < 0) {
bg.rx = bg.rx + 600;
}
_x = (_x + xspeed);
if (_x > endbound) {
xspeed = 0;
_x = endbound;
}
if (_x < startbound) {
xspeed = 0;
_x = startbound;
}
keepstationary(menu, false);
keepstationary(exclam, false);
keepstationary(bg, true);
keepstationary(rmenu, true);
xspeed = xspeed * res;
bg.rx = bg.rx + (xspeed / 5);
if (Key.isDown(37) || (Key.isDown(65))) {
xspeed = xspeed + (xac * skey);
}
if (Key.isDown(39) || (Key.isDown(68))) {
xspeed = xspeed - (xac * skey);
}
bground._x = ground._x;
bground._y = ground._y;
}
function shortcuts() {
if (Key.isDown(83) || (Key.isDown(40))) {
skey = 2;
} else {
skey = 1;
}
if (bubactive) {
if (!bubbleob.enemy) {
if (Key.isDown(88)) {
bubbleob.sold = true;
}
}
}
if (moneycheat) {
if (Key.isDown(77)) {
coins = coins + 10;
}
}
}
function moveob(ob) {
if (ob.startx == undefined) {
ob.startx = ob._x;
ob._x = 0;
}
ob._x = (ob.startx + ob._x) + (ground._x - 300);
}
function makehugground(o) {
o.rb = _root.createEmptyMovieClip((o + "rb") + _root.getNextHighestDepth(), _root.getNextHighestDepth());
o.lb = _root.createEmptyMovieClip((o + "lb") + _root.getNextHighestDepth(), _root.getNextHighestDepth());
o.lb._x = o._x - (o._width / 2);
o.rb._x = o._x + (o._width / 2);
o.rb._y = o._y + (o._height / 2);
o.lb._y = o._y + (o._height / 2);
}
function movehugground(o, grav) {
o.lb._x = o._x - (o._width / 2);
o.rb._x = o._x + (o._width / 2);
o.yspeedl = o.yspeedl + grav;
e.yspeedr = e.yspeedr + grav;
o.lb._y = o.lb._y + o.yspeedl;
o.rb._y = o.rb._y + o.yspeedr;
if (!ob.dead) {
o._rotation = 57.2957795130823 * Math.atan2(o.rb._y - o.lb._y, o.rb._x - o.lb._x);
}
if (o.enemy) {
if (o.grounded) {
while (ground.hitTest(o.lb._x, o.lb._y, true)) {
o.lb._y--;
o.yspeedl = 0;
o.jumping = false;
if (o.falldam != 0) {
o.damage = o.damage + o.falldam;
o.falldam = 0;
b = 0;
while (b < 10) {
makepart(o._x, o._y + 30, 1, 100, 4);
b++;
}
}
}
while (ground.hitTest(o.rb._x, o.rb._y, true)) {
o.rb._y--;
o.yspeedr = 0;
o.jumping = false;
if (o.falldam != 0) {
o.damage = o.damage + o.falldam;
o.falldam = 0;
b = 0;
while (b < 10) {
makepart(o._x, o._y + 30, 1, 100, 4);
b++;
}
}
}
}
} else {
while (ground.hitTest(o.lb._x, o.lb._y, true)) {
o.lb._y--;
o.yspeed = 0;
}
while (ground.hitTest(o.rb._x, o.rb._y, true)) {
o.rb._y--;
o.yspeed = 0;
}
}
}
function makehealthtext(e) {
d = _root.getNextHighestDepth();
t = attachMovie("enemytext", "enemytext" + d, d);
t._x = e._x;
t._y = e._y;
t.e = e;
t.healthtext = e.maxdam - e.damage;
healthtexts.push(t);
}
function movehealthtexts() {
for (i in healthtexts) {
t = healthtexts[i];
t._x = t.e._x;
t._y = t.e._y;
if ((t.e.maxdam - t.e.damage) > 0) {
t.healthtext = t.e.maxdam - t.e.damage;
} else {
t.healthtext = 0;
}
if (t.healthtext == 0) {
removeMovieClip(t);
healthtexts.splice(i, 1);
}
}
}
function makeenemy(x, y, type, speed, dam, payoff) {
enemiessent++;
d = _root.getNextHighestDepth();
if (randomenemies) {
type = random(12) + 1;
}
e = attachMovie("enemy" + type, ("enemy" + type) + d, d);
if (enhealths) {
makehealthtext(e);
}
e._x = x;
e._y = y;
e.type = type;
e.ninjid = 0;
e.payoff = payoff;
prepwalk(e.w);
e.yspeedl = 0;
e.yspeedr = 0;
e.enemy = true;
e.stopground = true;
e.speed = speed;
e.damage = 0;
e.grounded = true;
e.molehit = 0;
e.stonehit = 0;
e.maxdam = dam;
e.dead = false;
makehugground(e);
e.radius = Math.max(e._height, e._width) * 1.5;
e.falldam = 0;
e.jumping = false;
enemies.push(e);
}
function moveenemies() {
for (i in enemies) {
e = enemies[i];
if (checkbound(e)) {
e._visible = true;
} else {
e._visible = false;
}
e._y = ((e.lb._y + e.rb._y) / 2) - (e._height / 2);
if (e.jumping) {
e.gotoAndStop(2);
} else {
e.gotoAndStop(1);
}
e.healthtext = e.maxdam - e.damage;
walk(e.w, 6 - e.speed);
movehugground(e, 1.6);
if (!e.dead) {
e._x = e._x + (Math.cos(0.0174 * e._rotation) * e.speed);
if (e.damage >= e.maxdam) {
e.yspeedl = -10;
e.yspeedr = -10;
e.grounded = false;
e.dead = true;
makecoin(e._x, e._y - (e._height / 2));
coins = coins + e.payoff;
playsound(clicks, e);
enemieskilled++;
}
} else {
e.gotoAndStop(3);
}
if (e._y > (400 + (e._height / 2))) {
removeMovieClip(e.lb);
removeMovieClip(e.rb);
removeMovieClip(e);
enemies.splice(i, 1);
}
}
}
function walk(ob, speed) {
if (ob.c == undefined) {
ob.stop();
ob.c = 0;
ob.f = 1;
ob.m = ob._totalframes;
}
ob.speed = speed;
ob.c++;
if (ob.c > ob.speed) {
ob.f++;
ob.c = 0;
if (ob.f > ob.m) {
ob.f = 1;
}
ob.gotoAndStop(ob.f);
}
}
function buttonize(ob, esize, frame, active) {
if (ob.esize == undefined) {
ob.esize = ob._xscale;
}
if (ob.hitTest(_xmouse, _ymouse, false)) {
ob.esize = esize;
} else {
ob.esize = 100;
}
ob._xscale = ob._xscale + ((ob.esize - ob._xscale) / 1.5);
ob._yscale = ob._yscale + ((ob.esize - ob._yscale) / 1.5);
if (active) {
ob.onRelease = function () {
gotoAndStop(frame);
if (soundeffects) {
playsound(clicks);
}
};
}
}
function movemenu() {
menu._y = menu._y + ((menu.endy - menu._y) / 2);
rmenu.rx = rmenu.rx + ((menu.endx - rmenu.rx) / 2);
if (!menulock) {
if ((menu.hitTest(_xmouse, _ymouse, true) || (Key.isDown(40))) || (Key.isDown(90))) {
menu.endy = 42;
} else {
menu.endy = -15;
}
} else {
menu.endy = 42;
}
updatetopmenutext();
menu.clock.onRollOver = function () {
menu.clock.gotoAndStop(2);
};
menu.clock.onRollOut = function () {
menu.clock.gotoAndStop(1);
};
menu.clock.onReleaseOutside = function () {
menu.clock.gotoAndStop(1);
};
menu.clock.onRelease = function () {
if (!gamepaused) {
if (nolimits) {
menu.clock.hand._rotation = 0;
} else if ((menu.clock.hand._rotation > 90) || (menu.clock.hand._rotation < 0)) {
menu.clock.hand._rotation = 0;
} else {
playsound(deny2);
}
}
};
menu.previtem.onRelease = function () {
if (!gamepaused) {
prevtower();
}
};
menu.nextitem.onRelease = function () {
if (!gamepaused) {
nexttower();
}
};
menu.key.onRelease = function () {
if (!gamepaused) {
menulock = (menulock ? false : true);
}
};
menu.pbutton.onRelease = function () {
if (gamepaused) {
gamepaused = false;
fadeoutpause = true;
playsound(pausesound);
musicarray[musictypes[level]].setVolume(100);
} else {
if (pmenu != undefined) {
removeMovieClip(pmenu);
fadeoutpause = false;
}
playsound(continuesound);
musicarray[musictypes[level]].setVolume(25);
gamepaused = true;
attachMovie("pmenu", "pmenu", _root.getNextHighestDepth());
pmenu._x = 300 - _x;
pmenu._y = 200;
pmenu._alpha = 0;
if (_currentframe == 32) {
pmenu.currentlevel = "Level: " + levelnames[freeplvl];
} else if (_currentframe == 11) {
pmenu.currentlevel = "Level: Tutorial";
} else {
pmenu.currentlevel = "Level: " + levelnames[level];
}
}
};
if (fadeoutpause) {
if (pmenu._alpha > 0) {
pmenu._alpha = pmenu._alpha - 15;
} else {
removeMovieClip(pmenu);
}
}
if (itembannerpos < mintower) {
itembannerpos = mintower;
menu.itempic.itembanner._x = (itembannerpos - 1) * -50;
menu.towerde._y = (itembannerpos - 1) * -70;
}
}
function bublight(ob) {
bubbleob = ob;
bubactive = true;
}
function movebubble() {
if (bubactive) {
bubble._visible = true;
bubble._x = bubbleob._x;
bubble._y = bubbleob._y;
bubble._width = (bubble._height = bubbleob.radius);
menu.endx = -140;
updatermenu(bubbleob);
} else {
bubble._visible = false;
bubactive = false;
menu.endx = 10;
}
if (bubbleob.dead) {
bubactive = false;
}
if ((!checkbound(bubble)) || (bubble._y > 420)) {
bubactive = false;
}
}
function updatermenu(ob) {
if (ob.enemy == true) {
rmenu.gotoAndStop(1);
rmenu.iname = enemynames[ob.type];
if ((100 - ((ob.damage / ob.maxdam) * 100)) > 0) {
rmenu.bar._xscale = 100 - ((ob.damage / ob.maxdam) * 100);
} else {
rmenu.bar._xscale = 0;
}
rmenu.pic.gotoAndStop(ob.type);
if ((ob.maxdam - ob.damage) >= 0) {
rmenu.healthtext = ((ob.maxdam - ob.damage) + " / ") + ob.maxdam;
} else {
rmenu.healthtext = "0 / " + ob.maxdam;
}
rmenu.payoff = ob.payoff;
if (ob.dead) {
rmenu.statusmess = "Status : Dead";
} else if (ob.hitTest(castle)) {
rmenu.statusmess = "Status : Intruding";
} else {
if (ob.jumping == true) {
if (ob.yspeedl < 0) {
rmenu.statusmess = "Status : Jumping";
} else {
rmenu.statusmess = "Status : Falling";
}
} else {
rmenu.statusmess = "Status : Walking";
}
if (rmenu.bar._xscale < 0) {
rmenu.bar._xscale = 0;
}
}
} else {
rmenu.gotoAndStop(2);
rmenu.pic.gotoAndStop(ob.type);
rmenu.iname = towernames[ob.type];
upgradearray = _root[("t" + ob.type) + upgradeprop];
costarray = _root[(("t" + ob.type) + upgradeprop) + "cost"];
rmenu.homeup.onRelease = function () {
if (!gamepaused) {
rmenu.upscreen.gotoAndStop(1);
}
};
if (rmenu.upscreen._currentframe == 1) {
if ((!ob.reload) == 0) {
rmenu.upscreen.reloader._xscale = (ob.rs / ob.reload) * 100;
} else {
rmenu.upscreen.reloader._xscale = 100;
}
rmenu.upscreen.sellmess = "Sell for " + Math.round(ob.totalcost * 0.8);
rmenu.upscreen.sellb.onRelease = function () {
ob.sold = true;
};
rmenu.upscreen.countingtext = (ob.counter + " ") + countingends[ob.type];
}
rmenu.rangeup.onRelease = function () {
if (!gamepaused) {
rmenu.upscreen.gotoAndStop(2);
}
};
if (rmenu.upscreen._currentframe == 2) {
if (_root[("t" + ob.type) + "upgrades"][0]) {
rmenu.upscreen.upgraderange.onRelease = function () {
upgradeprop = "range";
upgradearray = _root[("t" + ob.type) + upgradeprop];
costarray = _root[(("t" + ob.type) + upgradeprop) + "cost"];
if (!(ob.rangelevel === upgradearray.length)) {
if ((coins - costarray[ob.rangelevel]) >= 0) {
ob.totalcost = ob.totalcost + costarray[ob.rangelevel];
coins = coins - costarray[ob.rangelevel];
ob.rangelevel++;
}
}
};
rmenu.upscreen.rangedet = (("Level : " + ob.rangelevel) + " / ") + _root[("t" + ob.type) + "range"].length;
} else {
rmenu.upscreen.rangedet = "Level : 1 / 1";
}
if (((((rmenu.upscreen.upgraderange._xmouse > -30) && (rmenu.upscreen.upgraderange._xmouse < 30)) && (rmenu.upscreen.upgraderange._ymouse > -10)) && (rmenu.upscreen.upgraderange._ymouse < 10)) && (_root[("t" + ob.type) + "range"][ob.rangelevel] != undefined)) {
rmenu.upscreen.currange = "Range : " + _root[("t" + ob.type) + "range"][ob.rangelevel];
} else {
rmenu.upscreen.currange = "Range : " + ob.radius;
}
if (!(_root[("t" + ob.type) + "rangecost"][ob.rangelevel] === undefined)) {
rmenu.upscreen.uprangecost = "Cost : " + _root[("t" + ob.type) + "rangecost"][ob.rangelevel];
} else {
rmenu.upscreen.uprangecost = "Cost : 0";
}
}
rmenu.damageup.onRelease = function () {
if (!gamepaused) {
rmenu.upscreen.gotoAndStop(3);
}
};
if (rmenu.upscreen._currentframe == 3) {
if (_root[("t" + ob.type) + "upgrades"][1]) {
rmenu.upscreen.upgradedamage.onRelease = function () {
upgradeprop = "damage";
upgradearray = _root[("t" + ob.type) + upgradeprop];
costarray = _root[(("t" + ob.type) + upgradeprop) + "cost"];
if (!(ob.damagelevel === upgradearray.length)) {
if ((coins - costarray[ob.damagelevel]) >= 0) {
ob.totalcost = ob.totalcost + costarray[ob.damagelevel];
coins = coins - costarray[ob.damagelevel];
ob.damagelevel++;
}
}
};
rmenu.upscreen.damagedet = (("Level : " + ob.damagelevel) + " / ") + _root[("t" + ob.type) + "damage"].length;
} else {
rmenu.upscreen.damagedet = "Level : 1 / 1";
}
if (((((rmenu.upscreen.upgradedamage._xmouse > -30) && (rmenu.upscreen.upgradedamage._xmouse < 30)) && (rmenu.upscreen.upgradedamage._ymouse > -10)) && (rmenu.upscreen.upgradedamage._ymouse < 10)) && (_root[("t" + ob.type) + "damage"][ob.damagelevel] != undefined)) {
rmenu.upscreen.curdamage = "Damage : " + _root[("t" + ob.type) + "damage"][ob.damagelevel];
} else {
rmenu.upscreen.curdamage = "Damage : " + ob.damage;
}
if (!(_root[("t" + ob.type) + "damagecost"][ob.damagelevel] === undefined)) {
rmenu.upscreen.updamagecost = "Cost : " + _root[("t" + ob.type) + "damagecost"][ob.damagelevel];
} else {
rmenu.upscreen.updamagecost = "Cost : 0";
}
}
rmenu.reloadup.onRelease = function () {
if (!gamepaused) {
rmenu.upscreen.gotoAndStop(4);
}
};
if (rmenu.upscreen._currentframe == 4) {
if (_root[("t" + ob.type) + "upgrades"][2]) {
rmenu.upscreen.upgradereload.onRelease = function () {
upgradeprop = "reload";
upgradearray = _root[("t" + ob.type) + upgradeprop];
costarray = _root[(("t" + ob.type) + upgradeprop) + "cost"];
if (!(ob.reloadlevel === upgradearray.length)) {
if ((coins - costarray[ob.reloadlevel]) >= 0) {
ob.totalcost = ob.totalcost + costarray[ob.reloadlevel];
coins = coins - costarray[ob.reloadlevel];
ob.reloadlevel++;
}
}
};
rmenu.upscreen.reloaddet = (("Level : " + ob.reloadlevel) + " / ") + _root[("t" + ob.type) + "reload"].length;
} else {
rmenu.upscreen.reloaddet = "Level : 1 / 1";
}
if (((((rmenu.upscreen.upgradereload._xmouse > -30) && (rmenu.upscreen.upgradereload._xmouse < 30)) && (rmenu.upscreen.upgradereload._ymouse > -10)) && (rmenu.upscreen.upgradereload._ymouse < 10)) && (_root[("t" + ob.type) + "reload"][ob.reloadlevel] != undefined)) {
rmenu.upscreen.curreload = "Reload : " + _root[("t" + ob.type) + "reload"][ob.reloadlevel];
} else {
rmenu.upscreen.curreload = "Reload : " + ob.reload;
}
if (!(_root[("t" + ob.type) + "reloadcost"][ob.reloadlevel] === undefined)) {
rmenu.upscreen.upreloadcost = "Cost : " + _root[("t" + ob.type) + "reloadcost"][ob.reloadlevel];
} else {
rmenu.upscreen.upreloadcost = "Cost : 0";
}
}
}
}
function getnearest(x, y) {
var _local2 = 0;
var _local3 = 9999999 /* 0x98967F */;
for (gn in enemies) {
e = enemies[gn];
if (!e.dead) {
var _local1 = Math.sqrt(Math.pow(x - e._x, 2) + Math.pow(x - e._y, 2));
if (_local1 < _local3) {
_local2 = e;
_local3 = _local1;
}
}
}
return(_local2);
}
function maintain() {
Q = getTimer() - (Q ? (Q) : 0);
fps = int(1000 / Q) + " FPS";
Q = getTimer();
if (wavenumber > 0) {
menu.clock.hand._rotation = menu.clock.hand._rotation + clockspeed;
}
castle.doorr._x = castle.doorr._x + ((castledoorx - castle.doorr._x) / 3);
castle.doorl._x = -castle.doorr._x;
mushroomhealthbar.gotoAndStop(((100 - health) / 10) + 1);
if (wavenumber == 0) {
if (enemies.length == 0) {
if ((endtimer++) > 30) {
gotoAndStop (7);
removeeverything();
}
}
}
for (i in enemies) {
e = enemies[i];
if ((e._x + (e._width / 2)) > castle._x) {
if (bubbleob == e) {
bubactive = false;
}
setshake(2, 3);
health = health - 10;
playsound(lifelose);
e.lb._y = 500;
e.rb._y = 500;
}
opendoors = false;
if (castle.hitTest(e)) {
opendoors = true;
}
if (opendoors) {
castledoorx = 20;
} else {
castledoorx = 6.8;
}
if (!checkbound(castle)) {
if (exclam._currentframe == 1) {
if (opendoors) {
exclam.gotoAndPlay(2);
}
}
} else {
exclam.gotoAndStop(1);
}
if (health <= 0) {
removeeverything();
gotoAndStop (6);
}
}
}
function makecoin(x, y) {
d = _root.getNextHighestDepth();
c = attachMovie("coin", "coin" + d, d);
c._x = x;
c._y = y;
gcoins.push(c);
}
function movecoins() {
for (i in gcoins) {
c = gcoins[i];
c._y = c._y - 5;
c._alpha = c._alpha - 8;
if (checkbound(c)) {
c._visible = true;
} else {
c._visible = false;
}
if (c._alpha <= 0) {
removeMovieClip(c);
gcoins.splice(i, 1);
}
}
}
function maketower(type) {
d = _root.getNextHighestDepth();
t = attachMovie("tower" + type, (("tower" + type) + "_") + d, d);
t.type = type;
t.dragging = true;
t._x = 0;
t.yspeed = 0;
t.placed = false;
t.placetimer = 0;
t.enemy = false;
t.totalcost = costs[type];
t.rs = 0;
t.radius = 20;
t.sold = false;
t.rangelevel = 1;
t.damagelevel = 1;
t.reloadlevel = 1;
t.counter = 0;
t._visible = false;
t.obstruct = true;
t.fp = 0;
if (t.type == 1) {
t.radius = 30;
t.damage = 1;
t.ground = true;
t.reload = 0;
}
if (t.type == 2) {
t.radius = 250;
t.damage = 2;
t.ground = false;
t.reload = 48;
}
if (t.type == 3) {
t.radius = 50;
t.damage = 5;
t.ground = true;
t.reload = 48;
t.ttimer = 0;
t.rising = true;
t.setoff = false;
t.tp._yscale = 10;
t.xpos = 0;
t.ypos = 0;
}
if (t.type == 4) {
t.radius = 500;
t.damage = 2;
t.reload = 10;
t.ground = true;
}
if (t.type == 5) {
t.radius = 200;
t.damage = 0;
t.ground = false;
t.reload = 48;
}
if (t.type == 6) {
t.radius = 300;
t.damage = 4;
t.ground = false;
t.reload = 8;
t.dir = -1;
}
if (t.type == 7) {
t.radius = 500;
t.damage = 20;
t.ground = true;
t.reload = 48;
}
if (t.type == 8) {
t.radius = 50;
t.damage = 25;
t.ground = true;
t.reload = 60;
}
if (t.type == 9) {
t.radius = 150;
t.damage = 10;
t.ground = true;
t.reload = 70;
}
if (t.type == 10) {
t.radius = 400;
t.damage = 30;
t.ground = true;
t.reload = 48;
}
if (t.type == 11) {
t.radius = 500;
t.damage = 1;
t.ground = true;
t.reload = 100;
}
if (t.type == 12) {
t.radius = 170;
t.damage = 30;
t.ground = false;
t.reload = 0;
t.stx = 0;
t.sty = 0;
t.speed = 3;
t.hitob = 0;
}
if (t.type == 13) {
t.gotoAndStop(10);
t.radius = 100;
t.damage = 10;
t.ground = true;
t.reload = 50;
}
if (t.ground) {
makehugground(t);
}
raisemenus();
towers.push(t);
}
function movetowers() {
for (i in towers) {
t = towers[i];
if (t.dragging) {
t2 = t;
}
if (!(t === t2)) {
if (t.hitTest(t2)) {
hittower = t;
obstruct = true;
}
}
if (hittower.hitTest(t2)) {
t.obstruct = true;
} else {
t.obstruct = false;
}
if (t.dragging) {
if (t.obstruct) {
t2._alpha = 40;
} else {
t2._alpha = 100;
}
}
if (!t.dragging) {
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (t.type == 1) {
if (e.hitTest(t._x, t._y, false)) {
if (!e.jumping) {
e.jumping = true;
e.falldam = e.falldam + t.damage;
e.yspeedl = -(15 + (t.damagelevel / 1));
e.yspeedr = -(15 + (t.damagelevel / 1));
t.counter++;
t.gotoAndPlay(2);
playsound(jump, t);
}
}
}
if (t.type == 2) {
if (getdis(t, e) < (t.radius / 2)) {
if (t.rs == t.reload) {
makebullet(t._x + ((t._xscale / 100) * 20), t._y + 15, 1, t.damage, t, getnearest(t._x, t._y));
t.rs = 0;
t.counter++;
playsound(drop, t);
}
}
}
if (t.type == 3) {
if (t.rs == t.reload) {
if (t._currentframe == 2) {
if (t.hitTest(e._x, e._y, true)) {
t.setoff = true;
playsound(thwompsound, t);
}
}
}
}
if (t.type == 4) {
if (t.rs == t.reload) {
if (getdis(t, e) < (t.radius / 2)) {
makebullet(t._x, t._y - 15, 2, t.damage, t);
playsound(koopasound, t);
t.rs = 0;
t.counter++;
}
}
}
if (t.type == 5) {
if (t.rs == t.reload) {
if (getdis(t, e) < (t.radius / 2)) {
makebullet(t._x, t._y - 15, 3, t.damage, t);
t.rs = 0;
t.counter++;
playsound(ninjisound, t);
pa = 0;
while (pa < 5) {
makepart(t._x, t._y - 15, 7, 100, 6);
pa++;
}
}
}
}
if (t.type == 6) {
if (t.rs == t.reload) {
if (getdis(t, e) < (t.radius / 2)) {
makebullet(t._x + (t.dir * 5), t._y - 15, 4, t.damage, t);
t.rs = 0;
t.counter++;
t.dir = t.dir * -1;
playsound(lowhit, t);
t._xscale = t._xscale * -1;
}
}
}
if (t.type == 7) {
if (t.rs == t.reload) {
if (getdis(t, e) < (t.radius / 2)) {
makebullet(t._x, t._y - 15, 5, t.damage, t, getnearest(t._x, t._y));
playsound(billsound, t);
t.rs = 0;
t.counter++;
if (checkbound(t)) {
setshake(4, 2);
}
pa = 0;
while (pa < 6) {
makepart(t._x, t._y - 15, 1, 300, 6);
pa++;
}
}
}
}
if (t.type == 8) {
if (t.rs == t.reload) {
makebullet(t._x, t._y - 30, 6, t.damage, t);
t.rs = 0;
t.counter++;
playsound(mechasound, t);
pa = 0;
while (pa < 4) {
makepart(t._x, t._y - 31, 4, 100, 4);
pa++;
}
}
}
if (t.type == 9) {
if (t.rs == t.reload) {
if (getdis(t, e) < (t.radius / 2)) {
makebullet(t._x, t._y - 31.6, 7, t.damage, t);
playsound(molesound, t);
t.rs = 0;
t.counter++;
pa = 0;
while (pa < 5) {
makepart(t._x, t._y - 31, 2, 200, 6);
pa++;
}
}
}
}
if (t.type == 10) {
if (t.rs == t.reload) {
if (getdis(t, e) < (t.radius / 2)) {
playsound(wigglersound, t);
makebullet(t._x, t._y - 25, 8, t.damage, t);
t.rs = 0;
t.counter++;
}
}
}
if (t.type == 11) {
if (t.rs == t.reload) {
if (getdis(t, e) < (t.radius / 2)) {
makebullet(t._x, t._y - 26, 9, t.damage, t);
playsound(boosound, t);
t.rs = 0;
t.counter++;
}
}
}
if (t.type == 12) {
if (getdis2(t.stx, t.sty, e._x, e._y) < 35) {
e.damage = e.damage + t.damage;
}
}
if (t.type == 13) {
if (t.rs == t.reload) {
if (getdis(t, e) < (t.radius / 2)) {
z = 0;
while (z < 3) {
makebullet(t._x, t._y - 5, 10, t.damage, t);
t.counter++;
makepart(t._x, t._y, 5, 200, 6);
z++;
}
playsound(volcanosound, t);
t.gotoAndPlay(2);
t.rs = 0;
}
}
}
}
}
}
if (_root[("t" + t.type) + "upgrades"][0]) {
t.radius = _root[("t" + t.type) + "range"][t.rangelevel - 1];
}
if (_root[("t" + t.type) + "upgrades"][1]) {
t.damage = _root[("t" + t.type) + "damage"][t.damagelevel - 1];
}
if (_root[("t" + t.type) + "upgrades"][2]) {
t.reload = _root[("t" + t.type) + "reload"][t.reloadlevel - 1];
}
if (checkbound(t)) {
t._visible = true;
} else {
t._visible = false;
}
if (t.sold) {
coins = coins + Math.round(t.totalcost * 0.8);
removeMovieClip(t.lb);
removeMovieClip(t.rb);
removeMovieClip(t);
towers.splice(i, 1);
bubactive = false;
}
if (t.dragging) {
if (!pressed) {
if (!t.obstruct) {
coins = coins - costs[itembannerpos];
t.dragging = false;
bublight(t);
} else {
removeMovieClip(t);
towers.splice(i, 1);
}
}
if (Key.isDown(88)) {
removeMovieClip(t);
towers.splice(t, 1);
}
t._x = _xmouse - xspeed;
if (Key.isDown(38) || (Key.isDown(87))) {
if (!updown) {
updown = true;
t._xscale = t._xscale * -1;
}
} else {
updown = false;
}
if (t.ground) {
if (t.dragging) {
if (t.type == 3) {
t.topx = t._x + (Math.sin(0.0174 * t._rotation) * 15);
t.topy = t._y - (Math.cos(0.0174 * t._rotation) * 15);
}
}
t.lb._x = t._x - (t._width / 2);
t.rb._x = t._x + (t._width / 2);
t.rb._y = t._y + (t._height / 2);
t.lb._y = t._y + (t._height / 2);
if ((t._x > -600) && (t._x < 1200)) {
while ((!ground.hitTest(t.lb._x, t.lb._y, true)) || (t.lb._y > 400)) {
t.lb._y++;
}
while ((!ground.hitTest(t.rb._x, t.rb._y, true)) || (t.rb._y > 400)) {
t.rb._y++;
}
}
while (ground.hitTest(t.lb._x, t.lb._y, true)) {
t.lb._y--;
}
while (ground.hitTest(t.rb._x, t.rb._y, true)) {
t.rb._y--;
}
t._rotation = 57.2957795130823 * Math.atan2(t.rb._y - t.lb._y, t.rb._x - t.lb._x);
t._y = ((t.lb._y + t.rb._y) / 2) - ((t._height / 2) - 4);
} else {
t._y = _ymouse;
t.fp = 0;
while ((ground.hitTest(t._x, t.getBounds(_root).yMax + (t._height / 2), true) || (ground.hitTest(t._x, t._y, true))) || (t._y > 400)) {
t._y--;
}
}
} else {
if (t.type == 3) {
t.tp._yscale = 100;
t.ttp._yscale = 100;
if (t.rs == t.reload) {
if (t.rising) {
if (t.ttimer < 24) {
t._x = t._x + (Math.sin(0.0174 * t._rotation) * 3);
t._y = t._y - (Math.cos(0.0174 * t._rotation) * 3);
if ((t.ttp._currentframe == 1) || (t.ttp._currentframe == 1)) {
t.ttp.gotoAndPlay(2);
}
} else {
t.gotoAndStop(2);
if (t.setoff) {
t.rising = false;
t.gotoAndStop(3);
}
}
}
t.ttimer++;
}
if (!t.rising) {
t._x = t._x - (Math.sin(0.0174 * t._rotation) * 16);
t._y = t._y + (Math.cos(0.0174 * t._rotation) * 16);
if (t.ttp._currentframe == 25) {
t.ttp.gotoAndPlay(26);
}
t.hittimes = 0;
if (ground.hitTest(t._x + (Math.sin(0.0174 * (t._rotation + 180)) * 16), t._y - (Math.cos(0.0174 * (t._rotation + 180)) * 16), true)) {
if (t.hittimes == 0) {
if (checkbound(t)) {
setshake(3, 4);
pa = 0;
while (pa < 8) {
makepart(t._x, t._y + 10, 1, 300, 5);
pa++;
}
}
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (getdis(e, t) < (t.radius / 2)) {
e.damage = e.damage + t.damage;
}
}
}
}
t.hittimes++;
t._x = t.xpos;
t._y = t.ypos;
t.rising = true;
t.rs = 0;
t.ttimer = 0;
t.setoff = false;
t.gotoAndStop(1);
}
}
if (!pressed) {
if (!t.placed) {
t.xpos = t._x;
t.ypos = t._y;
t.placed = true;
removeMovieClip(t.rb);
removeMovieClip(t.lb);
}
}
}
if (t.type == 12) {
t.speed = (t._xscale / 100) * 3.5;
t._rotation = t._rotation + t.speed;
t.stx = t._x + (Math.sin((Math.PI/180) * t._rotation) * 67);
t.sty = t._y - (Math.cos((Math.PI/180) * t._rotation) * 67);
if (t._xscale == 100) {
t.sb._rotation = -t._rotation;
t.ss._rotation = -t._rotation;
} else {
t.sb._rotation = t._rotation;
t.ss._rotation = t._rotation;
}
}
if (t.rs < t.reload) {
t.rs++;
}
if (t.rs > t.reload) {
t.rs = t.reload;
}
if (!t.placed) {
if (t.ground) {
if (!t.dragging) {
while (ground.hitTest(t.lb._x, t.lb._y, true)) {
t.lb._y--;
t.yspeed = 0;
}
while (ground.hitTest(t.rb._x, t.rb._y, true)) {
t.rb._y--;
t.yspeed = 0;
}
if (ground.hitTest(t._x, (t._y + (t._height / 2)) + 3, true)) {
if ((t.placetimer++) > 24) {
t.placed = true;
removeMovieClip(t.rb);
removeMovieClip(t.lb);
}
}
t._rotation = 57.2957795130823 * Math.atan2(t.rb._y - t.lb._y, t.rb._x - t.lb._x);
t._y = ((t.lb._y + t.rb._y) / 2) - ((t._height / 2) - 4);
t.lb._x = t._x - (t._width / 2);
t.rb._x = t._x + (t._width / 2);
t.yspeed++;
t.rb._y = t.rb._y + t.yspeed;
t.lb._y = t.lb._y + t.yspeed;
}
}
}
}
}
}
function getdis(ob1, ob2) {
var _local1 = ob1._x - ob2._x;
var _local2 = ob1._y - ob2._y;
return(Math.sqrt((_local1 * _local1) + (_local2 * _local2)));
}
function getdis2(x1, y1, x2, y2) {
var _local1 = x1 - x2;
var _local2 = y1 - y2;
return(Math.sqrt((_local1 * _local1) + (_local2 * _local2)));
}
function makebullet(x, y, type, dam, parent, tar) {
d = _root.getNextHighestDepth();
b = attachMovie("bullet" + type, (("bullet" + type) + "_") + d, d);
b._x = x;
b._y = y;
b.type = type;
b.damage = dam;
b._visible = false;
if (type == 1) {
b.walking = false;
b.thinking = false;
b.dead = false;
b.xspeed = 3;
b.tar = tar;
}
if (type == 2) {
b.dir = parent._xscale / 100;
b.yspeed = 0;
b._xscale = parent._xscale;
b.parent = parent;
}
if (type == 3) {
b.dir = parent._xscale / 100;
b.yspeed = -5;
b._xscale = parent._xscale;
b.stuck = false;
b.stuckob = 0;
b.dead = false;
}
if (type == 4) {
b.dir = parent.dir;
b.yspeed = -((Math.random() * 2) + 2);
b.grav = (Math.random() * 0.5) + 0.9;
b.rotspeed = (Math.random() * 10) + 10;
if (getnearest(parent._x, parent._y)._x > b._x) {
if (random(10) == 0) {
b.speed = ((-Math.random()) * 3) + 4;
} else {
b.speed = (Math.random() * 3) + 4;
}
} else if (random(10) == 0) {
b.speed = (Math.random() * 3) + 4;
} else {
b.speed = -((Math.random() * 3) + 4);
}
b.groundtimes = 0;
}
if (type == 5) {
b.yspeed = 0;
b.xspeed = 0;
b.speed = 5;
b.tar = tar;
}
if (type == 6) {
b.xspeed = 0;
b.yspeed = 0;
b.rb = _root.createEmptyMovieClip((b + "_rb") + _root.getNextHighestDepth(), _root.getNextHighestDepth());
b.lb = _root.createEmptyMovieClip((b + "_lb") + _root.getNextHighestDepth(), _root.getNextHighestDepth());
b.lb._x = b._x - 4.5;
b.rb._x = b._x + 8.5;
b.rb._y = b._y + (b._height / 2);
b.lb._y = b._y + (b._height / 2);
b.tar = getnearest(b._x, b._y);
b.dead = false;
}
if (type == 7) {
b.yspeed = 0;
b.dir = parent._xscale / -100;
b._xscale = parent._xscale;
b.maxspeed = b.dir * 5;
b.xspeed = b.dir * 2;
b.hitob = 0;
b.rb = _root.createEmptyMovieClip((b + "_rb") + _root.getNextHighestDepth(), _root.getNextHighestDepth());
b.lb = _root.createEmptyMovieClip((b + "_lb") + _root.getNextHighestDepth(), _root.getNextHighestDepth());
b.lb._x = b._x - (b._width / 2);
b.rb._x = b._x + (b._width / 2);
b.rb._y = b._y + (b._height / 2);
b.lb._y = b._y + (b._height / 2);
}
if (type == 8) {
b.yspeed = 0;
b.dir = parent._xscale / -100;
b._xscale = parent._xscale;
b.maxspeed = b.dir * 8;
b.xspeed = b.dir * 4;
b.rb = _root.createEmptyMovieClip((b + "_rb") + _root.getNextHighestDepth(), _root.getNextHighestDepth());
b.lb = _root.createEmptyMovieClip((b + "_lb") + _root.getNextHighestDepth(), _root.getNextHighestDepth());
b.lb._x = b._x - (b._width / 2);
b.rb._x = b._x + (b._width / 2);
b.rb._y = b._y + (b._height / 2);
b.lb._y = b._y + (b._height / 2);
b.hitob = 0;
b.counter = 0;
b.dead = false;
}
if (type == 9) {
b.xspeed = 0;
b.yspeed = -20;
b.tar = getnearest(b._x, b._y);
b.maxspeed = 10;
b.stuck = false;
b.stuckob = 0;
b.stucktimer = 0;
b.dead = false;
}
if (type == 10) {
b.speed = (Math.random() * 15) + 5;
b.rot = (parent._rotation + (Math.random() * 50)) - 25;
b.xspeed = Math.sin((Math.PI/180) * b.rot) * b.speed;
b.yspeed = Math.cos((Math.PI/180) * b.rot) * (-b.speed);
b.timer = 0;
b.dead = false;
b.active = false;
}
bullets.push(b);
}
function movebullets() {
for (i in bullets) {
b = bullets[i];
if (checkbound(b)) {
b._visible = true;
} else {
b._visible = false;
}
if (b.type == 1) {
if (b._y > 410) {
removeMovieClip(b);
bullets.splice(i, 1);
}
if (!b.dead) {
if (b.tar.dead) {
b.tar = getnearest(b._x, b._y);
}
if (!b.thinking) {
if (!b.walking) {
b._y = b._y + 3;
if (ground.hitTest(b._x, b._y, true)) {
b.walking = true;
}
} else {
b.gotoAndStop(2);
while (ground.hitTest(b._x, b._y, true)) {
b._y--;
}
b._y = b._y + 5;
b._x = b._x + b.xspeed;
if (b.tar._x > b._x) {
b.xspeed = 3;
b._xscale = 100;
} else {
b.xspeed = -3;
b._xscale = -100;
}
if (random(70) == 0) {
b.thinking = true;
}
}
} else {
if (random(70) == 0) {
b.thinking = false;
}
b.gotoAndStop(3);
}
if (b.walking) {
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (e.hitTest(b)) {
e.damage = e.damage + b.damage;
b._xscale = 100;
b.gotoAndPlay(4);
b.dead = true;
playsound(explode, b);
}
}
}
}
} else if (b._currentframe == 14) {
removeMovieClip(b);
bullets.splice(i, 1);
}
}
if (b.type == 2) {
b._x = b._x + (b.dir * -6);
b.yspeed++;
b._y = b._y + b.yspeed;
if (b._y > 410) {
removeMovieClip(b);
bullets.splice(i, 1);
}
while (ground.hitTest(b._x, b._y, true)) {
b.yspeed = 0;
b._y--;
}
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (e.hitTest(b)) {
e.damage = e.damage + b.damage;
removeMovieClip(b);
bullets.splice(i, 1);
}
}
}
}
if (b.type == 3) {
if (!b.dead) {
if (b.stuckob.dead) {
b.stuckob.speed = b.stuckob.speed * 2;
b.yspeed = -10;
b.dead = true;
}
if (!b.stuck) {
b._x = b._x + (b.dir * -4);
b._y = b._y + b.yspeed;
b.yspeed++;
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (e.ninjid < 2) {
if (getdis(b, e) < ((b._height + e._height) / 2)) {
e.speed = e.speed * 0.5;
b.stuck = true;
b.stuckob = e;
e.ninjid++;
b.swapDepths(_root.getNextHighestDepth());
}
}
}
}
} else {
b._x = b.stuckob._x;
b._y = b.stuckob._y;
b._alpha = b._alpha - 0.5;
b._rotation = b.stuckob._rotation;
if (b._alpha <= 30) {
b.stuckob.speed = b.stuckob.speed * 2;
b.stuckob.ninjid--;
b.yspeed = -10;
b.dead = true;
}
}
while (ground.hitTest(b._x, b._y, true)) {
b._y--;
b.yspeed = 0;
}
if (ground.hitTest(b._x, b._y + 1, true)) {
b.grounded = true;
} else {
b.grounded = false;
}
if (!b.stuck) {
if (b.grounded) {
b.gotoAndStop(2);
} else {
b.gotoAndStop(1);
}
} else {
b.gotoAndStop(3);
}
} else {
b.yspeed++;
b._y = b._y + b.yspeed;
}
if (b._y > 410) {
removeMovieClip(b);
bullets.splice(i, 1);
}
}
if (b.type == 4) {
b._x = b._x + b.speed;
b._y = b._y + b.yspeed;
b.yspeed = b.yspeed + b.grav;
b._rotation = b._rotation + b.rotspeed;
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (e.hitTest(b._x, b._y, false)) {
e.damage = e.damage + b.damage;
removeMovieClip(b);
bullets.splice(i, 1);
}
}
}
if (b.groundtimes == 0) {
if (ground.hitTest(b._x, b._y, true)) {
b.yspeed = b.yspeed * -0.5;
b.groundtimes++;
}
}
if (b._y > 410) {
removeMovieClip(b);
bullets.splice(i, 1);
}
}
if (b.type == 5) {
b.xdif = b.tar._x - b._x;
b.ydif = b.tar._y - b._y;
b._rotation = (57.2957795130823 * Math.atan2(b.ydif, b.xdif)) + 90;
if (Math.sin((Math.PI/180) * b._rotation) > 0) {
b._xscale = 100;
} else {
b._xscale = -100;
}
if (b.tar.dead) {
b.tar = getnearest(b._x, b._y);
}
if ((((b._x > 1220) || (b._x < -620)) || (b._y > 450)) || (b._y < -50)) {
removeMovieClip(b);
bullets.splice(i, 1);
}
b._x = b._x + (Math.sin((Math.PI/180) * b._rotation) * 7);
b._y = b._y - (Math.cos((Math.PI/180) * b._rotation) * 7);
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (e.hitTest(b._x, b._y, true)) {
e.damage = e.damage + b.damage;
removeMovieClip(b);
bullets.splice(i, 1);
}
}
}
}
if (b.type == 6) {
if (!b.dead) {
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (getdis(b, e) < ((b._height / 2) + (e._height / 2))) {
playsound(explode, b);
if (checkbound(b)) {
setshake(5, 3);
}
e.damage = e.damage + b.damage;
b.dead = true;
b.gotoAndPlay(18);
}
}
}
b._x = b._x + b.xspeed;
b.yspeed = b.yspeed + 2;
b._y = b._y + b.yspeed;
if (b.xspeed > 0) {
b._xscale = -100;
} else {
b._xscale = 100;
}
if (b.tar.dead) {
b.tar = getnearest(b._x, b._y);
}
while (ground.hitTest(b._x, b.getBounds(_root).yMax, true)) {
b._y--;
b.yspeed = 0;
}
if (b.tar._x > b._x) {
b.xspeed = 6;
} else {
b.xspeed = -6;
}
} else {
b._xscale = 100;
if (b._currentframe == 25) {
removeMovieClip(b.lb);
removeMovieClip(b.rb);
removeMovieClip(b);
bullets.splice(i, 1);
}
}
}
if (b.type == 7) {
b._x = b._x + b.xspeed;
b.lb._x = b._x - (b._width / 2);
b.rb._x = b._x + (b._width / 2);
b.yspeed = b.yspeed + (5.5 * Math.cos(0.0174 * b._rotation));
b.rb._y = b.rb._y + b.yspeed;
b.lb._y = b.lb._y + b.yspeed;
b._rotation = 57.2957795130823 * Math.atan2(b.rb._y - b.lb._y, b.rb._x - b.lb._x);
while (ground.hitTest(b.lb._x, b.lb._y, true)) {
b.lb._y--;
b.yspeed = 0;
}
while (ground.hitTest(b.rb._x, b.rb._y, true)) {
b.rb._y--;
b.yspeed = 0;
}
b._y = ((b.lb._y + b.rb._y) / 2) - ((b._height / 2) - 4);
if (Math.abs(b.xspeed) < Math.abs(b.maxspeed)) {
b.xspeed = b.xspeed + (b.dir / 10);
}
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (b.hitTest(e._x, e._y, false)) {
e.damage = e.damage + b.damage;
}
}
}
if (b._y > 450) {
removeMovieClip(b.lb);
removeMovieClip(b.rb);
removeMovieClip(b);
bullets.splice(i, 1);
}
}
if (b.type == 8) {
b.lb._x = b._x - (b._width / 2);
b.rb._x = b._x + (b._width / 2);
b._rotation = 57.2957795130823 * Math.atan2(b.rb._y - b.lb._y, b.rb._x - b.lb._x);
if (!b.dead) {
b.yspeed++;
b._x = b._x + (b.xspeed * Math.cos(0.0174 * b._rotation));
if ((b._x < 1200) && (b._x > -600)) {
while (ground.hitTest(b.lb._x, b.lb._y, true)) {
b.lb._y--;
b.yspeed = 0;
}
while (!ground.hitTest(b.lb._x, b.lb._y, true)) {
b.lb._y++;
b.yspeed = 0;
}
while (ground.hitTest(b.rb._x, b.rb._y, true)) {
b.rb._y--;
b.yspeed = 0;
}
while (!ground.hitTest(b.rb._x, b.rb._y, true)) {
b.rb._y++;
b.yspeed = 0;
}
}
if (b._x > 1200) {
b._xscale = b._xscale * -1;
b.dir = b.dir * -1;
b.xspeed = b.xspeed * -1;
b.counter = b.counter + 3;
b.hitob = 0;
} else if (b._x < -600) {
b._xscale = b._xscale * -1;
b.dir = b.dir * -1;
b.xspeed = b.xspeed * -1;
b.counter = b.counter + 3;
b.hitob = 0;
}
if (Math.abs(b.xspeed) < Math.abs(b.maxspeed)) {
b.xspeed = b.xspeed + (b.dir / 5);
}
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (getdis(b, e) < ((b._width / 2) + (e._height / 2))) {
if (!(b.hitob === e)) {
b.hitob = e;
b._xscale = b._xscale * -1;
b.dir = b.dir * -1;
b.xspeed = b.xspeed * -1;
e.damage = e.damage + b.damage;
b.counter++;
}
}
}
}
b.gotoAndStop(b.counter + 1);
if (b.counter >= 5) {
b.dead = true;
b.yspeed = -10;
}
} else {
b.rb._y = b.rb._y + b.yspeed;
b.lb._y = b.lb._y + b.yspeed;
b.yspeed = b.yspeed + 2;
}
b._y = ((b.lb._y + b.rb._y) / 2) - ((b._height / 2) - 4);
if (b._y > 450) {
removeMovieClip(b.lb);
removeMovieClip(b.rb);
removeMovieClip(b);
bullets.splice(i, 1);
}
}
if (b.type == 9) {
if (!b.dead) {
b._x = b._x + b.xspeed;
b._y = b._y + b.yspeed;
b.xspeed = b.xspeed * 0.9;
b.yspeed = b.yspeed * 0.9;
if (b.tar._x > b._x) {
if (b.xspeed < b.maxspeed) {
b.xspeed++;
}
} else if (b.xspeed > (-b.maxspeed)) {
b.xspeed--;
}
if (b.tar._y > b._y) {
if (b.yspeed < b.maxspeed) {
b.yspeed++;
}
} else if (b.yspeed > (-b.maxspeed)) {
b.yspeed--;
}
if ((((b._x > 1320) || (b._x < -720)) || (b._y > 550)) || (b._y < -150)) {
removeMovieClip(b);
bullets.splice(i, 1);
}
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (!b.stuck) {
if (e.hitTest(b._x, b._y, true)) {
b.stuck = true;
b.stuckob = e;
b.swapDepths(_root.getNextHighestDepth());
b.gotoAndStop(2);
}
}
}
}
if (b.stuck) {
b._x = b.stuckob._x;
b._y = b.stuckob._y;
b.stuckob.damage = b.stuckob.damage + b.damage;
b.stucktimer++;
if (b.stucktimer > 48) {
b.dead = true;
}
if (b.tar.dead) {
b.dead = true;
}
b._xscale = -100;
} else {
if (b.tar.dead) {
b.tar = getnearest(b._x, b._y);
}
if (b.tar._x > b._x) {
b._xscale = -100;
} else {
b._xscale = 100;
}
}
} else {
b._alpha = b._alpha - 10;
if (b._alpha <= 0) {
removeMovieClip(b);
bullets.splice(i, 1);
}
}
}
if (b.type == 10) {
if (!b.active) {
b._x = b._x + b.xspeed;
b._y = b._y + b.yspeed;
b.yspeed++;
while (ground.hitTest(b._x, b._y, true)) {
b._y--;
b.xspeed = 0;
b.active = true;
b.gotoAndPlay(2);
}
} else {
b.timer++;
if (b.timer > 480) {
b.dead = true;
}
if (b.dead) {
b._alpha = b._alpha - 3;
if (b._alpha <= 0) {
removeMovieClip(b);
bullets.splice(i, 1);
}
}
if (b._y > 450) {
b.dead = true;
}
for (j in enemies) {
e = enemies[j];
if (!e.dead) {
if (b.hitTest(e)) {
e.damage = e.damage + b.damage;
removeMovieClip(b);
bullets.splice(i, 1);
}
}
}
}
}
}
}
function makepart(x, y, type, size, speed) {
if (particleeffects) {
d = _root.getNextHighestDepth();
p = attachMovie("smoke" + type, (("smoke_" + type) + "_") + d, d);
p._x = x;
p._y = y;
p._xscale = (p._yscale = size);
p.xspeed = (Math.random() * speed) - (speed / 2);
p.yspeed = (Math.random() * speed) - (speed / 2);
parts.push(p);
}
}
function moveparts() {
for (i in parts) {
p = parts[i];
p._x = p._x + p.xspeed;
p._y = p._y + p.yspeed;
p._alpha = p._alpha - 6;
p._rotation = p._rotation + (p.xspeed * 5);
if (p._alpha <= 0) {
removeMovieClip(p);
parts.splice(i, 1);
}
}
}
function checkpress(array) {
for (i in array) {
ob = array[i];
if (!rmenu.hitTest(_xmouse, _ymouse, true)) {
if (ob.hitTest(_xmouse, _ymouse, false)) {
if (!ob.dead) {
clickob = true;
if (clickkill) {
if (ob.enemy) {
if (Key.isDown(32)) {
ob.damage = ob.maxdam;
}
}
}
bublight(ob);
}
}
}
}
}
function setshake(mag, stime) {
shakemag = mag;
shaketime = stime;
}
function shake() {
if (shaketime > 0) {
shaketime--;
_y = (_y + ((Math.random() * shakemag) - (shakemag / 2)));
} else {
_y = 0;
shakemag = 0;
}
}
function checkbound(ob) {
var _local2 = ob._height;
var _local3 = ob._x + _root._x;
if ((_local3 > (-_local2)) && (_local3 < (600 + _local2))) {
return(true);
}
return(false);
}
function makewave(amount, interval, frame, speed, damage, payoff) {
w = new Object();
w.created = 0;
w.amount = amount;
w.interval = interval;
w.timer = interval;
w.frame = frame;
w.speed = speed;
w.damage = damage;
w.payoff = payoff;
waves.push(w);
}
function movewaves() {
for (i in waves) {
w = waves[i];
w.timer++;
if (w.created < w.amount) {
if (w.timer > w.interval) {
w.created++;
w.timer = 0;
makeenemy(gpipe._x + (gpipe._width / 2), gpipe._y, w.frame, w.speed, w.damage, w.payoff);
enemycount++;
}
} else {
removeMovieClip(w);
waves.splice(i, 1);
}
}
}
function removearray(array) {
for (i in array) {
o = array[i];
removeMovieClip(o);
array.splice(i, 1);
}
}
function prevtower() {
if (_root.itembannerpos > _root.mintower) {
_root.itembannerpos--;
playsound(meep);
}
}
function nexttower() {
if (_root.itembannerpos < _root.maxtower) {
_root.itembannerpos++;
playsound(meep);
}
}
function removeeverything() {
removeMovieClip(menu);
removeMovieClip(rmenu);
removeMovieClip(exclam);
removearray(enemies);
removearray(towers);
removearray(gcoins);
removearray(bullets);
removearray(parts);
removearray(waves);
removearray(healthtexts);
_x = 0;
Mouse.removeListener(mouseListener);
Key.removeListener(scrolltowers);
delete this.onEnterFrame;
delete this.onMouseDown;
delete this.onMouseMove;
if (_currentframe == 32) {
removeMovieClip(ground);
removeMovieClip(bubble);
}
}
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 10) {
waveframe = 1;
}
makewave(5, 24, waveframe, 5, wave, Math.round(wave / 2));
waveframe++;
wavenumber--;
}
}
function updatetopmenutext() {
menu.tmenuh = health;
menu.tmcoins = coins;
menu.tewave = wavenumber;
menu.itempic.itembanner._x = menu.itempic.itembanner._x + ((((itembannerpos - 1) * -50) - menu.itempic.itembanner._x) / 3);
menu.towerdey = (itembannerpos - 1) * -70;
menu.towerde._y = menu.towerde._y + ((menu.towerdey - menu.towerde._y) / 3);
}
function movepausemenu() {
if (pmenu._alpha < 100) {
pmenu._alpha = pmenu._alpha + 15;
}
buttonize(pmenu.resume, 130, 5, false);
pmenu.resume.onRelease = function () {
gamepaused = false;
fadeoutpause = true;
playsound(pausesound);
musicarray[musictypes[level]].setVolume(100);
};
if (pmenu.quit._currentframe == 1) {
buttonize(pmenu.quit.qbut, 130, 5, false);
pmenu.quit.qbut.onRelease = function () {
pmenu.quit.gotoAndStop(2);
playsound(meep);
};
} else {
buttonize(pmenu.quit.ybut, 130, 5, false);
buttonize(pmenu.quit.nbut, 130, 5, false);
pmenu.quit.nbut.onRelease = function () {
pmenu.quit.gotoAndStop(1);
playsound(meep);
};
pmenu.quit.ybut.onRelease = function () {
removeeverything();
removeMovieClip(pmenu);
if (_currentframe == 32) {
gotoAndStop (10);
stopAllSounds();
musicarray[musictypes[level]].setVolume(100);
if (musicon) {
musictitle.start(0, 999999);
}
} else {
gotoAndStop (4);
musicarray[musictypes[level]].stop();
}
};
}
if (pmenu.retryb._currentframe == 1) {
buttonize(pmenu.retryb.qbut, 130, 5, false);
pmenu.retryb.qbut.onRelease = function () {
playsound(meep);
pmenu.retryb.gotoAndStop(2);
};
} else {
buttonize(pmenu.retryb.ybut, 130, 5, false);
buttonize(pmenu.retryb.nbut, 130, 5, false);
pmenu.retryb.nbut.onRelease = function () {
playsound(meep);
pmenu.retryb.gotoAndStop(1);
};
pmenu.retryb.ybut.onRelease = function () {
removeeverything();
removeMovieClip(pmenu);
musicarray[musictypes[level]].setVolume(100);
if (_currentframe == 32) {
stopAllSounds();
gotoAndStop (8);
} else {
gotoAndStop (9);
}
playsound(meep);
};
}
pmenu.autowavepad.onRelease = function () {
autowave = (autowave ? false : true);
};
pmenu.autowavepad.gotoAndStop(int(autowave) + 1);
pmenu.partpad.onRelease = function () {
particleeffects = (particleeffects ? false : true);
};
pmenu.partpad.gotoAndStop(int(particleeffects) + 1);
pmenu.soundpad.onRelease = function () {
soundeffects = (soundeffects ? false : true);
};
pmenu.soundpad.gotoAndStop(int(soundeffects) + 1);
pmenu.musicpad.onRelease = function () {
if (!musicon) {
musicon = true;
musicarray[musictypes[level]].start(0, 99999999);
} else {
musicon = false;
musicarray[musictypes[level]].stop();
}
};
pmenu.musicpad.gotoAndStop(int(musicon) + 1);
pmenu.qpad.onRelease = function () {
if (quality == 1) {
quality = 2;
_root._quality = "medium";
} else if (quality == 2) {
quality = 3;
_root._quality = "high";
} else if (quality == 3) {
quality = 1;
_root._quality = "low";
}
};
pmenu.qpad.gotoAndStop(quality);
}
function gameplay() {
if (Key.isDown(80)) {
if (!pauseheld) {
pauseheld = true;
if (gamepaused) {
gamepaused = false;
fadeoutpause = true;
playsound(pausesound);
musicarray[musictypes[level]].setVolume(100);
} else {
if (pmenu != undefined) {
removeMovieClip(pmenu);
fadeoutpause = false;
}
playsound(continuesound);
musicarray[musictypes[level]].setVolume(25);
gamepaused = true;
attachMovie("pmenu", "pmenu", _root.getNextHighestDepth());
pmenu._x = 300 - _x;
pmenu._y = 200;
pmenu._alpha = 0;
if (_currentframe == 32) {
pmenu.currentlevel = "Level: " + levelnames[freeplvl];
} else if (_currentframe == 11) {
pmenu.currentlevel = "Level: Tutorial";
} else {
pmenu.currentlevel = "Level: " + levelnames[level];
}
}
}
} else {
pauseheld = false;
}
if (!gamepaused) {
wavesent = false;
if (Math.round(menu.clock.hand._rotation) == 0) {
if (wave != 0) {
if (wavenumber != 0) {
nextwave();
playsound(nextwavesound);
menu.clock.hand._rotation = 360;
wavesent = true;
}
} else {
wave++;
}
}
if (autowave) {
if (enemies.length == 0) {
if (wave != 1) {
if (!wavesent) {
if (wavenumber != 0) {
menu.clock.hand._rotation = 0;
nextwave();
playsound(nextwavesound);
menu.clock.hand._rotation = 360;
}
}
}
}
}
maintain();
movemenu();
moveenemies();
movehealthtexts();
movetowers();
movebullets();
movebubble();
movecoins();
moveparts();
movewaves();
moveground();
shake();
shortcuts();
if (clickboo) {
if (Key.isDown(66)) {
if (pressed) {
if (!clickvar) {
makebullet(_xmouse, _ymouse, 9, 20, _root, getnearest(_xmouse, _ymouse));
clickvar = true;
}
} else {
clickvar = false;
}
}
}
if (holdshell) {
if (pressed) {
if (Key.isDown(75)) {
makebullet(_xmouse, _ymouse, 2, 5, _root);
}
}
}
} else {
movepausemenu();
}
}
function makesounds() {
billsound = new Sound();
billsound.attachSound("BullBill");
boosound = new Sound();
boosound.attachSound("boosound");
coinsound = new Sound();
coinsound.attachSound("coinget");
explode = new Sound();
explode.attachSound("explode");
jump = new Sound();
jump.attachSound("jump");
lifelose = new Sound();
lifelose.attachSound("lifelose");
wigglersound = new Sound();
wigglersound.attachSound("wigglersound");
volcanosound = new Sound();
volcanosound.attachSound("volcanosound");
thwompsound = new Sound();
thwompsound.attachSound("thwompsound");
molesound = new Sound();
molesound.attachSound("molesound");
nextwavesound = new Sound();
nextwavesound.attachSound("nextwavesound");
koopasound = new Sound();
koopasound.attachSound("koopasound");
clicks = new Sound();
clicks.attachSound("clicks");
deny = new Sound();
deny.attachSound("deny");
deny2 = new Sound();
deny2.attachSound("deny2");
musicholder = _root.createEmptyMovieClip("musicholder", _root.getNextHighestDepth());
musictitle = new Sound(musicholder);
musictitle.attachSound("musictitle");
musicl1 = new Sound(musicholder);
musicl1.attachSound("musicl1");
musicl2 = new Sound(musicholder);
musicl2.attachSound("musicl2");
musiccave = new Sound(musicholder);
musiccave.attachSound("musiccave");
musicwater = new Sound(musicholder);
musicwater.attachSound("musicwater");
musicforest = new Sound(musicholder);
musicforest.attachSound("musicforest");
musicvanilla = new Sound(musicholder);
musicvanilla.attachSound("musicvanilla");
musiccastle = new Sound(musicholder);
musiccastle.attachSound("musiccastle");
musicarray = new Array(musicl1, musicl2, musiccave, musicwater, musicforest, musicvanilla, musiccastle);
pausesound = new Sound();
pausesound.attachSound("pausesound");
meep = new Sound();
meep.attachSound("meep");
continuesound = new Sound();
continuesound.attachSound("continuesound");
drop = new Sound();
drop.attachSound("drop");
ninjisound = new Sound();
ninjisound.attachSound("ninjisound");
gameoversound = new Sound();
gameoversound.attachSound("gameoversound");
mechasound = new Sound();
mechasound.attachSound("mechasound");
lowhit = new Sound();
lowhit.attachSound("lowhit");
textapp = _root.createEmptyMovieClip("textapp", _root.getNextHighestDepth());
textap = new Sound(textapp);
textap.attachSound("textap");
}
function playsound(s, holder) {
if (holder != undefined) {
if (checkbound(holder)) {
if (soundeffects) {
s.start();
}
}
} else if (soundeffects) {
s.start();
}
}
function onEnterFrame() {
}
stopAllSounds();
makesounds();
stopAllSounds();
if (!smd.data.seenstory) {
gotoAndStop (35);
smd.data.seenstory = true;
} else {
gotoAndStop (4);
}
Frame 4
stop();
gmenu._x = 300;
mback.endx = 300;
gmenu.endx = lastmenux;
_x = 0;
stopAllSounds();
if (musicon) {
musictitle.start(0, 999999);
}
musictitle.setVolume(100);
gmenu.start.onRelease = function () {
gmenu.endx = -300;
playsound(clicks);
};
gmenu.options.onRelease = function () {
gmenu.endx = -900;
playsound(clicks);
};
gmenu.creds.onRelease = function () {
gmenu.endx = 1500;
playsound(clicks);
};
gmenu.insts.onRelease = function () {
gmenu.endx = 900;
playsound(clicks);
};
gmenu.nxtb.onRelease = function () {
gmenu.textin.nextFrame();
playsound(clicks);
};
gmenu.prvb.onRelease = function () {
gmenu.textin.prevFrame();
playsound(clicks);
};
i = 1;
while (i <= 20) {
gmenu.levelbuttons["l" + i].onRelease = function () {
level = int(this._name.substr(1));
playsound(clicks);
};
i++;
}
var i = 1;
while (i < 5) {
buttonize(gmenu["back" + i], 130, 7, false);
gmenu["back" + i].onRelease = function () {
gmenu.endx = 300;
playsound(clicks);
};
i++;
}
gmenu.autowavepad.onRelease = function () {
autowave = (autowave ? false : true);
playsound(clicks);
};
gmenu.enhealthpad.onRelease = function () {
enhealths = (enhealths ? false : true);
playsound(clicks);
};
gmenu.autowavepad.onRelease = function () {
autowave = (autowave ? false : true);
playsound(clicks);
};
gmenu.musicpad.onRelease = function () {
if (!musicon) {
musicon = true;
musictitle.start(0, 99999);
} else {
musicon = false;
musictitle.stop();
}
playsound(clicks);
};
gmenu.soundpad.onRelease = function () {
soundeffects = (soundeffects ? false : true);
playsound(clicks);
};
gmenu.partpad.onRelease = function () {
particleeffects = (particleeffects ? false : true);
playsound(clicks);
};
gmenu.qpad.onRelease = function () {
if (quality == 1) {
quality = 2;
_root._quality = "medium";
} else if (quality == 2) {
quality = 3;
_root._quality = "high";
} else if (quality == 3) {
quality = 1;
_root._quality = "low";
}
playsound(clicks);
};
gmenu.levelmedal.gotoAndStop(levelmedals[level - 1]);
gmenu.startgame.onRelease = function () {
if (level <= maxlevel) {
gotoAndStop(11 + level);
playsound(clicks);
if (musicon) {
musictitle.stop();
musicarray[musictypes[level]].start(0, 99999);
}
} else {
playsound(deny);
}
};
complevels = 0;
i = 0;
while (i < 20) {
if (passedlevels[i]) {
complevels++;
}
i++;
}
if ((complevels >= 3) && (maxlevel == 4)) {
maxlevel = 8;
}
if ((complevels >= 6) && (maxlevel == 8)) {
maxlevel = 12;
}
if ((complevels >= 9) && (maxlevel == 12)) {
maxlevel = 16;
}
if ((complevels >= 12) && (maxlevel == 16)) {
maxlevel = 20;
}
gmenu.menubest = totalscore;
gmenu.viewintro.onRelease = function () {
musictitle.stop();
playsound(meep);
gotoAndStop (35);
};
cheatcount = 0;
gmenu.apple1.onRelease = function () {
gmenu.apple1.play();
cheatcount++;
playsound(drop);
};
gmenu.apple2.onRelease = function () {
gmenu.apple2.play();
cheatcount++;
playsound(drop);
};
gmenu.apple3.onRelease = function () {
gmenu.apple3.play();
cheatcount++;
playsound(drop);
};
gmenu.apple4.onRelease = function () {
gmenu.apple4.play();
cheatcount++;
playsound(drop);
};
if (gotcheats) {
gmenu.backing.gotoAndStop(2);
gmenu.cheatsbutton._alpha = 100;
}
gmenu.scores.onRelease = function () {
getURL ("http://www.allgamesallfree.com/index.php?id=highscores&game=" + _root.gamename, "_blank");
};
gmenu.powerp.onRelease = function () {
gotoAndStop (38);
};
onEnterFrame = function () {
lastmenux = gmenu._x;
buttonize(gmenu.start, 130, 7, false);
buttonize(gmenu.options, 130, 7, false);
buttonize(gmenu.creds, 130, 7, false);
buttonize(gmenu.insts, 130, 7, false);
buttonize(gmenu.startgame, 130, 7, false);
buttonize(gmenu.nxtb, 130, 7, false);
buttonize(gmenu.prvb, 130, 7, false);
buttonize(gmenu.freeplay, 130, 10, true);
buttonize(gmenu.scores, 130, 11, false);
buttonize(gmenu.textin.viewtut, 130, 11, true);
buttonize(gmenu.viewintro, 130, 35, false);
buttonize(gmenu.subscore, 130, 5, true);
if (gotcheats) {
buttonize(gmenu.cheatsbutton, 130, 37, true);
}
var _local1 = 1;
while (_local1 < 5) {
buttonize(gmenu["back" + _local1], 130, 7, false);
_local1++;
}
gmenu.lnametext = (("Level: " + level) + " : ") + levelnames[level];
gmenu.levelbscore = "Best Score : " + levelscores[level - 1];
gmenu.levelmedal.gotoAndStop(levelmedals[level - 1]);
if (level > maxlevel) {
gmenu.levelstats = "Locked";
gmenu.medaltext = "Medal : None";
} else if (passedlevels[level - 1]) {
gmenu.levelstats = "Completed";
gmenu.medaltext = "Medal : ";
} else {
gmenu.levelstats = "To be completed";
gmenu.medaltext = "Medal : None";
}
mback.endx = 300 + ((gmenu.endx - 300) / 5);
gmenu._x = gmenu._x + ((gmenu.endx - gmenu._x) / 5);
mback._x = mback._x + ((mback.endx - mback._x) / 5);
gmenu.autowavepad.gotoAndStop(int(autowave) + 1);
gmenu.partpad.gotoAndStop(int(particleeffects) + 1);
gmenu.soundpad.gotoAndStop(int(soundeffects) + 1);
gmenu.musicpad.gotoAndStop(int(musicon) + 1);
gmenu.enhealthpad.gotoAndStop(int(enhealths) + 1);
gmenu.qpad.gotoAndStop(quality);
if (gmenu.clearsave._currentframe == 1) {
buttonize(gmenu.clearsave.qbut, 130, 5, false);
gmenu.clearsave.qbut.onRelease = function () {
gmenu.clearsave.gotoAndStop(2);
playsound(meep);
};
} else {
buttonize(gmenu.clearsave.ybut, 130, 5, false);
buttonize(gmenu.clearsave.nbut, 130, 5, false);
gmenu.clearsave.nbut.onRelease = function () {
gmenu.clearsave.gotoAndStop(1);
playsound(meep);
};
gmenu.clearsave.ybut.onRelease = function () {
newgame();
totalscore = 0;
gmenu.clearsave.gotoAndStop(1);
playsound(lifelose);
};
}
if (cheatcount >= 4) {
if ((cheatcount++) > 22) {
gotoAndStop (37);
gotcheats = true;
playsound(clicks);
}
}
};
onMouseUp = function () {
savegame();
};
Frame 5
startsentence = "You can only submit your score 3 times, you have ";
if (subscores >= 1) {
subsleft = (startsentence + subscores) + " submits remaining";
} else {
subsleft = "You have submitted your score 3 times already";
}
blanktimer = 0;
subscorescore = "Score: " + totalscore;
backb.onRelease = function () {
musictitle.stop();
gotoAndStop (4);
};
vscores._visible = false;
vscores.onRelease = function () {
getURL ("http://www.allgamesallfree.com/index.php?id=highscores&game=" + _root.gamename, "_blank");
};
subscore.onRelease = function () {
if (!cheated) {
if (totalscore != 0) {
if (subscorename != "") {
if (subscorename != "Enter Name") {
if (subscores > 0) {
if (sentScore != totalscore) {
add_pass = "flashapi";
name = subscorename;
score = totalscore;
sentScore = totalscore;
_root.loadVariables("http://www.allgamesallfree.com/new_score.php?game=" + gamename, "POST");
playsound(pausesound);
subscores--;
savegame();
subscore._visible = false;
vscores._visible = true;
} else {
subsleft = "Can't submit the same score twice";
}
} else {
playsound(deny2);
blanktimer = 0;
subsleft = "You've already submitted your score 3 times\rYou must first start a new game before submitting again";
}
} else {
playsound(deny2);
blanktimer = 0;
subsleft = "Change name from Enter Name";
}
} else {
playsound(deny2);
blanktimer = 0;
subsleft = "Enter a name";
}
} else {
blanktimer = 0;
playsound(deny2);
subsleft = "You can get a better score than that!";
}
} else {
blanktimer = 0;
playsound(deny2);
subsleft = "You can't submit your score because you have used the cheats.";
}
};
onEnterFrame = function () {
buttonize(backb, 130, 7, false);
buttonize(subscore, 130, 7, false);
buttonize(vscores, 130, 7, false);
blanktimer++;
if (blanktimer > 30) {
if (!cheated) {
if (subscores > 0) {
subsleft = (startsentence + subscores) + " submits remaining";
} else {
subsleft = "You have submitted your score 3 times already\rYou must first start a new game before submitting again";
}
} else {
subsleft = "You can't submit your score because you have used the cheats.";
}
}
};
Frame 6
stopAllSounds();
titlemusictimer = 0;
if (musicon) {
gameoversound.start();
}
prevlevel = "Failed " + levelnames[level];
_x = 0;
coinsleft = ((("You failed with " + coins) + " coins left, and killed ") + enemieskilled) + " enemies.";
back.onRelease = function () {
musictitle.stop();
gotoAndStop (4);
};
retry.onRelease = function () {
musictitle.stop();
if (musicon) {
musicarray[musictypes[level]].start(0, 99999);
}
gotoAndStop(11 + level);
};
onEnterFrame = function () {
titlemusictimer++;
if (titlemusictimer == 72) {
if (musicon) {
musictitle.start(0, 999999);
}
}
buttonize(back, 130, 4, false);
buttonize(retry, 130, 11 + level, false);
};
Frame 7
stopAllSounds();
if (musicon) {
musictitle.start(0, 999999);
}
passltext = (("Passed Level " + level) + " : ") + levelnames[level];
_x = 0;
l = (_root[("l" + level) + "passed"] = true);
passedlevels[level - 1] = true;
coinsleft = ((((("You finished with " + coins) + " coins, ") + health) + " health, and killed ") + enemieskilled) + " enemies.";
score = (health * enemieskilled) + coins;
if (score > levelscores[level - 1]) {
levelscores[level - 1] = score;
}
scoretext = "Level Score : " + score;
bscoretext = "Best Score : " + levelscores[level - 1];
totalscore = 0;
for (i in levelscores) {
totalscore = totalscore + levelscores[i];
}
tscoretext = "Total Score : " + totalscore;
medalcounter = 0;
if (health >= 80) {
medalcounter++;
}
if (enemieskilled >= (enemiessent * 0.8)) {
medalcounter++;
}
tempmedal = 3 - medalcounter;
if (levelmedals[level - 1] > tempmedal) {
levelmedals[level - 1] = tempmedal;
}
medallevel = medalnames[tempmedal] + " medal earnt";
savegame();
continueb.onRelease = function () {
musictitle.stop();
gotoAndStop (4);
};
onEnterFrame = function () {
buttonize(continueb, 130, 4, false);
};
Frame 8
gotoAndStop (32);
stopAllSounds();
Frame 9
stopAllSounds();
musicarray[musictypes[level]].stop();
if (musicon) {
musicarray[musictypes[level]].start(0, 999999);
}
gotoAndStop(11 + level);
Frame 10
leftarrow.onRelease = function () {
if (freeplvl > 1) {
freeplvl--;
}
};
rightarrow.onRelease = function () {
if (freeplvl < 20) {
freeplvl++;
}
};
leftarrow2.onRelease = function () {
if (freemusic > 0) {
freemusic--;
}
};
rightarrow2.onRelease = function () {
if (freemusic < 6) {
freemusic++;
}
};
leftarrow3.onRelease = function () {
if (freediff > 0) {
freediff--;
}
};
rightarrow3.onRelease = function () {
if (freediff < 3) {
freediff++;
}
};
start.onRelease = function () {
gotoAndStop (32);
stopAllSounds();
};
onEnterFrame = function () {
buttonize(leftarrow, 150, 1, false);
buttonize(rightarrow, 150, 1, false);
buttonize(leftarrow2, 150, 1, false);
buttonize(rightarrow2, 150, 1, false);
buttonize(leftarrow3, 150, 1, false);
buttonize(rightarrow3, 150, 1, false);
buttonize(back, 130, 4, true);
buttonize(start, 130, 1, false);
freeplaylevel = levelnames[freeplvl];
freeplaymusic = musicnames[freemusic];
freeplaydiff = diffs[freediff];
};
Frame 11
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 2) {
waveframe = 1;
}
makewave(3, 20, waveframe, 5, wave - 1, Math.round(wave / 2));
waveframe++;
wavenumber--;
}
}
function maketutbox(page, endpage) {
if (!tuton) {
tuton = true;
gamepaused = true;
d = _root.getNextHighestDepth();
b = attachMovie("tutbox", "tutbox", d);
b._x = 300 - _x;
b._y = 180;
b.gotoAndStop(page);
tutstartpage = page;
tutendpage = endpage;
stage++;
}
}
stop();
bgframe = 1;
makevars();
mintower = 1;
maxtower = 2;
wavenumber = 2;
clockspeed = 1.5;
coins = 80;
tuton = false;
tutstartpage = 0;
tutendpage = 0;
tutcurpage = 0;
stage = 0;
wavesetoff = 3;
goombay = 488;
towertimer = 0;
attachMovie("goomba", "goomba", _root.getNextHighestDepth());
goomba._x = 200;
goomba._y = 498;
if (stage == 0) {
maketutbox(1, 4);
}
onEnterFrame = function () {
if (Key.isDown(32)) {
removeeverything();
removeMovieClip(tutbox);
removeMovieClip(pmenu);
removeMovieClip(goomba);
gotoAndStop (4);
}
menu._y = menu._y + ((menu.endy - menu._y) / 2);
goomba._y = goomba._y + ((goombay - goomba._y) / 3);
if (tuton) {
goombay = 488;
buttonize(tutbox.continuebut, 130, 0, false);
tutbox.continuebut.onRelease = function () {
if (tutbox._currentframe == 15) {
removeeverything();
removeMovieClip(tutbox);
removeMovieClip(goomba);
tuton = false;
gamepaused = false;
gotoAndStop (4);
}
if (soundon) {
playsound(meep);
}
if (tutstartpage == tutendpage) {
removeMovieClip(tutbox);
tuton = false;
gamepaused = false;
} else if (tutbox._currentframe == tutendpage) {
removeMovieClip(tutbox);
tuton = false;
gamepaused = false;
} else {
tutbox.nextFrame();
}
};
} else if (goomba.hitTest(_xmouse, _ymouse, false)) {
goombay = 358;
} else {
goombay = 408;
}
goomba.gotoAndStop(stage);
goomba._x = (200 - _x) - xspeed;
if (stage == 1) {
if (coins < 40) {
coins = coins + 40;
}
if (_x >= 595) {
towersamount = towers.length;
maketutbox(5, 7);
}
}
if (stage == 2) {
if (towers.length > towersamount) {
tutdepth = -1;
for (i in towers) {
t = towers[i];
if (t.type == 1) {
if (t.placed) {
if (i > tutdepth) {
tutdepth = i;
}
tuttower = towers[tutdepth];
if ((towertimer++) > 6) {
maketutbox(8, 10);
}
}
}
}
}
}
if (stage == 3) {
if (coins < 5) {
coins = coins + 5;
}
if (tuttower.damage >= 2) {
maketutbox(11, 12);
}
}
if (stage == 4) {
if (enemies.length > 0) {
stage = 5;
}
}
if (stage == 5) {
if (enemies.length == 0) {
maketutbox(13, 14);
}
}
if (stage == 6) {
if (wavenumber == 0) {
if (enemies.length == 0) {
maketutbox(15, 15);
}
}
}
if (!tuton) {
if (!gamepaused) {
if (!menulock) {
if ((menu.hitTest(_xmouse, _ymouse, true) || (Key.isDown(40))) || (Key.isDown(70))) {
menu.endy = 42;
} else {
menu.endy = -15;
}
} else {
menu.endy = 42;
}
} else {
menu.endy = -15;
}
} else {
menu.endy = -15;
}
if (!gamepaused) {
wavesent = false;
if (stage > wavesetoff) {
if (Math.round(menu.clock.hand._rotation) == 0) {
if (wave != 0) {
if (wavenumber != 0) {
nextwave();
playsound(nextwavesound);
menu.clock.hand._rotation = 360;
wavesent = true;
}
} else {
wave++;
}
}
if (autowave) {
if (enemies.length == 0) {
if (wave != 1) {
if (!wavesent) {
if (wavenumber != 0) {
menu.clock.hand._rotation = 0;
nextwave();
playsound(nextwavesound);
menu.clock.hand._rotation = 360;
}
}
}
}
}
}
rmenu.rx = rmenu.rx + ((menu.endx - rmenu.rx) / 2);
updatetopmenutext();
menu.clock.onRollOver = function () {
menu.clock.gotoAndStop(2);
};
menu.clock.onRollOut = function () {
menu.clock.gotoAndStop(1);
};
menu.clock.onReleaseOutside = function () {
menu.clock.gotoAndStop(1);
};
menu.clock.onRelease = function () {
if (!gamepaused) {
if ((menu.clock.hand._rotation > 90) || (menu.clock.hand._rotation < 0)) {
menu.clock.hand._rotation = 0;
} else {
playsound(deny2);
}
}
};
menu.previtem.onRelease = function () {
if (!gamepaused) {
prevtower();
}
};
menu.nextitem.onRelease = function () {
if (!gamepaused) {
nexttower();
}
};
menu.key.onRelease = function () {
if (!gamepaused) {
menulock = (menulock ? false : true);
}
};
if (!tuton) {
menu.pbutton.onRelease = function () {
if (gamepaused) {
gamepaused = false;
fadeoutpause = true;
playsound(pausesound);
musicarray[musictypes[level]].setVolume(100);
} else {
if (pmenu != undefined) {
removeMovieClip(pmenu);
fadeoutpause = false;
}
playsound(continuesound);
musicarray[musictypes[level]].setVolume(25);
gamepaused = true;
attachMovie("pmenu", "pmenu", _root.getNextHighestDepth());
pmenu._x = 300 - _x;
pmenu._y = 200;
pmenu._alpha = 0;
pmenu.currentlevel = "Tutorial Level";
}
};
}
if (fadeoutpause) {
if (pmenu._alpha > 0) {
pmenu._alpha = pmenu._alpha - 15;
} else {
removeMovieClip(pmenu);
}
}
if (itembannerpos < mintower) {
itembannerpos = mintower;
menu.itempic.itembanner._x = (itembannerpos - 1) * -50;
menu.towerde._y = (itembannerpos - 1) * -70;
}
moveenemies();
movehealthtexts();
movetowers();
movebullets();
movebubble();
movecoins();
moveparts();
movewaves();
moveground();
shake();
shortcuts();
Q = getTimer() - (Q ? (Q) : 0);
fps = int(1000 / Q) + " FPS";
Q = getTimer();
if (stage > 3) {
if (wavenumber > 0) {
menu.clock.hand._rotation = menu.clock.hand._rotation + clockspeed;
}
}
castle.doorr._x = castle.doorr._x + ((castledoorx - castle.doorr._x) / 3);
castle.doorl._x = -castle.doorr._x;
mushroomhealthbar.gotoAndStop(((100 - health) / 10) + 1);
if (wavenumber == 0) {
if (enemies.length == 0) {
if ((endtimer++) > 30) {
removeMovieClip(goomba);
gotoAndStop (7);
removeeverything();
}
}
}
for (i in enemies) {
e = enemies[i];
if ((e._x + (e._width / 2)) > castle._x) {
if (bubbleob == e) {
bubactive = false;
}
setshake(2, 3);
health = health - 10;
playsound(lifelose);
e.lb._y = 500;
e.rb._y = 500;
}
opendoors = false;
if (castle.hitTest(e)) {
opendoors = true;
}
if (opendoors) {
castledoorx = 20;
} else {
castledoorx = 6.8;
}
if (!checkbound(castle)) {
if (exclam._currentframe == 1) {
if (opendoors) {
exclam.gotoAndPlay(2);
}
}
} else {
exclam.gotoAndStop(1);
}
if (health <= 0) {
removeMovieClip(goomba);
removeeverything();
gotoAndStop (4);
}
}
} else {
if (pmenu._alpha < 100) {
pmenu._alpha = pmenu._alpha + 15;
}
buttonize(pmenu.resume, 130, 5, false);
pmenu.resume.onRelease = function () {
gamepaused = false;
fadeoutpause = true;
playsound(pausesound);
musicarray[musictypes[level]].setVolume(100);
};
if (pmenu.quit._currentframe == 1) {
buttonize(pmenu.quit.qbut, 130, 5, false);
pmenu.quit.qbut.onRelease = function () {
pmenu.quit.gotoAndStop(2);
playsound(meep);
};
} else {
buttonize(pmenu.quit.ybut, 130, 5, false);
buttonize(pmenu.quit.nbut, 130, 5, false);
pmenu.quit.nbut.onRelease = function () {
pmenu.quit.gotoAndStop(1);
playsound(meep);
};
pmenu.quit.ybut.onRelease = function () {
removeMovieClip(goomba);
removeeverything();
removeMovieClip(pmenu);
gotoAndStop (4);
musicarray[musictypes[level]].stop();
};
}
if (pmenu.retryb._currentframe == 1) {
buttonize(pmenu.retryb.qbut, 130, 5, false);
pmenu.retryb.qbut.onRelease = function () {
pmenu.retryb.gotoAndStop(2);
};
} else {
buttonize(pmenu.retryb.ybut, 130, 5, false);
buttonize(pmenu.retryb.nbut, 130, 5, false);
pmenu.retryb.nbut.onRelease = function () {
pmenu.retryb.gotoAndStop(1);
};
pmenu.retryb.ybut.onRelease = function () {
playsound(meep);
removeMovieClip(goomba);
removeeverything();
removeMovieClip(pmenu);
musicarray[musictypes[level]].setVolume(100);
removeMovieClip(tutbox);
gotoAndStop (34);
};
}
pmenu.autowavepad.onRelease = function () {
autowave = (autowave ? false : true);
};
pmenu.autowavepad.gotoAndStop(int(autowave) + 1);
pmenu.partpad.onRelease = function () {
particleeffects = (particleeffects ? false : true);
};
pmenu.partpad.gotoAndStop(int(particleeffects) + 1);
pmenu.soundpad.onRelease = function () {
soundeffects = (soundeffects ? false : true);
};
pmenu.soundpad.gotoAndStop(int(soundeffects) + 1);
pmenu.musicpad.onRelease = function () {
if (!musicon) {
musicon = true;
musictitle.start(0, 99999999);
} else {
musicon = false;
musictitle.stop();
}
};
pmenu.musicpad.gotoAndStop(int(musicon) + 1);
pmenu.qpad.onRelease = function () {
if (quality == 1) {
quality = 2;
_root._quality = "medium";
} else if (quality == 2) {
quality = 3;
_root._quality = "high";
} else if (quality == 3) {
quality = 1;
_root._quality = "low";
}
};
pmenu.qpad.gotoAndStop(quality);
}
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
goomba.swapDepths(_root.getNextHighestDepth());
}
};
Frame 12
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 2) {
waveframe = 1;
}
makewave(3, 20, waveframe, 5, wave - 1, Math.round(wave / 2));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 1;
makevars();
mintower = 1;
maxtower = 2;
wavenumber = 15;
clockspeed = 1.5;
coins = 80;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 13
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 4) {
waveframe = 1;
}
makewave(5, 20, waveframe, 5, wave * 2, 1 + Math.round(wave * 0.8));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 2;
makevars();
wavenumber = 15;
mintower = 1;
maxtower = 3;
clockspeed = 1.5;
coins = 100;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 14
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 4) {
waveframe = 2;
}
makewave(6, 10, waveframe, 5, Math.round(wave * 2.07), Math.round(wave / 1.1));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 3;
makevars();
wavenumber = 15;
mintower = 1;
maxtower = 4;
clockspeed = 1.8;
coins = 130;
waveframe = 2;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 15
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 10) {
waveframe = 9;
}
makewave(3, 20, waveframe, 3.8, 4 + Math.round(wave * 1.9), 2 + Math.round(wave / 1.1));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 5;
makevars();
wavenumber = 20;
mintower = 2;
maxtower = 6;
clockspeed = 2;
coins = 120;
waveframe = 9;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 16
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 8) {
waveframe = 7;
}
makewave(4, 10, waveframe, 5.4, 3 + Math.round(wave * 3), 1 + Math.round(wave * 1.5));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 6;
makevars();
wavenumber = 14;
mintower = 5;
maxtower = 7;
clockspeed = 1.5;
coins = 300;
waveframe = 6;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 17
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 10) {
waveframe = 1;
}
makewave(3, 30, waveframe, 5, 5 + Math.round(wave * 4.6), 3 + Math.round(wave * 4.5));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 12;
makevars();
wavenumber = 16;
maxtower = 11;
mintower = 8;
clockspeed = 1.5;
coins = 500;
waveframe = 1;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 18
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 5) {
waveframe = 1;
}
makewave(5, 3, (waveframe * 2) - 1, 5, 10 + Math.round(wave * 2.8), Math.round(wave * 2.3));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 10;
makevars();
wavenumber = 15;
mintower = 3;
maxtower = 7;
clockspeed = 1.2;
coins = 600;
waveframe = 1;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 19
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 2) {
waveframe = 1;
}
makewave(1, 24, 11, 4.5, 5 + (wave * 28), 23 + (wave * 7));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 15;
makevars();
wavenumber = 25;
mintower = 1;
maxtower = 11;
clockspeed = 1.8;
coins = 700;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 20
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 6) {
waveframe = 1;
}
makewave(5, 4, waveframe, 5, Math.round(wave * 1.8), 6 + Math.round(wave * 2.45));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 10;
makevars();
wavenumber = 18;
mintower = 12;
maxtower = 13;
clockspeed = 1.3;
coins = 900;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 21
function nextwave() {
if (wavenumber > 0) {
wave++;
if (Math.round(wave / 2) == (wave / 2)) {
makewave(7, 5, 1, 4, Math.round(wave * 3.6), Math.round(wave * 2.5));
} else {
makewave(5, 6, 2, 6, Math.round(wave * 1.85), Math.round(wave * 3));
}
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 10;
makevars();
wavenumber = 20;
mintower = 5;
maxtower = 9;
clockspeed = 1.8;
coins = 500;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 22
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 10) {
waveframe = 1;
}
makewave(7, 15, random(10) + 1, 5, 5 + Math.round(wave * 7.5), 5 + Math.round(wave * 3.05));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 2;
makevars();
wavenumber = 20;
mintower = 1;
maxtower = 13;
clockspeed = 1.5;
coins = 650;
waveframe = 1;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 23
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 7) {
waveframe = 3;
}
makewave(3, 10, waveframe, 5, Math.round((wave * wave) * 0.8), 5 + (wave * 12));
waveframe = waveframe + 4;
wavenumber--;
}
}
stop();
bgframe = 8;
makevars();
wavenumber = 15;
mintower = 1;
maxtower = 4;
clockspeed = 1.2;
coins = 500;
waveframe = 3;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 24
function nextwave() {
if (wavenumber > 0) {
wave++;
makewave(2, 24, 12, 5, 9 + Math.round(wave * 10.3), 15 + Math.round(wave * 3.2));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 19;
makevars();
wavenumber = 18;
mintower = 5;
maxtower = 13;
clockspeed = 1.5;
coins = 300;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 25
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 10) {
waveframe = 5;
}
makewave(2, 15, waveframe, 5.5, wave * wave, wave * 5);
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 5;
makevars();
wavenumber = 20;
mintower = 11;
maxtower = 11;
clockspeed = 1.5;
coins = 360;
waveframe = 5;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 26
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 2) {
waveframe = 1;
}
makewave(5, 2, waveframe, 4.7, wave * 4, Math.round(wave * 2));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 6;
makevars();
wavenumber = 20;
mintower = 3;
maxtower = 9;
clockspeed = 1.5;
coins = 300;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 27
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 6) {
waveframe = 5;
}
makewave(5, 20, waveframe, 6, 20 + (wave * 7), 10 + Math.round(wave * 1.5));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 17;
makevars();
wavenumber = 18;
mintower = 9;
maxtower = 13;
clockspeed = 1.5;
coins = 500;
waveframe = 5;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 28
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 10) {
waveframe = 1;
}
makewave(6, 20, waveframe, 4.5, 20 + Math.round(wave * 5.3), 13 + Math.round(wave * 2.1));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 11;
makevars();
wavenumber = 15;
mintower = 1;
maxtower = 13;
clockspeed = 1.3;
coins = 300;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 29
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 6) {
waveframe = 3;
}
makewave(5, 7, waveframe, 4.5, 6 + Math.round(wave * 3.9), 1 + Math.round(wave * 2.4));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 14;
makevars();
wavenumber = 20;
mintower = 3;
maxtower = 6;
clockspeed = 1.2;
coins = 450;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 30
function nextwave() {
if (wavenumber > 0) {
wave++;
makewave(6, 12, random(10) + 1, 5, 6 + Math.round(wave * 5.9), 3 + Math.round(wave * 4.9));
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 18;
makevars();
wavenumber = 22;
mintower = 13;
maxtower = 13;
clockspeed = 1.2;
coins = 2000;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 31
function nextwave() {
if (wavenumber > 0) {
wave++;
if (waveframe > 10) {
waveframe = 1;
}
makewave(8, 13, waveframe, 5, 12 + Math.round(wave * 5.7), 10 + wave);
waveframe++;
wavenumber--;
}
}
stop();
bgframe = 16;
makevars();
wavenumber = 25;
mintower = 4;
maxtower = 13;
clockspeed = 1.5;
coins = 400;
onEnterFrame = function () {
gameplay();
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 32
function depwave() {
if (freediff == 0) {
if (waveframe > 2) {
waveframe = 1;
}
makewave(3, 20, waveframe, 5, wave + 3, Math.round(wave / 2));
} else if (freediff == 1) {
if (waveframe > 6) {
waveframe = 1;
}
makewave(3, 30, waveframe, 5, (5 + Math.round(wave * 4.8)) + Math.round((wave * wave) * 0.2), 3 + Math.round(wave * 4.5));
} else if (freediff == 2) {
if (waveframe > 8) {
waveframe = 1;
}
makewave(5, 8, waveframe, 4.6, (3 + (wave * 3)) + Math.round((wave * wave) * 0.25), Math.round(wave * 5.4));
} else if (freediff == 3) {
if (waveframe > 10) {
waveframe = 1;
}
makewave(8, 13, waveframe, 5, (4 + Math.round(wave * 3.7)) + Math.round((wave * wave) * 0.4), 10 + (wave * 4));
}
}
stop();
levelname = ["ground" + freeplvl];
_root.attachMovie(levelname, "ground", _root.getNextHighestDepth());
bubble.swapDepths(_root.getNextHighestDepth());
ground._x = 300;
ground._y = 371.8;
while (!ground.hitTest(gpipe._x, gpipe._y, true)) {
gpipe._y++;
}
gpipe._y = gpipe._y - 30;
while (!ground.hitTest(castle._x, castle.getBounds(_root).yMax, true)) {
castle._y++;
}
mushroomhealthbar._y = castle._y - 100;
if (musicon) {
musicarray[freemusic].start(0, 999999);
}
bgframe = bgnumbers[freeplvl];
makevars();
wavenumber = 0;
mintower = 1;
maxtower = 13;
waveframe = 1;
clockspeed = 1.5;
if (freediff == 0) {
coins = 100;
} else if (freediff == 1) {
coins = 400;
} else if (freediff == 2) {
coins = 300;
} else if (freediff == 3) {
coins = 400;
}
onEnterFrame = function () {
if (!gamepaused) {
wavesent = false;
if (Math.round(menu.clock.hand._rotation) == 0) {
if (wave != 0) {
wave++;
depwave();
waveframe++;
wavenumber++;
playsound(nextwavesound);
wavesent = true;
} else {
wave++;
}
}
if (autowave) {
if (enemies.length == 0) {
if (wavenumber != 0) {
if (!wavesent) {
menu.clock.hand._rotation = 0;
wave++;
depwave();
waveframe++;
wavenumber++;
playsound(nextwavesound);
}
}
}
}
Q = getTimer() - (Q ? (Q) : 0);
fps = int(1000 / Q) + " FPS";
Q = getTimer();
menu.clock.hand._rotation = menu.clock.hand._rotation + clockspeed;
castle.doorr._x = castle.doorr._x + ((castledoorx - castle.doorr._x) / 3);
castle.doorl._x = -castle.doorr._x;
mushroomhealthbar.gotoAndStop(((100 - health) / 10) + 1);
for (i in enemies) {
e = enemies[i];
if ((e._x + (e._width / 2)) > castle._x) {
if (bubbleob == e) {
bubactive = false;
}
setshake(2, 3);
health = health - 10;
playsound(lifelose);
e.lb._y = 500;
e.rb._y = 500;
}
opendoors = false;
if (castle.hitTest(e)) {
opendoors = true;
}
}
if (opendoors) {
castledoorx = 20;
} else {
castledoorx = 6.8;
}
if (wave != 0) {
if (!checkbound(castle)) {
if (exclam._currentframe == 1) {
if (opendoors) {
exclam.gotoAndPlay(2);
}
}
} else {
exclam.gotoAndStop(1);
}
}
if (health <= 0) {
removeeverything();
stopAllSounds();
if (musicon) {
musictitle.start(0, 9999);
}
gotoAndStop (33);
}
movemenu();
moveenemies();
movetowers();
movehealthtexts();
movebullets();
movebubble();
movecoins();
moveparts();
movewaves();
moveground();
shake();
shortcuts();
} else {
movepausemenu();
}
};
onMouseDown = function () {
if (!gamepaused) {
raisemenus();
pressed = true;
clickob = false;
checkpress(enemies);
checkpress(towers);
if (rmenu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (menu.hitTest(_xmouse, _ymouse, true)) {
clickob = true;
}
if (!clickob) {
bubactive = false;
}
}
};
onMouseUp = function () {
if (!gamepaused) {
pressed = false;
raisemenus();
}
};
onMouseMove = function () {
if (!gamepaused) {
raisemenus();
}
};
Frame 33
gamestat = ((((("You died on " + diffs[freediff]) + " mode, at wave ") + wave) + ", and with ") + coins) + " coins left. Here are you level stats:";
gmusic = musicnames[freemusic];
gdiff = diffs[freediff];
glevel = levelnames[freeplvl];
gwave = wave;
gcoins = coins;
onEnterFrame = function () {
buttonize(back, 130, 10, true);
};
Frame 34
gotoAndStop (11);
Frame 35
function maketext(speed, string) {
if (!texting) {
texting = true;
tstring = new String();
tstring = string;
tempstring = "";
i = 0;
e = tstring.length;
tempspeed = speed;
story.stop();
}
}
texting = false;
tempstring = "";
done = false;
texts = false;
skipy = 20;
transout.stop();
onEnterFrame = function () {
if (!done) {
subbox.tb = tempstring;
if (texting) {
if (!texts) {
textap.start(0, 999999);
texts = true;
}
if (i < e) {
i = i + tempspeed;
tempstring = tempstring + tstring.substr(i - tempspeed, tempspeed);
} else if (i == e) {
texting = false;
}
} else {
texts = false;
textap.stop();
}
if (story._currentframe >= 1056) {
done = true;
}
if (_ymouse < 200) {
skipy = 20;
} else {
skipy = -30;
}
} else {
texts = false;
textap.stop();
skipy = -30;
}
if (transout._currentframe >= 30) {
gotoAndStop (36);
textap.stop();
}
};
skippy.onRelease = function () {
if (story._currentframe > 258) {
if (story._currentframe < 794) {
_root.musicl1.stop();
_root.musiccastle.start(0, 99);
}
}
transout.play();
textap.stop();
};
onMouseDown = function () {
if (!done) {
if (i == e) {
tempstring = "";
texting = false;
story.play();
} else {
tempstring = tstring;
i = e;
}
}
};
Frame 36
stop();
gspeed = 5;
onEnterFrame = function () {
if (_xmouse > 300) {
q2._y = 175;
q1._y = 190;
wtut.gotoAndStop(1);
goomba._xscale = 100;
if (goomba._x < q2._x) {
goomba._x = goomba._x + gspeed;
goomba.gotoAndStop(2);
} else {
goomba.gotoAndStop(1);
}
subbox.tb = "I don't need the tutorial, I'm sure I'll figure it out. (Not Recommended)";
} else {
q2._y = 190;
q1._y = 175;
wtut.gotoAndStop(2);
goomba._xscale = -100;
if (goomba._x > q1._x) {
goomba._x = goomba._x - gspeed;
goomba.gotoAndStop(2);
} else {
goomba.gotoAndStop(1);
}
subbox.tb = "Learning is fun! Show me what to do. (Recommended)";
}
};
onMouseDown = function () {
playsound(clicks);
musiccastle.stop();
if (_xmouse > 300) {
gotoAndStop (4);
} else {
musictitle.start(0, 999);
gotoAndStop (11);
}
delete onMouseDown;
};
Frame 37
function makeswitcher(variable, switcher) {
if (variable) {
switcher.gotoAndStop(2);
} else {
switcher.gotoAndStop(1);
}
}
moneycheats.onRelease = function () {
moneycheat = (moneycheat ? false : true);
cheated = true;
savegame();
};
clickkillcheat.onRelease = function () {
clickkill = (clickkill ? false : true);
cheated = true;
savegame();
};
clickboocheat.onRelease = function () {
clickboo = (clickboo ? false : true);
cheated = true;
savegame();
};
holdkoopacheat.onRelease = function () {
holdshell = (holdshell ? false : true);
cheated = true;
savegame();
};
randomencheat.onRelease = function () {
randomenemies = (randomenemies ? false : true);
};
randombgcheat.onRelease = function () {
randombgs = (randombgs ? false : true);
};
nolimitscheat.onRelease = function () {
nolimits = (nolimits ? false : true);
cheated = true;
savegame();
};
lastmenux = 300;
onEnterFrame = function () {
buttonize(back, 130, 4, true);
makeswitcher(moneycheat, moneycheats);
makeswitcher(clickkill, clickkillcheat);
makeswitcher(clickboo, clickboocheat);
makeswitcher(holdshell, holdkoopacheat);
makeswitcher(randomenemies, randomencheat);
makeswitcher(randombgs, randombgcheat);
makeswitcher(nolimits, nolimitscheat);
};
Frame 38
function makemariovars(m, c) {
m.yspeed = 0;
m.xspeed = 0;
m.jumping = false;
m.coins = 0;
m.rdir = 0;
m.control = c;
if (c) {
m.cvar = pre.coins1;
} else {
m.cvar = pre.coins2;
}
}
function premakecoin(x, y) {
if (!pre.comp) {
d = _root.getNextHighestDepth();
c = attachMovie("coin", "coin" + d, d);
c._x = x;
c._y = y;
c.xspeed = (Math.random() * 10) - 5;
c.yspeed = Math.random() * -5;
c.timer = 0;
pre.coinsarray.push(c);
}
}
function movemario(m) {
m._x = m._x + m.xspeed;
m.xspeed = m.xspeed * 0.82;
m.yspeed++;
m._y = m._y + m.yspeed;
if (!m.jumping) {
if (Math.abs(m.xspeed) > 1) {
m.gotoAndStop(2);
} else {
m.gotoAndStop(1);
}
} else {
m.gotoAndStop(3);
}
if (m.yspeed >= 0) {
while (ground.hitTest(m._x, m.getBounds(_root).yMax, true)) {
m._y = m._y - 0.5;
m.yspeed = 0;
m.jumping = false;
}
}
if (m._x > 610) {
m._x = -10;
}
if (m._x < -10) {
m._x = 610;
}
if (m.control) {
if (Key.isDown(39)) {
predir(m, 1);
}
if (Key.isDown(37)) {
predir(m, -1);
}
if (Key.isDown(38)) {
m.control = true;
prejump(m);
m.controltimer = 0;
}
} else if (m.rdir == 0) {
if (random(30) == 0) {
m.rdir = 1;
}
if (random(30) == 0) {
m.rdir = -1;
}
if (random(30) == 0) {
prejump(m);
}
} else if (m.rdir == 1) {
predir(m, 1);
if (random(50) == 0) {
m.rdir = 0;
}
if (random(40) == 0) {
m.rdir = -1;
}
if (random(15) == 0) {
prejump(m);
}
} else if (m.rdir == -1) {
predir(m, -1);
if (random(50) == 0) {
m.rdir = 0;
}
if (random(40) == 0) {
m.rdir = 1;
}
if (random(15) == 0) {
prejump(m);
}
}
}
function onEnterFrame() {
buttonize(backb, 130, 4, false);
movemario(mario0);
i = 1;
while (i < 10) {
m = _root["mario" + i];
if (pre.pausedtimer == 0) {
movemario(m);
walk(m.w, 1);
}
i++;
}
coinstext1 = pre.coins1;
coinstext2 = pre.coins2;
if (random(10) == 0) {
premakecoin(Math.random() * 600, Math.random() * 150);
}
if (pre.pausedtimer > 0) {
pre.pausedtimer--;
} else {
pre.pausedtimer = 0;
}
if (mario0.hitTest(block)) {
if (!pre.blockhit) {
pre.blockhit = true;
coo = 0;
while (coo < 100) {
premakecoin(Math.random() * 600, Math.random() * 150);
coo++;
}
pre.pausedtimer = 100;
}
} else {
pre.blockhit = false;
}
for (i in pre.coinsarray) {
c = pre.coinsarray[i];
c._x = c._x + c.xspeed;
c._y = c._y + c.yspeed;
c.yspeed = c.yspeed + 0.6;
c.xspeed = c.xspeed * 0.95;
c.timer++;
if (c.timer > 500) {
removeMovieClip(c);
pre.coinsarray.splice(i, 1);
}
if (c._x > 600) {
c._x = 0;
}
if (c._x < 0) {
c._x = 600;
}
j = 0;
while (j < 10) {
mm = _root["mario" + j];
if (c.hitTest(mm)) {
if (mm.control) {
pre.coins1++;
removeMovieClip(c);
pre.coinsarray.splice(i, 1);
} else {
removeMovieClip(c);
pre.coinsarray.splice(i, 1);
if (pre.pausedtimer == 0) {
pre.coins2++;
}
}
}
j++;
}
while (ground.hitTest(c._x, c.getBounds(_root).yMax, true)) {
c.yspeed = c.yspeed * -0.8;
c._y--;
}
}
}
function prejump(m) {
if (!m.jumping) {
if (Math.round(m.yspeed) == 0) {
m.jumping = true;
m.yspeed = m.yspeed - 10;
}
}
}
function predir(m, d) {
m._xscale = d * 100;
m.xspeed = m.xspeed + d;
}
stop();
pre = new Object();
pre.coinsarray = new Array();
pre.blockhit = false;
pre.coins1 = 0;
pre.coins2 = 0;
pre.pausedtimer = 0;
pre.comp = false;
makemariovars(mario0, true);
makemariovars(mario1, false);
makemariovars(mario2, false);
makemariovars(mario3, false);
makemariovars(mario4, false);
makemariovars(mario5, false);
makemariovars(mario6, false);
makemariovars(mario7, false);
backb.onRelease = function () {
while ((!pre.coinsarray.length) == 0) {
i = 0;
while (i < pre.coinsarray.length) {
c = pre.coinsarray[i];
removeMovieClip(c);
pre.coinsarray.splice(i, 1);
i++;
}
}
pre.comp = true;
gotoAndStop (4);
};
Symbol 32 MovieClip [bullet3] Frame 1
stop();
Symbol 48 MovieClip Frame 1
stop();
Symbol 48 MovieClip Frame 25
stop();
Symbol 54 MovieClip [tower3] Frame 1
stop();
Symbol 62 MovieClip [bullet6] Frame 13
gotoAndPlay (1);
Symbol 62 MovieClip [bullet6] Frame 25
stop();
Symbol 111 MovieClip Frame 1
stop();
Symbol 118 MovieClip Frame 1
stop();
Symbol 125 MovieClip Frame 1
stop();
Symbol 133 MovieClip Frame 1
stop();
Symbol 140 MovieClip Frame 1
stop();
Symbol 146 MovieClip [enemy9] Frame 1
stop();
Symbol 150 MovieClip Frame 1
stop();
Symbol 156 MovieClip [enemy12] Frame 1
stop();
Symbol 188 MovieClip Frame 1
stop();
Symbol 237 MovieClip Frame 1
i = 1;
while (i < 14) {
this["c" + i] = _root.costs[i];
i++;
}
Symbol 238 MovieClip [topmenu] Frame 1
this.onMouseDown = function () {
if (!_root.gamepaused) {
if (itempic.hitTest(_parent._xmouse, _parent._ymouse, true)) {
if ((_root.coins - _root.costs[_root.itembannerpos]) >= 0) {
_root.maketower(_root.itembannerpos);
}
}
}
};
Symbol 258 MovieClip Frame 1
stop();
Symbol 293 MovieClip Frame 1
stop();
Symbol 306 MovieClip Frame 1
stop();
Symbol 319 MovieClip [rightmenu] Frame 1
stop();
Symbol 339 MovieClip [bullet1] Frame 1
stop();
Symbol 339 MovieClip [bullet1] Frame 14
stop();
Symbol 364 MovieClip [tower13] Frame 10
stop();
Symbol 367 MovieClip [bullet10] Frame 1
stop();
Symbol 367 MovieClip [bullet10] Frame 9
gotoAndPlay (2);
Symbol 384 MovieClip Frame 9
gotoAndPlay (1);
Symbol 384 MovieClip Frame 10
stop();
Symbol 387 MovieClip [bullet8] Frame 1
stop();
Symbol 390 MovieClip [exclam] Frame 1
stop();
Symbol 411 MovieClip Frame 1
stop();
Symbol 422 MovieClip Frame 1
stop();
Symbol 427 MovieClip Frame 1
stop();
Symbol 450 MovieClip Frame 1
stop();
Symbol 455 MovieClip Frame 1
stop();
Symbol 461 MovieClip [enemy5] Frame 1
stop();
Symbol 487 MovieClip Frame 1
stop();
Symbol 505 MovieClip Frame 1
i = 1;
while (i < 14) {
this["c" + i] = _root.costs[i];
i++;
}
Symbol 511 MovieClip [tower1] Frame 1
stop();
Symbol 544 MovieClip [tutbox] Frame 1
stop();
Symbol 550 MovieClip Frame 1
stop();
Symbol 556 MovieClip [enemy6] Frame 1
stop();
Symbol 646 MovieClip [bullet9] Frame 1
stop();
Symbol 647 MovieClip [enemy10] Frame 1
stop();
Symbol 650 MovieClip Frame 1
stop();
Symbol 653 MovieClip [enemy1] Frame 1
stop();
Symbol 656 MovieClip Frame 1
stop();
Symbol 659 MovieClip [enemy2] Frame 1
stop();
Symbol 679 MovieClip Frame 40
stop();
Symbol 693 Button
on (press) {
tellTarget (_root) {
nextFrame();
};
}
Symbol 694 Button
on (press) {
gotoAndStop ("end");
_root.play();
}
Instance of Symbol 669 MovieClip in Symbol 695 MovieClip Frame 1
onClipEvent (load) {
_root.stop();
PercentLoaded = int((_root.getBytesLoaded() / _root.getBytesTotal()) * 100);
if (PercentLoaded != 100) {
_parent.gotoAndStop(PercentLoaded);
} else {
_parent.gotoAndStop("lastframe");
}
}
onClipEvent (enterFrame) {
PercentLoaded = int((_root.getBytesLoaded() / _root.getBytesTotal()) * 100);
if (PercentLoaded != 100) {
_parent.gotoAndStop(PercentLoaded);
} else {
_parent.gotoAndPlay("loaded");
}
}
Symbol 695 MovieClip Frame 101
play();
Symbol 695 MovieClip Frame 165
stop();
Symbol 701 Button
on (release) {
NewgroundsAPI.loadNewgrounds();
}
Symbol 707 Button
on (release) {
NewgroundsAPI.loadNewgrounds();
}
Symbol 709 MovieClip Frame 1
function startAd(ngad_url) {
trace("opening " + ngad_url);
System.security.allowDomain("70.87.128.99");
System.security.allowInsecureDomain("70.87.128.99");
System.security.allowDomain("ads.shizmoo.com");
System.security.allowInsecureDomain("ads.shizmoo.com");
System.security.allowDomain("www.cpmstar.com");
System.security.allowInsecureDomain("www.cpmstar.com");
System.security.allowDomain("server.cpmstar.com");
System.security.allowInsecureDomain("server.cpmstar.com");
var ngads_redirect = new XML();
ngads_redirect.ignoreWhite = true;
ngads_redirect.onLoad = function (success) {
trace("[NEWGROUNDS FLASH ADS] :: You may get a 'Security Sandbox Violation' ... this is normal, do not freak out!");
if (success) {
ng_ad.loadMovie(ngads_redirect.toString(), "GET");
}
};
ngads_redirect.load(ngad_url);
}
if (NewgroundsAPI.getAdURL()) {
startAd(NewgroundsAPI.getAdURL());
}
NewgroundsAPI.onAdsApproved = function (ad_url) {
startAd(ad_url);
};
stop();
Symbol 1239 MovieClip [__Packages.NewgroundsAPI] Frame 0
class NewgroundsAPI
{
static var tracker_id, host, version, debug, error_format, header_format, normal_format, link_format;
function NewgroundsAPI () {
}
static function connectMovie(id) {
if (!id) {
SendError("Missing required 'id' parameter in NewgroundsAPI.connectMovie(id:Number)");
} else if (!tracker_id) {
SendMessage("Connecting to API gateway...");
tracker_id = id;
host = _url.split("/")[2].toLowerCase();
if (host.length < 1) {
host = "localhost";
}
var _local2 = new Object();
SendEvent(MOVIE_VIEWS);
}
}
static function setMovieVersion(movie_version) {
if (!movie_version) {
SendError("Missing required 'version' in NewgroundsAPI.setMovieVersion(version:String)");
} else {
version = movie_version;
}
}
static function debugMode() {
debug = true;
}
static function addCustomEvent(stat_id, stat_name) {
if (!stat_id) {
SendError("Missing required 'id' parameter in NewgroundsAPI.AddCustomEvent(id:Number, event_name:String)");
} else if (!stat_name) {
SendError("Missing required 'event_name' parameter in NewgroundsAPI.AddCustomEvent(id:Number, event_name:String)");
} else {
custom_events[stat_name] = CUSTOM_STATS + stat_id;
SendMessage("Created custom event: " + stat_name);
}
}
static function addCustomLink(stat_id, stat_name) {
if (!stat_id) {
SendError("Missing required 'id' parameter in NewgroundsAPI.AddCustomLink(id:Number, link_name:String)");
} else if (!stat_name) {
SendError("Missing required 'link_name' parameter in NewgroundsAPI.AddCustomLink(id:Number, link_name:String)");
} else {
custom_links[stat_name] = CUSTOM_STATS + stat_id;
SendMessage((("Created custom link " + stat_id) + ": ") + stat_name);
}
}
static function loadMySite() {
SendLink(AUTHOR_SITE);
}
static function loadNewgrounds(special) {
if (special) {
var _local1 = {page:special};
}
SendLink(NEWGROUNDS, _local1);
}
static function logCustomEvent(event_name) {
if (!event_name) {
SendError("Missing required 'event_name' parameter in NewgroundsAPI.logCustomEvent(event_name:String)");
} else if (!custom_events[event_name]) {
SendError("Attempted to log undefined custom event: " + event_name);
} else {
SendEvent(custom_events[event_name]);
}
}
static function loadCustomLink(link_name) {
if (!link_name) {
SendError("Missing required 'link_name' parameter in NewgroundsAPI.loadCustomLink(link_name:String)");
} else if (!custom_links[link_name]) {
SendError("Attempted to open undefined custom link: " + link_name);
} else {
SendLink(custom_links[link_name]);
}
}
static function getAdURL() {
return(movie_options.ad_url);
}
static function getMovieURL() {
if (movie_options.movie_url) {
return(movie_options.movie_url);
}
return("Newgrounds.com");
}
static function getNewVersionURL() {
return((((((GATEWAY_URL + "?&id=") + tracker_id) + "&host=") + escape(host)) + "&stat=") + NEW_VERSION);
}
static function SendEvent(id) {
SendStat(id, false);
}
static function SendLink(id, extra) {
SendStat(id, true, extra);
}
static function ReadGatewayData(params) {
for (var _local2 in params) {
params[_local2] = unescape(params[_local2]);
movie_options[_local2] = params[_local2];
}
if (params.settings_loaded) {
SendMessage("You have successfully connected to the Newgrounds API gateway!");
SendMessage(("Movie Identified as '" + movie_options.movie_name) + "'");
if (movie_options.message) {
SendMessage(movie_options.message);
}
if (movie_options.ad_url) {
SendMessage("Your movie has been approved to run Flash Ads");
onAdsApproved(movie_options.ad_url);
}
if (movie_options.movie_version and (movie_options.movie_version.toString() != version.toString())) {
SendMessage("WARNING: The movie version configured in your API settings does not match this movie's version!");
onNewVersionAvailable(movie_options.movie_version, getMovieURL(), getNewVersionURL());
}
if (movie_options.deny_host) {
SendMessage("You have blocked 'localHost' in your API settings.");
SendMessage("If you wish to test your movie you will need to remove this block.");
onDenyHost(host, getMovieURL(), getNewVersionURL());
}
if (movie_options.request_portal_url == 1) {
var _local4 = (((GATEWAY_URL + "?&id=") + tracker_id) + "&portal_url=") + escape(_url);
var _local3 = new XML();
_local3.ignoreWhite = true;
_local3.load(_local4);
}
} else if (!movie_options.settings_loaded) {
SendError("Could not establish connection to the API gateway.");
}
}
static function SendStat(stat_id, open_in_browser, extra) {
if (!tracker_id) {
SendError("API calls cannot be made without a valid movie id.");
SendError("Did you remember to add the \"NewgroundsAPI.connectMovie()\" code?");
} else {
var _local7 = (((((GATEWAY_URL + "?&id=") + tracker_id) + "&host=") + escape(host)) + "&stat=") + stat_id;
for (var _local9 in extra) {
_local7 = _local7 + ((("&" + escape(_local9)) + "=") + escape(extra[_local9]));
}
trace(_local7);
if (debug) {
_local7 = _local7 + "&debug=1";
}
if (open_in_browser) {
getURL (_local7, "_blank");
} else {
var _local10 = new XML();
_local10.ignoreWhite = true;
_local10.onLoad = function (success) {
var _local6 = new Object();
var _local3 = 0;
while (_local3 < this.firstChild.childNodes.length) {
var _local4 = this.firstChild.childNodes[_local3];
var _local5 = _local4.nodeName;
var _local2 = _local4.attributes.value;
if (_local2 == Number(_local2)) {
_local2 = Number(_local2);
}
_local6[_local5] = _local2;
_local3++;
}
NewgroundsAPI.ReadGatewayData(_local6);
};
_local10.load(_local7);
}
}
}
static function SendError(msg) {
trace("[NEWGROUNDS API ERROR] :: " + msg);
}
static function SendMessage(msg) {
trace("[NEWGROUNDS API] :: " + msg);
}
static function InitTextFormats() {
if (!error_format) {
error_format = new TextFormat();
error_format.font = "Arial Black";
error_format.size = 48;
error_format.color = 16711680 /* 0xFF0000 */;
}
if (!header_format) {
header_format = new TextFormat();
header_format.font = "Arial Black";
header_format.size = 24;
header_format.color = 16777215 /* 0xFFFFFF */;
}
if (!normal_format) {
normal_format = new TextFormat();
normal_format.font = "Arial";
normal_format.bold = true;
normal_format.size = 12;
normal_format.color = 16777215 /* 0xFFFFFF */;
}
if (!link_format) {
link_format = new TextFormat();
link_format.color = 16776960 /* 0xFFFF00 */;
link_format.underline = true;
}
}
static function onNewVersionAvailable(version, movie_url, redirect_url) {
InitTextFormats();
var _local2 = new Object();
_local2.x = Stage.width / 2;
_local2.y = Stage.height / 2;
_root.createEmptyMovieClip("NGAPI_new_version_overlay", _root.getNextHighestDepth());
_root.NGAPI_new_version_overlay.lineStyle(1, 0, 100);
_root.NGAPI_new_version_overlay.beginFill(0, 70);
_root.NGAPI_new_version_overlay.moveTo(-10, -10);
_root.NGAPI_new_version_overlay.lineTo(-10, 1000);
_root.NGAPI_new_version_overlay.lineTo(1000, 1000);
_root.NGAPI_new_version_overlay.lineTo(1000, -10);
_root.NGAPI_new_version_overlay.lineTo(-10, -10);
_root.NGAPI_new_version_overlay.endFill();
_root.NGAPI_new_version_overlay.lineStyle(10, 0, 100);
_root.NGAPI_new_version_overlay.beginFill(51);
_root.NGAPI_new_version_overlay.moveTo(_local2.x - 240, _local2.y - 120);
_root.NGAPI_new_version_overlay.lineTo(_local2.x + 240, _local2.y - 120);
_root.NGAPI_new_version_overlay.lineTo(_local2.x + 240, _local2.y + 80);
_root.NGAPI_new_version_overlay.lineTo(_local2.x - 240, _local2.y + 80);
_root.NGAPI_new_version_overlay.lineTo(_local2.x - 240, _local2.y - 120);
_root.NGAPI_new_version_overlay.endFill();
_root.NGAPI_new_version_overlay.createEmptyMovieClip("exit", 1000);
_root.NGAPI_new_version_overlay.exit.lineStyle(2, 39423, 100);
_root.NGAPI_new_version_overlay.exit.beginFill(0, 50);
_root.NGAPI_new_version_overlay.exit.moveTo(_local2.x + 210, _local2.y - 110);
_root.NGAPI_new_version_overlay.exit.lineTo(_local2.x + 230, _local2.y - 110);
_root.NGAPI_new_version_overlay.exit.lineTo(_local2.x + 230, _local2.y - 90);
_root.NGAPI_new_version_overlay.exit.lineTo(_local2.x + 210, _local2.y - 90);
_root.NGAPI_new_version_overlay.exit.lineTo(_local2.x + 210, _local2.y - 110);
_root.NGAPI_new_version_overlay.exit.endFill();
_root.NGAPI_new_version_overlay.exit.moveTo(_local2.x + 214, _local2.y - 106);
_root.NGAPI_new_version_overlay.exit.lineTo(_local2.x + 226, _local2.y - 94);
_root.NGAPI_new_version_overlay.exit.moveTo(_local2.x + 226, _local2.y - 106);
_root.NGAPI_new_version_overlay.exit.lineTo(_local2.x + 214, _local2.y - 94);
_root.NGAPI_new_version_overlay.exit.onMouseUp = function () {
if (_root.NGAPI_new_version_overlay.exit.hitTest(_root._xmouse, _root._ymouse)) {
_root.NGAPI_new_version_overlay.removeMovieClip();
}
};
var _local3 = (("Version " + version) + " is now available at:") + newline;
var _local5 = _local3.length;
_local3 = _local3 + movie_url;
var _local4 = _local3.length;
_root.NGAPI_new_version_overlay.createTextField("mouseblocker", 99, -10, -10, 1000, 1000);
_root.NGAPI_new_version_overlay.createTextField("newversion", 100, _local2.x - 210, _local2.y - 90, 400, 80);
_root.NGAPI_new_version_overlay.newversion.text = "New Version Available!";
_root.NGAPI_new_version_overlay.newversion.setTextFormat(header_format);
_root.NGAPI_new_version_overlay.createTextField("message", 101, (Stage.width - 400) / 2, Stage.height / 2, 400, 40);
_root.NGAPI_new_version_overlay.message.text = _local3;
_root.NGAPI_new_version_overlay.message.multiline = true;
_root.NGAPI_new_version_overlay.message.wordWrap = true;
_root.NGAPI_new_version_overlay.message.html = true;
_root.NGAPI_new_version_overlay.message.setTextFormat(normal_format);
link_format.url = redirect_url;
_root.NGAPI_new_version_overlay.message.setTextFormat(_local5, _local4, link_format);
}
static function onDenyHost(hostname, movie_url, redirect_url) {
InitTextFormats();
_root.createEmptyMovieClip("NGAPI_deny_host_overlay", _root.getNextHighestDepth());
_root.NGAPI_deny_host_overlay.lineStyle(20, 0, 100);
_root.NGAPI_deny_host_overlay.beginFill(6684672);
_root.NGAPI_deny_host_overlay.moveTo(0, 0);
_root.NGAPI_deny_host_overlay.lineTo(Stage.width, 0);
_root.NGAPI_deny_host_overlay.lineTo(Stage.width, Stage.height);
_root.NGAPI_deny_host_overlay.lineTo(0, Stage.height);
_root.NGAPI_deny_host_overlay.lineTo(0, 0);
_root.NGAPI_deny_host_overlay.endFill();
var _local2 = ("This movie has not been approved for use on " + hostname) + ".";
_local2 = _local2 + "\r\rFor an aproved copy, please visit:\r";
var _local4 = _local2.length;
_local2 = _local2 + movie_url;
var _local3 = _local2.length;
_root.NGAPI_deny_host_overlay.createTextField("mousekill", 100, 0, 0, Stage.width, Stage.height);
_root.NGAPI_deny_host_overlay.createTextField("error", 101, (Stage.width - 400) / 2, (Stage.height / 2) - 100, 400, 200);
_root.NGAPI_deny_host_overlay.error.text = "ERROR!";
_root.NGAPI_deny_host_overlay.error.setTextFormat(error_format);
_root.NGAPI_deny_host_overlay.createTextField("message", 102, (Stage.width - 400) / 2, Stage.height / 2, 400, 200);
_root.NGAPI_deny_host_overlay.message.text = _local2;
_root.NGAPI_deny_host_overlay.message.multiline = true;
_root.NGAPI_deny_host_overlay.message.wordWrap = true;
_root.NGAPI_deny_host_overlay.message.html = true;
_root.NGAPI_deny_host_overlay.message.setTextFormat(normal_format);
link_format.url = redirect_url;
_root.NGAPI_deny_host_overlay.message.setTextFormat(_local4, _local3, link_format);
}
static function isInstalled() {
return(true);
}
static function onAdsApproved(ad_url) {
}
static var movie_options = new Object();
static var custom_events = new Object();
static var custom_links = new Object();
static var MOVIE_VIEWS = 1;
static var AUTHOR_SITE = 2;
static var NEWGROUNDS = 3;
static var NEW_VERSION = 4;
static var CUSTOM_STATS = 50;
static var GATEWAY_URL = "http://www.ngads.com/gateway.php";
}
Symbol 719 MovieClip Frame 1
stopAllSounds();
stop();
Symbol 879 MovieClip Frame 1
stop();
Symbol 919 MovieClip Frame 1
stop();
Symbol 926 MovieClip Frame 1
stop();
Symbol 934 MovieClip Frame 1
function onEnterFrame() {
credtext._y = credtext._y + ((credtexty - credtext._y) / 3);
}
credtexty = 0;
upscoll.onRelease = function () {
if (credtexty < 0) {
credtexty = credtexty + 30;
}
};
downscroll.onRelease = function () {
if (credtexty > -400) {
credtexty = credtexty - 30;
}
};
Symbol 941 MovieClip Frame 1
stop();
Symbol 941 MovieClip Frame 18
stop();
Symbol 944 MovieClip Frame 1
stop();
Symbol 997 MovieClip Frame 43
stop();
Symbol 1043 MovieClip Frame 1
stop();
Symbol 1046 MovieClip Frame 1
stop();
Symbol 1154 MovieClip Frame 46
stop();
Symbol 1195 MovieClip Frame 1
_root.maketext(1, "Click to skip text");
_root.musiccastle.start(0, 9);
Symbol 1195 MovieClip Frame 50
_root.maketext(1, "Ha ha ha ha. At last, the DUPLICON 3000 is finally complete...");
Symbol 1195 MovieClip Frame 51
_root.maketext(1, "With it I shall begin my elaborate plan to take over Mushroom Kingdom and become the Ruler Of The World!");
Symbol 1195 MovieClip Frame 91
_root.maketext(2, "All that's left to do now is to fly over there without anything going wrong...");
Symbol 1195 MovieClip Frame 92
_root.maketext(1, "What! What's going wrong?");
Symbol 1195 MovieClip Frame 224
_root.maketext(2, "NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO...");
Symbol 1195 MovieClip Frame 225
_root.maketext(1, "My plan is runied...");
Symbol 1195 MovieClip Frame 226
_root.maketext(1, "I think everyone can guess where that pipe goes");
Symbol 1195 MovieClip Frame 258
_root.musiccastle.stop();
_root.musicl1.start(0, 9);
Symbol 1195 MovieClip Frame 344
_root.maketext(1, "Mario: Such a nice quiet day today. No wind, no flying machines...");
Symbol 1195 MovieClip Frame 345
_root.maketext(1, "Luigi: What's that noise? It sounds as though it's coming from the pipe...");
Symbol 1195 MovieClip Frame 405
_root.maketext(1, "Mario: What? What's that?");
Symbol 1195 MovieClip Frame 427
_root.maketext(1, "Mario: Looks like some kind of evil plan, let's keep away from it.");
Symbol 1195 MovieClip Frame 428
_root.maketext(1, "Mario: Ha ha ha, it'll take more than wind to knock me off this ledge...");
Symbol 1195 MovieClip Frame 504
_root.maketext(1, "Luigi: He's gone... I'm free at last!");
Symbol 1195 MovieClip Frame 505
_root.maketext(1, "Luigi: I can see it now - 'Super Luigi World'");
Symbol 1195 MovieClip Frame 551
_root.maketext(1, "Luigi: Damn! Now there's two of you?");
Symbol 1195 MovieClip Frame 685
_root.maketext(1, "It appears to be some kind of note... From Bowser!");
Symbol 1195 MovieClip Frame 686
_root.maketext(1, "'Dear Mario & Luigi'...Blah blah blah...Yada yada yada...'From the office of Mr. Bowser'");
Symbol 1195 MovieClip Frame 687
_root.maketext(2, "Luigi: It would seem Bowser is going invade Mushroom Kingdom, and kidnap the Princess");
Symbol 1195 MovieClip Frame 688
_root.maketext(1, "....Original....");
Symbol 1195 MovieClip Frame 746
_root.maketext(1, "Mario: This gives me a plan, a plan so devious it must have been hastily tagged onto the game after it was complete.");
Symbol 1195 MovieClip Frame 782
_root.musicl1.stop();
_root.musiccastle.start(0, 9);
Symbol 1195 MovieClip Frame 897
_root.maketext(1, "Bowser: Who's knocking on my door at this time?");
Symbol 1195 MovieClip Frame 1003
_root.maketext(1, "Goomba: It seems there's some kind of red-green blur fast approaching!");
Symbol 1195 MovieClip Frame 1004
_root.maketext(1, "Bowser: I see... This is most disturbing");
Symbol 1195 MovieClip Frame 1005
_root.maketext(1, "Bowser: It would seem we are at war.");
Symbol 1195 MovieClip Frame 1006
_root.maketext(2, "Bowser: Prepare the troops! Secure the castle! Man the stations!");
Symbol 1195 MovieClip Frame 1007
_root.maketext(1, "Bowser: And Goomba, show this Warrior how things are done around here...");
Symbol 1195 MovieClip Frame 1008
_root.maketext(1, "Goomba: Yes, Right this way...");
Symbol 1195 MovieClip Frame 1009
stop();
if (_root.transout._currentframe == 1) {
_root.transout.play();
}
Symbol 1204 MovieClip Frame 1
stop();
Symbol 1205 MovieClip Frame 31
stop();
Symbol 1210 MovieClip Frame 1
stop();
Symbol 1230 MovieClip Frame 1
stop();
Symbol 1237 MovieClip Frame 1
stop();