Frame 1
MochiAd.showPreloaderAd({id:"3ff39bf11d8a384d", res:"700x500"});
Frame 2
totalBytes = Math.round(getBytesTotal() / 1024);
loadedBytes = Math.round(getBytesLoaded() / 1024);
percentDone = Math.round((loadedBytes / totalBytes) * 100);
if (_root._framesloaded >= _root._totalframes) {
gotoAndStop ("game");
}
Instance of Symbol 160 MovieClip in Frame 2
onClipEvent (enterFrame) {
_xscale = _root.percentDone;
}
Frame 3
gotoAndPlay (1);
Frame 4
Frame 5
function onEnterFrame() {
game.FrameTick();
game.CommTick();
}
var game = new Game();
var keyListener = new Object();
keyListener.onKeyDown = function () {
if ((_root.game.gridField.dragTower != undefined) && (Key.isDown(27))) {
_root.game.CancelSelect();
}
if (Key.isDown(16)) {
game.shiftDown = true;
}
if (Key.isDown(32)) {
game.KeyPress(32);
}
if (Key.isDown(78)) {
game.KeyPress(78);
}
if (Key.isDown(85)) {
game.KeyPress(85);
}
if (Key.isDown(83)) {
game.KeyPress(83);
}
if (Key.isDown(48)) {
game.KeyPress(48);
}
if (Key.isDown(49)) {
game.KeyPress(49);
}
if (Key.isDown(50)) {
game.KeyPress(50);
}
if (Key.isDown(51)) {
game.KeyPress(51);
}
if (Key.isDown(52)) {
game.KeyPress(52);
}
if (Key.isDown(53)) {
game.KeyPress(53);
}
if (Key.isDown(54)) {
game.KeyPress(54);
}
if (Key.isDown(88)) {
game.KeyPress(88);
}
};
keyListener.onKeyUp = function () {
if (!Key.isDown(27)) {
game.shiftDown = false;
}
};
Key.addListener(keyListener);
game.SetMap(28, 24, 50, 68, 14, 9, 14, 10, 17);
game.ShowStart();
score.text = _root.game.score;
function __com_mochibot__(swfid, mc, lv, trk) {
var x;
var g;
var s;
var fv;
var sb;
var u;
var res;
var mb;
var mbc;
mb = "__mochibot__";
mbc = "mochibot.com";
g = (_global ? (_global) : (_level0._root));
if (g[mb + swfid]) {
return(g[mb + swfid]);
}
s = System.security;
x = mc._root.getSWFVersion;
fv = (x ? (mc.getSWFVersion()) : ((_global ? 6 : 5)));
if (!s) {
s = {};
}
sb = s.sandboxType;
if (sb == "localWithFile") {
return(null);
}
x = s.allowDomain;
if (x) {
s.allowDomain(mbc);
}
x = s.allowInsecureDomain;
if (x) {
s.allowInsecureDomain(mbc);
}
u = (((((((((((("http://" + mbc) + "/my/core.swf?mv=7&fv=") + fv) + "&v=") + escape(getVersion())) + "&swfid=") + escape(swfid)) + "&l=") + lv) + "&f=") + mc) + (sb ? ("&sb=" + sb) : "")) + (trk ? "&t=1" : "");
lv = ((fv > 6) ? (mc.getNextHighestDepth()) : ((g[mb + "level"] ? (g[mb + "level"] + 1) : (lv))));
g[mb + "level"] = lv;
if (fv == 5) {
res = "_level" + lv;
if (!eval (res)) {
loadMovieNum (u, lv);
}
} else {
res = mc.createEmptyMovieClip(mb + swfid, lv);
res.loadMovie(u);
}
return(res);
}
__com_mochibot__("e0c27420", this, 10301, true);
Instance of Symbol 195 MovieClip "scoreBoard" in Frame 5
onClipEvent (load) {
swapDepths(5001);
}
Instance of Symbol 185 MovieClip "Interface" in Frame 5
onClipEvent (load) {
swapDepths(5000);
}
Symbol 23 MovieClip [PauseOverlay] Frame 1
function Show() {
fade = 0;
this.cacheAsBitmap = true;
this._visible = true;
this._alpha = fade;
this.onEnterFrame = function () {
fade = fade + 20;
this._alpha = fade;
if (fade >= 80) {
this.cacheAsBitmap = false;
this._alpha = 80;
this.onEnterFrame = "";
}
};
}
function Hide() {
fade = 80;
this.cacheAsBitmap = true;
this.onEnterFrame = function () {
fade = fade - 10;
this._alpha = fade;
if (fade <= 0) {
this.cacheAsBitmap = false;
this._visible = false;
this._alpha = 0;
this.onEnterFrame = "";
}
};
}
var fade;
Instance of Symbol 39 MovieClip "btnStart" in Symbol 40 MovieClip [Top] Frame 1
onClipEvent (load) {
msg.text = "START";
}
on (press) {
if (_root.game.gameState > 2) {
return(undefined);
}
if (_root.game.gameState == -1) {
return(undefined);
}
if (msg.text == "START") {
_root.game.Start();
} else if (msg.text == "PAUSE") {
_root.game.Pause();
} else if (msg.text == "RESUME") {
_root.game.Resume();
}
_root.game.PlayButtonSound();
}
Instance of Symbol 39 MovieClip "btnReset" in Symbol 40 MovieClip [Top] Frame 1
onClipEvent (load) {
msg.text = "RESET";
}
on (press) {
if (_root.game.gameState == -1) {
return(undefined);
}
_root.game.ShowStart();
_root.game.PlayButtonSound();
}
Symbol 47 MovieClip Frame 1
function SetPercentage(p) {
this.innerBar._width = 160 * p;
}
Symbol 63 MovieClip [UpgradePanel] Frame 1
#initclip 29
Object.registerClass("UpgradePanel", UpgradePanel);
#endinitclip
Instance of Symbol 61 MovieClip "upgradeButton" in Symbol 63 MovieClip [UpgradePanel] Frame 1
on (press) {
if (_root.game.gameState == 1) {
this._parent.Upgrade();
} else if (_root.game.gameState < 2) {
_root.game.UpgradeSelectedTower(true);
_root.game.SelectCell(this._parent.tower.topLeftCell.row, this._parent.tower.topLeftCell.col);
}
}
Symbol 68 MovieClip [LevelBarItem] Frame 1
var txt;
var fc;
var lvl;
level.text = txt;
levelNum.num.text = lvl;
levelNum.filters = [new flash.filters.GlowFilter(16750848, 0.8, 5, 5, 2, 3)];
lineStyle(2, 0, 100);
beginFill(fc, 100);
moveTo(0, 0);
lineTo(60, 0);
lineTo(60, 30);
lineTo(0, 30);
lineTo(0, 0);
endFill();
cacheAsBitmap = true;
Symbol 69 MovieClip [LevelBar] Frame 1
#initclip 21
Object.registerClass("LevelBar", LevelBar);
#endinitclip
Symbol 89 MovieClip [InfoPanel] Frame 1
#initclip 22
Object.registerClass("InfoPanel", InfoPanel);
#endinitclip
Instance of Symbol 84 MovieClip "sell" in Symbol 89 MovieClip [InfoPanel] Frame 1
on (press) {
_root.game.SellSelectedTower();
}
Instance of Symbol 88 MovieClip "close" in Symbol 89 MovieClip [InfoPanel] Frame 1
on (press) {
_root.game.CancelSelect();
}
Symbol 112 MovieClip Frame 1
function SetPips(num) {
pip1._visible = num > 0;
pip2._visible = num > 1;
pip3._visible = num > 2;
pip4._visible = num > 3;
pip5._visible = num > 4;
}
pip1._visible = false;
pip2._visible = false;
pip3._visible = false;
pip4._visible = false;
pip5._visible = false;
Symbol 123 MovieClip [Tower] Frame 1
#initclip 23
Object.registerClass("Tower", Tower);
#endinitclip
Symbol 125 MovieClip [ShotSpray] Frame 1
#initclip 24
Object.registerClass("ShotSpray", ShotSpray);
#endinitclip
Symbol 133 MovieClip [Shot] Frame 1
#initclip 25
Object.registerClass("Shot", Shot);
#endinitclip
Symbol 141 MovieClip [Grid] Frame 1
#initclip 26
Object.registerClass("Grid", Grid);
#endinitclip
Symbol 143 MovieClip [Fragment] Frame 1
#initclip 27
Object.registerClass("Fragment", Fragment);
#endinitclip
Symbol 156 MovieClip [Creep] Frame 1
#initclip 28
Object.registerClass("Creep", Creep);
#endinitclip
Symbol 158 MovieClip [Bounty] Frame 1
function SetBounty() {
if (num > 0) {
bounty.text = "+" + num;
} else {
bounty.text = num;
var _local1 = new Color(bounty);
_local1.setRGB(0);
}
}
function onEnterFrame() {
if (speed > -1) {
_y = (_y - speed);
speed = speed - 0.1;
}
ticks++;
if (ticks > 35) {
removeMovieClip(this);
}
}
var ticks = 0;
var speed = 1.3;
var num;
SetBounty();
Symbol 221 MovieClip [__Packages.MochiAd] Frame 0
class MochiAd
{
function MochiAd () {
}
static function showPreloaderAd(options) {
var _local29 = {clip:_root, ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:16747008, background:16777161, outline:13994812};
options = _parseOptions(options, _local29);
var _local15 = options.clip;
var _local25 = 11000;
var _local28 = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!load(options)) {
return(undefined);
}
_local15.stop();
var mc = _local15._mochiad;
mc.onUnload = function () {
this._parent.play();
};
var _local16 = _getRes(options);
var _local5 = _local16[0];
var _local14 = _local16[1];
mc._x = _local5 * 0.5;
mc._y = _local14 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk._x = _local5 * -0.5;
chk._y = _local14 * -0.5;
var _local8 = chk.createEmptyMovieClip("_mochiad_bar", 4);
_local8._x = 10;
_local8._y = _local14 - 20;
var _local24 = options.color;
delete options.color;
var _local21 = options.background;
delete options.background;
var _local26 = options.outline;
delete options.outline;
var _local6 = _local8.createEmptyMovieClip("_outline", 1);
_local6.beginFill(_local21);
_local6.moveTo(0, 0);
_local6.lineTo(_local5 - 20, 0);
_local6.lineTo(_local5 - 20, 10);
_local6.lineTo(0, 10);
_local6.lineTo(0, 0);
_local6.endFill();
var _local4 = _local8.createEmptyMovieClip("_inside", 2);
_local4.beginFill(_local24);
_local4.moveTo(0, 0);
_local4.lineTo(_local5 - 20, 0);
_local4.lineTo(_local5 - 20, 10);
_local4.lineTo(0, 10);
_local4.lineTo(0, 0);
_local4.endFill();
_local4._xscale = 0;
var _local7 = _local8.createEmptyMovieClip("_outline", 3);
_local7.lineStyle(0, _local26, 100);
_local7.moveTo(0, 0);
_local7.lineTo(_local5 - 20, 0);
_local7.lineTo(_local5 - 20, 10);
_local7.lineTo(0, 10);
_local7.lineTo(0, 0);
chk.ad_msec = _local25;
chk.ad_timeout = _local28;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
mc.lc.adjustProgress = function (msec) {
var _local2 = this.mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = msec;
};
chk.onEnterFrame = function () {
var _local6 = this._parent._parent;
var _local12 = this._parent._mochiad_ctr;
var _local5 = getTimer() - this.started;
var _local3 = false;
var _local4 = _local6.getBytesTotal();
var _local8 = _local6.getBytesLoaded();
var _local10 = (100 * _local8) / _local4;
var _local11 = (100 * _local5) / chk.ad_msec;
var _local9 = this._mochiad_bar._inside;
var _local2 = Math.min(100, Math.min(_local10 || 0, _local11));
_local2 = Math.max(this.last_pcnt, _local2);
this.last_pcnt = _local2;
_local9._xscale = _local2;
if (!chk.showing) {
var _local7 = _local12.getBytesTotal();
if ((_local7 > 0) || (typeof(_local7) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local5 > chk.ad_timeout) {
_local3 = true;
}
}
if (_local5 > chk.ad_msec) {
_local3 = true;
}
if (((_local4 > 0) && (_local8 >= _local4)) && (_local3)) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
}
}
};
}
static function showTimedAd(options) {
var _local15 = {clip:_root, ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd"};
options = _parseOptions(options, _local15);
var _local6 = options.clip;
var _local12 = 11000;
var _local14 = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!load(options)) {
return(undefined);
}
_local6.stop();
var mc = _local6._mochiad;
mc.onUnload = function () {
this._parent.play();
};
var _local7 = _getRes(options);
var _local16 = _local7[0];
var _local13 = _local7[1];
mc._x = _local16 * 0.5;
mc._y = _local13 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk.ad_msec = _local12;
chk.ad_timeout = _local14;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
mc.lc.adjustProgress = function (msec) {
var _local2 = this.mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = msec - 250;
};
chk.onEnterFrame = function () {
var _local5 = this._parent._mochiad_ctr;
var _local4 = getTimer() - this.started;
var _local2 = false;
if (!chk.showing) {
var _local3 = _local5.getBytesTotal();
if ((_local3 > 0) || (typeof(_local3) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local4 > chk.ad_timeout) {
_local2 = true;
}
}
if (_local4 > chk.ad_msec) {
_local2 = true;
}
if (_local2) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
}
}
};
}
static function _allowDomains(server) {
var _local1 = server.split("/")[2].split(":")[0];
if (System.security) {
if (System.security.allowDomain) {
System.security.allowDomain("*");
System.security.allowDomain(_local1);
}
if (System.security.allowInsecureDomain) {
System.security.allowInsecureDomain("*");
System.security.allowInsecureDomain(_local1);
}
}
return(_local1);
}
static function _loadCommunicator(options) {
var _local25 = {clip:_root, com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = _parseOptions(options, _local25);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = "1.4";
var _local18 = options.clip;
var _local20 = "_mochiad_com_" + options.id;
if (!_isNetworkAvailable()) {
return(null);
}
if (_local18[_local20]) {
return(_local18[_local20].lc);
}
var _local21 = options.com_server + options.id;
_allowDomains(_local21);
delete options.id;
delete options.com_server;
var _local24 = options.depth;
delete options.depth;
var _local17 = _local18.createEmptyMovieClip(_local20, _local24);
var _local11 = _local17.createEmptyMovieClip("_mochiad_com", 1);
for (var _local15 in options) {
_local11[_local15] = options[_local15];
}
var _local6 = new LocalConnection();
var _local16 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local6.mc = _local17;
_local6.name = _local16;
_local6.allowDomain = function (d) {
return(true);
};
_local6.allowInsecureDomain = _local6.allowDomain;
_local6.connect(_local16);
_local17.lc = _local6;
_local11.lc = _local16;
_local6._id = 0;
_local6._queue = [];
_local6.rpcResult = function (cb) {
cb = parseInt(cb);
var _local4 = this._callbacks[cb];
if (!_local4) {
return(undefined);
}
delete this._callbacks[cb];
var _local5 = [];
var _local3 = 2;
while (_local3 < _local4.length) {
_local5.push(_local4[_local3]);
_local3++;
}
_local3 = 1;
while (_local3 < arguments.length) {
_local5.push(arguments[_local3]);
_local3++;
}
var _local6 = _local4[1];
var _local7 = _local4[0];
if (_local7 && (typeof(_local6) == "string")) {
_local6 = _local7[_local6];
}
if (_local6) {
_local6.apply(_local7, _local5);
}
};
_local6._didConnect = function (endpoint) {
this._endpoint = endpoint;
var _local4 = this._queue;
delete this._queue;
var _local5 = this.doSend;
var _local2 = 0;
while (_local2 < _local4.length) {
var _local3 = _local4[_local2];
_local5.apply(this, _local3);
_local2++;
}
};
_local6.doSend = function (args, cbobj, cbfn) {
if (this._endpoint == null) {
var _local4 = [];
var _local3 = 0;
while (_local3 < arguments.length) {
_local4.push(arguments[_local3]);
_local3++;
}
this._queue.push(_local4);
return(undefined);
}
this._id = this._id + 1;
var _local5 = this._id;
if ((cbfn === undefined) || (cbfn === null)) {
cbfn = cbobj;
}
this._callbacks[_local5] = [cbobj, cbfn];
var _local7 = new LocalConnection();
var _local9 = _local7.send(this._endpoint, "rpc", _local5, args);
};
_local6._callbacks = {};
_local6._callbacks[0] = [_local6, "_didConnect"];
_local11.st = getTimer();
_local11.loadMovie(_local21 + ".swf", "POST");
return(_local6);
}
static function fetchHighScores(options, callbackObj, callbackMethod) {
var _local1 = _loadCommunicator({id:options.id});
if (!_local1) {
return(false);
}
var _local4 = ["fetchHighScores", options];
_local1.doSend(["fetchHighScores", options], callbackObj, callbackMethod);
return(true);
}
static function sendHighScore(options, callbackObj, callbackMethod) {
var _local1 = _loadCommunicator({id:options.id});
if (!_local1) {
return(false);
}
var _local4 = ["sendHighScore", options];
_local1.doSend(["sendHighScore", options], callbackObj, callbackMethod);
return(true);
}
static function load(options) {
var _local13 = {clip:_root, server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = _parseOptions(options, _local13);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = "1.4";
var _local7 = options.clip;
if (!_isNetworkAvailable()) {
return(null);
}
if (_local7._mochiad_loaded) {
return(null);
}
var _local12 = options.depth;
delete options.depth;
var _local6 = _local7.createEmptyMovieClip("_mochiad", _local12);
var _local11 = _getRes(options);
options.res = (_local11[0] + "x") + _local11[1];
options.server = options.server + options.id;
delete options.id;
_local7._mochiad_loaded = true;
var _local4 = _local6.createEmptyMovieClip("_mochiad_ctr", 1);
for (var _local8 in options) {
_local4[_local8] = options[_local8];
}
if (_local7._url.indexOf("http") != 0) {
options.no_page = true;
}
var _local10 = _local4.server;
delete _local4.server;
var _local14 = _allowDomains(_local10);
_local6.onEnterFrame = function () {
if (this._mochiad_ctr._url != this._url) {
this.onEnterFrame = function () {
if (!this._mochiad_ctr) {
delete this.onEnterFrame;
MochiAd.unload(this._parent);
}
};
}
};
var _local5 = new LocalConnection();
var _local9 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local5.mc = _local6;
_local5.name = _local9;
_local5.hostname = _local14;
_local5.allowDomain = function (d) {
return(true);
};
_local5.allowInsecureDomain = _local5.allowDomain;
_local5.connect(_local9);
_local6.lc = _local5;
_local4.lc = _local9;
_local4.st = getTimer();
_local4.loadMovie(_local10 + ".swf", "POST");
return(_local6);
}
static function unload(clip) {
if (typeof(clip) == "undefined") {
clip = _root;
}
if (clip.clip && (clip.clip._mochiad)) {
clip = clip.clip;
}
if (!clip._mochiad) {
return(false);
}
clip._mochiad.removeMovieClip();
delete clip._mochiad_loaded;
delete clip._mochiad;
return(true);
}
static function _isNetworkAvailable() {
if (System.security) {
var _local1 = System.security;
if (_local1.sandboxType == "localWithFile") {
return(false);
}
}
return(true);
}
static function _getRes(options) {
var _local3 = options.clip.getBounds();
var _local2 = 0;
var _local1 = 0;
if (typeof(options.res) != "undefined") {
var _local4 = options.res.split("x");
_local2 = parseFloat(_local4[0]);
_local1 = parseFloat(_local4[1]);
} else {
_local2 = _local3.xMax - _local3.xMin;
_local1 = _local3.yMax - _local3.yMin;
}
if ((_local2 == 0) || (_local1 == 0)) {
_local2 = Stage.width;
_local1 = Stage.height;
}
return([_local2, _local1]);
}
static function _parseOptions(options, defaults) {
var _local4 = {};
for (var _local8 in defaults) {
_local4[_local8] = defaults[_local8];
}
if (options) {
for (var _local8 in options) {
_local4[_local8] = options[_local8];
}
}
if (_root.mochiad_options) {
var _local5 = _root.mochiad_options.split("&");
var _local2 = 0;
while (_local2 < _local5.length) {
var _local3 = _local5[_local2].split("=");
_local4[unescape(_local3[0])] = unescape(_local3[1]);
_local2++;
}
}
return(_local4);
}
}
Symbol 222 MovieClip [__Packages.LevelBar] Frame 0
class LevelBar extends MovieClip
{
var setMask, attachMovie, getNextHighestDepth, increment, posX, _x;
function LevelBar () {
super();
}
function CreateLevels(levels) {
Clear();
setMask();
var _local3 = 1;
while (_local3 < levels.length) {
var _local11 = levels[_local3];
var _local10;
var _local4 = _local11.color;
var _local5 = HEXtoRGB(_local4);
if (_local11.immune) {
_local10 = "IMMUNE";
} else if (_local11.flying) {
_local10 = "FLYING";
} else if (_local11.speed > 1) {
_local10 = "FAST";
} else if (_local11.delay < 14) {
_local10 = "GROUP";
} else if (_local11.spawn > 1) {
_local10 = "SPAWN";
} else {
_local10 = "NORMAL";
}
if (_local11.count < 4) {
_local10 = "BOSS";
}
attachMovie("LevelBarItem", "levelBarItem" + (_local3 - 1), _local3 - 1, {_x:(_local3 - 1) * 60, _y:0, txt:_local10, fc:_local4, lvl:_local11.level});
_local3++;
}
Reset();
setMask(_root.Interface.levelMaskBar);
}
function Clear() {
var _local2 = 0;
while (_local2 < getNextHighestDepth()) {
var _local3 = this["levelBarItem" + _local2];
_local3.removeMovieClip();
_local2++;
}
}
function HEXtoRGB(hex) {
var _local1 = (isNaN(hex) ? (parseInt(hex, 16)) : (hex));
var _local4 = _local1 >> 16;
var _local5 = (_local1 ^ (_local4 << 16)) >> 8;
var _local3 = (_local1 ^ (_local4 << 16)) ^ (_local5 << 8);
return({r:_local4, g:_local5, b:_local3});
}
function SetLevel(level, timeToLevel, lastLevel) {
if (!lastLevel) {
increment = 60 / (timeToLevel * 24);
posX = 60 + ((-level) * 60);
} else {
increment = 0;
posX = 60 + ((-level) * 60);
}
_x = posX;
}
function onEnterFrame() {
if (_root.game.gameState == 1) {
posX = posX - increment;
_x = int(posX);
}
}
function Reset() {
_x = 60;
}
}
Symbol 223 MovieClip [__Packages.InfoPanel] Frame 0
class InfoPanel extends MovieClip
{
var _visible, filters, towerObj, towerBtn, tower, creep, creepPanelDetails, towerName, desc, panelDetails, sell, close;
function InfoPanel () {
super();
_visible = false;
filters = [new flash.filters.GlowFilter(16750848, 0.8, 10, 10, 2, 3)];
}
function GetSpeed(hr) {
if (hr < 7) {
return("very fast");
}
if (hr < 13) {
return("fast");
}
if (hr < 37) {
return("average");
}
if (hr < 61) {
return("slow");
}
return("very slow");
}
function CheckGold() {
if (towerObj) {
if (towerObj.cost > _root.game.gold) {
towerBtn.filters = [new flash.filters.GlowFilter(10027008, 0.8, 10, 10, 2, 3)];
} else {
towerBtn.filters = [new flash.filters.GlowFilter(39168, 0.8, 10, 10, 2, 3)];
}
}
}
function SetCreep(c) {
tower = undefined;
towerObj = undefined;
towerBtn = undefined;
creep = c;
with (creepPanelDetails) {
_visible = true;
flying.text = (c.flying ? "Yes" : "No");
immune.text = (c.immune ? "Yes" : "No");
health.text = c.health;
speed.text = c.speed;
}
towerName.text = (((c.size == 150) ? "BOSS" : "Creep") + " Level ") + c.level;
desc.text = "";
panelDetails._visible = false;
_visible = true;
sell._visible = false;
close._visible = true;
}
function onEnterFrame() {
if (creep) {
creepPanelDetails.health.text = creep.health;
}
}
function SetTowerInfo(to, btn) {
if ((!tower) && (!creep)) {
with (panelDetails) {
cost.text = to.cost;
damage.text = to.damage;
range.text = to.range;
speed.text = GetSpeed(to.hitRate);
}
towerName.text = to.towerName;
desc.text = to.desc;
_visible = true;
sell._visible = false;
close._visible = false;
creepPanelDetails._visible = false;
towerObj = to;
towerBtn = btn;
}
}
function CancelInfo() {
if ((!tower) && (!creep)) {
_visible = false;
}
}
function SetTower(t) {
towerObj = undefined;
towerBtn = undefined;
creep = undefined;
tower = t;
with (panelDetails) {
_visible = true;
cost.text = t.cost;
damage.text = t.damage;
range.text = t.range;
speed.text = GetSpeed(t.hitRate);
}
towerName.text = t.towerName;
desc.text = t.desc;
creepPanelDetails._visible = false;
_visible = true;
close._visible = true;
if (t.topLeftCell) {
sell._visible = true;
sell.msg.text = "sell for " + int(t.cost * 0.75);
} else {
sell._visible = false;
}
}
function Cancel() {
_visible = false;
tower = undefined;
creep = undefined;
towerObj = undefined;
towerBtn = undefined;
}
}
Symbol 224 MovieClip [__Packages.Tower] Frame 0
class Tower extends MovieClip
{
var shotField, groundField, hTower, _visible, _width, _height, size, upgradeBar, gotoAndStop, towerType, shotTick, targetAngle, targetTick, scanTick, upTicks, upTickTotal, targets, targetNum, selling, override, sellTickTotal, sellTicks, chassis, removeMovieClip, upObject, level, range, towerName, damage, hitRate, splash, slow, cost, bash, pips, rotating, topLeftCell, selectFade, selectNum, filters, creeps, dragged, _x, _y, target;
function Tower () {
super();
shotField = _root.shotField;
groundField = _root.groundField;
hTower = _root.game.gridField.hTower;
_visible = false;
_width = (_height = _root.game.gridSize * size);
upgradeBar._visible = false;
gotoAndStop(towerType);
shotTick = 0;
size = 2;
targetAngle = 0;
targetTick = 0;
scanTick = 6;
upTicks = 0;
upTickTotal = 0;
targets = [];
targetNum = -1;
selling = false;
override = false;
SetSelected(false);
}
function Sell(num) {
var _local2 = 12 + ((num / 3) * 24);
if (_local2 > 240) {
_local2 = 240;
}
sellTickTotal = _local2;
sellTicks = sellTickTotal;
upgradeBar._visible = true;
upgradeBar._width = 20;
chassis._visible = false;
selling = true;
}
function DoSell() {
_root.game.SellTower(this);
(removeMovieClip());// not popped
}
function Upgrade(obj) {
upObject = obj;
upTickTotal = (2 + ((level - 1) * 4)) * 24;
upTicks = upTickTotal;
upgradeBar._visible = true;
upgradeBar._width = 0;
chassis._visible = false;
}
function ApplyUpgrade() {
var _local3 = upObject.range != range;
if (_local3) {
_root.game.ModifyTowerRangeBox(this, false);
}
towerName = upObject.towerName;
damage = upObject.damage;
range = upObject.range;
hitRate = upObject.hitRate;
splash = upObject.splash;
slow = upObject.slow;
cost = upObject.cost;
level = upObject.level;
bash = upObject.bash;
if (_local3) {
_root.game.ModifyTowerRangeBox(this, true);
}
pips.SetPips(level - 1);
SetRotation();
upObject = undefined;
upTicks = 0;
upTickTotal = 0;
upgradeBar._visible = false;
chassis._visible = true;
}
function SetRotation() {
if (rotating) {
targetAngle = Math.random() * 360;
chassis.turret._rotation = targetAngle;
}
}
function SetSelected(tf) {
hTower._visible = tf;
select = tf;
if (tf) {
hTower._x = topLeftCell.left + 1;
hTower._y = topLeftCell.top + 1;
selectFade = 1;
selectNum = 50;
filters = [new flash.filters.GlowFilter(16750848, 0.5, 10, 10, 3, 3)];
} else {
selectFade = 0;
filters = [];
}
}
function FadeSelect() {
selectNum = selectNum + (selectFade * 5);
if (selectFade == 1) {
if (selectNum >= 50) {
selectFade = -1;
}
} else if (selectNum <= 0) {
selectFade = 1;
}
hTower._alpha = selectNum;
}
function TargetValid(c) {
if (c) {
if (c.flying) {
if (towerType == 4) {
ok = !c.forcedFly;
} else {
ok = (towerType != 2) && (towerType != 6);
}
} else if (c.immune) {
ok = (towerType != 4) && (towerType != 5);
} else {
ok = towerType != 4;
}
if (ok) {
ok = c.shotHealth > 0;
}
}
return(ok);
}
function AcquireTarget(num) {
var _local7 = [];
var _local3;
var _local6 = 0;
var _local5 = creeps.length;
var _local4 = targetNum;
targetTick = 0;
while (_local6 < _local5) {
_local6++;
_local4++;
if (_local4 > _local5) {
_local4 = 0;
}
var _local2 = creeps[_local4];
_local3 = false;
if (_local2) {
if (_local2.flying) {
if (towerType == 4) {
_local3 = !_local2.forcedFly;
} else {
_local3 = towerType != 2;
}
} else if (_local2.immune) {
_local3 = (towerType != 5) && (towerType != 4);
} else {
_local3 = towerType != 4;
}
if (_local3) {
if ((_local2.shotHealth > 0) && (InRange(_local2))) {
if (_local7.push(_local2) == num) {
break;
}
}
}
}
}
if (_local7.length > 0) {
targetNum = _local7[0].id;
} else {
targetNum = -1;
}
return(_local7);
}
function onEnterFrame() {
if (dragged) {
return(undefined);
}
if (selectFade != 0) {
FadeSelect();
}
if (_root.game.gameState != 1) {
return(undefined);
}
if (upTicks > 0) {
if ((--upTicks) == 0) {
ApplyUpgrade();
} else {
upgradeBar._width = (1 - (upTicks / upTickTotal)) * 20;
}
return(undefined);
}
if (sellTicks > 0) {
if ((--sellTicks) == 0) {
DoSell();
} else {
upgradeBar._width = (sellTicks / sellTickTotal) * 20;
}
return(undefined);
}
shotTick--;
if (towerType == 4) {
if (_root.game.flyingCreeps) {
if (shotTick < 0) {
var _local3 = 0;
while (_local3 < targets.length) {
if (!InRange(targets[_local3])) {
targets.splice(_local3, 1);
} else {
_local3++;
}
}
if (targets.length < 4) {
targets = targets.concat(AcquireTarget(4 - targets.length));
}
var _local4 = [];
_local4.push([_x - 7, _y]);
_local4.push([_x + 7, _y]);
_local4.push([_x, _y + 7]);
_local4.push([_x, _y - 7]);
_local3 = 0;
while (_local3 < targets.length) {
Fire(targets[_local3], _local4[_local3][0], _local4[_local3][1], _local3 == 0);
_local3++;
}
shotTick = hitRate;
}
}
} else {
if (("" + target) == "") {
target = undefined;
targetTick = ((shotTick < scanTick) ? (shotTick) : (scanTick));
}
targetTick--;
if (target && (shotTick < 0)) {
if (((target.shotHealth > 0) || (override)) && (InRange(target))) {
shotTick = hitRate;
Fire(target, _x, _y, true);
} else {
target = undefined;
targetTick = scanTick;
}
}
}
if (rotating) {
if (target) {
var _local6 = target._x - _x;
var _local5 = target._y - _y;
var _local7 = Math.round((Math.atan2(_local5, _local6) * 180) / Math.PI);
targetAngle = _local7;
}
chassis.turret._rotation = targetAngle;
}
}
function Fire(target, posX, posY, playsnd) {
if (towerType != 6) {
var _local4 = shotField.getNextHighestDepth();
shotField.attachMovie("Shot", "shot" + _local4, _local4, {creeps:creeps, _x:posX, _y:posY, target:target, damage:damage, splash:splash, shotType:towerType, slow:slow, bash:bash, hitAir:towerType != 2, hitGround:towerType != 4});
target.shotHealth = target.shotHealth - damage;
} else {
var _local4 = groundField.getNextHighestDepth();
groundField.attachMovie("Shot", "shot" + _local4, _local4, {creeps:creeps, _x:posX, _y:posY, target:target, damage:damage, splash:splash, shotType:towerType, slow:slow, bash:bash, hitAir:towerType != 2, hitGround:towerType != 4});
}
if (playsnd) {
var _local3;
switch (towerType) {
case 1 :
_local3 = "eep.wav";
break;
case 2 :
_local3 = "kow.wav";
break;
case 3 :
_local3 = "pop.wav";
break;
case 4 :
_local3 = "zip.wav";
break;
case 5 :
_local3 = "frost.wav";
break;
case 6 :
_local3 = "THUD.WAV";
}
_root.game.PlaySound(_local3);
}
}
function InRange(c) {
var _local3 = _x - c._x;
var _local2 = _y - c._y;
var _local4 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local4 < range) {
return(true);
}
return(false);
}
}
Symbol 225 MovieClip [__Packages.Cell] Frame 0
class Cell
{
var creepCount, rangeTowers, parentCellsLR, nextCellLR, parentCellsUD, nextCellUD, pathID;
function Cell () {
ClearPath(true);
ClearPath(false);
creepCount = 0;
rangeTowers = [];
}
function AddRangeTower(t, partial) {
rangeTowers.push({id:t.id, tower:t, partial:partial});
}
function RemoveRangeTower(t) {
var _local2 = 0;
while (_local2 < rangeTowers.length) {
if (rangeTowers[_local2].id == t.id) {
rangeTowers.splice(_local2, 1);
break;
}
_local2++;
}
}
function ClearPath(LR) {
if (LR) {
parentCellsLR = [];
nextCellLR = undefined;
} else {
parentCellsUD = [];
nextCellUD = undefined;
}
pathID = 0;
}
}
Symbol 226 MovieClip [__Packages.Creep] Frame 0
class Creep extends MovieClip
{
var gridSize, offSet, startHealth, health, lastHealth, hCreepSlow, dead, entering, forcedFly, slowRatio, bashed, flying, speed, spawnMax, spawnLevel, creep, _visible, onEnterFrame, jitterX, jitterY, size, color, cacheAsBitmap, slowTicks, bashTicks, _x, _y, expTicks, angle, dx, dy, nowX, nextX, nowY, nextY, startDelay, cCell, endCell, LR, startCell, removeMovieClip, healthBar;
function Creep () {
super();
gridSize = _root.game.gridSize;
offSet = gridSize / 2;
startHealth = health;
lastHealth = startHealth;
hCreepSlow._visible = false;
dead = false;
entering = true;
forcedFly = false;
slowRatio = 1;
bashed = false;
var _local4 = 1;
if (flying) {
_local4 = 2;
}
if (speed > 1) {
_local4 = 3;
}
if ((spawnMax > 1) && (spawnLevel == 1)) {
_local4 = 4;
}
creep.gotoAndStop(_local4);
hCreepSlow.gotoAndStop(_local4);
_visible = false;
onEnterFrame = FrameTick;
}
function Init() {
jitterX = int(((Math.random() * gridSize) / 2) - (gridSize / 4));
jitterY = int(((Math.random() * gridSize) / 2) - (gridSize / 4));
creep._xscale = size;
creep._yscale = size;
hCreepSlow._xscale = size;
hCreepSlow._yscale = size;
var _local2 = HEXtoRGB(color);
creep._color = SetTint(_local2.r, _local2.g, _local2.b, 35);
cacheAsBitmap = true;
}
function onPress() {
_root.game.SelectCreep(this);
_root.game.AssignTargetCreep(this);
}
function SetTint(r, g, b, amount) {
var _local2 = new Object();
_local2.ra = (_local2.ga = (_local2.ba = 100 - amount));
var _local3 = amount / 100;
_local2.rb = r * _local3;
_local2.gb = g * _local3;
_local2.bb = b * _local3;
var _local4 = new Color(creep);
_local4.setTransform(_local2);
return(_local4);
}
function HEXtoRGB(hex) {
var _local1 = (isNaN(hex) ? (parseInt(hex, 16)) : (hex));
var _local4 = _local1 >> 16;
var _local5 = (_local1 ^ (_local4 << 16)) >> 8;
var _local3 = (_local1 ^ (_local4 << 16)) ^ (_local5 << 8);
return({r:_local4, g:_local5, b:_local3});
}
function SetSlow(slow, time) {
slowRatio = (100 - slow) / 100;
slowTicks = time;
hCreepSlow._visible = true;
}
function StopSlow() {
hCreepSlow._visible = false;
slowRatio = 1;
}
function SetBash(time) {
bashTicks = time;
}
function StopBash() {
}
function DoExplode(posX, posY) {
_x = posX;
_y = posY;
expTicks = 0;
onEnterFrame = function () {
if ((++this.expTicks) > 50) {
trace((this._x + ",") + this._y);
}
if (!this._visible) {
this._visible = true;
this.Init();
var _local3 = (this.startCell.left + this.offSet) - this._x;
var _local2 = (this.startCell.top + this.offSet) - this._y;
this.creep._rotation = Math.round((Math.atan2(_local2, _local3) * 180) / Math.PI);
} else {
var _local3 = ((this.startCell.left + this.offSet) + this.jitterX) - this._x;
var _local2 = ((this.startCell.top + this.offSet) + this.jitterY) - this._y;
if ((Math.abs(_local3) > 1) || (Math.abs(_local2) > 1)) {
this._x = this._x + (_local3 / 5);
this._y = this._y + (_local2 / 5);
} else {
this._x = int(this._x);
this._y = int(this._y);
this.onEnterFrame = this.FrameTick;
}
}
};
}
function SetDirection(fromCell, toCell) {
var _local4 = ((creep._rotation > 0) ? 180 : -180);
if (toCell.left == fromCell.left) {
angle = ((toCell.top > fromCell.top) ? 90 : -90);
} else if (toCell.top == fromCell.top) {
angle = ((toCell.left > fromCell.left) ? 0 : (_local4));
} else {
angle = ((toCell.left > fromCell.left) ? 0 : (_local4));
if (angle == 0) {
angle = ((toCell.top > fromCell.top) ? 45 : -45);
} else {
angle = ((toCell.top > fromCell.top) ? 135 : -135);
}
}
}
function SetSpeed() {
dx = 0;
dy = 0;
if (nextX == nowX) {
dy = ((nextY > nowY) ? (speed) : (-speed));
} else if (nextY == nowY) {
dx = ((nextX > nowX) ? (speed) : (-speed));
} else {
dx = ((nextX > nowX) ? (speed / 1.4) : ((-speed) / 1.4));
dy = ((nextY > nowY) ? (speed / 1.4) : ((-speed) / 1.4));
}
}
function FrameTick() {
var _local5;
if (_root.game.gameState != 1) {
return(undefined);
}
if (startDelay >= 0) {
if (startDelay == 0) {
Init();
}
startDelay--;
} else {
if (cCell == undefined) {
_visible = true;
if (flying) {
cCell = endCell;
nextX = endCell.left + offSet;
nextY = endCell.top + offSet;
if (LR) {
nowX = -14;
nowY = nextY;
angle = 0;
} else {
nowX = nextX;
nowY = -14;
angle = 90;
}
} else {
cCell = startCell;
cCell.creepCount++;
nextX = cCell.left + offSet;
nextY = cCell.top + offSet;
if (spawnLevel < 2) {
if (LR) {
nowX = -14;
nowY = nextY;
angle = 0;
} else {
nowX = nextX;
nowY = -14;
angle = 90;
}
} else {
if (LR) {
nowX = nextX - 1;
nowY = nextY;
angle = 0;
} else {
nowX = nextX;
nowY = nextY - 1;
angle = 90;
}
creep._rotation = int(creep._rotation / 15) * 15;
}
}
SetSpeed();
entering = false;
}
if (bashTicks > 0) {
if ((--bashTicks) == 0) {
StopBash();
_x = nowX + jitterX;
_y = nowY + jitterY;
} else {
_x = ((nowX + jitterX) + int(Math.random() * 2)) - 1;
_y = ((nowY + jitterY) + int(Math.random() * 2)) - 1;
}
} else {
if (slowTicks > 0) {
if ((--slowTicks) == 0) {
StopSlow();
}
}
nowX = nowX + (dx * slowRatio);
nowY = nowY + (dy * slowRatio);
var _local3 = creep._rotation;
if (angle == _local3) {
} else if (angle > _local3) {
_local3 = _local3 + 15;
creep._rotation = _local3;
hCreepSlow._rotation = _local3;
} else if (angle < _local3) {
_local3 = _local3 - 15;
creep._rotation = _local3;
hCreepSlow._rotation = _local3;
}
_x = nowX + jitterX;
_y = nowY + jitterY;
if ((Math.abs(nowX - nextX) < speed) && (Math.abs(nowY - nextY) < speed)) {
if (dead) {
_root.game.LoseALife(this);
(removeMovieClip());// not popped
return(undefined);
}
var _local4;
var _local6;
if (LR) {
if (cCell.bestChildrenLR == undefined) {
FloodPath.CreateBestChildren(_root.game.cells, cCell, LR);
}
if (cCell.bestChildrenLR.length) {
_local4 = cCell.bestChildrenLR[int(Math.random() * cCell.bestChildrenLR.length)];
}
} else {
if (cCell.bestChildrenUD == undefined) {
FloodPath.CreateBestChildren(_root.game.cells, cCell, LR);
}
if (cCell.bestChildrenUD.length) {
_local4 = cCell.bestChildrenUD[int(Math.random() * cCell.bestChildrenUD.length)];
}
}
cCell.creepCount--;
if (_local4 != undefined) {
SetDirection(cCell, _local4);
_local4.creepCount++;
nextX = _local4.left + offSet;
nextY = _local4.top + offSet;
nowX = cCell.left + offSet;
nowY = cCell.top + offSet;
cCell = _local4;
SetSpeed();
} else {
dead = true;
if (LR) {
nextX = nextX + 48;
nextY = nowY;
angle = 0;
} else {
nextY = nextY + 48;
nextX = nowX;
angle = 90;
}
SetSpeed();
}
}
}
if (health <= 0) {
_root.game.AddKill(this);
if (spawnMax > 0) {
_root.game.AddSpawnCreeps(this);
}
if (cCell) {
cCell.creepCount--;
}
(removeMovieClip());// not popped
} else if (health != lastHealth) {
healthBar._width = (health / startHealth) * 15;
lastHealth = health;
}
}
}
}
Symbol 227 MovieClip [__Packages.FloodPath] Frame 0
class FloodPath
{
function FloodPath () {
}
function Go(cells, startCell, endCells, LR) {
ClearMoveCosts(cells, LR);
FloodCells(cells, endCells, LR);
if (startCell.tmpMoveCost == 0) {
return(false);
}
with (_root.game) {
var i = 0;
while (i < creeps.length) {
var cr = creeps[i];
if ((!cr.entering) && (!cr.dead)) {
var c = cells[int((cr.nextY - startY) / gridSize)][int((cr.nextX - startX) / gridSize)];
if (c && (c.tmpMoveCost == 0)) {
trace((((i + ":") + c.row) + ",") + c.col);
return(false);
}
}
i++;
}
}
UpdateMoveCosts(cells, endCells, LR);
return(true);
}
static function CreateBestChildren(cells, c, LR) {
var _local13 = cells.length;
var _local12 = cells[0].length;
var _local8;
var _local3 = (LR ? (c.moveCostLR) : (c.moveCostUD));
if (_local3 == -1) {
return(undefined);
}
var _local10 = _local3;
var _local4 = c.row - 1;
while (_local4 < (c.row + 2)) {
var _local1 = c.col - 1;
while (_local1 < (c.col + 2)) {
if (((((_local4 < 0) || (_local4 >= _local13)) || (_local1 < 0)) || (_local1 >= _local12)) || ((_local4 == c.row) && (_local1 == c.col))) {
} else {
var _local6 = true;
var _local7 = 1;
if ((_local4 != c.row) && (_local1 != c.col)) {
_local7 = 0.7;
if (cells[_local4][c.col].cost == 0) {
_local6 = false;
} else if (cells[c.row][_local1].cost == 0) {
_local6 = false;
}
}
if (_local6) {
var _local5 = cells[_local4][_local1];
_local3 = (LR ? (_local5.moveCostLR) : (_local5.moveCostUD));
if (_local3 == 0) {
} else {
if (_local3 == -1) {
return([]);
}
_local3 = _local3 - _local7;
if (_local3 == _local10) {
_local8.push(_local5);
} else if (_local3 < _local10) {
_local8 = [];
_local8.push(_local5);
_local10 = _local3;
}
}
}
}
_local1++;
}
_local4++;
}
if (LR) {
c.bestChildrenLR = _local8;
} else {
c.bestChildrenUD = _local8;
}
}
function FloodCells(cells, endCells, LR) {
var _local12;
var _local11 = new Array();
var _local14 = cells.length;
var _local13 = cells[0].length;
_local11 = endCells.concat();
_local11.reverse();
var _local5 = 0;
while (_local5 < endCells.length) {
if (LR) {
endCells[_local5].moveCostLR = -1;
} else {
endCells[_local5].moveCostUD = -1;
}
endCells[_local5].tmpMoveCost = -1;
_local5++;
}
while (_local11.length > 0) {
_local12 = _local11;
_local11 = new Array();
while (_local12.length) {
var _local1 = _local12.pop();
var _local8 = _local1.tmpMoveCost;
if (_local8 == -1) {
_local8 = 0;
}
_local1.pathVisited = true;
_local5 = 0;
var _local3 = _local1.row - 1;
while (_local3 < (_local1.row + 2)) {
var _local2 = _local1.col - 1;
while (_local2 < (_local1.col + 2)) {
_local5++;
if (((((_local3 < 0) || (_local3 >= _local14)) || (_local2 < 0)) || (_local2 >= _local13)) || ((_local3 == _local1.row) && (_local2 == _local1.col))) {
} else {
var _local4 = cells[_local3][_local2];
if (((!_local4.pathVisited) && (_local4.cost == 1)) && (_local4.tmpMoveCost != -1)) {
var _local6 = true;
if ((_local3 != _local1.row) && (_local2 != _local1.col)) {
if (cells[_local3][_local1.col].cost == 0) {
_local6 = false;
} else if (cells[_local1.row][_local2].cost == 0) {
_local6 = false;
}
}
if (_local6) {
var _local7 = _local4.tmpMoveCost;
var _local9 = (((((_local5 == 1) || (_local5 == 3)) || (_local5 == 7)) || (_local5 == 9)) ? 1.4 : 1);
if ((_local7 == 0) || ((_local8 + _local9) < _local7)) {
_local4.tmpMoveCost = _local8 + _local9;
_local11.push(_local4);
}
}
}
}
_local2++;
}
_local3++;
}
}
_local11.sortOn("tmpMoveCost", Array.NUMERIC | Array.DESCENDING);
}
}
function OpenCell(openCells, cell, LR) {
var _local1 = 0;
while (_local1 < openCells.length) {
var _local2 = openCells[_local1];
if (_local2.tmpMoveCost > cell.tmpMoveCost) {
}
_local1++;
}
}
function UpdateMoveCosts(cells, endCells, LR) {
var _local3 = 0;
while (_local3 < cells.length) {
var _local2 = 0;
while (_local2 < cells[_local3].length) {
var _local1 = cells[_local3][_local2];
if (LR) {
_local1.moveCostLR = _local1.tmpMoveCost;
_local1.bestChildrenLR = undefined;
} else {
_local1.moveCostUD = _local1.tmpMoveCost;
_local1.bestChildrenUD = undefined;
}
_local2++;
}
_local3++;
}
}
function ClearMoveCosts(cells, LR) {
var _local3 = 0;
while (_local3 < cells.length) {
var _local1 = 0;
while (_local1 < cells[_local3].length) {
var _local2 = cells[_local3][_local1];
_local2.tmpMoveCost = 0;
_local2.pathVisited = false;
_local1++;
}
_local3++;
}
}
}
Symbol 228 MovieClip [__Packages.ShotSpray] Frame 0
class ShotSpray extends MovieClip
{
var tick, timeToSpawn, _x, _y, shotNum, shotCount, dx, dy, damage, timeToLive, removeMovieClip;
function ShotSpray () {
super();
tick = timeToSpawn;
}
function SetTarget(c, t) {
_x = t._x;
_y = t._y;
shotNum = shotCount;
dx = c._x - t._x;
dy = c._y - t._y;
var _local4 = Math.sqrt((dx * dx) + (dy * dy));
var _local2 = 10 / _local4;
dx = dx * _local2;
dy = dy * _local2;
}
function onEnterFrame() {
tick--;
if ((tick == 0) && (shotNum > 0)) {
var _local3 = _root.game.shotField.getNextHighestDepth();
_root.game.shotField.attachMovie("ShotSpray", "shot" + _local3, _local3, {_x:_x + dx, _y:_y + dy, dx:dx, dy:dy, shotCount:shotCount, shotNum:shotNum - 1, timeToSpawn:timeToSpawn, timeToLive:timeToLive, damage:damage});
}
if (tick <= (-timeToLive)) {
(removeMovieClip());// not popped
}
}
}
Symbol 229 MovieClip [__Packages.Shot] Frame 0
class Shot extends MovieClip
{
var gotoAndStop, shotType, _visible, tick, _xscale, _yscale, _alpha, splash, bashed, lineStyle, moveTo, lineTo, _x, target, _y, lastX, lastY, _rotation, creeps, damage, bash, removeMovieClip, slow, hitAir, hitGround;
function Shot () {
super();
(gotoAndStop(shotType));// not popped
pointAtTarget();
_visible = false;
switch (shotType) {
case 1 :
tick = 2;
speed = 5;
break;
case 2 :
tick = 2;
speed = 1;
accel = 0.1;
break;
case 3 :
tick = 4;
break;
case 4 :
speed = 1;
accel = 0.2;
tick = 1;
_xscale = (_yscale = 50);
break;
case 5 :
tick = 1;
break;
case 6 :
_alpha = 60;
_xscale = (_yscale = (splash / 35) * 100);
tick = 1;
bashed = false;
}
}
function LaserTarget() {
lineStyle(1, 0, 100);
moveTo(0, 0);
lineTo(target._x - _x, target._y - _y);
_visible = true;
_root.game.AddExplosion(shotType, target._x, target._y, target.dx, target.dy);
}
function pointAtTarget() {
switch (shotType) {
case 1 :
break;
case 2 :
case 4 :
var _local3 = lastX - _x;
var _local2 = lastY - _y;
_rotation = Math.round((Math.atan2(_local2, _local3) * 180) / Math.PI);
break;
case 3 :
_rotation = _rotation + 40;
break;
case 5 :
_rotation = _rotation + 20;
}
}
function BashTargets() {
var _local4;
var _local3 = 0;
while (_local3 < creeps.length) {
var _local2 = creeps[_local3];
if (_local2) {
if (!_local2.flying) {
if (InRange(_local2)) {
_local2.shotHealth = _local2.shotHealth - damage;
_local2.health = _local2.health - damage;
if (bash > 0) {
if (bash > (Math.random() * 100)) {
_local2.SetBash(64);
}
}
}
}
}
_local3++;
}
bashed = true;
}
function onEnterFrame() {
if (_root.game.gameState != 1) {
return(undefined);
}
if (("" + target) == "") {
target = undefined;
}
if ((--tick) == 0) {
_visible = true;
}
if (shotType == 6) {
if (!bashed) {
BashTargets();
}
if (tick < -12) {
(removeMovieClip());// not popped
} else {
_alpha = _alpha - 5;
}
} else {
if (target) {
lastX = target._x;
lastY = target._y;
pointAtTarget();
}
if (accel > 0) {
speed = speed + accel;
}
var _local7 = lastX - _x;
var _local6 = lastY - _y;
var _local9 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
var _local8 = speed / _local9;
_x = _x + (_local7 * _local8);
_y = _y + (_local6 * _local8);
if ((Math.abs(_local7) < speed) && (Math.abs(_local6) < speed)) {
if (target) {
_root.game.AddExplosion(shotType, _x, _y, target.dx, target.dy);
} else {
_root.game.AddExplosion(shotType, _x, _y, 0, 0);
}
if (splash == 0) {
if (target) {
target.health = target.health - damage;
if ((slow > 0) && (!target.immune)) {
target.SetSlow(slow, 100);
}
}
} else {
var _local4;
var _local5 = 0;
while (_local5 < creeps.length) {
var _local3 = creeps[_local5];
if (_local3) {
if (_local3.flying) {
_local4 = hitAir;
} else {
_local4 = hitGround;
}
if (_local4) {
_local4 = (_local3.immune ? (!slow) : true);
}
if (_local4) {
if (InRange(_local3)) {
if (_local3 != target) {
_local3.shotHealth = _local3.shotHealth - damage;
_local3.health = _local3.health - damage;
} else {
_local3.health = _local3.health - damage;
}
if (slow > 0) {
_local3.SetSlow(slow, 100);
}
}
}
}
_local5++;
}
}
(removeMovieClip());// not popped
}
}
}
function InRange(c) {
var _local3 = _x - c._x;
var _local2 = _y - c._y;
var _local4 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local4 <= splash) {
return(true);
}
return(false);
}
var speed = 4;
var accel = 0;
}
Symbol 230 MovieClip [__Packages.Grid] Frame 0
class Grid extends MovieClip
{
var gotoAlpha, _alpha, active, hCell, showCell, hRange, hTower, rows, cols, startX, startY, gridSize, dragTower, cRow, cCol, hitTest, cCell, clear, lineStyle, cells, moveTo, lineTo, beginFill, endFill, cacheAsBitmap, createTextField, getNextHighestDepth;
function Grid () {
super();
gotoAlpha = 0;
_alpha = 0;
active = false;
hCell = _root.attachMovie("hCell", "hCell", 21);
hCell._visible = false;
hCell._alpha = 50;
showCell = false;
hRange = _root.attachMovie("hRange", "hRange", 20);
hRange._visible = false;
hRange._alpha = 30;
hTower = _root.attachMovie("hTower", "hTower", 30);
hTower._alpha = 65;
hTower._visible = false;
hCell.goldChar._visible = false;
}
function Init() {
rows = _root.game.cellRows;
cols = _root.game.cellCols;
startX = _root.game.startX;
startY = _root.game.startY;
gridSize = _root.game.gridSize;
}
function CheckGold() {
if (active) {
HighlightCell();
}
}
function CancelSelect() {
hRange._visible = false;
}
function SelectTower(t) {
hRange._width = (hRange._height = t.range * 2);
hRange._x = t.topLeftCell.left + gridSize;
hRange._y = t.topLeftCell.top + gridSize;
hRange._visible = true;
}
function ToggleGrid() {
if (!_root.game.gridOn) {
gotoAlpha = 0;
}
if (_root.game.gridOn) {
gotoAlpha = 50;
}
active = true;
}
function FollowTower(t) {
if (!_root.game.gridOn) {
gotoAlpha = 50;
active = true;
}
showCell = true;
dragTower = t;
hCell._width = (gridSize * t.size) - 2;
hCell._height = hCell._width;
hRange._width = (hRange._height = t.range * 2);
rangeOffset = t._width / 2;
HighlightCell();
CheckGold();
}
function StopFollowTower() {
if (!_root.game.gridOn) {
gotoAlpha = 0;
active = true;
}
showCell = false;
hCell._visible = false;
hRange._visible = false;
cRow = -1;
cCol = -1;
hitTest = 4;
dragTower.dragged = false;
dragTower = undefined;
}
function onMouseMove() {
if (showCell && (_alpha > 0)) {
HighlightCell();
}
}
function onMouseDown() {
if (hitTest == 0) {
_root.game.DropTower(dragTower, cCell);
} else {
var _local6 = _root._xmouse;
var _local5 = _root._ymouse;
var _local4 = int((_local6 - startX) / gridSize);
var _local3 = int((_local5 - startY) / gridSize);
if (dragTower) {
if ((((((_local4 >= 0) && (_local4 < cols)) && (_local3 >= 0)) && (_local3 < rows)) && (hitTest != 3)) && (!_root.game.shiftDown)) {
_root.game.CancelSelect();
}
} else {
_root.game.SelectCell(_local3, _local4);
}
}
}
function DrawGrid() {
clear();
lineStyle(1, 11184810);
var _local7 = startY + (rows * gridSize);
var _local8 = startX + (cols * gridSize);
cells = _root.game.cells;
var _local6 = gridSize * 10;
lineStyle(1, 16777215, 80);
moveTo(startX + ((cols / 2) * gridSize), startY + _local6);
lineTo(startX + ((cols / 2) * gridSize), _local7 - _local6);
moveTo(startX + _local6, startY + ((rows / 2) * gridSize));
lineTo(_local8 - _local6, startY + ((rows / 2) * gridSize));
lineStyle(1, 16777215, 0);
var _local5 = 0;
while (_local5 < rows) {
var _local4 = 0;
while (_local4 < cols) {
var _local3 = cells[_local5][_local4];
if (_local3.barrier && (_local3.cost == 0)) {
beginFill(16777215, 80);
moveTo(_local3.left, _local3.top);
lineTo(_local3.left + gridSize, _local3.top);
lineTo(_local3.left + gridSize, _local3.top + gridSize);
lineTo(_local3.left, _local3.top + gridSize);
lineTo(_local3.left, _local3.top);
endFill();
}
_local4++;
}
_local5++;
}
cacheAsBitmap = true;
}
function DrawMoveCosts() {
var _local6;
trace("DMC");
var _local5 = 0;
while (_local5 < rows) {
var _local4 = 0;
while (_local4 < cols) {
var _local2 = cells[_local5][_local4];
if (_local2.moveCostLR > 0) {
var _local3 = _local2.moveCostLR * 6;
if (_local3 > 254) {
_local3 = 254;
}
beginFill(255 - _local3, 80);
trace(_local3);
moveTo(_local2.left, _local2.top);
lineTo(_local2.left + gridSize, _local2.top);
lineTo(_local2.left + gridSize, _local2.top + gridSize);
lineTo(_local2.left, _local2.top + gridSize);
lineTo(_local2.left, _local2.top);
endFill();
}
_local4++;
}
_local5++;
}
}
function DrawRanges() {
var _local3;
var _local5 = 0;
while (_local5 < rows) {
var _local4 = 0;
while (_local4 < cols) {
var _local2 = cells[_local5][_local4];
if (_local2.rangeTowers.length > 0) {
beginFill(16715792, 80);
moveTo(_local2.left, _local2.top);
lineTo(_local2.left + gridSize, _local2.top);
lineTo(_local2.left + gridSize, _local2.top + gridSize);
lineTo(_local2.left, _local2.top + gridSize);
lineTo(_local2.left, _local2.top);
endFill();
_local3 = this[(("tf:" + _local5) + ":") + _local4];
if (_local3) {
_local3.text = "" + _local2.rangeTowers.length;
} else {
_local3 = createTextField((("tf:" + _local5) + ":") + _local4, getNextHighestDepth(), _local2.left, _local2.top, gridSize, gridSize);
_local3.text = "" + _local2.rangeTowers.length;
}
} else {
_local3 = this[(("tf:" + _local5) + ":") + _local4];
if (_local3) {
_local3.removeTextField();
}
}
_local4++;
}
_local5++;
}
}
function onEnterFrame() {
if (active) {
if (gotoAlpha > _alpha) {
_alpha = _alpha + 10;
if (gotoAlpha < _alpha) {
active = false;
}
} else {
_alpha = _alpha - 10;
if (gotoAlpha > _alpha) {
active = false;
}
}
}
}
function HighlightCell() {
var _local7;
var _local6 = _root._xmouse;
var _local5 = _root._ymouse;
var _local4 = int((_local6 - startX) / gridSize);
var _local3 = int((_local5 - startY) / gridSize);
if ((((_local4 < 0) || (_local4 >= cols)) || (_local3 < 0)) || (_local3 >= rows)) {
hCell._visible = false;
hRange._visible = false;
cRow = -1;
cCol = -1;
cCell = undefined;
hitTest = 4;
} else {
_local7 = _root.game.cells[_local3][_local4];
if (_local5 < (_local7.top + (gridSize / 2))) {
cRow = _local3 - 1;
} else {
cRow = _local3;
}
if (_local6 < (_local7.left + (gridSize / 2))) {
cCol = _local4 - 1;
} else {
cCol = _local4;
}
if (cCol < 0) {
cCol = 0;
}
if (cRow < 0) {
cRow = 0;
}
if (cCol >= (cols - 1)) {
cCol = cols - 2;
}
if (cRow >= (rows - 1)) {
cRow = rows - 2;
}
cCell = _root.game.cells[cRow][cCol];
if (showCell) {
hCell._x = cCell.left;
hCell._y = cCell.top;
hCell._visible = true;
}
hRange._x = cCell.left + gridSize;
hRange._y = cCell.top + gridSize;
hRange._visible = true;
hitTest = _root.game.CellHitTest(cRow, cCol, dragTower);
}
if (hitTest == 0) {
hCell.gotoAndStop(1);
} else {
hCell.gotoAndStop(2);
}
}
}
Symbol 231 MovieClip [__Packages.Fragment] Frame 0
class Fragment extends MovieClip
{
var gotoAndStop, frame, _alpha, ticks, removeMovieClip, xVel, yVel, dx, dy, _x, _y, rotate, _rotation;
function Fragment () {
super();
gotoAndStop(frame);
if (frame == 2) {
_alpha = 25;
} else {
_alpha = 100;
}
}
function onEnterFrame() {
if (_root.game.gameState != 1) {
return(undefined);
}
if ((ticks--) <= 0) {
(removeMovieClip());// not popped
} else {
xVel = xVel - (xVel / (ticks + 1));
yVel = yVel - (yVel / (ticks + 1));
dx = dx - (dx / (ticks + 1));
dy = dy - (dy / (ticks + 1));
_x = _x + xVel;
_y = _y + yVel;
if (rotate > 0) {
_rotation = _rotation + rotate;
}
}
}
}
Symbol 232 MovieClip [__Packages.UpgradePanel] Frame 0
class UpgradePanel extends MovieClip
{
var _visible, upgradePanel, filters, upgradeBar, tower, panelDetails, upgradeButton, towerObject, upgradeName, desc;
function UpgradePanel () {
super();
_visible = false;
upgradePanel._visible = false;
active = false;
filters = [new flash.filters.GlowFilter(16750848, 0.8, 10, 10, 2, 3)];
}
function onEnterFrame() {
if (upgradeBar._visible && (tower)) {
ShowUpgrade();
}
}
function Upgrade() {
_root.game.UpgradeSelectedTower(false);
panelDetails._visible = false;
upgradeBar._visible = true;
upgradeButton._visible = false;
ShowUpgrade();
}
function CheckGold() {
if (_visible) {
if (tower && (tower.upTicks > 0)) {
upgradeButton._visible = false;
} else if (_root.game.gold >= (int(towerObject.cost) - tower.cost)) {
upgradeButton._visible = true;
} else {
upgradeButton._visible = false;
}
}
}
function ShowUpgrade() {
if (tower && (tower.upTicks > 0)) {
upgradeBar.SetPercentage(1 - (tower.upTicks / tower.upTickTotal));
} else {
panelDetails._visible = true;
upgradeBar._visible = false;
upgradeButton._visible = true;
_root.game.SelectCell(tower.topLeftCell.row, tower.topLeftCell.col);
}
}
function GetSpeed(hr) {
if (hr < 7) {
return("very fast");
}
if (hr < 13) {
return("fast");
}
if (hr < 37) {
return("average");
}
if (hr < 61) {
return("slow");
}
return("very slow");
}
function SetTower(oldTower, newTower) {
tower = oldTower;
towerObject = newTower;
upgradeName.text = newTower.towerName;
desc.text = newTower.desc;
with (panelDetails) {
cost.text = newTower.cost - oldTower.cost;
damage.text = newTower.damage;
range.text = newTower.range;
speed.text = GetSpeed(newTower.hitRate);
}
_visible = true;
if (oldTower.upTicks > 0) {
panelDetails._visible = false;
upgradeBar._visible = true;
ShowUpgrade();
} else {
panelDetails._visible = true;
upgradeBar._visible = false;
}
CheckGold();
}
function Cancel() {
_visible = false;
panelDetails._visible = true;
upgradeBar._visible = false;
upgradeButton._visible = true;
tower = undefined;
towerObject = undefined;
}
}
Symbol 233 MovieClip [__Packages.Game] Frame 0
class Game
{
var useComms, host, netComms, clientID, topMenu, infoPanel, upgradePanel, mpPanel, levelBar, levelBarHighlight, btnNextLevel, creeps, creepCount, pathFinder, pathID, floodPath, groundField, towerField, creepField, shotField, effectsField, bountyField, gridField, pauseField, gameState, expLevel, muted, inited, difficulty, gridOn, speedChal, gameSent, mapMode, NoPellet, NoSquirt, NoDart, NoSwarm, NoFrost, NoBash, endTime, waves, sellNum, infChal, onlySpawn, tick, tTick, fcount, cTick, gold, levelBonus, level, lives, creepKills, timeToLevel, currentLevelTime, levelTime, score, cells, finished, startCellUD, startCellLR, endCellsUD, endCellsLR, startTime, pauseTime, newLevelTick, creepDied, flyingCreeps, startX, endX, startY, endY, gridSize, towers, cellCols, cellRows, shiftDown, cg, midRow, midCol, currentWave, creepCountLR, creepCountUD, openingStartRow, openingEndRow, openingStartCol, openingEndCol, endCellLR, endCellUD;
function Game () {
useComms = false;
if (host == undefined) {
host = true;
}
if (useComms) {
netComms = new NetComms();
trace("COMMS ON");
clientID = (host ? 1 : 2);
netComms.game = this;
netComms.clientID = 1;
useComms = false;
}
topMenu = _root.Interface.topMenu;
infoPanel = _root.Interface.infoPanel;
upgradePanel = _root.Interface.upgradePanel;
mpPanel = _root.mpPanel;
mpPanel.btnACK._visible = false;
mpPanel._visible = false;
levelBar = _root.Interface.levelBar;
levelBarHighlight = _root.Interface.levelBarHighlight;
btnNextLevel = _root.Interface.btnNextLevel;
creeps = [];
creepCount = 0;
pathFinder = new PathFinder();
pathID = 1;
floodPath = new FloodPath();
groundField = _root.createEmptyMovieClip("groundField", 1);
towerField = _root.createEmptyMovieClip("towerField", 2);
creepField = _root.createEmptyMovieClip("creepField", 3);
shotField = _root.createEmptyMovieClip("shotField", 4);
effectsField = _root.createEmptyMovieClip("effectsField", 6);
bountyField = _root.createEmptyMovieClip("bountyField", 7);
gridField = _root.attachMovie("Grid", "gridField", 10);
pauseField = _root.Interface.attachMovie("PauseOverlay", "pauseField", 100);
gameState = 0;
expLevel = 0;
muted = false;
inited = false;
difficulty = 0;
gridOn = false;
speedChal = false;
gameSent = false;
mapMode = 0;
}
function ShowACK() {
mpPanel.btnACK._visible = true;
}
function KeyPress(code) {
if ((gameState > 1) || (gameState < 0)) {
if ((gameState == 2) && (code == 32)) {
Resume();
}
return(undefined);
}
switch (code) {
case 88 :
Reset();
levelBar.Reset();
trace("88");
break;
case 32 :
if (gameState == 1) {
Pause();
}
break;
case 78 :
if (btnNextLevel._visible) {
SendNextLevel();
}
break;
case 85 :
if ((upgradePanel.tower && (upgradePanel.upgradeButton._visible)) && (!infoPanel.tower.dragged)) {
if (gameState == 1) {
upgradePanel.Upgrade();
} else {
UpgradeSelectedTower(true);
SelectCell(upgradePanel.tower.topLeftCell.row, upgradePanel.tower.topLeftCell.col);
}
}
break;
case 83 :
if (infoPanel.tower && (!infoPanel.tower.dragged)) {
SellSelectedTower(gameState == 0);
}
break;
case 48 :
CancelSelect();
break;
case 49 :
if (!NoPellet) {
AddTower(1, true);
}
break;
case 50 :
if (!NoSquirt) {
AddTower(3, true);
}
break;
case 51 :
if (!NoDart) {
AddTower(2, true);
}
break;
case 52 :
if (!NoSwarm) {
AddTower(4, true);
}
break;
case 53 :
if (!NoFrost) {
AddTower(5, true);
}
break;
case 54 :
if (NoBash) {
break;
}
AddTower(6, true);
}
}
function ShowStart() {
if (inited) {
endTime = GetTime();
Reset();
}
gameState = -1;
pauseField._visible = false;
_root.scoreBoard._visible = false;
_root.Interface.blockingPopup._visible = false;
_root.startPanel.Show();
_root.Interface.bottomBar.levelBarHighlight._visible = false;
levelBar.Clear();
levelBar._visible = false;
levelBarHighlight._visible = false;
ResetChallengeMode();
SetChallengeMode();
ToggleGrid(false);
}
function Init() {
var _local3;
InitMap();
InitWaves();
InitTowers();
levelBar.CreateLevels(waves);
_root.Interface.bottomBar.levelBarHighlight._visible = true;
switch (difficulty) {
case 1 :
_local3 = "Easy Mode";
break;
case 2 :
_local3 = "Normal Mode";
break;
case 3 :
_local3 = "Hard Mode";
break;
case 4 :
_local3 = "Challenge Mode";
break;
case 5 :
_local3 = "Fun Mode";
}
_root.Interface.difficulty.diff.text = _local3;
SetChallengeMode();
Reset();
ToggleGrid(true);
inited = true;
sellNum = 0;
gameState = 0;
if (speedChal) {
Start();
}
}
function ResetChallengeMode() {
NoPellet = false;
NoSquirt = false;
NoDart = false;
NoSwarm = false;
NoFrost = false;
NoBash = false;
speedChal = false;
infChal = false;
mapMode = 0;
onlySpawn = false;
}
function SetChallengeMode() {
_root.Interface.btnPellet._visible = !NoPellet;
_root.Interface.btnSquirt._visible = !NoSquirt;
_root.Interface.btnDart._visible = !NoDart;
_root.Interface.btnSwarm._visible = !NoSwarm;
_root.Interface.btnFrost._visible = !NoFrost;
_root.Interface.btnBash._visible = !NoBash;
}
function Reset() {
if (gameState > 0) {
SendGame();
}
tick = 0;
tTick = 0;
fcount = 0;
if (useComms) {
netComms.Reset();
cTick = 0;
}
gold = 80;
if (gold != 80) {
gold = 80;
}
levelBonus = 0;
level = 0;
lives = 20;
creepKills = 0;
timeToLevel = 1;
currentLevelTime = timeToLevel;
if (difficulty == 1) {
levelTime = 35;
} else {
levelTime = 25;
}
btnNextLevel._visible = true;
score = 0;
topMenu.score.text = 0;
_root.scoreBoard._visible = false;
CancelSelect();
ClearShots();
ClearCreeps();
ClearEffects();
ClearTowers();
if (cells.length > 0) {
CreateCellArray();
if (floodPath != undefined) {
var _local3 = GetTime();
MakeFloodPath(true);
MakeFloodPath(false);
}
}
topMenu.lives.text = lives;
topMenu.kills.text = 0;
topMenu.timeleft.text = timeToLevel;
topMenu.gold.text = gold;
finished = false;
gameState = 0;
_root.Interface.topMenu.btnStart.msg.text = "START";
pauseField._visible = false;
levelBar.Reset();
levelBar._visible = true;
}
function MakeFloodPath(LR) {
trace("flood:" + LR);
return(floodPath.Go(cells, (LR ? (startCellLR) : (startCellUD)), (LR ? (endCellsLR) : (endCellsUD)), LR));
}
function GetTime() {
var _local1 = new Date();
return(_local1.getTime());
}
function Start() {
startTime = GetTime();
gameState = 1;
if (infoPanel.tower) {
SelectCell(infoPanel.tower.topLeftCell.row, infoPanel.tower.topLeftCell.col);
}
_root.Interface.topMenu.btnStart.msg.text = "PAUSE";
levelBar.SetLevel(-1, timeToLevel, false);
levelBarHighlight._visible = true;
gameSent = false;
}
function Pause() {
gameState = 2;
_root.Interface.topMenu.btnStart.msg.text = "RESUME";
pauseField.Show();
pauseTime = GetTime();
}
function Resume() {
if ((gameState = 2)) {
gameState = 1;
}
_root.Interface.topMenu.btnStart.msg.text = "PAUSE";
pauseField.Hide();
startTime = startTime + (GetTime() - pauseTime);
}
function GetLowestCreepLevel() {
var _local4 = 100;
var _local2 = 0;
while (_local2 < creeps.length) {
var _local3 = creeps[_local2];
if (_local3.level < _local4) {
_local4 = _local3.level;
}
_local2++;
}
return(_local4);
}
function ShowFinish() {
endTime = GetTime();
CancelSelect();
gameState = 3;
FilterCreeps();
if ((level > 50) && (infChal)) {
level = GetLowestCreepLevel();
finished = true;
} else {
finished = finished && (creeps.length == 0);
if (finished) {
score = score + (lives * 25);
score = score + levelBonus;
}
finished = finished && (lives > 0);
}
_root.scoreBoard.SetScore(score, difficulty, finished);
if ((score > 5000) && (difficulty > 1)) {
PlaySound("ivor.wav");
}
SendGame();
}
function ToggleGrid(tf) {
CancelSelect();
if (tf != undefined) {
gridOn = tf;
} else {
gridOn = !gridOn;
}
gridField.ToggleGrid();
if (gridOn) {
_root.Interface.btnGrid.msg.text = "NO GRID";
} else {
_root.Interface.btnGrid.msg.text = "GRID";
}
}
function CommTick() {
if (useComms) {
fcount++;
if ((++cTick) == 18) {
cTick = 1;
netComms.ServerLoad(fcount);
netComms.ServerSend(fcount);
}
netComms.FrameTick(fcount);
}
}
function FrameTick() {
if (gameState == 1) {
if ((++tick) > 24) {
tick = 1;
Tick();
}
if ((++tTick) == 6) {
tTick = 1;
AssignTowerTargets();
}
if (newLevelTick > 0) {
newLevelTick--;
PlaySound("LETSGO.WAV");
}
}
}
function Tick() {
if (creepDied) {
FilterCreeps();
}
creepDied = false;
if (finished && (creeps.length == 0)) {
ShowFinish();
}
if (!finished) {
timeToLevel--;
if (timeToLevel == 0) {
NextLevel();
}
topMenu.timeleft.text = timeToLevel;
}
}
function AssignTowerTargets() {
flyingCreeps = false;
var _local10 = 0;
while (_local10 < creeps.length) {
var _local2 = creeps[_local10];
if ((((_local2._x >= startX) && (_local2._x <= endX)) && (_local2._y >= startY)) && (_local2._y <= endY)) {
var _local8 = _local2.cCell;
if (_local2.flying) {
_local8 = cells[int((_local2._y - startY) / gridSize)][int((_local2._x - startX) / gridSize)];
flyingCreeps = true;
}
if (_local8) {
var _local5 = 0;
while (_local5 < _local8.rangeTowers.length) {
var _local4 = _local8.rangeTowers[_local5];
var _local3 = _local4.tower;
if (!_local3.target) {
if (_local3.TargetValid(_local2)) {
if (!_local4.partial) {
_local3.target = _local2;
} else {
var _local7 = _local4.tower._x - _local2._x;
var _local6 = _local4.tower._y - _local2._y;
var _local9 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
if (_local9 <= _local3.range) {
_local3.target = _local2;
}
}
}
}
_local5++;
}
}
}
_local10++;
}
}
function AssignTargetCreep(cr) {
var _local8 = [];
var _local3 = 0;
while (_local3 < towerField.getNextHighestDepth()) {
var _local2 = towerField["tower" + _local3];
trace(_local2.id);
if ((_local2 && (_local2.towerType == 1)) && (_local2.level == 6)) {
var _local5 = _local2._x - cr._x;
var _local4 = _local2._y - cr._y;
var _local7 = Math.sqrt((_local5 * _local5) + (_local4 * _local4));
if (_local7 <= _local2.range) {
_local2.target = cr;
_local2.override = true;
}
}
_local3++;
}
}
function ModifyTowerRangeBox(t, addtower) {
var _local20 = int(t.range / gridSize) + 1;
var _local18 = t.topLeftCell;
var _local14 = _local18.left + gridSize;
var _local13 = _local18.top + gridSize;
var _local19 = _local18.row - _local20;
var _local17 = (_local18.row + _local20) + 1;
var _local15 = _local18.col - _local20;
var _local12 = (_local18.col + _local20) + 1;
var _local9 = _local19;
while (_local9 < _local17) {
var _local3 = _local15;
while (_local3 < _local12) {
var _local2 = cells[_local9][_local3];
var _local11 = _local2.left + (gridSize / 2);
var _local10 = _local2.top + (gridSize / 2);
var _local6 = _local14 - _local11;
var _local5 = _local13 - _local10;
var _local7 = Math.sqrt((_local6 * _local6) + (_local5 * _local5));
if (_local7 <= t.range) {
if (addtower) {
var _local8 = _local7 > (t.range - gridSize);
_local2.AddRangeTower(t, _local8);
} else {
_local2.RemoveRangeTower(t);
}
}
_local3++;
}
_local9++;
}
gridField.DrawGrid();
}
function TowerButtonRollover(type, btn) {
if (gameState == -1) {
return(undefined);
}
infoPanel.SetTowerInfo(towers[type][1], btn);
if (int(towers[type][1].cost) > gold) {
btn.filters = [new flash.filters.GlowFilter(10027008, 0.8, 10, 10, 2, 3)];
} else {
btn.filters = [new flash.filters.GlowFilter(39168, 0.8, 10, 10, 2, 3)];
}
}
function SelectCreep(c) {
if (gameState > 1) {
return(undefined);
}
if (c) {
CancelSelect();
infoPanel.SetCreep(c);
} else {
CancelSelect();
}
}
function SelectCell(cellRow, cellCol) {
var _local2 = cells[cellRow][cellCol];
if (gameState > 1) {
return(undefined);
}
if (_local2.tower && (!_local2.tower.selling)) {
CancelSelect();
gridField.SelectTower(_local2.tower);
infoPanel.SetTower(_local2.tower);
if (_local2.tower.level < 6) {
var _local3 = towers[_local2.tower.towerType][_local2.tower.level + 1];
upgradePanel.SetTower(_local2.tower, _local3);
_local2.tower.SetSelected(true);
gridField.SelectTower(_local2.tower);
}
} else if ((((cellCol >= 0) && (cellCol < cellCols)) && (cellRow >= 0)) && (cellRow < cellRows)) {
CancelSelect();
}
}
function CancelSelect() {
var _local3;
if (gridField.dragTower) {
_local3 = gridField.dragTower;
gridField.StopFollowTower();
removeMovieClip(_local3);
infoPanel.Cancel();
} else if (infoPanel.tower) {
_local3 = infoPanel.tower;
infoPanel.Cancel();
upgradePanel.Cancel();
gridField.CancelSelect();
} else if (infoPanel.creep) {
infoPanel.Cancel();
}
if (_local3) {
_local3.SetSelected(false);
}
if (_root.Interface.blockingPopup._visible) {
_root.Interface.blockingPopup.Hide();
}
}
function UpgradeSelectedTower(quick) {
var _local2 = upgradePanel.tower;
var _local3 = upgradePanel.towerObject;
if (_local2 && (_local3)) {
AdjustGold(-(int(_local3.cost) - _local2.cost));
_local2.Upgrade(_local3);
if (quick) {
_local2.ApplyUpgrade();
}
}
}
function SellTower(t) {
if (gameState == 0) {
AdjustGold(int(t.cost));
} else {
AdjustGold(int(t.cost * 0.75));
}
var _local5 = 0;
while (_local5 < t.size) {
var _local2 = 0;
while (_local2 < t.size) {
var _local3 = cells[t.topLeftCell.row + _local5][t.topLeftCell.col + _local2];
_local3.tower = undefined;
_local3.cost = 1;
_local2++;
}
_local5++;
}
ModifyTowerRangeBox(t, false);
t.topLeftCell = undefined;
PlaySound("Kaching.wav");
FilterCreeps();
MakeFloodPath(true);
if (difficulty > 1) {
MakeFloodPath(false);
}
}
function SellSelectedTower(quick) {
if (quick) {
SellTower(infoPanel.tower);
} else {
infoPanel.tower.Sell(sellNum++);
}
infoPanel.tower.SetSelected(false);
if (quick) {
infoPanel.tower.removeMovieClip();
}
infoPanel.Cancel();
upgradePanel.Cancel();
gridField.CancelSelect();
}
function CellHitTest(cellRow, cellCol, t) {
var _local3;
var _local4 = 0;
if (gold >= t.cost) {
var _local5 = 0;
while (_local5 < t.size) {
var _local2 = 0;
while (_local2 < t.size) {
_local3 = cells[cellRow + _local5][cellCol + _local2];
if (_local3.cost == 0) {
_local4 = 2;
break;
}
if (_local3.creepCount > 0) {
_local4 = 3;
break;
}
if (_local3.barrier) {
_local4 = 4;
break;
}
_local2++;
}
if (_local4 > 0) {
break;
}
_local5++;
}
} else {
_local4 = 1;
}
return(_local4);
}
function DropTower(t, c) {
if (useComms) {
netComms.AddCommand(fcount, fcount + 24, ((("AT" + t.towerType) + t.level) + PadNumber(c.row, 2)) + PadNumber(c.col, 2));
infoPanel.Cancel();
gridField.StopFollowTower();
AdjustGold(-t.cost);
if (shiftDown) {
AddTower(t.towerType, true);
}
} else {
gridField.HighlightCell();
if ((gridField.hitTest == 0) && (gameState < 2)) {
PlaceTower(t, c);
}
}
}
function PlaceTowerFromComms(cmd) {
var _local9 = int(cmd.substr(0, 1));
var _local10 = int(cmd.substr(1, 1));
var _local7 = int(cmd.substr(2, 2));
var _local8 = int(cmd.substr(4, 2));
var _local5 = cells[_local7][_local8];
var _local3 = towerField.getNextHighestDepth();
var _local6;
var _local2 = towers[_local9][_local10];
if (_local3 == 0) {
_local3 = 1;
}
towerField.attachMovie("Tower", "tower" + _local3, _local3, {id:_local3, creeps:creeps, level:_local2.level, towerName:_local2.towerName, desc:_local2.desc, cost:int(_local2.cost), towerType:_local2.towerType, hitRate:_local2.hitRate, range:_local2.range, damage:_local2.damage, splash:_local2.splash, slow:_local2.slow, rotating:_local2.rotating, dragged:false});
_local6 = towerField["tower" + _local3];
PlaceTower(_local6, _local5);
}
function PlaceTower(t, c) {
var _local8 = [];
var _local4;
var _local13 = false;
var _local12 = false;
var _local14;
var _local6 = 0;
while (_local6 < t.size) {
var _local3 = 0;
while (_local3 < t.size) {
_local4 = cells[c.row + _local6][c.col + _local3];
_local8.push(_local4);
_local4.tower = t;
_local4.cost = 0;
_local3++;
}
_local6++;
}
FilterCreeps();
var _local11 = GetTime();
var _local10 = MakeFloodPath(true);
if (difficulty > 1) {
_local10 = _local10 && (MakeFloodPath(false));
}
if (!_local10) {
var _local7 = 0;
while (_local7 < _local8.length) {
_local8[_local7].cost = 1;
_local8[_local7].tower = undefined;
_local7++;
}
PlaySound("X.wav");
_root.Interface.blockingPopup.Show();
return(undefined);
}
trace("ms" + (GetTime() - _local11));
t.topLeftCell = c;
t._x = c.left + gridSize;
t._y = c.top + gridSize;
t._visible = true;
t.SetRotation();
ModifyTowerRangeBox(t, true);
AdjustGold(-t.cost);
PlaySound("scratch.wav");
infoPanel.Cancel();
gridField.StopFollowTower();
if (shiftDown) {
AddTower(t.towerType, true);
}
}
function BuildCreepPaths(LR) {
var _local2;
var _local3;
pathID++;
ClearPath(LR);
MakePath(LR);
var _local4 = 0;
while (_local4 < creepField.getNextHighestDepth()) {
_local2 = creepField["creep" + _local4];
if ((_local2 && (!_local2.flying)) && (!_local2.dead)) {
if (_local2.entering) {
_local3 = _local2.startCell;
} else {
_local3 = _local2.cCell;
}
if (_local3) {
if (((LR && (_local2.LR)) && (_local3.nextCellLR == undefined)) || (((!LR) && (!_local2.LR)) && (_local3.nextCellUD == undefined))) {
if (!MakePathFromCell(_local3, _local2.LR)) {
if (_local2.entering) {
_local2.flying = true;
_local2.forcedFly = true;
} else {
_local2.SetFlying();
_local2.forcedFly = true;
}
}
}
}
}
_local4++;
}
}
function ClearPath(LR) {
var _local4 = 0;
while (_local4 < cellRows) {
var _local2 = 0;
while (_local2 < cellCols) {
var _local3 = cells[_local4][_local2];
_local3.ClearPath(LR);
_local2++;
}
_local4++;
}
}
function PlayButtonSound() {
PlaySound("CHANGEOP.WAV");
}
function PlaySound(wav) {
if (!muted) {
var _local2 = new Sound();
_local2.attachSound(wav);
_local2.start();
}
}
function AdjustGold(byVal) {
gold = gold + byVal;
topMenu.gold.text = gold;
infoPanel.CheckGold();
upgradePanel.CheckGold();
gridField.CheckGold();
cg = cg + byVal;
if ((isNaN(gold) || (gold == undefined)) || (cg < 0)) {
gameState = 3;
}
}
function AdjustScore(byVal) {
score = score + byVal;
if (levelBonus > 0) {
topMenu.score.text = (score + "+") + levelBonus;
} else {
topMenu.score.text = score;
}
}
function AddTower(type, drag) {
var _local3 = towerField.getNextHighestDepth();
var _local4;
var _local2 = towers[type][1];
CancelSelect();
if (_local3 == 0) {
_local3 = 1;
}
towerField.attachMovie("Tower", "tower" + _local3, _local3, {id:_local3, creeps:creeps, level:_local2.level, towerName:_local2.towerName, desc:_local2.desc, cost:int(_local2.cost), towerType:_local2.towerType, hitRate:_local2.hitRate, range:_local2.range, damage:_local2.damage, splash:_local2.splash, slow:_local2.slow, bash:_local2.bash, rotating:_local2.rotating, dragged:drag});
_local4 = towerField["tower" + _local3];
if (drag) {
gridField.FollowTower(_local4);
}
infoPanel.SetTower(_local4);
}
function MakePathFromCell(c, LR) {
var _local2;
if (LR) {
_local2 = pathFinder.FindPath(cells, c.row, c.col, midRow, cellCols - 1);
if (_local2 == undefined) {
return(false);
}
StorePath(_local2, true, false);
return(true);
}
_local2 = pathFinder.FindPath(cells, c.row, c.col, cellRows - 1, midCol);
if (_local2 == undefined) {
return(false);
}
StorePath(_local2, false, false);
return(true);
}
function CheckPath(LR) {
var _local2;
if (LR) {
_local2 = pathFinder.FindPath(cells, midRow, 0, midRow, cellCols - 1);
} else {
_local2 = pathFinder.FindPath(cells, 0, midCol, cellRows - 1, midCol);
}
return(_local2 != undefined);
}
function MakePath(LR, force) {
var _local2;
pathID++;
if (LR) {
_local2 = pathFinder.FindPath(cells, midRow, 0, midRow, cellCols - 1);
} else {
_local2 = pathFinder.FindPath(cells, 0, midCol, cellRows - 1, midCol);
}
if (_local2 != undefined) {
StorePath(_local2, LR, force);
return(true);
}
return(false);
}
function SendGame() {
var _local5 = endTime - startTime;
if (gameSent) {
return(undefined);
}
if ((_local5 < 20) || (level < 3)) {
return(undefined);
}
var _local3 = new LoadVars();
_local3.onLoad = function (success) {
if (success) {
trace("ok sent");
} else {
trace("Error not sent");
}
};
var _local4 = GetMapString();
var _local2 = GetURLArgs(_local4, "");
trace("http://www.handdrawngames.com/DesktopTD/addgame.asp?" + _local2);
_local3.load("http://www.handdrawngames.com/DesktopTD/addgame.asp?" + _local2);
gameSent = true;
}
function SendScore(pn) {
var _local3 = GetMapString();
var _local2 = GetURLArgs(_local3, pn);
trace("TEST ADDSCORE");
getURL ("http://www.handdrawngames.com/DesktopTD/AddScore.asp?" + _local2, "_self");
trace("http://www.handdrawngames.com/DesktopTD/AddScore.asp?" + _local2);
}
function GetURLArgs(map, pn) {
var _local5 = endTime - startTime;
var _local3;
if (speedChal) {
_local3 = "210000";
} else if (infChal) {
_local3 = "310000";
} else if (mapMode == 1) {
_local3 = "410000";
} else if (mapMode == 2) {
_local3 = "420000";
} else if (onlySpawn) {
_local3 = "440000";
} else {
_local3 = (((("1" + int(NoPellet)) + int(NoSquirt)) + int(NoDart)) + int(NoSwarm)) + int(NoFrost);
}
var _local2 = (((((((((((("v=2&t=" + _local5) + "&d=") + difficulty) + "&s=") + score) + "&l=") + lives) + "&c=") + _local3) + "&cr=") + creepKills) + "&lv=") + level;
if (pn.length > 0) {
_local2 = (_local2 + "&n=") + escape(pn);
}
_local2 = (_local2 + "&m=") + map;
var _local4 = new md5();
var _local6 = _local4.hash((((_local2 + "p") + "s") + "p") + "2007");
_local2 = (_local2 + "&md5=") + _local6;
return(_local2);
}
function AddExplosion(type, posX, posY, dx, dy) {
var _local15 = 2;
var _local14 = 0;
var _local3 = 5;
var _local7 = 8;
var _local8;
switch (type) {
case 1 :
PlaySound("bop.wav");
break;
case 2 :
_local15 = 5;
_local3 = 8;
break;
case 3 :
dx = (-dx) * 2;
dy = (-dy) * 2;
_local15 = 4;
break;
default :
return(undefined);
}
_local3 = (Math.random() * _local3) + (_local3 / 2);
var _local2 = 0;
while (_local2 < _local15) {
var _local4 = {frame:type, ticks:_local7, _x:posX, _y:posY, xVel:(Math.random() * _local3) - (_local3 / 2), yVel:(Math.random() * _local3) - (_local3 / 2), dx:dx, dy:dy, rotate:_local14, deaccel:_local8};
effectsField.attachMovie("Fragment", "fragment" + (expLevel + _local2), expLevel + _local2, _local4);
_local2++;
}
expLevel = expLevel + _local15;
if (expLevel > 100) {
expLevel = 0;
}
}
function GetMapString() {
var _local9 = ((("v1:" + cellRows) + ":") + cellCols) + ":";
var _local4 = [];
var _local8 = 0;
while (_local8 < cellRows) {
var _local5 = 0;
while (_local5 < cellCols) {
var _local3 = cells[_local8][_local5];
if (_local3.tower) {
var _local6 = true;
var _local2 = 0;
while (_local2 < _local4.length) {
if ((_local4[_local2].topLeftCell.row == _local3.tower.topLeftCell.row) && (_local4[_local2].topLeftCell.col == _local3.tower.topLeftCell.col)) {
_local6 = false;
break;
}
_local2++;
}
if (_local6) {
_local4.push(_local3.tower);
}
}
_local5++;
}
_local8++;
}
_local8 = 0;
while (_local8 < _local4.length) {
var _local7 = _local4[_local8];
_local9 = _local9.concat(PadNumber(_local7.topLeftCell.row, 2), PadNumber(_local7.topLeftCell.col, 2), _local7.towerType, _local7.level);
_local8++;
}
return(_local9);
}
function PadNumber(num, chars) {
var _local2 = "" + num;
var _local1 = 0;
while (_local1 < (chars - _local2.length)) {
_local2 = "0" + _local2;
_local1++;
}
return(_local2);
}
function TraceCells() {
var _local5 = 0;
while (_local5 < cellRows) {
var _local3 = "";
var _local2 = 0;
while (_local2 < cellCols) {
var _local4 = cells[_local5][_local2];
_local3 = _local3.concat(_local4.cost);
_local2++;
}
trace(_local3);
_local5++;
}
}
function StorePath(path, LR, force) {
var _local7;
var _local6;
var _local9;
var _local8;
var _local12;
var _local2;
var _local4;
var _local3 = path.length - 1;
while (_local3 > 0) {
_local6 = path[_local3][0];
_local7 = path[_local3][1];
_local8 = path[_local3 - 1][0];
_local9 = path[_local3 - 1][1];
_local2 = cells[_local6][_local7];
_local4 = cells[_local8][_local9];
_local2.pathID = pathID;
if (LR) {
if (_local2.nextCellLR == undefined) {
_local2.nextCellLR = _local4;
_local4.parentCellsLR.push(_local2);
} else if (!force) {
break;
}
} else if (_local2.nextCellUD == undefined) {
_local2.nextCellUD = _local4;
_local4.parentCellsUD.push(_local2);
} else if (!force) {
break;
}
_local3--;
}
}
function AddKill(c) {
var _local3 = bountyField.getNextHighestDepth();
if (infoPanel.creep == c) {
CancelSelect();
}
AdjustGold(c.bounty);
AdjustScore(c.bounty);
if (c.bounty > 0) {
bountyField.attachMovie("Bounty", "bounty" + _local3, _local3, {_x:c._x, _y:c._y - 10, num:c.bounty});
}
PlaySound("SPLAT.WAV");
creepDied = true;
creepKills++;
}
function LoseALife(c) {
lives--;
topMenu.lives.text = lives;
if (infoPanel.creep == c) {
CancelSelect();
}
PlaySound("YIPPEE.WAV");
if (lives == 0) {
ShowFinish();
}
creepDied = true;
}
function SendNextLevel() {
if (gameState == 1) {
NextLevel(true);
} else if (gameState == 0) {
Start();
}
}
function NextLevel(early) {
if (finished && (creeps.length == 0)) {
ShowFinish();
return(undefined);
}
if (early && (!infChal)) {
levelBonus = levelBonus + (timeToLevel * 2);
AdjustScore(0);
}
if (speedChal) {
currentLevelTime = 15;
timeToLevel = currentLevelTime;
} else {
currentLevelTime = levelTime + int(level / 5);
timeToLevel = currentLevelTime;
}
if (timeToLevel > 50) {
timeToLevel = 50;
}
levelBar.SetLevel(level, timeToLevel, (infChal ? (level > 98) : (level > 48)));
level++;
currentWave = waves[level];
topMenu.level.text = level;
AddWave(currentWave);
if (level == (waves.length - 1)) {
btnNextLevel._visible = false;
finished = true;
topMenu.timeleft.text = "";
timeToLevel = 0;
}
}
function InitWaves() {
var _local5;
var _local3;
var _local15;
var _local18 = false;
var _local7 = 0;
var _local6 = 0;
var _local16 = 0;
var _local2;
switch (difficulty) {
case 1 :
_local5 = 1;
_local3 = 20;
_local15 = 2.2;
break;
case 2 :
case 5 :
_local5 = 1;
_local3 = 20;
_local15 = 2.2;
break;
case 3 :
_local5 = 1;
_local3 = 30;
_local15 = 2.2;
break;
case 4 :
_local5 = 1;
_local3 = 30;
_local15 = 2.1;
}
waves = new Array();
waves[0] = 1;
var _local17 = (infChal ? 100 : 50);
var _local4 = 0;
while (_local4 < _local17) {
if (_local4 == 48) {
_local2 = {count:1, bounty:_local5 * 20, size:200, health:_local3 * 12, speed:1, flying:true, immune:false, spawn:1, delay:20};
if (difficulty == 2) {
_local2.immune = false;
}
_local2.color = 11184640 /* 0xAAAA00 */;
_local2.level = _local4 + 1;
waves.push(_local2);
} else if (_local4 == 49) {
_local2 = {count:30, bounty:_local5, size:100, health:int(_local3 / 1.3), speed:1, flying:false, immune:true, spawn:1, delay:30};
if (difficulty == 2) {
_local2.immune = false;
}
_local2.color = 11141290 /* 0xAA00AA */;
_local2.level = _local4 + 1;
waves.push(_local2);
} else {
_local6++;
_local7++;
if (onlySpawn) {
_local2 = {count:4, bounty:_local5 * 20, size:130, health:_local3 * 3, speed:1, flying:false, immune:false, spawn:3, delay:20};
if (_local4 < 20) {
_local2.spawn = 2;
}
} else {
switch (_local6) {
case 1 :
_local2 = {count:10, bounty:_local5, size:100, health:_local3, speed:1, flying:false, immune:false, spawn:1, delay:20};
break;
case 2 :
_local2 = {count:10, bounty:_local5, size:100, health:_local3 * 1.33, speed:1, flying:false, spawn:1, delay:20};
break;
case 3 :
_local2 = {count:10, bounty:_local5, size:110, health:_local3 * 1.5, speed:1, flying:false, immune:false, spawn:1, delay:1};
break;
case 4 :
_local2 = {count:10, bounty:_local5, size:120, health:_local3 * 1.66, speed:1, flying:false, immune:true, spawn:1, delay:20};
break;
case 5 :
_local2 = {count:10, bounty:_local5, size:110, health:_local3 * 1.8, speed:(((difficulty < 3) && (_local4 == 3)) ? 1.25 : 1.5), flying:false, immune:false, spawn:1, delay:20};
break;
case 6 :
_local2 = {count:4, bounty:int(_local5 * 2.5), size:130, health:_local3 * 3, speed:1, flying:false, immune:false, spawn:((difficulty < 3) ? 2 : 3), delay:20};
break;
case 7 :
_local2 = {count:10, bounty:_local5, size:120, health:_local3 * 2, speed:1, flying:true, immune:false, spawn:1, delay:20};
}
}
_local2.level = _local4 + 1;
if ((difficulty == 1) && (_local4 < 8)) {
_local2.flying = false;
_local2.immune = false;
_local2.speed = 1;
_local2.delay = 25;
_local2.spawn = 1;
_local2.count = 10;
}
if (difficulty == 1) {
_local2.bounty = int(_local2.bounty * 1.5);
if (_local2.flying) {
_local2.health = _local2.health / 2;
}
if (_local2.spawn > 1) {
_local2.spawn = 2;
}
}
if (_local4 > 49) {
_local3 = _local3 * 1.09;
_local2.health = _local3;
}
if (_local6 == 7) {
if (_local4 < 50) {
_local3 = _local3 * _local15;
}
_local6 = 0;
_local5 = _local5 + 1;
}
_local2.color = 2236962 /* 0x222222 */;
if (_local2.immune) {
_local2.color = 11141290 /* 0xAA00AA */;
}
if (_local2.flying) {
_local2.color = 11184640 /* 0xAAAA00 */;
}
if (_local2.speed > 1) {
_local2.color = 11141120 /* 0xAA0000 */;
}
if (_local2.delay < 15) {
_local2.color = 21930;
}
if (_local2.spawn > 1) {
_local2.color = 21760;
if (_local4 == 6) {
_local2.spawn = 2;
}
}
if (_local7 == 8) {
if (!onlySpawn) {
if (_local2.speed > 1.25) {
_local2.speed = 1.25;
} else {
_local2.speed = 0.8;
}
if (_local2.delay < 15) {
_local2.count = 3;
_local2.bounty = _local5 * 6;
_local2.health = _local2.health * 5;
_local2.speed = 1;
} else if (_local2.spawn == 1) {
_local2.count = 1;
_local2.bounty = _local5 * 20;
_local2.health = _local2.health * 12;
} else {
_local2.count = 1;
_local2.bounty = _local5 * 20;
_local2.health = _local2.health * 12;
}
_local2.size = 150;
}
_local7 = 0;
}
_local2.health = int(_local2.health);
_local16 = _local16 + (_local2.count * _local2.bounty);
waves.push(_local2);
}
trace((((((_local2.level + " ") + _local2.count) + " ") + _local2.health) + " ") + _local2.bounty);
_local4++;
}
trace(_local16 * 2);
cg = _local16 * 2;
}
function InitTowers() {
towers = [];
towers[1] = [];
towers[1][1] = {level:1, towerName:"Pellet Tower", towerType:1, cost:"5", hitRate:48, range:60, damage:10, splash:0, slow:0, bash:0, rotating:true, desc:"Cheap tower that fires pellets."};
towers[1][2] = {level:2, towerName:"Pellet Tower 2", towerType:1, cost:"10", hitRate:48, range:60, damage:20, splash:0, slow:0, bash:0, rotating:true, desc:"Adds more damage."};
towers[1][3] = {level:3, towerName:"Pellet Tower 3", towerType:1, cost:"20", hitRate:48, range:60, damage:40, splash:0, slow:0, bash:0, rotating:true, desc:"Adds more damage."};
towers[1][4] = {level:4, towerName:"Pellet Tower 4", towerType:1, cost:"40", hitRate:48, range:60, damage:80, splash:0, slow:0, bash:0, rotating:true, desc:"Adds more damage."};
towers[1][5] = {level:5, towerName:"Pellet Tower 5", towerType:1, cost:"80", hitRate:48, range:60, damage:160, splash:0, slow:0, bash:0, rotating:true, desc:"Adds more damage."};
towers[1][6] = {level:6, towerName:"Sniper Tower", towerType:1, cost:"200", hitRate:64, range:180, damage:400, splash:0, slow:0, bash:0, rotating:true, desc:"Turns into a sniper tower. Final upgrade."};
towers[2] = [];
towers[2][1] = {level:1, towerName:"Dart Tower", towerType:2, cost:"20", hitRate:72, range:90, damage:8, splash:35, slow:0, bash:0, rotating:true, desc:"Slow firing tower that damages an area on the ground."};
towers[2][2] = {level:2, towerName:"Dart Tower 2", towerType:2, cost:"35", hitRate:72, range:100, damage:16, splash:40, slow:0, bash:0, rotating:true, desc:"Increases damage, splash and range."};
towers[2][3] = {level:3, towerName:"Dart Tower 3", towerType:2, cost:"70", hitRate:72, range:110, damage:32, splash:45, slow:0, bash:0, rotating:true, desc:"Increases damage, splash and range."};
towers[2][4] = {level:4, towerName:"Dart Tower 4", towerType:2, cost:"130", hitRate:72, range:120, damage:64, splash:55, slow:0, bash:0, rotating:true, desc:"Increases damage, splash and range."};
towers[2][5] = {level:5, towerName:"Dart Tower 5", towerType:2, cost:"240", hitRate:72, range:130, damage:128, splash:60, slow:0, bash:0, rotating:true, desc:"Increases damage, splash and range."};
towers[2][6] = {level:6, towerName:"ICBM Tower", towerType:2, cost:"400", hitRate:72, range:140, damage:256, splash:65, slow:0, bash:0, rotating:true, desc:"Increases damage, splash and range. Final upgrade."};
towers[3] = [];
towers[3][1] = {level:1, towerName:"Squirt Tower", towerType:3, cost:"15", hitRate:12, range:70, damage:5, splash:0, slow:0, bash:0, rotating:true, desc:"Quick firing tower that upgrades well."};
towers[3][2] = {level:2, towerName:"Squirt Tower 2", towerType:3, cost:"27", hitRate:12, range:70, damage:10, splash:0, slow:0, bash:0, rotating:true, desc:"Increases damage by +90%."};
towers[3][3] = {level:3, towerName:"Squirt Tower 3", towerType:3, cost:"50", hitRate:12, range:70, damage:18, splash:0, slow:0, bash:0, rotating:true, desc:"Increases damage by +90%."};
towers[3][4] = {level:4, towerName:"Squirt Tower 4", towerType:3, cost:"85", hitRate:12, range:70, damage:34, splash:0, slow:0, bash:0, rotating:true, desc:"Increases damage by +90%."};
towers[3][5] = {level:5, towerName:"Squirt Tower 5", towerType:3, cost:"160", hitRate:12, range:70, damage:65, splash:0, slow:0, bash:0, rotating:true, desc:"Increases damage by +90%."};
towers[3][6] = {level:6, towerName:"Typhoon Tower", towerType:3, cost:"450", hitRate:8, range:90, damage:320, splash:0, slow:0, bash:0, rotating:true, desc:"Increases range and damage by +400%. Final upgrade."};
towers[4] = [];
towers[4][1] = {level:1, towerName:"Swarm Tower", towerType:4, cost:"50", hitRate:18, range:60, damage:20, splash:0, slow:0, bash:0, rotating:false, desc:"Anti-air tower that fires 4 missiles at a time."};
towers[4][2] = {level:2, towerName:"Swarm Tower 2", towerType:4, cost:"80", hitRate:18, range:60, damage:40, splash:0, slow:0, bash:0, rotating:false, desc:"Increases damage."};
towers[4][3] = {level:3, towerName:"Swarm Tower 3", towerType:4, cost:"130", hitRate:18, range:65, damage:80, splash:5, slow:0, bash:0, rotating:false, desc:"Increases damage, range and adds splash."};
towers[4][4] = {level:4, towerName:"Swarm Tower 4", towerType:4, cost:"205", hitRate:18, range:65, damage:160, splash:10, slow:0, bash:0, rotating:false, desc:"Increases damage and splash."};
towers[4][5] = {level:5, towerName:"Swarm Tower 5", towerType:4, cost:"330", hitRate:18, range:70, damage:320, splash:15, slow:0, bash:0, rotating:false, desc:"Increases damage, splash and range."};
towers[4][6] = {level:6, towerName:"Storm Tower", towerType:4, cost:"640", hitRate:12, range:75, damage:480, splash:20, slow:0, bash:0, rotating:false, desc:"Increases damage, splash and range. Final upgrade."};
towers[5] = [];
towers[5][1] = {level:1, towerName:"Frost Tower", towerType:5, cost:"50", hitRate:48, range:50, damage:10, splash:35, slow:15, bash:0, rotating:true, desc:"This tower freezes creeps to slow them down."};
towers[5][2] = {level:2, towerName:"Frost Tower 2", towerType:5, cost:"75", hitRate:48, range:50, damage:15, splash:35, slow:20, bash:0, rotating:true, desc:"Increases splash and slow."};
towers[5][3] = {level:3, towerName:"Frost Tower 3", towerType:5, cost:"100", hitRate:48, range:50, damage:20, splash:40, slow:25, bash:0, rotating:true, desc:"Increases splash and slow."};
towers[5][4] = {level:4, towerName:"Frost Tower 4", towerType:5, cost:"125", hitRate:48, range:50, damage:25, splash:45, slow:30, bash:0, rotating:true, desc:"Increases splash and slow."};
towers[5][5] = {level:5, towerName:"Frost Tower 5", towerType:5, cost:"150", hitRate:48, range:50, damage:30, splash:50, slow:35, bash:0, rotating:true, desc:"Increases splash and slow."};
towers[5][6] = {level:6, towerName:"Blizzard Tower", towerType:5, cost:"200", hitRate:48, range:75, damage:40, splash:50, slow:40, bash:0, rotating:true, desc:"Increases splash, slow and range. Final upgrade."};
towers[6] = [];
towers[6][1] = {level:1, towerName:"Bash Tower", towerType:6, cost:"30", hitRate:52, range:40, damage:10, splash:40, slow:0, bash:4, rotating:false, desc:"Damages the ground around it, plus a chance to stun."};
towers[6][2] = {level:2, towerName:"Bash Tower 2", towerType:6, cost:"55", hitRate:52, range:40, damage:20, splash:40, slow:0, bash:7, rotating:false, desc:"7% stun, increases damage."};
towers[6][3] = {level:3, towerName:"Bash Tower 3", towerType:6, cost:"105", hitRate:52, range:40, damage:40, splash:40, slow:0, bash:10, rotating:false, desc:"10% stun, increases damage."};
towers[6][4] = {level:4, towerName:"Bash Tower 4", towerType:6, cost:"205", hitRate:52, range:40, damage:80, splash:40, slow:0, bash:13, rotating:false, desc:"13% stun, increases damage."};
towers[6][5] = {level:5, towerName:"Bash Tower 5", towerType:6, cost:"390", hitRate:52, range:40, damage:160, splash:40, slow:0, bash:15, rotating:false, desc:"15% stun, increases damage."};
towers[6][6] = {level:6, towerName:"Quake Tower", towerType:6, cost:"745", hitRate:44, range:40, damage:320, splash:40, slow:0, bash:20, rotating:false, desc:"20% stun, increases damage. Final upgrade."};
}
function FilterCreeps() {
var _local2 = 0;
while (_local2 < creeps.length) {
if (("" + creeps[_local2]) == "") {
creeps.splice(_local2, 1);
} else {
_local2++;
}
}
}
function AddSpawnCreeps(cr) {
if (cr.spawnLevel == cr.spawnMax) {
return(undefined);
}
var _local6 = creepField.getNextHighestDepth();
var _local14 = cr.LR;
var _local29 = 2;
var _local8 = cells[int((cr.nextY - startY) / gridSize)][int((cr.nextX - startX) / gridSize)];
var _local9 = int(cr.startHealth / _local29);
var _local7 = [];
var _local5 = _local8.row - 2;
while (_local5 < (_local8.row + 3)) {
var _local3 = _local8.col - 2;
while (_local3 < (_local8.col + 3)) {
if ((((_local5 > 0) && (_local5 < cellRows)) && (_local3 > 0)) && (_local3 < cellCols)) {
var _local4 = cells[_local5][_local3];
if (_local14) {
if (_local4.moveCostLR > 0) {
_local7.push(_local4);
}
} else if (_local4.moveCostUD > 0) {
_local7.push(_local4);
}
}
_local3++;
}
_local5++;
}
if (_local7.length == 0) {
_local7.push(cr.cCell);
}
var _local12 = 0;
while (_local12 < _local29) {
var _local11 = _local7[int(Math.random() * _local7.length)];
var _local10 = cr.endCell;
if (_local14) {
creeps.push(creepField.attachMovie("Creep", "creep" + _local6, _local6, {id:_local6, spawnMax:cr.spawnMax, spawnLevel:cr.spawnLevel + 1, startDelay:0, startCell:_local11, endCell:_local10, bounty:0, size:cr.size - 10, health:_local9, shotHealth:_local9, speed:cr.speed, immune:cr.immune, flying:cr.flying, color:cr.color, level:cr.level, LR:true}));
_local6++;
} else {
creeps.push(creepField.attachMovie("Creep", "creep" + _local6, _local6, {id:_local6, spawnMax:cr.spawnMax, spawnLevel:cr.spawnLevel + 1, startDelay:0, startCell:_local11, endCell:_local10, bounty:0, size:cr.size - 10, health:_local9, shotHealth:_local9, speed:cr.speed, immune:cr.immune, flying:cr.flying, color:cr.color, level:cr.level, LR:false}));
_local6++;
}
creeps[creeps.length - 1].DoExplode(cr._x, cr._y);
_local12++;
}
}
function AddWave(lvl) {
var _local3 = creepField.getNextHighestDepth();
creepCountLR = lvl.count;
if (difficulty > 1) {
creepCountUD = lvl.count;
} else {
creepCountUD = 0;
}
_local3 = (_local3 + creepCountLR) + creepCountUD;
FilterCreeps();
var _local4 = 0;
while (_local4 < lvl.count) {
var _local6;
var _local5;
var _local7 = openingStartRow + int(Math.random() * ((openingEndRow - openingStartRow) + 1));
_local6 = cells[_local7][0];
_local5 = cells[_local7][cellCols - 1];
creeps.push(creepField.attachMovie("Creep", "creep" + _local3, _local3, {id:creepCount, startDelay:_local4 * lvl.delay, startCell:_local6, endCell:_local5, bounty:lvl.bounty, size:lvl.size, health:lvl.health, shotHealth:lvl.health, speed:lvl.speed, immune:lvl.immune, flying:lvl.flying, color:lvl.color, level:lvl.level, spawnMax:lvl.spawn, spawnLevel:1, LR:true}));
_local3--;
creepCount++;
if (difficulty > 1) {
var _local8 = openingStartCol + int(Math.random() * ((openingEndCol - openingStartCol) + 1));
_local6 = cells[0][_local8];
_local5 = cells[cellRows - 1][_local8];
creeps.push(creepField.attachMovie("Creep", "creep" + _local3, _local3, {id:creepCount, startDelay:_local4 * lvl.delay, startCell:_local6, endCell:_local5, bounty:lvl.bounty, size:lvl.size, health:lvl.health, shotHealth:lvl.health, speed:lvl.speed, immune:lvl.immune, flying:lvl.flying, color:lvl.color, level:lvl.level, spawnMax:lvl.spawn, spawnLevel:1, LR:false}));
_local3--;
creepCount++;
}
_local4++;
}
newLevelTick = ((lvl.count < 3) ? 2 : 5);
}
function InitMap() {
CreateCellArray();
}
function SetMap(numAcross, numHigh, posX, posY, gridPixels, openingSR, openingER, openingSC, openingEC) {
startX = posX;
endX = startX + (numAcross * gridPixels);
startY = posY;
endY = startY + (numHigh * gridPixels);
gridSize = gridPixels;
cellCols = numAcross;
cellRows = numHigh;
openingStartRow = openingSR;
openingStartCol = openingSC;
openingEndRow = openingER;
openingEndCol = openingEC;
midRow = int(cellRows / 2);
midCol = int(cellCols / 2);
gridField.Init();
}
function CreateCellArray() {
cells = new Array(cellRows - 1);
var _local4 = 0;
while (_local4 < cellRows) {
cells[_local4] = new Array(cellCols - 1);
var _local2 = 0;
while (_local2 < cellCols) {
var _local3 = new Cell();
_local3.row = _local4;
_local3.col = _local2;
_local3.top = (_local4 * gridSize) + startY;
_local3.left = (_local2 * gridSize) + startX;
if ((((_local4 == 0) || (_local4 == (cellRows - 1))) || (_local2 == 0)) || (_local2 == (cellCols - 1))) {
_local3.cost = 0;
_local3.barrier = true;
} else {
_local3.cost = 1;
}
cells[_local4][_local2] = _local3;
_local2++;
}
_local4++;
}
endCellsLR = [];
endCellsUD = [];
_local4 = openingStartRow;
while (_local4 <= openingEndRow) {
cells[_local4][0].cost = 1;
cells[_local4][cellCols - 1].cost = 1;
endCellsLR.push(cells[_local4][cellCols - 1]);
_local4++;
}
if (difficulty > 1) {
_local4 = openingStartCol;
while (_local4 <= openingEndCol) {
cells[0][_local4].cost = 1;
cells[cellRows - 1][_local4].cost = 1;
endCellsUD.push(cells[cellRows - 1][_local4]);
_local4++;
}
}
startCellLR = cells[midRow][0];
endCellLR = cells[midRow][cellCols - 1];
startCellUD = cells[0][midCol];
endCellUD = cells[cellRows - 1][midCol];
switch (mapMode) {
case 0 :
break;
case 1 :
_local4 = 2;
while (_local4 < (cellRows - 2)) {
cells[_local4][midCol].cost = 0;
cells[_local4][midCol].barrier = true;
cells[_local4][midCol - 1].cost = 0;
cells[_local4][midCol - 1].barrier = true;
_local4++;
}
_local4 = 2;
while (_local4 < (cellCols - 2)) {
cells[midRow][_local4].cost = 0;
cells[midRow][_local4].barrier = true;
cells[midRow - 1][_local4].cost = 0;
cells[midRow - 1][_local4].barrier = true;
_local4++;
}
break;
case 2 :
var _local6 = 3;
for(;;){
if (_local6 >= (cellCols - 5)) {
break;
}
var _local5 = 4;
while (_local5 < cellCols) {
_local4 = 0;
while (_local4 < 3) {
var _local2 = 0;
while (_local2 < 4) {
cells[_local6 + _local4][_local5 + _local2].barrier = true;
cells[_local6 + _local4][_local5 + _local2].cost = 0;
_local2++;
}
_local4++;
}
_local5 = _local5 + 8;
}
_local6 = _local6 + 5;
};
}
gridField.DrawGrid();
}
function ClearTowers() {
var _local3;
var _local4 = 0;
while (_local4 < cellRows) {
var _local2 = 0;
while (_local2 < cellCols) {
_local3 = cells[_local4][_local2];
if (_local3.tower) {
removeMovieClip(_local3.tower);
}
_local3.rangeTowers = [];
_local2++;
}
_local4++;
}
}
function ClearCreeps() {
var _local2 = 0;
while (_local2 < creepField.getNextHighestDepth()) {
removeMovieClip(creepField["creep" + _local2]);
_local2++;
}
creeps = [];
}
function ClearEffects() {
var _local2 = 0;
while (_local2 < effectsField.getNextHighestDepth()) {
removeMovieClip(effectsField["bounty" + _local2]);
removeMovieClip(effectsField["fragment" + _local2]);
_local2++;
}
}
function ClearShots() {
var _local2 = 0;
while (_local2 < shotField.getNextHighestDepth()) {
removeMovieClip(shotField["shot" + _local2]);
_local2++;
}
_local2 = 0;
while (_local2 < groundField.getNextHighestDepth()) {
removeMovieClip(groundField["shot" + _local2]);
_local2++;
}
}
function Chk() {
var _local2 = new LocalConnection();
var _local1 = _local2.domain();
if (_local1.indexOf("handdrawngames.com", 0) > 0) {
return(true);
}
return(false);
}
}
Symbol 234 MovieClip [__Packages.NetComms] Frame 0
class NetComms
{
var received, sndCmds, cmds, sendOK, loadOK, ID, connected, myRoomNum, smartFox, clientID, oppID, oppRID, llv, slv;
function NetComms () {
received = new Object();
sndCmds = [];
cmds = [];
sendOK = true;
loadOK = true;
ID = 0;
connected = false;
myRoomNum = Math.floor(Math.random() * 100000);
}
function Connect() {
smartFox = new it.gotoandplay.smartfoxserver.SmartFoxClient();
smartFox.onConnection = handleConnection;
smartFox.onLogin = handleOnLogin;
smartFox.onJoinRoom = handleJoinRoom;
smartFox.onRoundTripResponse = handleRoundTripResponse;
smartFox.onUserEnterRoom = handleUserEnterRoom;
smartFox.onUserVariablesUpdate = handleUserVariablesUpdate;
smartFox.connect("65.110.55.10", 9339);
}
function Login() {
smartFox.login("DesktopTD", "Player" + clientID, "");
}
function JoinRoom() {
smartFox.autoJoin();
}
function Ping() {
smartFox.roundTripBench();
}
function RequestGame() {
var _local2 = {roomNum:myRoomNum, request:true};
smartFox.setUserVariables(_local2);
}
function CreateMyRoom() {
var _local2 = new Object();
_local2.name = "GR" + myRoomNum;
_local2.maxUsers = 2;
smartFox.createRoom(_local2);
}
function StartGame(UserName) {
if (oppID != undefined) {
smartFox.sendPrivateMessage("START", oppID);
smartFox.joinRoom("GR" + oppRID);
} else {
trace("no other user");
}
}
function GetUserID() {
var _local9 = int(smartFox.getActiveRoom());
trace(_local9);
var _local8 = smartFox.getRoom(_local9);
trace(_local8.getName());
var _local5 = _local8.getUserList();
for (var _local7 in _local5) {
var _local2 = _local5[_local7];
var _local3 = _local2.getName();
var _local4 = _local2.getId();
trace((_local3 + ":") + _local4);
if (_local3 != smartFox.myUserName) {
var _local6 = _local2.variables;
return(_local4);
}
}
}
function CreateNewRoom() {
}
function handleConnection(success) {
if (success) {
trace("Connection succesfull!");
connected = true;
} else {
trace("Can't connect!");
connected = false;
}
}
function handleOnLogin(resObj) {
if (resObj.success) {
trace("Login");
} else {
trace("Login fail");
}
}
function handleJoinRoom(roomObj) {
trace("Joined room:" + roomObj.getName());
if (roomObj.getName() == "Waiting") {
_root.game.netComms.CreateMyRoom();
}
}
function handleUserEnterRoom(fromRoom, user) {
trace("UserEnter:" + user.getName());
}
function handleUserLeaveRoom(fromRoom, userID, userName) {
trace("UserLeave:" + userName);
}
function handleUserVariablesUpdate(user) {
var _local3 = user.getVariables();
trace(user.getName() + " UserVariables");
var _local5 = _local3.request;
var _local4 = _local3.roomNum;
if (_local5) {
trace("requested OK " + user.getId());
_root.game.mpPanel.btnACK._visible = true;
_root.game.mpPanel.btnACK.msg.text = user.getName();
_root.game.netComms.oppID = user.getId();
_root.game.netComms.oppRID = _local4;
}
}
function handleRoundTripResponse(trip) {
trace("Ping:" + trip);
}
function AutoJoin() {
smartFox.autoJoin();
}
function Reset() {
sndCmds = [];
cmds = [];
sendOK = true;
loadOK = true;
ID = 0;
}
function FrameTick(frame) {
var _local4 = 0;
while (_local4 < cmds.length) {
var _local3 = cmds[_local4];
if (_local3.expFrame == frame) {
if (_local3.ack) {
var _local6 = int(_local3.cmd.substr(0, 1));
var _local5 = _local3.cmd.substr(1, 2);
if (_local5 == "AT") {
_root.game.PlaceTowerFromComms(_local3.cmd.substr(3));
}
}
}
_local4++;
}
}
function AddCommand(frame, expFrame, cmd) {
var _local2 = {id:++ID, frame:frame, expFrame:expFrame, cmd:cmd, ack:false, sentFrame:0};
cmds.push(_local2);
trace("AC:" + _local2);
}
function ServerLoad(frame) {
if (loadOK) {
llv = new LoadVars();
llv.ref = this;
loadOK = false;
llv.onLoad = function (success) {
if (success) {
trace("load ok");
this.ref.DecodeLoad();
this.ref.loadOK = true;
} else {
trace("load fail");
this.ref.loadOK = true;
}
};
llv.load((("http://www.handdrawngames.com/desktoptd/ServerLoad.asp?cid=" + clientID) + "&frame=") + frame);
}
}
function ServerSend(frame) {
var _local3;
trace("Send");
if (sendOK) {
sndCmds = [];
var _local2 = 0;
while (_local2 < cmds.length) {
_local3 = cmds[_local2];
if ((!_local3.ack) && (_local3.sentFrame == 0)) {
sndCmds.push(_local3);
}
_local2++;
}
if (sndCmds.length > 0) {
SendCommands();
}
}
}
function SendCommands(frame) {
slv = new LoadVars();
slv.ref = this;
slv.frame = frame;
sendOK = false;
slv.onLoad = function (success) {
if (success) {
trace("send ok");
this.ref.DecodeSave();
this.ref.sendOK = true;
} else {
trace("send fail");
this.ref.sendOK = true;
}
};
var _local2 = CreateURLArguments();
trace("Send Args:" + _local2);
slv.load("http://www.handdrawngames.com/desktoptd/ServerSave.asp?" + _local2);
sendOK = false;
}
function DecodeSave() {
var _local2 = 0;
while (_local2 < sndCmds.length) {
var _local3 = sndCmds[_local2];
_local3.sentFrame = slv.frame;
_local2++;
}
}
function DecodeLoad() {
var _local4 = int(llv.id);
var _local5 = int(llv.cid);
if (_local5 == clientID) {
var _local2 = 0;
while (_local2 < cmds.length) {
var _local3 = cmds[_local2];
if (_local3.id == _local4) {
trace("ID ACK:" + _local4);
_local3.ack = true;
break;
}
_local2++;
}
}
}
function CreateURLArguments() {
var _local4 = "";
var _local3 = 0;
while (_local3 < sndCmds.length) {
var _local2 = sndCmds[_local3];
_local4 = _local4.concat((("cid=" + clientID) + "&id=") + _local2.id, "&frame=" + _local2.frame, "&expFrame=" + _local2.expFrame, "&cmd=" + _local2.cmd);
_local3++;
}
return(_local4);
}
}
Symbol 235 MovieClip [__Packages.it.gotoandplay.smartfoxserver.SmartFoxClient] Frame 0
class it.gotoandplay.smartfoxserver.SmartFoxClient extends XMLSocket
{
var objRef, os, roomList, activeRoomId, myUserId, myUserName, playerId, debug, isConnected, changingRoom, arrayTags, messageHandlers, onConnect, onData, onXML, onClose, t1, onConnectionLost, close;
function SmartFoxClient (objRef) {
super();
this.objRef = objRef;
os = it.gotoandplay.smartfoxserver.ObjectSerializer.getInstance();
roomList = new Object();
activeRoomId = null;
myUserId = null;
myUserName = "";
playerId = null;
debug = false;
isConnected = false;
changingRoom = false;
arrayTags = {userList:true, rmList:true, vars:true};
messageHandlers = new Object();
onConnect = connectionEstablished;
onData = gotData;
onXML = xmlReceived;
onClose = connectionClosed;
setupMessageHandlers();
}
function setupMessageHandlers() {
addMessageHandler("sys", handleSysMessages);
}
function addMessageHandler(handlerId, handlerMethod) {
if (messageHandlers[handlerId] == undefined) {
messageHandlers[handlerId] = new Object();
messageHandlers[handlerId].handleMessage = handlerMethod;
} else {
trace(("Warning: [" + handlerId) + "] handler could not be created. A handler with this name already exist!");
}
}
function handleSysMessages(xmlObj, scope) {
var _local14 = xmlObj.attributes.action;
var _local22 = xmlObj.attributes.r;
if (_local14 == "apiOK") {
scope.onConnection(true);
} else if (_local14 == "apiKO") {
scope.onConnection(false);
trace("--------------------------------------------------------");
trace(" WARNING! The API you are using are not compatible with ");
trace(" the SmartFoxServer you're trying to connect to");
trace("--------------------------------------------------------");
} else if (_local14 == "logOK") {
scope.myUserId = xmlObj.login.attributes.id;
scope.myUserName = xmlObj.login.attributes.n;
scope.onLogin({success:true, name:scope.myUserName, error:""});
scope.getRoomList();
} else if (_local14 == "logKO") {
var _local37 = xmlObj.login.attributes.e;
scope.onLogin({success:false, name:"", error:_local37});
} else if (_local14 == "rmList") {
var _local9 = xmlObj.rmList.rmList;
scope.roomList = new Array();
for (var _local5 in _local9) {
var _local7 = _local9[_local5].attributes.id;
var _local3 = _local9[_local5].attributes;
var _local6 = _local3.id;
var _local15 = _local9[_local5].n.value;
var _local16 = Number(_local3.max);
var _local40 = (_local3.temp ? true : false);
var _local35 = (_local3.game ? true : false);
var _local20 = (_local3.priv ? true : false);
var _local21 = Number(_local3.ucnt);
scope.roomList[_local7] = new it.gotoandplay.smartfoxserver.Room(_local6, _local15, _local16, _local40, _local35, _local20);
scope.roomList[_local7].userCount = _local21;
var _local2 = _local9[_local5].vars.vars;
var _local4 = 0;
while (_local4 < _local2.length) {
var _local18 = _local2[_local4].attributes.n;
var _local8 = _local2[_local4].attributes.t;
var _local17 = _local2[_local4].value;
if (_local8 == "b") {
var _local19 = Boolean;
} else if (_local8 == "n") {
var _local19 = Number;
} else if (_local8 == "s") {
var _local19 = String;
} else if (_local8 == "x") {
var _local19 = function (n) {
return(null);
};
}
scope.roomList[_local7].variables[_local18] = _local19(_local17);
_local4++;
}
}
scope.onRoomListUpdate(scope.roomList);
} else if (_local14 == "joinOK") {
var _local29 = xmlObj.userList.attributes.r;
var _local13 = xmlObj.userList.userList;
scope.activeRoomId = Number(_local29);
var _local24 = scope.roomList[_local29];
_local24.userList = new Object();
scope.playerId = xmlObj.pid.attributes.id;
var _local5 = 0;
while (_local5 < _local13.length) {
var _local15 = _local13[_local5].attributes.name;
var _local6 = _local13[_local5].attributes.id;
_local24.userList[_local6] = new it.gotoandplay.smartfoxserver.User(_local6, _local15);
var _local11 = _local13[_local5].vars.vars;
_local24.userList[_local6].variables = {};
var _local25 = _local24.userList[_local6].variables;
var _local4 = 0;
while (_local4 < _local11.length) {
var _local18 = _local11[_local4].attributes.n;
var _local8 = _local11[_local4].attributes.t;
var _local17 = _local11[_local4].value;
if (_local8 == "b") {
var _local19 = Boolean;
} else if (_local8 == "n") {
var _local19 = Number;
} else if (_local8 == "s") {
var _local19 = String;
} else if (_local8 == "x") {
var _local19 = function (n) {
return(null);
};
}
_local25[_local18] = _local19(_local17);
_local4++;
}
_local5++;
}
scope.changingRoom = false;
scope.onJoinRoom(scope.roomList[_local29]);
} else if (_local14 == "joinKO") {
scope.changingRoom = false;
var _local39 = xmlObj.error.attributes.msg;
scope.onJoinRoomError(_local39);
} else if (_local14 == "userEnterRoom") {
var _local44 = xmlObj.user.attributes.id;
var _local38 = xmlObj.user.attributes.name;
var _local24 = scope.roomList[_local22];
_local24.userList[_local44] = new it.gotoandplay.smartfoxserver.User(_local44, _local38);
var _local11 = xmlObj.user.vars.vars;
_local24.userList[_local44].variables = {};
var _local25 = _local24.userList[_local44].variables;
var _local4 = 0;
while (_local4 < _local11.length) {
var _local18 = _local11[_local4].attributes.n;
var _local8 = _local11[_local4].attributes.t;
var _local17 = _local11[_local4].value;
if (_local8 == "b") {
var _local19 = Boolean;
} else if (_local8 == "n") {
var _local19 = Number;
} else if (_local8 == "s") {
var _local19 = String;
} else if (_local8 == "x") {
var _local19 = function (n) {
return(null);
};
}
_local25[_local18] = _local19(_local17);
_local4++;
}
scope.onUserEnterRoom(_local22, _local24.userList[_local44]);
} else if (_local14 == "userGone") {
var _local44 = xmlObj.user.attributes.id;
var _local24 = scope.roomList[_local22];
var _local38 = _local24.userList[_local44].name;
delete _local24.userList[_local44];
scope.onUserLeaveRoom(_local22, _local44, _local38);
} else if (_local14 == "pubMsg") {
var _local44 = xmlObj.user.attributes.id;
var _local28 = xmlObj.txt.value;
_local28 = scope.os.decodeEntities(_local28.toString());
scope.onPublicMessage(_local28.toString(), scope.roomList[_local22].userList[_local44]);
} else if (_local14 == "prvMsg") {
var _local44 = xmlObj.user.attributes.id;
var _local28 = xmlObj.txt.value;
_local28 = scope.os.decodeEntities(_local28);
scope.onPrivateMessage(_local28.toString(), scope.roomList[_local22].userList[_local44]);
} else if (_local14 == "dataObj") {
var _local45 = xmlObj.user.attributes.id;
var _local32 = xmlObj.dataObj.value;
trace("XML: " + _local32);
var _local27 = scope.os.deserialize(_local32);
trace("GOT OBJECT : " + _local27);
scope.dumpObj(_local27);
scope.onObjectReceived(_local27, scope.roomList[_local22].userList[_local45]);
} else if (_local14 == "uVarsUpdate") {
var _local44 = xmlObj.user.attributes.id;
var _local12 = xmlObj.vars.vars;
var _local23 = scope.roomList[_local22].userList[_local44];
if (_local23.variables == undefined) {
_local23.variables = {};
}
var _local4 = 0;
while (_local4 < _local12.length) {
var _local18 = _local12[_local4].attributes.n;
var _local8 = _local12[_local4].attributes.t;
var _local17 = _local12[_local4].value;
if (_local8 == "b") {
var _local19 = Boolean;
} else if (_local8 == "n") {
var _local19 = Number;
} else if (_local8 == "s") {
var _local19 = String;
} else if (_local8 == "x") {
var _local19 = function (n) {
return(null);
};
}
_local23.variables[_local18] = _local19(_local17);
_local4++;
}
scope.onUserVariablesUpdate(_local23);
} else if (_local14 == "rVarsUpdate") {
var _local12 = xmlObj.vars.vars;
var _local24 = scope.roomList[_local22];
_local24.variables = new Object();
var _local4 = 0;
while (_local4 < _local12.length) {
var _local18 = _local12[_local4].attributes.n;
var _local8 = _local12[_local4].attributes.t;
var _local17 = _local12[_local4].value;
if (_local8 == "b") {
var _local19 = Boolean;
} else if (_local8 == "n") {
var _local19 = Number;
} else if (_local8 == "s") {
var _local19 = String;
} else if (_local8 == "x") {
var _local19 = function (n) {
return(null);
};
}
_local24.variables[_local18] = _local19(_local17);
_local4++;
}
scope.onRoomVariablesUpdate(_local24);
} else if (_local14 == "createRmKO") {
var _local37 = xmlObj.room.attributes.e;
scope.onCreateRoomError(_local37);
} else if (_local14 == "uCount") {
var _local41 = xmlObj.attributes.c;
var _local30 = scope.roomList[_local22];
_local30.userCount = Number(_local41);
scope.onUserCountChange(_local30);
} else if (_local14 == "roomAdd") {
var _local26 = xmlObj.rm.attributes;
var _local33 = _local26.id;
var _local42 = xmlObj.rm.name.value;
var _local46 = Number(_local26.max);
var _local40 = (_local26.temp ? true : false);
var _local35 = (_local26.game ? true : false);
var _local43 = (_local26.priv ? true : false);
var _local31 = new it.gotoandplay.smartfoxserver.Room(_local33, _local42, _local46, _local40, _local35, _local43);
scope.roomList[_local33] = _local31;
scope.onRoomAdded(_local31);
} else if (_local14 == "roomDel") {
var _local34 = xmlObj.rm.attributes.id;
var _local36 = scope.roomList[_local34];
delete scope.roomList[_local34];
scope.onRoomDeleted(_local36);
} else if (_local14 == "roundTripRes") {
scope.t2 = getTimer();
scope.onRoundTripResponse(scope.t2 - scope.t1);
}
}
function dumpObj(obj) {
if (debug) {
trace("------------------------------------------------");
trace("+ Object Dump +");
trace("------------------------------------------------");
trace("Obj TYPE:" + typeof(obj));
for (var _local3 in obj) {
trace((_local3 + " > ") + obj[_local3]);
}
} else {
trace("nodebug");
}
}
function login(zone, nick, pass) {
var _local3 = {t:"sys"};
var _local2 = ((((("<login z='" + zone) + "'><nick><![CDATA[") + nick) + "]]></nick><pword><![CDATA[") + pass) + "]]></pword></login>";
send(_local3, "login", 0, _local2);
}
function getRoomList() {
var _local2 = {t:"sys"};
send(_local2, "getRmList", (activeRoomId ? (activeRoomId) : "-1"), "");
}
function autoJoin() {
var _local2 = {t:"sys"};
send(_local2, "autoJoin", (activeRoomId ? (activeRoomId) : "-1"), "");
}
function joinRoom(newRoom, pword, dontLeave, oldRoom) {
var _local2 = null;
if (!changingRoom) {
if (typeof(newRoom) == "number") {
_local2 = newRoom;
} else {
for (var _local4 in roomList) {
if (roomList[_local4].name == newRoom) {
_local2 = roomList[_local4].id;
break;
}
}
}
if (_local2 != null) {
var _local8 = {t:"sys"};
var _local6 = (dontLeave ? "0" : "1");
var _local5;
if (oldRoom) {
_local5 = oldRoom;
} else {
_local5 = activeRoomId;
}
if (activeRoomId == null) {
_local6 = "0";
_local5 = -1;
}
var _local7 = ((((((("<room id='" + _local2) + "' pwd='") + pword) + "' leave='") + _local6) + "' old='") + _local5) + "' />";
send(_local8, "joinRoom", (activeRoomId ? (activeRoomId) : -1), _local7);
changingRoom = true;
} else {
trace("SmartFoxError: requested room to join does not exist!");
}
}
}
function sendPublicMessage(msg, roomId) {
if (roomId == undefined) {
roomId = activeRoomId;
}
var _local2 = {t:"sys"};
var _local3 = ("<txt><![CDATA[" + os.encodeEntities(msg)) + "]]></txt>";
send(_local2, "pubMsg", roomId, _local3);
}
function sendPrivateMessage(msg, userId, roomId) {
if (roomId == undefined) {
roomId = activeRoomId;
}
var _local2 = {t:"sys"};
var _local3 = ((("<txt rcp='" + userId) + "'><![CDATA[") + os.encodeEntities(msg)) + "]]></txt>";
send(_local2, "prvMsg", roomId, _local3);
}
function sendObject(obj, roomId) {
if (roomId == undefined) {
roomId = activeRoomId;
}
var _local2 = ("<![CDATA[" + os.serialize(obj)) + "]]>";
var _local3 = {t:"sys"};
send(_local3, "asObj", roomId, _local2);
}
function setUserVariables(varObj, roomId) {
if (roomId == undefined) {
roomId = activeRoomId;
}
var _local7 = {t:"sys"};
var _local5 = "<vars>";
for (var _local6 in varObj) {
var _local2 = varObj[_local6];
var _local3 = null;
if (typeof(_local2) == "boolean") {
_local3 = "b";
_local2 = (_local2 ? 1 : 0);
} else if (typeof(_local2) == "number") {
_local3 = "n";
} else if (typeof(_local2) == "string") {
_local3 = "s";
} else if (typeof(_local2) == "null") {
_local3 = "x";
}
if (_local3 != null) {
_local5 = _local5 + (((((("<var n='" + _local6) + "' t='") + _local3) + "'><![CDATA[") + _local2) + "]]></var>");
}
}
_local5 = _local5 + "</vars>";
send(_local7, "setUvars", roomId, _local5);
}
function createRoom(roomObj) {
var _local7 = activeRoomId;
var _local6 = {t:"sys"};
var _local8 = (roomObj.updatable ? 1 : 0);
var _local4 = (roomObj.isGame ? 1 : 0);
var _local5 = 1;
if (_local4 && (roomObj.exitCurrentRoom != undefined)) {
_local5 = (roomObj.exitCurrentRoom ? 1 : 0);
}
var _local2 = ((((("<room upd='" + _local8) + "' tmp='1' gam='") + _local4) + "' exit='") + _local5) + "'>";
_local2 = _local2 + (("<name><![CDATA[" + roomObj.name) + "]]></name>");
_local2 = _local2 + (("<pwd><![CDATA[" + roomObj.password) + "]]></pwd>");
_local2 = _local2 + (("<max>" + roomObj.maxUsers) + "</max>");
_local2 = _local2 + "<vars></vars>";
_local2 = _local2 + "</room>";
send(_local6, "createRoom", _local7, _local2);
}
function getRoom(roomId) {
if (typeof(roomId) == "number") {
return(roomList[roomId]);
}
if (typeof(roomId) == "string") {
for (var _local4 in roomList) {
var _local2 = roomList[_local4];
if (_local2.getName() == roomId) {
return(_local2);
}
}
}
}
function getActiveRoom() {
return(roomList[activeRoomId]);
}
function setRoomVariables(varObj, roomId) {
if (roomId == undefined) {
roomId = activeRoomId;
}
var _local11 = {t:"sys"};
var _local9 = "<vars>";
for (var _local10 in varObj) {
var _local4 = varObj[_local10];
var _local6 = _local4.name;
var _local2 = _local4.val;
var _local7 = (_local4.priv ? "1" : "0");
var _local5 = (_local4.persistent ? "1" : "0");
var _local3 = null;
if (typeof(_local2) == "boolean") {
_local3 = "b";
_local2 = (_local2 ? 1 : 0);
} else if (typeof(_local2) == "number") {
_local3 = "n";
} else if (typeof(_local2) == "string") {
_local3 = "s";
} else if (typeof(_local2) == "null") {
_local3 = "x";
}
if (_local3 != null) {
_local9 = _local9 + (((((((((("<var n='" + _local6) + "' t='") + _local3) + "' pr='") + _local7) + "' pe='") + _local5) + "'><![CDATA[") + _local2) + "]]></var>");
}
}
_local9 = _local9 + "</vars>";
send(_local11, "setRvars", roomId, _local9);
}
function roundTripBench() {
t1 = getTimer();
var _local2 = {t:"sys"};
send(_local2, "roundTrip", activeRoomId, "");
}
function send(header, action, fromRoom, message) {
var _local3 = makeHeader(header);
_local3 = _local3 + ((((((("<body action='" + action) + "' r='") + fromRoom) + "'>") + message) + "</body>") + closeHeader());
if (debug) {
trace(("[Sending]: " + _local3) + newline);
}
super.send(_local3);
}
function sendString(message) {
super.send(message);
}
function gotData(message) {
if (message.charAt(0) == "%") {
strReceived(message);
} else if (message.charAt(0) == "<") {
onXML(new XML(message));
}
}
function connectionEstablished() {
var _local3 = {t:"sys"};
var _local2 = ((("<ver v='" + majVersion.toString()) + minVersion.toString()) + subVersion.toString()) + "' />";
send(_local3, "verChk", 0, _local2);
}
function connectionClosed() {
onConnectionLost();
}
function connect(serverIp, serverPort) {
super.connect(serverIp, serverPort);
}
function disconnect() {
close();
onConnectionLost();
}
function xmlReceived(message) {
var _local2 = new Object();
message2Object(message.childNodes, _local2);
if (debug) {
trace("[Received]: " + message);
}
var _local3 = _local2.msg.attributes.t;
messageHandlers[_local3].handleMessage(_local2.msg.body, this, "xml");
}
function strReceived(message) {
var _local2 = message.substr(1, message.length - 2).split("%");
if (debug) {
trace(("[Received - Str]: " + message) + newline);
}
var _local4 = _local2[0];
messageHandlers[_local4].handleMessage(_local2.splice(1, _local2.length - 1), this, "str");
}
function message2Object(xmlNodes, parentObj) {
var _local8 = 0;
var _local7 = null;
while (_local8 < xmlNodes.length) {
var _local3 = xmlNodes[_local8];
var _local4 = _local3.nodeName;
var _local5 = _local3.nodeValue;
if (parentObj instanceof Array) {
_local7 = new Object();
parentObj.push(_local7);
_local7 = parentObj[parentObj.length - 1];
} else {
parentObj[_local4] = new Object();
_local7 = parentObj[_local4];
}
for (var _local11 in _local3.attributes) {
if (typeof(_local7.attributes) == "undefined") {
_local7.attributes = new Object();
}
var _local2 = _local3.attributes[_local11];
if (!isNaN(_local2)) {
_local2 = Number(_local2);
}
if (_local2.toLowerCase() == "true") {
_local2 = true;
} else if (_local2.toLowerCase() == "false") {
_local2 = false;
}
_local7.attributes[_local11] = _local2;
}
if (arrayTags[_local4]) {
_local7[_local4] = new Array();
_local7 = _local7[_local4];
}
if (_local3.hasChildNodes() && (_local3.firstChild.nodeValue == undefined)) {
var _local9 = _local3.childNodes;
message2Object(_local9, _local7);
} else {
_local5 = _local3.firstChild.nodeValue;
if (!isNaN(_local5)) {
_local5 = Number(_local5);
}
_local7.value = _local5;
}
_local8++;
}
}
function makeHeader(headerObj) {
var _local2 = "<msg";
for (var _local3 in headerObj) {
_local2 = _local2 + ((((" " + _local3) + "='") + headerObj[_local3]) + "'");
}
_local2 = _local2 + ">";
return(_local2);
}
function closeHeader() {
return("</msg>");
}
var majVersion = 0;
var minVersion = 8;
var subVersion = 0;
}
Symbol 236 MovieClip [__Packages.it.gotoandplay.smartfoxserver.ObjectSerializer] Frame 0
class it.gotoandplay.smartfoxserver.ObjectSerializer
{
static var __instance;
var tabs, xmlStr, debug, eof, ascTab, ascTabRev, hexTable;
function ObjectSerializer () {
init();
}
static function getInstance() {
if (__instance == null) {
__instance = new it.gotoandplay.smartfoxserver.ObjectSerializer();
}
return(__instance);
}
function init() {
tabs = "\t\t\t\t\t\t\t\t\t\t";
xmlStr = "";
debug = false;
eof = "";
ascTab = [];
ascTab[">"] = ">";
ascTab["<"] = "<";
ascTab["&"] = "&";
ascTab["'"] = "'";
ascTab["\""] = """;
ascTabRev = [];
ascTabRev[">"] = ">";
ascTabRev["<"] = "<";
ascTabRev["&"] = "&";
ascTabRev["'"] = "'";
ascTabRev["""] = "\"";
var _local2 = 127;
while (_local2 <= 255) {
ascTab[_local2] = ("&#x" + _local2.toString(16)) + ";";
ascTabRev[("&#x" + _local2.toString(16)) + ";"] = chr(_local2);
_local2++;
}
hexTable = new Array();
hexTable["0"] = 0;
hexTable["1"] = 1;
hexTable["2"] = 2;
hexTable["3"] = 3;
hexTable["4"] = 4;
hexTable["5"] = 5;
hexTable["6"] = 6;
hexTable["7"] = 7;
hexTable["8"] = 8;
hexTable["9"] = 9;
hexTable.A = 10;
hexTable.B = 11;
hexTable.C = 12;
hexTable.D = 13;
hexTable.E = 14;
hexTable.F = 15;
}
function serialize(obj) {
var _local2 = {};
_local2.xmlStr = "";
if (debug) {
eof = newline;
}
obj2xml(_local2, obj, 0, "");
return(_local2.xmlStr);
}
function obj2xml(envelope, obj, lev, objn) {
if (lev == 0) {
envelope.xmlStr = envelope.xmlStr + ("<dataObj>" + eof);
} else {
if (debug) {
envelope.xmlStr = envelope.xmlStr + tabs.substr(0, lev);
}
var _local8 = ((obj instanceof Array) ? "a" : "o");
envelope.xmlStr = envelope.xmlStr + ((((("<obj t='" + _local8) + "' o='") + objn) + "'>") + eof);
}
for (var _local7 in obj) {
var _local2 = typeof(obj[_local7]);
var _local3 = obj[_local7];
if ((((_local2 == "boolean") || (_local2 == "number")) || (_local2 == "string")) || (_local2 == "null")) {
if (_local2 == "boolean") {
_local3 = Number(_local3);
} else if (_local2 == "null") {
_local2 = "x";
_local3 = "";
} else if (_local2 == "string") {
_local3 = encodeEntities(_local3);
}
if (debug) {
envelope.xmlStr = envelope.xmlStr + tabs.substr(0, lev + 1);
}
envelope.xmlStr = envelope.xmlStr + ((((((("<var n='" + _local7) + "' t='") + _local2.substr(0, 1)) + "'>") + _local3) + "</var>") + eof);
} else if (_local2 == "object") {
obj2xml(envelope, _local3, lev + 1, _local7);
if (debug) {
envelope.xmlStr = envelope.xmlStr + tabs.substr(0, lev + 1);
}
envelope.xmlStr = envelope.xmlStr + ("</obj>" + eof);
}
}
if (lev == 0) {
envelope.xmlStr = envelope.xmlStr + ("</dataObj>" + eof);
}
}
function deserialize(xmlObj) {
var _local3 = new XML(xmlObj);
_local3.ignoreWhite = true;
var _local2 = new Object();
xml2obj(_local3, _local2);
return(_local2);
}
function xml2obj(xmlNode, currObj) {
var _local2 = 0;
var _local3 = xmlNode.firstChild;
while (_local3.childNodes[_local2]) {
if (_local3.childNodes[_local2].nodeName == "obj") {
var _local7 = _local3.childNodes[_local2].attributes.o;
var _local8 = _local3.childNodes[_local2].attributes.t;
if (_local8 == "a") {
currObj[_local7] = [];
} else if (_local8 == "o") {
currObj[_local7] = {};
}
xml2obj(new XML(_local3.childNodes[_local2]), currObj[_local7]);
} else {
var _local7 = _local3.childNodes[_local2].attributes.n;
var _local5 = _local3.childNodes[_local2].attributes.t;
var _local9 = _local3.childNodes[_local2].firstChild.nodeValue;
var _local4;
if (_local5 == "b") {
_local4 = Boolean;
} else if (_local5 == "n") {
_local4 = Number;
} else if (_local5 == "s") {
_local4 = String;
} else if (_local5 == "x") {
_local4 = function (n) {
return(null);
};
}
currObj[_local7] = _local4(_local9);
if (_local4 == String) {
currObj[_local7] = decodeEntities(currObj[_local7]);
}
}
_local2++;
}
}
function encodeEntities(st) {
var _local5 = "";
var _local4 = 0;
while (_local4 < st.length) {
var _local3 = st.charAt(_local4);
var _local2 = st.charCodeAt(_local4);
if (((_local2 == 9) || (_local2 == 10)) || (_local2 == 13)) {
_local5 = _local5 + _local3;
} else if ((_local2 >= 32) && (_local2 <= 126)) {
if (ascTab[_local3] != undefined) {
_local5 = _local5 + ascTab[_local3];
} else {
_local5 = _local5 + _local3;
}
} else if ((_local2 > 126) && (_local2 <= 255)) {
_local5 = _local5 + ascTab[_local2];
} else if (_local2 > 255) {
_local5 = _local5 + (("&#x" + _local2.toString(16)) + ";");
}
_local4++;
}
return(_local5);
}
function decodeEntities(st) {
var _local7;
var _local5;
var _local4;
var _local3;
var _local8;
var _local2 = 0;
_local7 = "";
while (_local2 < st.length) {
_local5 = st.charAt(_local2);
if (_local5 == "&") {
_local4 = _local5;
do {
_local2++;
_local3 = st.charAt(_local2);
_local4 = _local4 + _local3;
} while (_local3 != ";");
_local8 = ascTabRev[_local4];
if (_local8 != undefined) {
_local7 = _local7 + _local8;
} else {
_local7 = _local7 + String.fromCharCode(getCharCode(_local4));
}
} else {
_local7 = _local7 + _local5;
}
_local2++;
}
return(_local7);
}
function getCharCode(ent) {
var _local1 = ent.substr(3, ent.length);
_local1 = _local1.substr(0, _local1.length - 1);
return(Number("0x" + _local1));
}
}
Symbol 237 MovieClip [__Packages.it.gotoandplay.smartfoxserver.Room] Frame 0
class it.gotoandplay.smartfoxserver.Room
{
var id, name, maxUsers, temp, game, priv, updatable, description, userCount, userList, variables;
function Room (id, name, maxUsers, isTemp, isGame, isPrivate) {
this.id = id;
this.name = name;
this.maxUsers = maxUsers;
temp = isTemp;
game = isGame;
priv = isPrivate;
updatable = false;
description = "";
userCount = 0;
userList = new Object();
variables = new Array();
}
function getUserList() {
return(userList);
}
function getUser(userId) {
if (typeof(userId) == "number") {
return(userList[userId]);
}
if (typeof(userId) == "string") {
for (var _local4 in userList) {
var _local2 = userList[_local4];
if (_local2.getName() == userId) {
return(_local2);
}
}
}
}
function getVariable(varName) {
return(variables[varName]);
}
function getVariables() {
return(variables);
}
function getName() {
return(name);
}
function getId() {
return(id);
}
function isTemp() {
return(temp);
}
function isGame() {
return(game);
}
function isPrivate() {
return(priv);
}
function getUserCount() {
return(userCount);
}
function getMaxUsers() {
return(maxUsers);
}
}
Symbol 238 MovieClip [__Packages.it.gotoandplay.smartfoxserver.User] Frame 0
class it.gotoandplay.smartfoxserver.User
{
var id, name, variables;
function User (id, name) {
this.id = id;
this.name = name;
variables = new Object();
}
function getId() {
return(id);
}
function getName() {
return(name);
}
function getVariable(varName) {
return(variables[varName]);
}
function getVariables() {
return(variables);
}
}
Symbol 239 MovieClip [__Packages.PathFinder] Frame 0
class PathFinder
{
var mapH, mapW, mapStatus, openList;
function PathFinder () {
}
function FindPath(map, startY, startX, endY, endX) {
var _local17 = 10;
var _local14 = 14;
var _local16 = true;
var _local15 = false;
mapH = map.length;
mapW = map[0].length;
mapStatus = new Array();
var _local13 = 0;
while (_local13 < mapH) {
mapStatus[_local13] = new Array();
_local13++;
}
if (startY == undefined) {
return("ERROR: No starting point");
}
if (endY == undefined) {
return("ERROR: No ending point");
}
openList = new Array();
openSquare(startY, startX, undefined, 0);
while ((openList.length > 0) && (!isClosed(endY, endX))) {
_local13 = nearerSquare();
var _local9 = openList[_local13][0];
var _local10 = openList[_local13][1];
closeSquare(_local9, _local10);
var _local3 = _local9 + 1;
while (_local3 >= (_local9 - 1)) {
var _local2 = _local10 - 1;
while (_local2 <= (_local10 + 1)) {
if ((((((_local3 >= 0) && (_local3 < mapH)) && (_local2 >= 0)) && (_local2 < mapW)) && (!((_local3 == _local9) && (_local2 == _local10)))) && ((_local16 || (_local3 == _local9)) || (_local2 == _local10))) {
var _local4 = true;
if (((!_local15) && (_local3 != _local9)) && (_local2 != _local10)) {
if (map[_local3][_local10].cost == 0) {
_local4 = false;
} else if (map[_local9][_local2].cost == 0) {
_local4 = false;
}
}
if (_local4 && (map[_local3][_local2].cost != 0)) {
if (!isClosed(_local3, _local2)) {
var _local7;
if (mapStatus[_local9][_local10].movementCost == undefined) {
_local7 = 0;
} else {
_local7 = mapStatus[_local9][_local10].movementCost;
}
var _local5 = _local7 + ((((_local3 == _local9) || (_local2 == _local10)) ? (_local17) : (_local14)) * map[_local3][_local2].cost);
if (isOpen(_local3, _local2)) {
if (_local5 < mapStatus[_local3][_local2].movementCost) {
openSquare(_local3, _local2, [_local9, _local10], _local5, undefined, true);
}
} else {
var _local8 = (Math.abs(_local3 - endY) + Math.abs(_local2 - endX)) * 10;
openSquare(_local3, _local2, [_local9, _local10], _local5, _local8, false);
}
}
}
}
_local2++;
}
_local3--;
}
}
var _local23 = isClosed(endY, endX);
if (_local23) {
var _local20 = new Array();
var _local9 = endY;
var _local10 = endX;
while ((_local9 != startY) || (_local10 != startX)) {
_local20.push([_local9, _local10, mapStatus[_local9][_local10].movementCost]);
var _local18 = mapStatus[_local9][_local10].parent[0];
var _local19 = mapStatus[_local9][_local10].parent[1];
_local9 = _local18;
_local10 = _local19;
}
_local20.push([startY, startX]);
return(_local20);
}
return(undefined);
}
function isOpen(y, x) {
return(mapStatus[y][x].open);
}
function isClosed(y, x) {
return(mapStatus[y][x].closed);
}
function nearerSquare() {
var _local5 = 999999 /* 0x0F423F */;
var _local6 = 0;
var _local3;
var _local4;
var _local2 = openList.length;
while ((_local2--) > 0) {
_local4 = mapStatus[openList[_local2][0]][openList[_local2][1]];
_local3 = _local4.heuristic + _local4.movementCost;
if (_local3 <= _local5) {
_local5 = _local3;
_local6 = _local2;
}
}
return(_local6);
}
function closeSquare(y, x) {
var _local3 = openList.length;
var _local2 = 0;
while (_local2 < _local3) {
if (openList[_local2][0] == y) {
if (openList[_local2][1] == x) {
openList.splice(_local2, 1);
break;
}
}
_local2++;
}
mapStatus[y][x].open = false;
mapStatus[y][x].closed = true;
}
function openSquare(y, x, parent, movementCost, heuristic, replacing) {
if (!replacing) {
openList.push([y, x]);
mapStatus[y][x] = {heuristic:heuristic, open:true, closed:false};
}
mapStatus[y][x].parent = parent;
mapStatus[y][x].movementCost = movementCost;
}
}
Symbol 240 MovieClip [__Packages.md5] Frame 0
class md5
{
function md5 (b64pad, chrsz) {
if (b64pad != undefined) {
this.b64pad = b64pad;
}
if (((chrsz != undefined) && (chrsz == 8)) || (chrsz == 16)) {
this.chrsz = chrsz;
}
}
function hash(s) {
return(hex_md5(s));
}
function hex_md5(s) {
return(binl2hex(core_md5(str2binl(s), s.length * chrsz)));
}
function b64_md5(s) {
return(binl2b64(core_md5(str2binl(s), s.length * chrsz)));
}
function str_md5(s) {
return(binl2str(core_md5(str2binl(s), s.length * chrsz)));
}
function hex_hmac_md5(key, data) {
return(binl2hex(core_hmac_md5(key, data)));
}
function b64_hmac_md5(key, data) {
return(binl2b64(core_hmac_md5(key, data)));
}
function str_hmac_md5(key, data) {
return(binl2str(core_hmac_md5(key, data)));
}
function md5_cmn(q, a, b, x, s, t) {
return(safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b));
}
function md5_ff(a, b, c, d, x, s, t) {
return(md5_cmn((b & c) | ((~b) & d), a, b, x, s, t));
}
function md5_gg(a, b, c, d, x, s, t) {
return(md5_cmn((b & d) | (c & (~d)), a, b, x, s, t));
}
function md5_hh(a, b, c, d, x, s, t) {
return(md5_cmn((b ^ c) ^ d, a, b, x, s, t));
}
function md5_ii(a, b, c, d, x, s, t) {
return(md5_cmn(c ^ (b | (~d)), a, b, x, s, t));
}
function core_md5(x, len) {
x[len >> 5] = x[len >> 5] | (128 << (len % 32));
x[(((len + 64) >>> 9) << 4) + 14] = len;
var _local5 = 1732584193 /* 0x67452301 */;
var _local4 = -271733879;
var _local3 = -1732584194;
var _local2 = 271733878 /* 0x10325476 */;
var _local6 = 0;
while (_local6 < x.length) {
var _local11 = _local5;
var _local10 = _local4;
var _local9 = _local3;
var _local8 = _local2;
_local5 = md5_ff(_local5, _local4, _local3, _local2, x[_local6 + 0], 7, -680876936);
_local2 = md5_ff(_local2, _local5, _local4, _local3, x[_local6 + 1], 12, -389564586);
_local3 = md5_ff(_local3, _local2, _local5, _local4, x[_local6 + 2], 17, 606105819);
_local4 = md5_ff(_local4, _local3, _local2, _local5, x[_local6 + 3], 22, -1044525330);
_local5 = md5_ff(_local5, _local4, _local3, _local2, x[_local6 + 4], 7, -176418897);
_local2 = md5_ff(_local2, _local5, _local4, _local3, x[_local6 + 5], 12, 1200080426);
_local3 = md5_ff(_local3, _local2, _local5, _local4, x[_local6 + 6], 17, -1473231341);
_local4 = md5_ff(_local4, _local3, _local2, _local5, x[_local6 + 7], 22, -45705983);
_local5 = md5_ff(_local5, _local4, _local3, _local2, x[_local6 + 8], 7, 1770035416);
_local2 = md5_ff(_local2, _local5, _local4, _local3, x[_local6 + 9], 12, -1958414417);
_local3 = md5_ff(_local3, _local2, _local5, _local4, x[_local6 + 10], 17, -42063);
_local4 = md5_ff(_local4, _local3, _local2, _local5, x[_local6 + 11], 22, -1990404162);
_local5 = md5_ff(_local5, _local4, _local3, _local2, x[_local6 + 12], 7, 1804603682);
_local2 = md5_ff(_local2, _local5, _local4, _local3, x[_local6 + 13], 12, -40341101);
_local3 = md5_ff(_local3, _local2, _local5, _local4, x[_local6 + 14], 17, -1502002290);
_local4 = md5_ff(_local4, _local3, _local2, _local5, x[_local6 + 15], 22, 1236535329);
_local5 = md5_gg(_local5, _local4, _local3, _local2, x[_local6 + 1], 5, -165796510);
_local2 = md5_gg(_local2, _local5, _local4, _local3, x[_local6 + 6], 9, -1069501632);
_local3 = md5_gg(_local3, _local2, _local5, _local4, x[_local6 + 11], 14, 643717713);
_local4 = md5_gg(_local4, _local3, _local2, _local5, x[_local6 + 0], 20, -373897302);
_local5 = md5_gg(_local5, _local4, _local3, _local2, x[_local6 + 5], 5, -701558691);
_local2 = md5_gg(_local2, _local5, _local4, _local3, x[_local6 + 10], 9, 38016083);
_local3 = md5_gg(_local3, _local2, _local5, _local4, x[_local6 + 15], 14, -660478335);
_local4 = md5_gg(_local4, _local3, _local2, _local5, x[_local6 + 4], 20, -405537848);
_local5 = md5_gg(_local5, _local4, _local3, _local2, x[_local6 + 9], 5, 568446438);
_local2 = md5_gg(_local2, _local5, _local4, _local3, x[_local6 + 14], 9, -1019803690);
_local3 = md5_gg(_local3, _local2, _local5, _local4, x[_local6 + 3], 14, -187363961);
_local4 = md5_gg(_local4, _local3, _local2, _local5, x[_local6 + 8], 20, 1163531501);
_local5 = md5_gg(_local5, _local4, _local3, _local2, x[_local6 + 13], 5, -1444681467);
_local2 = md5_gg(_local2, _local5, _local4, _local3, x[_local6 + 2], 9, -51403784);
_local3 = md5_gg(_local3, _local2, _local5, _local4, x[_local6 + 7], 14, 1735328473);
_local4 = md5_gg(_local4, _local3, _local2, _local5, x[_local6 + 12], 20, -1926607734);
_local5 = md5_hh(_local5, _local4, _local3, _local2, x[_local6 + 5], 4, -378558);
_local2 = md5_hh(_local2, _local5, _local4, _local3, x[_local6 + 8], 11, -2022574463);
_local3 = md5_hh(_local3, _local2, _local5, _local4, x[_local6 + 11], 16, 1839030562);
_local4 = md5_hh(_local4, _local3, _local2, _local5, x[_local6 + 14], 23, -35309556);
_local5 = md5_hh(_local5, _local4, _local3, _local2, x[_local6 + 1], 4, -1530992060);
_local2 = md5_hh(_local2, _local5, _local4, _local3, x[_local6 + 4], 11, 1272893353);
_local3 = md5_hh(_local3, _local2, _local5, _local4, x[_local6 + 7], 16, -155497632);
_local4 = md5_hh(_local4, _local3, _local2, _local5, x[_local6 + 10], 23, -1094730640);
_local5 = md5_hh(_local5, _local4, _local3, _local2, x[_local6 + 13], 4, 681279174);
_local2 = md5_hh(_local2, _local5, _local4, _local3, x[_local6 + 0], 11, -358537222);
_local3 = md5_hh(_local3, _local2, _local5, _local4, x[_local6 + 3], 16, -722521979);
_local4 = md5_hh(_local4, _local3, _local2, _local5, x[_local6 + 6], 23, 76029189);
_local5 = md5_hh(_local5, _local4, _local3, _local2, x[_local6 + 9], 4, -640364487);
_local2 = md5_hh(_local2, _local5, _local4, _local3, x[_local6 + 12], 11, -421815835);
_local3 = md5_hh(_local3, _local2, _local5, _local4, x[_local6 + 15], 16, 530742520);
_local4 = md5_hh(_local4, _local3, _local2, _local5, x[_local6 + 2], 23, -995338651);
_local5 = md5_ii(_local5, _local4, _local3, _local2, x[_local6 + 0], 6, -198630844);
_local2 = md5_ii(_local2, _local5, _local4, _local3, x[_local6 + 7], 10, 1126891415);
_local3 = md5_ii(_local3, _local2, _local5, _local4, x[_local6 + 14], 15, -1416354905);
_local4 = md5_ii(_local4, _local3, _local2, _local5, x[_local6 + 5], 21, -57434055);
_local5 = md5_ii(_local5, _local4, _local3, _local2, x[_local6 + 12], 6, 1700485571);
_local2 = md5_ii(_local2, _local5, _local4, _local3, x[_local6 + 3], 10, -1894986606);
_local3 = md5_ii(_local3, _local2, _local5, _local4, x[_local6 + 10], 15, -1051523);
_local4 = md5_ii(_local4, _local3, _local2, _local5, x[_local6 + 1], 21, -2054922799);
_local5 = md5_ii(_local5, _local4, _local3, _local2, x[_local6 + 8], 6, 1873313359);
_local2 = md5_ii(_local2, _local5, _local4, _local3, x[_local6 + 15], 10, -30611744);
_local3 = md5_ii(_local3, _local2, _local5, _local4, x[_local6 + 6], 15, -1560198380);
_local4 = md5_ii(_local4, _local3, _local2, _local5, x[_local6 + 13], 21, 1309151649);
_local5 = md5_ii(_local5, _local4, _local3, _local2, x[_local6 + 4], 6, -145523070);
_local2 = md5_ii(_local2, _local5, _local4, _local3, x[_local6 + 11], 10, -1120210379);
_local3 = md5_ii(_local3, _local2, _local5, _local4, x[_local6 + 2], 15, 718787259);
_local4 = md5_ii(_local4, _local3, _local2, _local5, x[_local6 + 9], 21, -343485551);
_local5 = safe_add(_local5, _local11);
_local4 = safe_add(_local4, _local10);
_local3 = safe_add(_local3, _local9);
_local2 = safe_add(_local2, _local8);
_local6 = _local6 + 16;
}
return(Array(_local5, _local4, _local3, _local2));
}
function core_hmac_md5(key, data) {
var _local3 = new Array(str2binl(key));
if (_local3.length > 16) {
_local3 = core_md5(_local3, key.length * chrsz);
}
var _local4 = new Array(16);
var _local5 = new Array(16);
var _local2 = 0;
while (_local2 < 16) {
_local4[_local2] = _local3[_local2] ^ 909522486;
_local5[_local2] = _local3[_local2] ^ 1549556828;
_local2++;
}
var _local6 = new Array(core_md5(_local4.concat(str2binl(data)), 512 + (data.length * chrsz)));
return(core_md5(_local5.concat(_local6), 640));
}
function safe_add(x, y) {
var _local1 = new Number((x & 65535) + (y & 65535));
var _local2 = new Number(((x >> 16) + (y >> 16)) + (_local1 >> 16));
return((_local2 << 16) | (_local1 & 65535));
}
function bit_rol(num, cnt) {
return((num << cnt) | (num >>> (32 - cnt)));
}
function str2binl(str) {
var _local4 = new Array();
var _local5 = (1 << chrsz) - 1;
var _local2 = 0;
while (_local2 < (str.length * chrsz)) {
_local4[_local2 >> 5] = _local4[_local2 >> 5] | ((str.charCodeAt(_local2 / chrsz) & _local5) << (_local2 % 32));
_local2 = _local2 + chrsz;
}
return(_local4);
}
function binl2str(bin) {
var _local4 = new String("");
var _local5 = (1 << chrsz) - 1;
var _local2 = 0;
while (_local2 < (bin.length * 32)) {
_local4 = _local4 + String.fromCharCode((bin[_local2 >> 5] >>> (_local2 % 32)) & _local5);
_local2 = _local2 + chrsz;
}
return(_local4);
}
function binl2hex(binarray) {
var _local3 = "0123456789abcdef";
var _local4 = new String("");
var _local1 = 0;
while (_local1 < (binarray.length * 4)) {
_local4 = _local4 + (_local3.charAt((binarray[_local1 >> 2] >> (((_local1 % 4) * 8) + 4)) & 15) + _local3.charAt((binarray[_local1 >> 2] >> ((_local1 % 4) * 8)) & 15));
_local1++;
}
return(_local4);
}
function binl2b64(binarray) {
var _local7 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var _local5 = new String("");
var _local3 = 0;
while (_local3 < (binarray.length * 4)) {
var _local6 = ((((binarray[_local3 >> 2] >> (8 * (_local3 % 4))) & 255) << 16) | (((binarray[(_local3 + 1) >> 2] >> (8 * ((_local3 + 1) % 4))) & 255) << 8)) | ((binarray[(_local3 + 2) >> 2] >> (8 * ((_local3 + 2) % 4))) & 255);
var _local2 = 0;
while (_local2 < 4) {
if (((_local3 * 8) + (_local2 * 6)) > (binarray.length * 32)) {
_local5 = _local5 + b64pad;
} else {
_local5 = _local5 + _local7.charAt((_local6 >> (6 * (3 - _local2))) & 63);
}
_local2++;
}
_local3 = _local3 + 3;
}
return(_local5);
}
var b64pad = new String("");
var chrsz = new Number(8);
}
Symbol 164 MovieClip Frame 1
_root.Interface.difficulty.difficulty;
Symbol 173 MovieClip Frame 1
function Show() {
fade = 0;
this.cacheAsBitmap = true;
this._visible = true;
this._alpha = fade;
this.onEnterFrame = function () {
fade = fade + 20;
this._alpha = fade;
if (fade >= 80) {
this.cacheAsBitmap = false;
this._alpha = 80;
clearInterval(intervalID);
intervalId = setInterval(this, "executeCallback", 1000);
this.onEnterFrame = "";
}
};
}
function Hide() {
fade = 80;
this.cacheAsBitmap = true;
this.onEnterFrame = function () {
fade = fade - 10;
this._alpha = fade;
if (fade <= 0) {
this.cacheAsBitmap = false;
this._visible = false;
this._alpha = 0;
this.onEnterFrame = "";
}
};
}
function executeCallback() {
clearInterval(intervalId);
Hide();
}
var intervalId = 0;
var fade;
Instance of Symbol 181 MovieClip "levelBarHighlight" in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
this.filters = [new flash.filters.GlowFilter(16750848, 0.8, 10, 10, 5, 3)];
}
Instance of Symbol 179 MovieClip "btnPellet" in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
this.gotoAndStop(1);
}
on (press) {
if (_root.game.gameState == -1) {
return(undefined);
}
if (_root.game.gameState < 2) {
_root.game.AddTower(1, true);
}
}
on (rollOver) {
_root.game.TowerButtonRollover(1, this);
}
on (rollOut) {
_root.game.infoPanel.CancelInfo();
this.filters = [];
}
Instance of Symbol 177 MovieClip "btnNextLevel" in Symbol 185 MovieClip Frame 1
on (press) {
_root.game.SendNextLevel();
}
Instance of Symbol 179 MovieClip "btnSquirt" in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
this.gotoAndStop(3);
}
on (press) {
if (_root.game.gameState == -1) {
return(undefined);
}
if (_root.game.gameState < 2) {
_root.game.AddTower(3, true);
}
}
on (rollOver) {
_root.game.TowerButtonRollover(3, this);
}
on (rollOut) {
_root.game.infoPanel.CancelInfo();
this.filters = [];
}
Instance of Symbol 179 MovieClip "btnDart" in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
this.gotoAndStop(2);
}
on (press) {
if (_root.game.gameState == -1) {
return(undefined);
}
if (_root.game.gameState < 2) {
_root.game.AddTower(2, true);
}
}
on (rollOver) {
_root.game.TowerButtonRollover(2, this);
}
on (rollOut) {
_root.game.infoPanel.CancelInfo();
this.filters = [];
}
Instance of Symbol 179 MovieClip "btnFrost" in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
this.gotoAndStop(5);
}
on (press) {
if (_root.game.gameState == -1) {
return(undefined);
}
if (_root.game.gameState < 2) {
_root.game.AddTower(5, true);
}
}
on (rollOver) {
_root.game.TowerButtonRollover(5, this);
}
on (rollOut) {
_root.game.infoPanel.CancelInfo();
this.filters = [];
}
Instance of Symbol 179 MovieClip "btnSwarm" in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
this.gotoAndStop(4);
}
on (press) {
if (_root.game.gameState == -1) {
return(undefined);
}
if (_root.game.gameState < 2) {
_root.game.AddTower(4, true);
}
}
on (rollOver) {
_root.game.TowerButtonRollover(4, this);
}
on (rollOut) {
_root.game.infoPanel.CancelInfo();
this.filters = [];
}
Instance of Symbol 39 MovieClip in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
msg.text = "MUTE";
}
on (press) {
if (msg.text == "MUTE") {
_root.game.muted = true;
msg.text = "UNMUTE";
} else {
_root.game.muted = false;
msg.text = "MUTE";
}
}
Instance of Symbol 39 MovieClip "btnGrid" in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
msg.text = "GRID";
}
on (press) {
_root.game.ToggleGrid();
}
Instance of Symbol 179 MovieClip "btnBash" in Symbol 185 MovieClip Frame 1
onClipEvent (load) {
this.gotoAndStop(6);
}
on (press) {
if (_root.game.gameState == -1) {
return(undefined);
}
if (_root.game.gameState < 2) {
_root.game.AddTower(6, true);
}
}
on (rollOver) {
_root.game.TowerButtonRollover(6, this);
}
on (rollOut) {
_root.game.infoPanel.CancelInfo();
this.filters = [];
}
Instance of Symbol 40 MovieClip [Top] "topMenu" in Symbol 185 MovieClip Frame 1
/* no clip actions */
Symbol 195 MovieClip Frame 1
function SetScore(num, diff, finished) {
btnCancel._visible = true;
if (diff == 5) {
if (finished) {
btnSubmit._visible = false;
desc.text = "You have beaten the fun mode! Well done :o)";
playerName._visible = false;
} else {
btnSubmit._visible = false;
desc.text = "You have failed to beat the fun mode! You didn't have enough fun.";
playerName._visible = false;
}
} else if (diff == 4) {
if (finished) {
btnSubmit._visible = true;
desc.text = "You have beaten the challenge! You may submit your score.";
playerName._visible = true;
Selection.setFocus("playerName");
} else {
btnSubmit._visible = false;
desc.text = "You have failed to beat the challenge! You must beat the challenge to submit a score.";
playerName._visible = false;
Selection.setFocus("playerName");
}
} else if ((num > 499) && (_root.game.difficulty > 1)) {
btnSubmit._visible = true;
desc.text = "You may submit your score by filling in your name and clicking submit.";
playerName._visible = true;
Selection.setFocus("playerName");
} else if (_root.game.difficulty == 1) {
btnSubmit._visible = false;
playerName._visible = false;
desc.text = "Play at a harder level to submit your scores. Click 'Reset' and try again!";
} else {
btnSubmit._visible = false;
playerName._visible = false;
desc.text = "You have lost.\rClick 'Reset' and try again!";
}
score.text = num;
_visible = true;
}
this.filters = [new flash.filters.GlowFilter(16750848, 0.8, 10, 10, 2, 3)];
Instance of Symbol 39 MovieClip "btnCancel" in Symbol 195 MovieClip Frame 1
onClipEvent (load) {
msg.text = "CLOSE";
}
on (press) {
_root.scoreBoard._visible = false;
_root.game.PlayButtonSound();
if (!_root.game.Chk()) {
getURL ("http://www.handdrawngames.com/DesktopTD", "_self");
}
}
Instance of Symbol 39 MovieClip "btnSubmit" in Symbol 195 MovieClip Frame 1
onClipEvent (load) {
msg.text = "SUBMIT";
}
on (press) {
_root.scoreBoard.btnSubmit._visible = false;
_root.scoreBoard.btnCancel._visible = false;
_root.game.PlayButtonSound();
_root.game.SendScore(this._parent.playerName.text);
}
Instance of Symbol 39 MovieClip in Symbol 205 MovieClip Frame 1
onClipEvent (load) {
msg.text = "EASY";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
_root.game.difficulty = 1;
_root.game.Init();
_root.startPanel.Fade();
_root.game.PlayButtonSound();
}
Instance of Symbol 39 MovieClip in Symbol 205 MovieClip Frame 1
onClipEvent (load) {
msg.text = "MEDIUM";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
_root.game.difficulty = 2;
_root.game.Init();
_root.startPanel.Fade();
_root.game.PlayButtonSound();
}
Instance of Symbol 39 MovieClip in Symbol 205 MovieClip Frame 1
onClipEvent (load) {
msg.text = "HARD";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
_root.game.difficulty = 3;
_root.game.Init();
_root.startPanel.Fade();
_root.game.PlayButtonSound();
}
Instance of Symbol 39 MovieClip in Symbol 205 MovieClip Frame 1
onClipEvent (load) {
msg.text = "CHALLENGE";
var format = msg.getTextFormat();
format.size = format.size - 2;
msg.setTextFormat(format);
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
_parent._visible = false;
_parent._parent.challengeSelect._visible = true;
_root.game.PlayButtonSound();
}
Instance of Symbol 39 MovieClip in Symbol 205 MovieClip Frame 1
onClipEvent (load) {
msg.text = "FUN";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
_parent._visible = false;
_parent._parent.funSelect._visible = true;
_root.game.PlayButtonSound();
}
Instance of Symbol 39 MovieClip in Symbol 212 MovieClip Frame 1
onClipEvent (load) {
msg.text = "BACK";
}
on (press) {
_parent._visible = false;
_parent._parent.levelSelect._visible = true;
_root.game.PlayButtonSound();
}
Instance of Symbol 39 MovieClip in Symbol 212 MovieClip Frame 1
onClipEvent (load) {
msg.text = "SPEED!";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
with (_root.game) {
difficulty = 4;
speedChal = true;
Init();
_root.startPanel.Fade();
PlayButtonSound();
}
}
Instance of Symbol 39 MovieClip in Symbol 212 MovieClip Frame 1
onClipEvent (load) {
msg.text = "NO DART";
var format = msg.getTextFormat();
format.size = format.size - 2;
msg.setTextFormat(format);
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
with (_root.game) {
difficulty = 4;
NoDart = true;
Init();
_root.startPanel.Fade();
PlayButtonSound();
}
}
Instance of Symbol 39 MovieClip in Symbol 212 MovieClip Frame 1
onClipEvent (load) {
msg.text = "NO SQUIRT";
var format = msg.getTextFormat();
format.size = format.size - 2;
msg.setTextFormat(format);
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
with (_root.game) {
difficulty = 4;
NoSquirt = true;
Init();
_root.startPanel.Fade();
PlayButtonSound();
}
}
Instance of Symbol 39 MovieClip in Symbol 212 MovieClip Frame 1
onClipEvent (load) {
msg.text = "THE 100";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
with (_root.game) {
difficulty = 4;
infChal = true;
Init();
_root.startPanel.Fade();
PlayButtonSound();
}
}
Instance of Symbol 39 MovieClip in Symbol 212 MovieClip Frame 1
onClipEvent (load) {
msg.text = "SQUIRTS";
var format = msg.getTextFormat();
format.size = format.size - 2;
msg.setTextFormat(format);
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
with (_root.game) {
difficulty = 4;
NoPellet = true;
NoDart = true;
NoSwarm = true;
NoBash = true;
Init();
_root.startPanel.Fade();
PlayButtonSound();
}
}
Instance of Symbol 39 MovieClip in Symbol 217 MovieClip Frame 1
onClipEvent (load) {
msg.text = "BACK";
}
on (press) {
_parent._visible = false;
_parent._parent.levelSelect._visible = true;
_root.game.PlayButtonSound();
}
Instance of Symbol 39 MovieClip in Symbol 217 MovieClip Frame 1
onClipEvent (load) {
msg.text = "CROSS";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
with (_root.game) {
difficulty = 5;
mapMode = 1;
Init();
_root.startPanel.Fade();
PlayButtonSound();
}
}
Instance of Symbol 39 MovieClip in Symbol 217 MovieClip Frame 1
onClipEvent (load) {
msg.text = "SPAWNS!";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
with (_root.game) {
difficulty = 5;
onlySpawn = true;
Init();
_root.startPanel.Fade();
PlayButtonSound();
}
}
Instance of Symbol 39 MovieClip in Symbol 217 MovieClip Frame 1
onClipEvent (load) {
msg.text = "Checkered";
}
on (press) {
if (_root.startPanel.fade > 0) {
return(undefined);
}
with (_root.game) {
difficulty = 5;
mapMode = 2;
Init();
_root.startPanel.Fade();
PlayButtonSound();
}
}
Symbol 218 MovieClip Frame 1
function Show() {
_visible = true;
challengeSelect._visible = false;
funSelect._visible = false;
levelSelect._visible = true;
}
function Fade() {
fade = 100;
this.cacheAsBitmap = true;
this.onEnterFrame = function () {
fade = fade - 10;
this._alpha = fade;
this.filters = [new flash.filters.BlurFilter((100 - fade) / 5, 0, 3)];
if (fade <= 0) {
this.filters = [new flash.filters.GlowFilter(16750848, 0.8, 10, 10, 2, 3)];
this.cacheAsBitmap = false;
this._visible = false;
this._alpha = 100;
this.onEnterFrame = "";
}
};
}
var fade;
this.filters = [new flash.filters.GlowFilter(16750848, 0.8, 10, 10, 2, 3)];
challengeSelect._visible = false;
funSelect._visible = false;
Instance of Symbol 39 MovieClip in Symbol 220 MovieClip Frame 1
onClipEvent (load) {
msg.text = "CONN";
}
on (press) {
_root.game.netComms.Connect();
}
Instance of Symbol 39 MovieClip in Symbol 220 MovieClip Frame 1
onClipEvent (load) {
msg.text = "LOGIN1";
}
on (press) {
_root.game.netComms.clientID = 1;
_root.game.netComms.Login();
}
Instance of Symbol 39 MovieClip in Symbol 220 MovieClip Frame 1
onClipEvent (load) {
msg.text = "JOIN";
}
on (press) {
_root.game.netComms.JoinRoom();
}
Instance of Symbol 39 MovieClip in Symbol 220 MovieClip Frame 1
onClipEvent (load) {
msg.text = "LOGIN2";
}
on (press) {
_root.game.netComms.clientID = 2;
_root.game.netComms.Login();
}
Instance of Symbol 39 MovieClip in Symbol 220 MovieClip Frame 1
onClipEvent (load) {
msg.text = "REQ";
}
on (press) {
_root.game.netComms.RequestGame();
}
Instance of Symbol 39 MovieClip in Symbol 220 MovieClip Frame 1
onClipEvent (load) {
msg.text = "PING";
}
on (press) {
_root.game.netComms.Ping();
}
Instance of Symbol 39 MovieClip "btnACK" in Symbol 220 MovieClip Frame 1
onClipEvent (load) {
msg.text = "ACK";
}
on (press) {
_root.game.netComms.StartGame();
}