Frame 1
function __com_mochibot__(swfid, mc, lv, trk) {
var _local5;
var _local4;
var _local3;
var _local7;
var _local13;
var _local10;
var _local11;
var _local2;
var _local8;
var _local12;
_local2 = "__mochibot__";
_local8 = "mochibot.com";
_local4 = (_global ? _global : (_level0._root));
if (_local4[_local2 + swfid]) {
return(_local4[_local2 + swfid]);
}
_local3 = System.security;
_local5 = mc._root.getSWFVersion;
_local7 = (_local5 ? (mc.getSWFVersion()) : ((_global ? 6 : 5)));
if (!_local3) {
_local3 = {};
}
}
Frame 2
stop();
Frame 3
stop();
Frame 4
stop();
intromusic = new Sound();
intromusic.attachSound("intrito");
intromusic.start(0, 99);
Frame 5
stop();
Frame 6
stop();
Frame 7
stop();
Frame 8
stop();
Frame 9
_root.remove = true;
_root.waves = [];
stop();
stopAllSounds();
Frame 10
_root.remove = true;
_root.waves = [];
stop();
stopAllSounds();
Frame 11
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Instance of Symbol 198 MovieClip "deselect" in Frame 11
on (press) {
_root.selectedTower = "";
_root.ranger._x = 3000;
_root.ranger._width = 10;
_root.ranger._height = 10;
_root.UpgradeTowerInfo._visible = false;
}
Instance of Symbol 284 MovieClip "creep1" in Frame 11
onClipEvent (load) {
}
onClipEvent (enterFrame) {
if (_root.remove == true) {
this.removeMovieClip();
}
}
Instance of Symbol 296 MovieClip "info_message" in Frame 11
onClipEvent (load) {
_visible = false;
}
Instance of Symbol 311 MovieClip "timeline" in Frame 11
onClipEvent (load) {
clearInterval(_root.levelInterval);
}
on (press) {
if (!_root.hasGameStarted) {
return(undefined);
}
if ((_root.wave >= 0) && ((_root.wave - 1) <= (_root.waves.length - 1))) {
_root.score = _root.score + (_root.wave * (_root.maxCount - _root.count));
_root.gold = _root.gold + int(_root.gold * 0.03);
_root.count = 1;
_root.newLevel();
}
}
onClipEvent (enterFrame) {
}
Instance of Symbol 324 MovieClip "UpgradeTowerInfo" in Frame 11
onClipEvent (load) {
_visible = false;
swapDepths(100000);
}
Instance of Symbol 329 MovieClip in Frame 11
on (press) {
if (_root.gold >= 30) {
_root.marker.active = 1;
_root.marker.tower = "cannon";
_root.marker.cost = 30;
}
_root.UpgradeTowerInfo._visible = false;
}
on (rollOver) {
_root.selectedTower = "";
_root.ranger._x = 3000;
_root.ranger._width = 10;
_root.ranger._height = 10;
_root.UpgradeTowerInfo._visible = false;
_parent.info_message.title.text = _root.tower_cannon.title;
_parent.info_message.desc.text = _root.tower_cannon.desc;
_parent.info_message.type.text = _root.tower_cannon.type;
_parent.info_message._visible = true;
}
on (rollOut) {
_parent.info_message._visible = false;
}
Instance of Symbol 330 MovieClip "tower_cannon" in Frame 11
onClipEvent (load) {
title = "Machine Gun";
desc = "Medium attack speed, high damage, high range";
type = "Cost $30";
cost = 0;
range = 120;
rate = 5;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 15;
splash = 0;
slow = 0;
poison = 0;
level = 1;
upgrades = [["Damage: 20\rRange: 120\rDebris:No\rSlow:No\rResidual:No\r", 40, 20, 120, 5, 0, 0, 0], ["Damage: 25\rRange: 120\rDebris:No\rSlow:No\rResidual:No\r", 60, 25, 120, 5, 0, 0, 0], ["Damage: 30\rRange: 120\rDebris:No\rSlow:No\rResidual:No\r", 110, 30, 120, 5, 0, 0, 0], ["Damage: 40\rRange: 120\rDebris:40\rSlow:No\rResidual:No\r", 170, 40, 120, 5, 40, 0, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if (_root.remove == true) {
this.removeMovieClip();
}
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_cannonball", damage, splash, slow);
}
}
}
}
}
Instance of Symbol 333 MovieClip "marker" in Frame 11
onClipEvent (load) {
active = 0;
}
onClipEvent (enterFrame) {
if (active == 1) {
_x = ((int((_root._xmouse - 10) / 20) * 20) + 20);
_y = ((int((_root._ymouse - 10) / 20) * 20) + 20);
hitTestOnGrassMovieClip = _root.grass.hitTest(_x, _y, 1);
if (hitTestOnGrassMovieClip) {
gotoAndStop (1);
_root.ranger.gotoAndStop(1);
} else {
gotoAndStop (2);
_root.ranger.gotoAndStop(2);
}
_root.ranger._x = _x;
_root.ranger._y = _y;
_root.ranger._width = _root["tower_" + tower].range * 2;
_root.ranger._height = _root["tower_" + tower].range * 2;
}
}
on (press) {
hitTestOnGrassMovieClip = _root.grass.hitTest(_x, _y, 1);
hitTestOnDeSelectMovieClip = _root.deselect.hitTest(_x, _y, 1);
if (hitTestOnGrassMovieClip || (hitTestOnDeSelectMovieClip)) {
if (hitTestOnGrassMovieClip && (!_root.hasGameFinished)) {
_root.towerCount++;
_root["tower_" + tower].duplicateMovieClip("t" + _root.towerCount, 500 + _root.towerCount);
a = _root["t" + _root.towerCount];
a._x = _x;
a._y = _y;
a.active = 1;
a.cost = cost;
_root.gold = _root.gold - cost;
_root.updateInfoBar();
if (!_root.hasGameStarted) {
_root.newLevel();
_root.hasGameStarted = true;
_root.instructions._visible = false;
}
}
active = 0;
_x = 1000;
_root.selectedTower = "";
_root.ranger._x = 1000;
_root.ranger._width = 10;
_root.ranger._height = 10;
}
}
Instance of Symbol 348 MovieClip in Frame 11
on (press) {
if (_root.gold >= 160) {
_root.marker.active = 1;
_root.marker.tower = "fire";
_root.marker.cost = 160;
}
_root.UpgradeTowerInfo._visible = false;
}
on (rollOver) {
_root.selectedTower = "";
_root.ranger._x = 3000;
_root.ranger._width = 10;
_root.ranger._height = 10;
_root.UpgradeTowerInfo._visible = false;
_parent.info_message.title.text = _root.tower_fire.title;
_parent.info_message.desc.text = _root.tower_fire.desc;
_parent.info_message.type.text = _root.tower_fire.type;
_parent.info_message._visible = true;
}
on (rollOut) {
_parent.info_message._visible = false;
}
Instance of Symbol 354 MovieClip "tower_fire" in Frame 11
onClipEvent (load) {
title = "Cannon";
desc = "Fast attack speed, moderate damage, low range, splash damage to nearby enemies";
type = "Cost $160";
cost = 0;
range = 80;
rate = 4;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 5;
splash = 40;
slow = 0;
poison = 0;
level = 1;
upgrades = [["Damage: 15\rRange: 80\rDebris:50\rSlow:No\rResidual:No\r", 90, 15, 80, 2, 50, 0, 0], ["Damage: 25\rRange: 80\rDebris:60\rSlow:No\rResidual:No\r", 150, 25, 80, 2, 60, 0, 0], ["Damage: 40\rRange: 80\rDebris:65\rSlow:No\rResidual:No\r", 190, 40, 80, 2, 65, 0, 0], ["Damage: 50\rRange: 80\rDebris:70\rSlow:20\rResidual:No\r", 250, 50, 80, 2, 70, 20, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if (_root.remove == true) {
this.removeMovieClip();
}
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_fire", damage, splash, slow);
}
}
}
}
}
Instance of Symbol 358 MovieClip in Frame 11
on (press) {
if (_root.gold >= 60) {
_root.marker.active = 1;
_root.marker.tower = "water";
_root.marker.cost = 60;
}
_root.UpgradeTowerInfo._visible = false;
}
on (rollOver) {
_root.selectedTower = "";
_root.ranger._x = 3000;
_root.ranger._width = 10;
_root.ranger._height = 10;
_root.UpgradeTowerInfo._visible = false;
_parent.info_message.title.text = _root.tower_water.title;
_parent.info_message.desc.text = _root.tower_water.desc;
_parent.info_message.type.text = _root.tower_water.type;
_parent.info_message._visible = true;
}
on (rollOut) {
_parent.info_message._visible = false;
}
Instance of Symbol 359 MovieClip "tower_water" in Frame 11
onClipEvent (load) {
title = "Medium Machine Gun";
desc = "Fast attack speed, low damage, low range, slows down nearby enemies, debris damage";
type = "Cost $60";
cost = 0;
range = 80;
rate = 2;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 3;
splash = 10;
slow = 25;
poison = 0;
level = 1;
upgrades = [["Damage: 5\rRange: 80\rDebris:10\rSlow:40\rResidual:No\r", 70, 5, 80, 2, 10, 40, 0], ["Damage: 15\rRange: 80\rDebris:20\rSlow:60\rResidual:No\r", 140, 15, 80, 2, 20, 60, 0], ["Damage: 20\rRange: 80\rDebris:30\rSlow:65\rResidual:No\r", 180, 20, 80, 2, 30, 65, 0], ["Damage: 30\rRange: 80\rDebris:40\rSlow:70\rResidual:No\r", 230, 35, 80, 2, 40, 70, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if (_root.pauseyes == 0) {
if (_root.remove == true) {
this.removeMovieClip();
}
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_water", damage, splash, slow);
}
}
}
}
}
}
Instance of Symbol 368 MovieClip in Frame 11
on (press) {
if (_root.gold >= 100) {
_root.marker.active = 1;
_root.marker.tower = "poison";
_root.marker.cost = 100;
}
_root.UpgradeTowerInfo._visible = false;
}
on (rollOver) {
_root.selectedTower = "";
_root.ranger._x = 3000;
_root.ranger._width = 10;
_root.ranger._height = 10;
_root.UpgradeTowerInfo._visible = false;
_parent.info_message.title.text = _root.tower_poison.title;
_parent.info_message.desc.text = _root.tower_poison.desc;
_parent.info_message.type.text = _root.tower_poison.type;
_parent.info_message._visible = true;
}
on (rollOut) {
_parent.info_message._visible = false;
}
Instance of Symbol 369 MovieClip "tower_poison" in Frame 11
onClipEvent (load) {
title = "Big Machine Gun";
desc = "Fast attack speed, medium damage, low range, residual damage";
type = "Cost $100";
cost = 0;
range = 80;
rate = 8;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 5;
splash = 0;
slow = 0;
poison = 5;
level = 1;
upgrades = [["Damage: 10\rRange: 80\rDebris:No\rSlow:No\rResidual:10\r", 50, 10, 80, 8, 0, 10], ["Damage: 15\rRange: 80\rDebris:No\rSlow:No\rResidual:15\r", 150, 15, 80, 8, 0, 15], ["Damage: 20\rRange: 80\rDebris:No\rSlow:No\rResidual:20\r", 300, 20, 80, 8, 0, 20], ["Damage: 30\rRange: 80\rDebris:No\rSlow:No\rResidual:30\r", 700, 30, 80, 8, 0, 30]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if (_root.remove == true) {
this.removeMovieClip();
}
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_poison", damage, splash, slow, poison);
}
}
}
}
}
Instance of Symbol 376 MovieClip in Frame 11
onClipEvent (load) {
this.useHandCursor = false;
}
onClipEvent (enterFrame) {
if (_root.gold < 30) {
this._visible = true;
} else {
this._visible = false;
}
}
Instance of Symbol 377 MovieClip in Frame 11
onClipEvent (load) {
this.useHandCursor = false;
}
onClipEvent (enterFrame) {
if (_root.gold < 60) {
this._visible = true;
} else {
this._visible = false;
}
}
Instance of Symbol 378 MovieClip in Frame 11
onClipEvent (load) {
this.useHandCursor = false;
}
onClipEvent (enterFrame) {
if (_root.gold < 160) {
this._visible = true;
} else {
this._visible = false;
}
}
Instance of Symbol 379 MovieClip in Frame 11
onClipEvent (load) {
this.useHandCursor = false;
}
onClipEvent (enterFrame) {
if (_root.gold < 100) {
this._visible = true;
} else {
this._visible = false;
}
}
Instance of Symbol 383 MovieClip in Frame 11
on (press) {
if (_root.gold >= 300) {
_root.marker.active = 1;
_root.marker.tower = "five";
_root.marker.cost = 300;
}
_root.UpgradeTowerInfo._visible = false;
}
on (rollOver) {
_root.selectedTower = "";
_root.ranger._x = 3000;
_root.ranger._width = 10;
_root.ranger._height = 10;
_root.UpgradeTowerInfo._visible = false;
_parent.info_message.title.text = _root.tower_five.title;
_parent.info_message.desc.text = _root.tower_five.desc;
_parent.info_message.type.text = _root.tower_five.type;
_parent.info_message._visible = true;
}
on (rollOut) {
_parent.info_message._visible = false;
}
Instance of Symbol 384 MovieClip in Frame 11
onClipEvent (load) {
this.useHandCursor = false;
}
onClipEvent (enterFrame) {
if (_root.gold < 300) {
this._visible = true;
} else {
this._visible = false;
}
}
Instance of Symbol 385 MovieClip "tower_five" in Frame 11
onClipEvent (load) {
title = "Flak Cannon";
desc = "Good attack speed, high damage, high range";
type = "Cost $300";
cost = 0;
range = 130;
rate = 5;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 20;
splash = 10;
slow = 0;
poison = 1;
level = 1;
upgrades = [["Damage: 30\rRange: 120\rSplash:No\rSlow:No\rPoison:No\r", 80, 30, 120, 5, 0, 0, 0], ["Damage: 40\rRange: 120\rSplash:No\rSlow:No\rPoison:No\r", 140, 40, 120, 5, 0, 0, 0], ["Damage: 50\rRange: 120\rSplash:No\rSlow:No\rPoison:No\r", 190, 50, 120, 5, 0, 0, 0], ["Damage: 60\rRange: 120\rSplash:40\rSlow:No\rPoison:No\r", 230, 60, 120, 5, 40, 0, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if (_root.remove == true) {
this.removeMovieClip();
}
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_five", damage, splash, slow);
}
}
}
}
}
Instance of Symbol 394 MovieClip in Frame 11
on (press) {
if (_root.gold >= 600) {
_root.marker.active = 1;
_root.marker.tower = "six";
_root.marker.cost = 600;
}
_root.UpgradeTowerInfo._visible = false;
}
on (rollOver) {
_root.selectedTower = "";
_root.ranger._x = 3000;
_root.ranger._width = 10;
_root.ranger._height = 10;
_root.UpgradeTowerInfo._visible = false;
_parent.info_message.title.text = _root.tower_six.title;
_parent.info_message.desc.text = _root.tower_six.desc;
_parent.info_message.type.text = _root.tower_six.type;
_parent.info_message._visible = true;
}
on (rollOut) {
_parent.info_message._visible = false;
}
Instance of Symbol 395 MovieClip in Frame 11
onClipEvent (load) {
this.useHandCursor = false;
}
onClipEvent (enterFrame) {
if (_root.gold < 600) {
this._visible = true;
} else {
this._visible = false;
}
}
Instance of Symbol 396 MovieClip "tower_six" in Frame 11
onClipEvent (load) {
title = "Mega Cannon";
desc = "Ultra attack speed, ultra damage, ultra range";
type = "Cost $600";
cost = 0;
range = 150;
rate = 6;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 30;
splash = 15;
slow = 5;
poison = 1;
level = 1;
upgrades = [["Damage: 40\rRange: 120\rDebris:60\rSlow:10\rResidual:No\r", 100, 40, 120, 5, 60, 10, 0], ["Damage: 75\rRange: 120\rDebris:65\rSlow:15\rResidual:No\r", 150, 75, 120, 5, 65, 15, 0], ["Damage: 150\rRange: 120\rDebris:70\rSlow:20\rResidual:No\r", 200, 150, 120, 5, 70, 20, 0], ["Damage: 250\rRange: 120\rDebris:75\rSlow:25\rResidual:No\r", 250, 250, 120, 5, 75, 25, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if (_root.remove == true) {
this.removeMovieClip();
}
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_six", damage, splash, slow);
}
}
}
}
}
Frame 12
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Instance of Symbol 311 MovieClip "timeline" in Frame 12
onClipEvent (load) {
clearInterval(_root.levelInterval);
}
on (press) {
if (!_root.hasGameStarted) {
return(undefined);
}
if ((_root.wave >= 0) && ((_root.wave - 1) <= (_root.waves.length - 1))) {
_root.score = _root.score + (_root.wave * (_root.maxCount - _root.count));
_root.gold = _root.gold + int(_root.gold * 0.03);
_root.count = 1;
_root.newLevel();
}
}
onClipEvent (enterFrame) {
}
Instance of Symbol 330 MovieClip "tower_cannon" in Frame 12
onClipEvent (load) {
title = "Machine Gun";
desc = "Medium attack speed, high damage, high range";
type = "Cost $30";
cost = 0;
range = 120;
rate = 5;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 15;
splash = 0;
slow = 0;
poison = 0;
level = 1;
upgrades = [["Damage: 20\rRange: 120\rDebris:No\rSlow:No\rResidual:No\r", 40, 20, 120, 5, 0, 0, 0], ["Damage: 25\rRange: 120\rDebris:No\rSlow:No\rResidual:No\r", 60, 25, 120, 5, 0, 0, 0], ["Damage: 30\rRange: 120\rDebris:No\rSlow:No\rResidual:No\r", 110, 30, 120, 5, 0, 0, 0], ["Damage: 40\rRange: 120\rDebris:40\rSlow:No\rResidual:No\r", 170, 40, 120, 5, 40, 0, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_cannonball", damage, splash, slow);
}
}
}
}
}
Instance of Symbol 354 MovieClip "tower_fire" in Frame 12
onClipEvent (load) {
title = "Cannon";
desc = "Fast attack speed, moderate damage, low range, splash damage to nearby enemies";
type = "Cost $160";
cost = 0;
range = 80;
rate = 4;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 5;
splash = 40;
slow = 0;
poison = 0;
level = 1;
upgrades = [["Damage: 15\rRange: 80\rDebris:50\rSlow:No\rResidual:No\r", 90, 15, 80, 2, 50, 0, 0], ["Damage: 25\rRange: 80\rDebris:60\rSlow:No\rResidual:No\r", 150, 25, 80, 2, 60, 0, 0], ["Damage: 40\rRange: 80\rDebris:65\rSlow:No\rResidual:No\r", 190, 40, 80, 2, 65, 0, 0], ["Damage: 50\rRange: 80\rDebris:70\rSlow:20\rResidual:No\r", 250, 50, 80, 2, 70, 20, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_fire", damage, splash, slow);
}
}
}
}
}
Instance of Symbol 359 MovieClip "tower_water" in Frame 12
onClipEvent (load) {
title = "Medium Machine Gun";
desc = "Fast attack speed, low damage, low range, slows down nearby enemies, debris damage";
type = "Cost $60";
cost = 0;
range = 80;
rate = 2;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 3;
splash = 10;
slow = 25;
poison = 0;
level = 1;
upgrades = [["Damage: 5\rRange: 80\rDebris:10\rSlow:40\rResidual:No\r", 70, 5, 80, 2, 10, 40, 0], ["Damage: 15\rRange: 80\rDebris:20\rSlow:60\rResidual:No\r", 140, 15, 80, 2, 20, 60, 0], ["Damage: 20\rRange: 80\rDebris:30\rSlow:65\rResidual:No\r", 180, 20, 80, 2, 30, 65, 0], ["Damage: 30\rRange: 80\rDebris:40\rSlow:70\rResidual:No\r", 230, 35, 80, 2, 40, 70, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if (_root.pauseyes == 0) {
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_water", damage, splash, slow);
}
}
}
}
}
}
Instance of Symbol 369 MovieClip "tower_poison" in Frame 12
onClipEvent (load) {
title = "Big Machine Gun";
desc = "Fast attack speed, medium damage, low range, residual damage";
type = "Cost $100";
cost = 0;
range = 80;
rate = 8;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 5;
splash = 0;
slow = 0;
poison = 5;
level = 1;
upgrades = [["Damage: 10\rRange: 80\rDebris:No\rSlow:No\rResidual:10\r", 50, 10, 80, 8, 0, 10], ["Damage: 15\rRange: 80\rDebris:No\rSlow:No\rResidual:15\r", 150, 15, 80, 8, 0, 15], ["Damage: 20\rRange: 80\rDebris:No\rSlow:No\rResidual:20\r", 300, 20, 80, 8, 0, 20], ["Damage: 30\rRange: 80\rDebris:No\rSlow:No\rResidual:30\r", 700, 30, 80, 8, 0, 30]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_poison", damage, splash, slow, poison);
}
}
}
}
}
Instance of Symbol 385 MovieClip "tower_five" in Frame 12
onClipEvent (load) {
title = "Flak Cannon";
desc = "Good attack speed, high damage, high range";
type = "Cost $300";
cost = 0;
range = 130;
rate = 5;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 20;
splash = 10;
slow = 0;
poison = 1;
level = 1;
upgrades = [["Damage: 30\rRange: 120\rSplash:No\rSlow:No\rPoison:No\r", 80, 30, 120, 5, 0, 0, 0], ["Damage: 40\rRange: 120\rSplash:No\rSlow:No\rPoison:No\r", 140, 40, 120, 5, 0, 0, 0], ["Damage: 50\rRange: 120\rSplash:No\rSlow:No\rPoison:No\r", 190, 50, 120, 5, 0, 0, 0], ["Damage: 60\rRange: 120\rSplash:40\rSlow:No\rPoison:No\r", 230, 60, 120, 5, 40, 0, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_five", damage, splash, slow);
}
}
}
}
}
Instance of Symbol 396 MovieClip "tower_six" in Frame 12
onClipEvent (load) {
title = "Mega Cannon";
desc = "Ultra attack speed, ultra damage, ultra range";
type = "Cost $600";
cost = 0;
range = 150;
rate = 6;
lastFire = rate;
lastChecked = rate;
creep = "";
target = 0;
damage = 30;
splash = 15;
slow = 5;
poison = 1;
level = 1;
upgrades = [["Damage: 40\rRange: 120\rDebris:60\rSlow:10\rResidual:No\r", 100, 40, 120, 5, 60, 10, 0], ["Damage: 75\rRange: 120\rDebris:65\rSlow:15\rResidual:No\r", 150, 75, 120, 5, 65, 15, 0], ["Damage: 150\rRange: 120\rDebris:70\rSlow:20\rResidual:No\r", 200, 150, 120, 5, 70, 20, 0], ["Damage: 250\rRange: 120\rDebris:75\rSlow:25\rResidual:No\r", 250, 250, 120, 5, 75, 25, 0]];
}
on (press) {
_root.towerInfo(this);
}
onClipEvent (enterFrame) {
if ((active == 1) && (_root.creepArray.length > 0)) {
lastChecked++;
if (lastChecked >= rate) {
lastChecked = 0;
if (target == 0) {
i = 0;
while (i <= _root.creepArray.length) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < range) {
target = 1;
creep = _root.creepArray[i];
break;
}
i++;
}
} else if (("" + creep) == "") {
target = 0;
} else {
d = Math.sqrt(Math.pow(this._x - creep._x, 2) + Math.pow(this._y - creep._y, 2));
if (d > range) {
lastChecked = 999;
target = 0;
} else {
_rotation = ((Math.atan2(creep._y - this._y, creep._x - this._x) * 180) / 3.141593);
_root.fire(this, creep, 10, 1, 10, "projectile_six", damage, splash, slow);
}
}
}
}
}
Frame 13
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 14
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 15
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 16
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 17
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 10) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 18
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 19
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 20
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 9) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 21
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 14) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 22
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 23
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 24
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 25
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 10) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 26
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 9) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 27
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 28
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 29
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 7) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 30
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 11) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 31
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 6) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 32
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 33
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 6) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 34
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 9) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 35
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 36
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 37
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 10) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 38
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 39
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 11) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Frame 40
function executeCallback() {
if (_root.hasGameStarted) {
if (_root.count >= _root.maxCount) {
_root.newLevel();
}
if (_root.wave < (_root.waves.length - 1)) {
_root.count++;
} else if (_root.currentNumberOfCreeps <= 0) {
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.remove = true;
_root.gotoAndPlay(10);
}
} else {
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
Explosion("projectile_fire", b._x, b._y);
b.removeMovieClip();
}
_local2++;
}
}
}
function towerInfo(tower) {
_root.selectedTower = tower;
_root.ranger._x = tower._x;
_root.ranger._y = tower._y;
_root.ranger._width = tower.range * 2;
_root.ranger._height = tower.range * 2;
_root.UpgradeTowerInfo._visible = true;
if (tower.upgrades.length >= tower.level) {
_root.UpgradeTowerInfo.UpgradeInfoText.text = tower.upgrades[tower.level - 1][0];
_root.UpgradeTowerInfo.TowerInfoText.text = (((((((("Damage: " + tower.damage) + "\rRange: ") + tower.range) + "\rDebris: ") + (tower.splash ? "Yes" : "No")) + "\rSlow: ") + (tower.slow ? "Yes" : "No")) + "\rResidual: ") + (tower.poison ? "Yes" : "No");
_root.UpgradeTowerInfo.UpgradeButton.UpgradeButtonText.text = ("Upgrade [$" + tower.upgrades[tower.level - 1][1]) + "]";
_root.UpgradeTowerInfo.UpgradeButton._visible = true;
} else {
_root.UpgradeTowerInfo.f.text = "";
_root.UpgradeTowerInfo.UpgradeButton._visible = false;
_root.UpgradeTowerInfo.h.text = "";
}
}
function newLevel() {
_root.wave++;
updateInfoBar();
if ((_root.wave - 1) < (_root.waves.length - 1)) {
_root.inGameMessage(("<font color='#ffffff'><b>Start Wave: " + _root.wave) + " </b></font>");
_root["spawnInterval" + _root.wave] = setInterval(_root, "spawn", _root.waves[_root.wave][3], _root.wave, "creep1", _root.waves[_root.wave][2], _root.waves[_root.wave][1], _root.waves[_root.wave][4]);
_root["creepEventInterval" + _root.wave] = setInterval(_root, "creepEvent", 500);
_root["spawned" + _root.wave] = _root.waves[_root.wave][0];
}
updateScore();
}
function creepEvent() {
i = 0;
while (i <= _root.creepArray.length) {
if (("" + _root.creepArray[i]) != "") {
if (_root.creepArray[i].poison > 0) {
_root.creepArray[i].health = _root.creepArray[i].health - ((_root.creepArray[i].poison * _root.creepArray[i].health) / 100);
_root.creepArray[i].poison--;
}
}
i++;
}
}
function spawn(level, creep, speed, health, gold) {
if (_root.contero == 0) {
if (_root.wave == 30) {
_root.theend._visible = true;
}
_root.nextwave._visible = true;
_root.nextwave._visible = 1;
}
if (_root["spawned" + level] == 0) {
} else {
_root["spawned" + level]--;
_root.creepCount++;
_root.currentNumberOfCreeps++;
_root[creep].duplicateMovieClip("c" + _root.creepCount, 1000 + _root.creepCount);
c = _root["c" + _root.creepCount];
_root.creepArray[_root.creepArray.length] = c;
c.creep.gotoAndStop(level);
c._x = wp1._x;
c._y = wp1._y;
c.speed = speed;
c.maxspeed = speed;
c.targ = 2;
c.rnd = random(10);
c.health = health;
c.maxHealth = health;
c.isDead = 0;
c.gold = gold;
_root.oldtimer = getTimer();
_root.contero--;
c.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (_root.oldTimer != getTimer()) {
_root.newtimer = getTimer() - _root.oldtimer;
}
if (c.targ < 2) {
c.targ = 2;
}
if (this.health <= 0) {
_root.kill(this);
}
if (this.speed < this.maxspeed) {
this.speed = this.speed + 0.1;
}
this.targX = (_root["wp" + this.targ]._x - 5) + this.rnd;
this.targY = (_root["wp" + this.targ]._y - 5) + this.rnd;
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
_root.dt = getTimer() - _root.newtimer;
this.r = this.dir + (Math.sin((getTimer() + (this.rnd * 100)) / 100) * 7);
if ((this.creep._rotation + 10) < this.r) {
this.creep._rotation = this.creep._rotation + 10;
} else if ((this.creep._rotation - 10) > this.r) {
this.creep._rotation = this.creep._rotation - 10;
} else {
this.creep._rotation = r;
}
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 5) {
this.targ++;
if (this.targ > 8) {
_root.leak(this);
_root.updateInfoBar();
}
}
} else {
_root.oldtimer = getTimer();
c.onEnterFrame = null;
}
this.health_bar.health._width = (30 / this.maxHealth) * this.health;
this.health_bar._visible = true;
};
}
}
function Explosion(type, x, y) {
i = 1;
while (i <= 10) {
_root.explosionCount++;
duplicateMovieClip (_root[type + "_explosion"], "explosion" + _root.explosionCount, 4900 + _root.explosionCount);
a = _root["explosion" + _root.explosionCount];
a._x = x;
a._y = y;
a.rads = random(360);
a.speed = (5 + random(20)) / 5;
a._rotation = a.rads;
a.onEnterFrame = function () {
if (_root.pauseyes == 0) {
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
this._alpha = this._alpha - 20;
if (this.speed > 0.5) {
this.speed = this.speed - 0.5;
}
if (this._alpha <= 0) {
this.removeMovieClip();
}
} else {
a.onEnterFrame = null;
this.removeMovieClip();
}
};
i++;
}
if (_root.explosionCount > 10) {
_root.explosionCount = 0;
}
}
function fire(from, to, speed, acc, maxspeed, projectile, damage, splash, slow, poison) {
_root.particleCount++;
_root[projectile].duplicateMovieClip("p" + _root.particleCount, 2000 + _root.particleCount);
r = _root["p" + _root.particleCount];
dir = (Math.atan2(from._y - to._y, from._x - to._x) * 180) / 3.141593;
rads = (dir * 3.141593) / 180;
r._x = from._x;
r._y = from._y;
r._x = r._x - (Math.cos(rads) * (from._width / 2));
r._y = r._y - (Math.sin(rads) * (from._height / 2));
r.targ = to;
if (("" + to) == "") {
r.removeMovieClip();
}
r.speed = speed;
r.acc = acc;
r.maxspeed = maxspeed;
r.projectile = projectile;
r.damage = damage;
r.splash = splash;
r.slow = slow;
r.poison = poison;
r.onEnterFrame = function () {
if (_root.pauseyes == 0) {
if (("" + this.targ) != "") {
this.targX = this.targ._x;
this.targY = this.targ._y;
} else if (("" + this.targX) == "undefined") {
this.removeMovieClip();
}
this.dir = (Math.atan2(this.targY - this._y, this.targX - this._x) * 180) / 3.141593;
this._rotation = this.dir + 90;
this.rads = (this.dir * 3.141593) / 180;
this._x = this._x + (Math.cos(this.rads) * this.speed);
this._y = this._y + (Math.sin(this.rads) * this.speed);
if (this.speed < this.maxspeed) {
this.speed = this.speed + this.acc;
}
d = Math.sqrt(Math.pow(this._x - this.targX, 2) + Math.pow(this._y - this.targY, 2));
if (d < 10) {
Explosion(projectile, this._x, this._y);
if (this.slow > 0) {
this.targ.speed = (this.targ.maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
this.targ.poison = this.poison;
}
if (this.splash > 0) {
i = 0;
while (i <= _root.creepArray.length) {
if ((("" + _root.creepArray[i]) != "") && (_root.creepArray[i] != this.targ)) {
d = Math.sqrt(Math.pow(this._x - _root.creepArray[i]._x, 2) + Math.pow(this._y - _root.creepArray[i]._y, 2));
if (d < this.splash) {
_root.creepArray[i].health = _root.creepArray[i].health - (this.damage * (1 - (d / this.splash)));
if (this.slow > 0) {
_root.creepArray[i].speed = (_root.creepArray[i].maxspeed / 100) * (100 - this.slow);
}
if (this.poison > 0) {
_root.creepArray[i].poison = int(this.poison * (d / this.splash));
}
}
}
i++;
}
}
this.targ.health = this.targ.health - this.damage;
if (targ.health <= 0) {
targ.isDead = 1;
}
metra = new Sound(this);
metra.attachSound("metralleta");
metra.start(0, 1);
metra.attachSound("");
this.removeMovieClip();
}
if (_root.particleCount > 50) {
_root.particleCount = 0;
}
} else {
r.onEnterFrame = null;
this.removeMovieClip();
}
};
}
function kill(creep) {
_root.kills++;
if (_root.kills >= _root.waves[_root.wave - 1][0]) {
_root.kills = 0;
}
creep.onEnterFrame = function () {
if (_root.pauseyes == 0) {
_root.currentNumberOfCreeps--;
_root.gold = _root.gold + creep.gold;
updateScore();
updateInfoBar();
this.removeMovieClip();
} else {
creep.onEnterFrame = null;
}
};
}
function leak(creep) {
_root.creepLeaks++;
if (!_root.hasGameFinished) {
creep._x = _root.wp0._x;
creep._y = _root.wp0._y;
creep.targ = 1;
creep.removeMovieClip();
} else {
creep.removeMovieClip();
}
_root.health--;
if (_root.health <= 0) {
_root.health = 0;
_root.hasGameStarted = false;
if (!_root.hasGameFinished) {
_root.inGameMessage("<font color='#ffffff'>Oh No! You let them break through, AHHHHGGGGRRRR!</font>");
}
_root.hasGameFinished = true;
_root.remove = true;
_root.gotoAndPlay(9);
}
}
function updateScore() {
var _local3 = _root.gold;
var _local2 = 1;
while (_local2 <= _root.towerCount) {
b = _root["t" + _local2];
if (("" + b) != "undefined") {
_local3 = _local3 + b.cost;
}
_local2++;
}
_root.score = _root.score + _local3;
}
function upgrade() {
a = _root.selectedTower;
b = a.level - 1;
if (int(a.upgrades[b][1]) <= _root.gold) {
a.damage = int(a.upgrades[b][2]);
a.range = a.upgrades[b][3];
a.rate = a.upgrades[b][4];
a.splash = a.upgrades[b][5];
a.slow = a.upgrades[b][6];
a.cost = a.cost + int(a.upgrades[b][1]);
a.level++;
_root.towerInfo(_root.selectedTower);
_root.gold = _root.gold - int(a.upgrades[b][1]);
updateInfoBar();
}
updateScore();
}
function updateInfoBar() {
_root.InfoBar.GoldAmount.text = _root.gold;
_root.InfoBar.ScoreAmount.text = _root.score;
_root.InfoBar.HealthAmount.text = _root.health;
}
function inGameMessage(n) {
_root.ingame_message.htmlText = (n + "<br>") + _root.ingame_message.htmlText;
_root.ingame_message.vPosition = _root.ingame_message.maxVPosition;
}
stopAllSounds();
_root.waves = [];
var remove = false;
ambi = new Sound(this);
ambi.attachSound("ambience");
ambi.start(0, 100);
_root.wave = 0;
_root.level = 0;
stop();
_root.waves = [[10, 50, 2.5, 1000, 2], [10, 100, 3.5, 4000, 2], [10, 150, 2.5, 1500, 2], [10, 200, 1.5, 2000, 2], [10, 250, 3.5, 3000, 2], [5, 500, 2.5, 2000, 4], [10, 350, 2.5, 2000, 5], [15, 450, 3.5, 3000, 5], [15, 550, 2.5, 4000, 6], [10, 650, 1.5, 4000, 6], [10, 750, 3.5, 3500, 7], [15, 850, 3.5, 3500, 7], [15, 950, 2.5, 4000, 8], [10, 1050, 3.5, 4000, 8], [10, 1050, 2.5, 3500, 9], [15, 1150, 2.5, 3500, 9], [15, 1150, 3.5, 4000, 9], [15, 1200, 2.5, 4000, 15], [10, 1250, 2.5, 5000, 10], [10, 1330, 3.5, 4500, 10], [15, 1330, 2.5, 4000, 10], [15, 1350, 2.5, 4500, 10], [10, 1400, 3, 5000, 10], [10, 1500, 3, 5000, 10], [15, 1600, 2.5, 5000, 10], [15, 1700, 2.5, 5000, 10], [10, 1800, 2.5, 5000, 10], [15, 1900, 3, 5000, 10], [10, 2000, 3.5, 5000, 10], [15, 2100, 4, 5000, 20]];
_root.wave = 0;
_root.hasGameStarted = false;
_root.hasGameFinished = false;
_root.towerCount = 0;
_root.selectedTower = "";
_root.currentNumberOfCreeps = 0;
_root.creepCount = 0;
_root.creepArray = [];
_root.creepLeaks = 0;
_root.explosionCount = 0;
_root.particleCount = 0;
_root.kills = 0;
_root.gold = 50;
_root.count = 1;
_root.maxCount = 3;
_root.updateDuration = 2;
_root.health = 100;
_root.score = 0;
_root.pauseyes = 0;
_root.oldtimer = 0;
_root.newtimer = 0;
_root.dt = 0;
_root.nextwave._visible = 0;
_root.contero = _root.waves[_root.wave][0];
_root.wavecounter = 0;
_root.theend._visible = false;
Symbol 13 MovieClip Frame 1
_parent.stop();
this.onEnterFrame = function () {
if (_parent.getBytesTotal() > 1) {
percent = int((_parent.getBytesLoaded() / _parent.getBytesTotal()) * 100);
text_info.text = percent + "%";
bar_mask._xscale = percent;
if (percent >= 100) {
_root.gotoAndPlay(2);
}
}
};
Symbol 61 MovieClip Frame 55
gotoAndPlay (6);
Symbol 62 MovieClip Frame 100
stop();
Symbol 63 MovieClip Frame 9
stop();
Symbol 65 Button
on (release) {
getURL ("http://247gamesonline.com", "_self");
}
Symbol 68 Button
on (release) {
gotoAndStop (4);
}
Symbol 77 MovieClip Frame 1
_root.stop();
play();
Symbol 77 MovieClip Frame 168
stop();
Symbol 81 Button
on (release) {
gotoAndStop (8);
}
Symbol 82 Button
on (release) {
getURL ("http://www.247gamesonline.com/?utm_medium=brandedgames_external&utm_campaign=ww2towerdefence&utm_source=host&utm_content=ingame", _blank);
}
Symbol 88 Button
on (release) {
gotoAndStop (6);
}
Symbol 91 Button
on (release) {
intromusic.stop();
gotoAndPlay (11);
}
Symbol 94 Button
on (release) {
intromusic.stop();
gotoAndPlay (12);
}
Symbol 97 Button
on (release) {
intromusic.stop();
gotoAndPlay (13);
}
Symbol 100 Button
on (release) {
intromusic.stop();
gotoAndPlay (14);
}
Symbol 103 Button
on (release) {
intromusic.stop();
gotoAndPlay (15);
}
Symbol 106 Button
on (release) {
intromusic.stop();
gotoAndPlay (16);
}
Symbol 109 Button
on (release) {
intromusic.stop();
gotoAndPlay (17);
}
Symbol 112 Button
on (release) {
intromusic.stop();
gotoAndPlay (18);
}
Symbol 115 Button
on (release) {
intromusic.stop();
gotoAndPlay (19);
}
Symbol 118 Button
on (release) {
intromusic.stop();
gotoAndPlay (20);
}
Symbol 119 Button
on (release) {
gotoAndStop (7);
}
Symbol 122 Button
on (release) {
gotoAndStop (5);
}
Symbol 125 Button
on (release) {
intromusic.stop();
gotoAndPlay (21);
}
Symbol 128 Button
on (release) {
intromusic.stop();
gotoAndPlay (22);
}
Symbol 131 Button
on (release) {
intromusic.stop();
gotoAndPlay (23);
}
Symbol 134 Button
on (release) {
intromusic.stop();
gotoAndPlay (24);
}
Symbol 137 Button
on (release) {
intromusic.stop();
gotoAndPlay (25);
}
Symbol 140 Button
on (release) {
intromusic.stop();
gotoAndPlay (26);
}
Symbol 143 Button
on (release) {
intromusic.stop();
gotoAndPlay (27);
}
Symbol 146 Button
on (release) {
intromusic.stop();
gotoAndPlay (28);
}
Symbol 149 Button
on (release) {
intromusic.stop();
gotoAndPlay (29);
}
Symbol 152 Button
on (release) {
intromusic.stop();
gotoAndPlay (30);
}
Symbol 153 Button
on (release) {
gotoAndStop (6);
}
Symbol 156 Button
on (release) {
intromusic.stop();
gotoAndPlay (31);
}
Symbol 159 Button
on (release) {
intromusic.stop();
gotoAndPlay (32);
}
Symbol 162 Button
on (release) {
intromusic.stop();
gotoAndPlay (33);
}
Symbol 165 Button
on (release) {
intromusic.stop();
gotoAndPlay (34);
}
Symbol 168 Button
on (release) {
intromusic.stop();
gotoAndPlay (35);
}
Symbol 171 Button
on (release) {
intromusic.stop();
gotoAndPlay (36);
}
Symbol 174 Button
on (release) {
intromusic.stop();
gotoAndPlay (37);
}
Symbol 177 Button
on (release) {
intromusic.stop();
gotoAndPlay (38);
}
Symbol 180 Button
on (release) {
intromusic.stop();
gotoAndPlay (39);
}
Symbol 183 Button
on (release) {
intromusic.stop();
gotoAndPlay (40);
}
Symbol 186 Button
on (release) {
gotoAndPlay (5);
}
Symbol 189 Button
on (release) {
gotoAndPlay (4);
}
Symbol 190 Button
on (release) {
getURL ("http://www.247gamesonline.com/?utm_medium=brandedgames_external&utm_campaign=ww2towerdefence&utm_source=host&utm_content=ingame", _blank);
}
Symbol 280 MovieClip Frame 1
stop();
Symbol 290 MovieClip Frame 2
stop();
Symbol 311 MovieClip Frame 1
Instance of Symbol 309 MovieClip "tl" in Symbol 311 MovieClip Frame 1
onClipEvent (enterFrame) {
_x = ((190 + (_root.wave * 100)) + (_root.count * (100 / _root.maxCount)));
}
Symbol 314 Button
on (press) {
if (!_root.hasGameStarted) {
return(undefined);
}
if ((_root.wave >= 0) && ((_root.wave - 1) <= (_root.waves.length - 1))) {
_root.score = _root.score + (_root.wave * (_root.maxCount - _root.count));
_root.gold = _root.gold + int(_root.gold * 0.03);
_root.count = 1;
_root.newLevel();
_root.contero = _root.waves[_root.wave][0];
_root.nextwave._visible = 0;
_root.nextwave._visible = false;
}
}
Instance of Symbol 320 MovieClip "UpgradeButton" in Symbol 324 MovieClip Frame 1
on (press) {
_root.upgrade();
}
Symbol 336 MovieClip Frame 1
stop();
Symbol 402 Button
on (release) {
var s = new Sound(this);
s.setVolume(100);
_root.mutero._visible = true;
}
Symbol 404 Button
on (release) {
var s = new Sound(this);
s.setVolume(0);
_root.mutero._visible = false;
}
Symbol 406 Button
on (release) {
if (_root.pauseyes == 1) {
_root.pauseyes = 0;
} else {
_root.pauseyes = 1;
}
}
Symbol 409 Button
on (release) {
_root.remove = true;
_root.hasGameStarted = false;
_root.inGameMessage("<font color='#ffffff'>Great Job! You did, you saved us all!</font>");
_root.gotoAndPlay(10);
}
Symbol 414 Button
on (press) {
if (!_root.hasGameStarted) {
return(undefined);
}
if ((_root.wave >= 0) && ((_root.wave - 1) <= (_root.waves.length - 1))) {
_root.score = _root.score + (_root.wave * (_root.maxCount - _root.count));
_root.gold = _root.gold + int(_root.gold * 0.03);
_root.count = 1;
_root.newLevel();
_root.contero = _root.waves[_root.wave][0];
trace("this wave is: " + _root.waves[_root.wave + 1][0]);
_root.nextwave._visible = 0;
_root.nextwave._visible = false;
}
}