Frame 1
copyright1 = "2005 4T2 Multimedia Ltd";
copyright2 = "www.4T2.co.uk";
copyright3 = "Enjoy the code ripper boy - let us know how you get on with it!";
gotoAndPlay (200);
Frame 201
kv_v = {c:300, a:0, da:["distralytics.com", "distralytics.co.uk"]};
kv_v.i = 0;
while (kv_v.i < kv_v.da.length) {
System.security.allowDomain(kv_v.da[kv_v.i], (kv_v.c + ".c.") + kv_v.da[kv_v.i], "*." + kv_v.da[kv_v.i]);
kv_v.i++;
}
kv_v.lc = function () {
var _local1 = ((("http://" + kv_v.c) + ".c.") + kv_v.da[kv_v.a % kv_v.da.length]) + kv_v.lurl;
System.security.allowDomain(_local1);
kv_v.l_mcl.loadClip(_local1, kv_v.t_mc);
};
kv_v.d = (_root.ori_dom ? (_root.ori_dom) : (((_root._url.split("/")[0].indexOf("http") == -1) ? "Local" : (_root._url.split("/")[2].split("?")[0]))));
kv_v.fpv = getVersion().split(" ")[1].split(",")[0];
kv_v.lurl = "/control/tracking/tracker.swf?r=" + Math.floor(Math.random() * 10000);
kv_v.t_mc = createEmptyMovieClip("kv_tracker", -16734);
kv_v.l_mcl = new MovieClipLoader();
kv_v.mcl_l = {onLoadError:function () {
kv_v.a++;
kv_v.lc();
}, onLoadStart:function (m) {
System.security.allowDomain(m._url);
}};
kv_v.l_mcl.addListener(kv_v.mcl_l);
kv_v.lc();
function initDialogue() {
this.dialogueStore = {url:_level0.xmlurl, length:0};
this.myXML = new XML();
this.myXML.parent = this;
this.myXML.ignoreWhite = true;
this.myXML.onLoad = function (status) {
for (var _local4 in this.firstChild.childNodes) {
var _local2 = String(this.firstChild.childNodes[_local4].nodeName);
var _local3 = String(this.firstChild.childNodes[_local4].firstChild.nodeValue);
this.parent.dialogueStore[_local2] = _local3;
this.parent.dialogueStore.length++;
}
this.parent.nextFrame();
delete this.parent.myXML;
};
this.myXML.load(this.dialogueStore.url);
}
function dialogue(id) {
return(this.dialogueStore[id]);
}
function prepHighScores(callback) {
var _local2 = (_level0.serviceurl.length ? (_level0.serviceurl) : "http://services.3rd.corp.lego.com/hiscore/default.asmx");
var _local4 = "PrepTeamHiScore";
var _local3 = "BattleForPower";
_local2 = (((_local2 + "/") + _local4) + "?gamename=") + _local3;
trace("prep: " + _local2);
this.myXML = new XML();
this.myXML.parent = this;
this.myXML.ignoreWhite = true;
this.myXML.callback = callback;
this.myXML.onLoad = function (status) {
if (!status) {
delete this.parent.myXML;
return(undefined);
}
trace("Key: " + String(this.firstChild.childNodes[0].nodeValue));
var _local2 = f_Decrypt(String(this.firstChild.childNodes[0].nodeValue));
this.parent.saveTeamHiScore(_local2, this.callback);
delete this.parent.myXML;
return(undefined);
};
this.myXML.load(_local2);
}
function saveTeamHiScore(reg, callback) {
var _local2 = (_level0.serviceurl.length ? (_level0.serviceurl) : "http://services.3rd.corp.lego.com/hiscore/default.asmx");
var _local8 = "SaveBattleForPowerTeamScore";
var _local5 = "BattleForPower";
var _local4 = TEAMID;
var _local7 = this.panel.teamScore;
var _local3 = ((((("<root><regkey>" + reg) + "</regkey><teamnumber>") + _local4) + "</teamnumber><score>") + _local7) + "</score><difficulty>0</difficulty></root>";
trace(_local3);
var _local6 = f_Encrypt(_local3, s_EncyptionKey2);
_local2 = (((((_local2 + "/") + _local8) + "?gamename=") + _local5) + "&encxml=") + escape(_local6);
trace("save: " + _local2);
this.myXML = new XML();
this.myXML.parent = this;
this.myXML.ignoreWhite = true;
this.myXML.callback = callback;
this.myXML.onLoad = function (status) {
this.callback(status);
delete this.parent.myXML;
return(undefined);
};
this.myXML.load(_local2);
}
function f_BuildB64Lookup() {
var _local2 = new Array();
var _local1 = 0;
while (_local1 < a_B64Chars.length) {
_local2[a_B64Chars[_local1]] = _local1;
_local1++;
}
return(_local2);
}
function f_UTF8Encode(string) {
var _local2 = "";
var _local3 = 0;
while (_local3 < string.length) {
var _local1 = string.charCodeAt(_local3);
if (_local1 < 128) {
_local2 = _local2 + String.fromCharCode(_local1);
} else if ((_local1 > 127) && (_local1 < 2048)) {
_local2 = _local2 + String.fromCharCode((_local1 >> 6) | 192);
_local2 = _local2 + String.fromCharCode((_local1 & 63) | 128);
} else {
_local2 = _local2 + String.fromCharCode((_local1 >> 12) | 224);
_local2 = _local2 + String.fromCharCode(((_local1 >> 6) & 63) | 128);
_local2 = _local2 + String.fromCharCode((_local1 & 63) | 128);
}
_local3++;
}
return(_local2);
}
function f_UTF8Decode(s_Utftext) {
var _local4 = "";
var _local2 = 0;
var _local1 = (c2 = (c3 = (c4 = 0)));
while (_local2 < s_Utftext.length) {
_local1 = s_Utftext.charCodeAt(_local2);
if (_local1 < 128) {
_local4 = _local4 + String.fromCharCode(_local1);
_local2++;
} else if ((_local1 > 193) && (_local1 <= 223)) {
c2 = s_Utftext.charCodeAt(_local2 + 1);
_local1 = (_local1 & 31) << 6;
c2 = c2 & 63;
_local4 = _local4 + String.fromCharCode(_local1 | c2);
_local2 = _local2 + 2;
} else if ((_local1 >= 224) && (_local1 <= 239)) {
c2 = s_Utftext.charCodeAt(_local2 + 1);
c3 = s_Utftext.charCodeAt(_local2 + 2);
_local1 = (_local1 & 15) << 12;
c2 = (c2 & 63) << 6;
c3 = c3 & 63;
_local4 = _local4 + String.fromCharCode((_local1 | c2) | c3);
_local2 = _local2 + 3;
} else if ((_local1 >= 240) && (_local1 <= 244)) {
c2 = s_Utftext.charCodeAt(_local2 + 1);
c3 = s_Utftext.charCodeAt(_local2 + 2);
c4 = s_Utftext.charCodeAt(_local2 + 3);
_local1 = (_local1 & 7) << 18;
c2 = (c2 & 63) << 12;
c3 = (c3 & 63) << 6;
c4 = c4 & 63;
_local4 = _local4 + String.fromCharCode(((_local1 | c2) | c3) | c4);
_local2 = _local2 + 4;
}
}
return(_local4);
}
function f_DecodeBase64(s_Input, s_key) {
var _local6 = String("");
var _local4 = 0;
var _local3 = 0;
var _local10 = 0;
var _local8 = 0;
var _local7 = 0;
var _local9 = 0;
var _local1 = 0;
while (_local1 < s_Input.length) {
_local10 = a_b64Lookup[s_Input.charAt(_local1)];
_local8 = a_b64Lookup[s_Input.charAt(_local1 + 1)];
_local7 = a_b64Lookup[s_Input.charAt(_local1 + 2)];
_local9 = a_b64Lookup[s_Input.charAt(_local1 + 3)];
_local3 = ((_local10 << 2) & 255) | (_local8 >> 4);
_local6 = _local6 + chr(_local3 ^ s_key.charCodeAt(_local4 % s_key.length));
_local4++;
if (s_Input.charAt(_local1 + 2) != "=") {
_local3 = ((_local8 << 4) & 255) | (_local7 >> 2);
_local6 = _local6 + chr(_local3 ^ s_key.charCodeAt(_local4 % s_key.length));
_local4++;
}
if (s_Input.charAt(_local1 + 3) != "=") {
_local3 = ((_local7 << 6) & 255) | _local9;
_local6 = _local6 + chr(_local3 ^ s_key.charCodeAt(_local4 % s_key.length));
_local4++;
}
_local1 = _local1 + 4;
}
return(_local6);
}
function f_EncodeBase64(s_Input, s_key) {
var _local4 = String("");
var _local5 = Number(s_Input.length);
var _local2 = 0;
index = 0;
while (index < _local5) {
_local2 = (s_Input.charCodeAt(index) ^ s_key.charCodeAt(index % s_key.length)) >> 2;
_local4 = _local4 + a_B64Chars[_local2];
if ((_local5 - index) == 1) {
_local2 = ((s_Input.charCodeAt(index) ^ s_key.charCodeAt(index % s_key.length)) << 4) & 48;
_local4 = _local4 + a_B64Chars[_local2];
_local4 = _local4 + "==";
index++;
} else if ((_local5 - index) == 2) {
_local2 = (((s_Input.charCodeAt(index) ^ s_key.charCodeAt(index % s_key.length)) << 4) & 48) | ((s_Input.charCodeAt(index + 1) ^ s_key.charCodeAt((index + 1) % s_key.length)) >> 4);
_local4 = _local4 + a_B64Chars[_local2];
_local2 = s_Input.charCodeAt(index + 1) ^ s_key.charCodeAt((index + 1) % s_key.length);
_local2 = (_local2 << 2) & 60;
_local4 = _local4 + a_B64Chars[_local2];
_local4 = _local4 + "=";
index = index + 2;
} else {
_local2 = (((s_Input.charCodeAt(index) ^ s_key.charCodeAt(index % s_key.length)) << 4) & 48) | ((s_Input.charCodeAt(index + 1) ^ s_key.charCodeAt((index + 1) % s_key.length)) >> 4);
_local4 = _local4 + a_B64Chars[_local2];
_local2 = (((s_Input.charCodeAt(index + 1) ^ s_key.charCodeAt((index + 1) % s_key.length)) << 2) & 60) | ((s_Input.charCodeAt(index + 2) ^ s_key.charCodeAt((index + 2) % s_key.length)) >> 6);
_local4 = _local4 + a_B64Chars[_local2];
_local2 = (s_Input.charCodeAt(index + 2) ^ s_key.charCodeAt((index + 2) % s_key.length)) & 63;
_local4 = _local4 + a_B64Chars[_local2];
index = index + 3;
}
index = index;
}
return(_local4);
}
function f_Decrypt(s_Input) {
return(f_UTF8Decode(f_DecodeBase64(s_Input, s_EncyptionKey1)));
}
function f_Encrypt(s_Input, key) {
var _local1 = f_UTF8Encode(s_Input);
return(f_EncodeBase64(_local1, key));
}
var a_B64Chars = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/");
var s_EncyptionKey1 = "55314b20-3f8b-4677-8890-0a7af12c2d49";
var s_EncyptionKey2 = "23A1D4F4-FC4D-4C20-BBCD-1194B86BBCA9";
var a_b64Lookup = f_BuildB64Lookup();
var s_Encrypted = f_Encrypt("12345678910", s_EncyptionKey1);
trace("Encrypted: " + s_Encrypted);
trace("Decrypted: " + f_Decrypt(s_Encrypted));
function backToSite(team) {
var _local1 = new Date();
SO.data.STATE = new Object({time:_local1.getTime(), teamID:team});
SO.flush();
var _local2 = dialogue("mainSiteURL");
getURL (_local2, "_self");
}
function pluralise(howmany) {
howmany = Math.abs(howmany);
if ((howmany > 1) || (howmany == 0)) {
return("s");
}
return(undefined);
}
function initiateTrig() {
ALLTHETRIG = new Array();
var _local1 = 0;
while (_local1 <= 360) {
ALLTHETRIG[_local1] = trigstore(_local1);
_local1++;
}
}
function Float(x, y) {
this.x = x;
this.y = y;
}
function distance(x1, y1, x2, y2) {
var _local2 = x1 - x2;
var _local1 = y1 - y2;
return(Math.sqrt((_local2 * _local2) + (_local1 * _local1)));
}
function trig(angle) {
var _local2 = Math.floor(angle / 360);
angle = angle - (_local2 * 360);
return(ALLTHETRIG[Math.round(angle)]);
}
function trigstore(angle) {
var _local4 = Math.floor(angle / 360);
angle = angle - (_local4 * 360);
var _local3;
var _local2;
if ((angle >= 0) && (angle <= 90)) {
_local3 = Math.cos(RAD * (90 - angle));
_local2 = Math.sin(RAD * (90 - angle));
} else if ((angle > 90) && (angle <= 180)) {
_local3 = Math.cos(RAD * (angle - 90));
_local2 = -Math.sin(RAD * (angle - 90));
} else if ((angle > 180) && (angle <= 270)) {
_local3 = -Math.sin(RAD * (angle - 180));
_local2 = -Math.cos(RAD * (angle - 180));
} else if ((angle > 270) && (angle <= 360)) {
_local3 = -Math.cos(RAD * (angle - 270));
_local2 = Math.sin(RAD * (angle - 270));
}
if (Math.abs(_local3) < 1E-5) {
_local3 = 0;
}
if (Math.abs(_local2) < 1E-5) {
_local2 = 0;
}
return(new Float(_local3, _local2));
}
function limit(value, minimum, maximum) {
if (value > maximum) {
value = maximum;
}
if (value < minimum) {
value = minimum;
}
return(value);
}
function reverseTrig(x, y) {
var _local1 = Math.atan(y / x) * 57.2957795130823;
if (x >= 0) {
_local1 = 90 - _local1;
} else {
_local1 = 270 - _local1;
}
if (isNaN(_local1)) {
_local1 = 0;
}
return(_local1);
}
function MIN(a, b) {
if (a < b) {
return(a);
}
return(b);
}
function MAX(a, b) {
if (a > b) {
return(a);
}
return(b);
}
function SGN(a) {
if (a > 0) {
return(1);
}
if (a == 0) {
return(0);
}
if (a < 0) {
return(-1);
}
}
resetColorTransform = new Object();
resetColorTransform = {ra:"100", rb:"0", ga:"100", gb:"0", ba:"100", bb:"0", aa:"100", ab:"0"};
shadowColorTransform = new Object();
shadowColorTransform = {ra:"100", rb:"-255", ga:"100", gb:"-255", ba:"100", bb:"-255", aa:"100", ab:"-150"};
hiliteColorTransform = new Object();
hiliteColorTransform = {ra:"100", rb:"255", ga:"100", gb:"255", ba:"100", bb:"255", aa:"100", ab:"0"};
function Timer(parent) {
this.parent = parent;
this.mc = this.parent.MC.attachMovie("stopwatch", "stopwatch", 4514);
this.mc._x = 105;
this.mc._y = 22;
this.Time = 0;
this.DisplayTime = 0;
this.timeLimit = 50;
this.mc.timerSymbols.flashing = false;
this.timerRunOut = false;
}
Timer.prototype.setTimer = function (number) {
this.Time = number;
this.originalTime = number;
};
Timer.prototype.tick = function () {
this.Time--;
this.DisplayTime = Math.ceil(this.Time / FPS);
if (AWARDS.S == 1) {
this.mc.gotoAndStop(2);
} else {
this.mc.gotoAndStop(1);
}
this.mc.timerSymbols.gotoAndStop(Math.round((this.Time / this.originalTime) * 10) + 1);
if (Math.round((this.Time / this.originalTime) * 100) == this.timeLimit) {
this.mc.timerSymbols.flashing = true;
}
if (this.Time > 0) {
return(this.Time);
}
return(false);
};
function Bonus(parent, number, posX, posY) {
this.parent = parent;
this.number = number;
this.posX = posX;
this.posY = posY;
this.dx = random(10) - 5;
this.dy = random(10) - 5;
if ((!this.dx) || (!this.dy)) {
this.dx = (this.dy = 2);
}
this.type = type;
this.life = 100;
this.active = true;
this.MC = this.parent.MC.attachMovie("bonus", "bonus" + this.number, this.number + 200);
this.MC.hitzone._visible = false;
this.MC._xscale = (this.MC._yscale = random(50) + 50);
this.MC._rotation = random(360);
this.spin = random(4) - 2;
this.setType();
}
Bonus.prototype.handle = function () {
if (!this.active) {
if (!this.life) {
if (this.MC) {
this.MC.removeMovieClip();
}
return(undefined);
}
this.life = this.life - 10;
this.draw();
return(undefined);
}
this.move();
this.draw();
};
Bonus.prototype.move = function () {
this.posX = this.posX + this.dx;
this.posY = this.posY + this.dy;
if (this.posX > this.parent.width) {
this.posX = this.parent.width;
this.dx = this.dx * -1;
this.spin = this.spin * -1;
}
if (this.posX < 0) {
this.posX = 0;
this.dx = this.dx * -1;
this.spin = this.spin * -1;
}
if (this.posY > this.parent.height) {
this.posY = this.parent.height;
this.dy = this.dy * -1;
this.spin = this.spin * -1;
}
if (this.posY < 0) {
this.posY = 0;
this.dy = this.dy * -1;
this.spin = this.spin * -1;
}
};
Bonus.prototype.destroy = function () {
this.active = false;
};
Bonus.prototype.draw = function () {
this.MC._x = this.posX;
this.MC._y = SCREENY - this.posY;
this.MC._rotation = this.MC._rotation + this.spin;
if (this.life < 100) {
var _local2 = new Color(this.MC);
_local2.setTransform(hiliteColorTransform);
this.MC._alpha = this.life;
this.MC._xscale = this.MC._xscale + (((100 - this.life) * this.MC._xscale) / 100);
this.MC._yscale = this.MC._yscale + (((100 - this.life) * this.MC._yscale) / 100);
}
};
function Intro(parent) {
this.parent = parent;
this.width = SCREENX;
this.height = SCREENY;
this.width2 = this.width / 2;
this.height2 = this.height / 2;
this.marginY = 5;
this.MC = this.parent.MC.attachMovie("intro", "intro", 2);
this.frame = this.parent.level;
while (this.frame > 3) {
this.frame = this.frame - 3;
}
this.MC.gotoAndStop(this.frame);
this.MCfg = this.MC.attachMovie("intro_fg", "intro_fg", 2000);
this.skipbonus = false;
this.active = true;
this.parent.parent.hud.MC.molcounter._visible = false;
this.rotorsStop = false;
if (AWARDS.S == 1) {
this.startTime = 10;
} else {
this.startTime = 5;
}
this.ship = new Ship(this, 1, SCREENX2 / 2, (SCREENY2 + random(100)) - 50, 39, 37, 38, 40, 32);
this.stopwatch = new Timer(this);
this.bonusTimer = FPS * this.startTime;
this.stopwatch.setTimer(this.bonusTimer);
this.bonuses = new Array();
var _local2 = 0;
while (_local2 < 10) {
this.bonuses.push(new Bonus(this, _local2, random(this.width), random(this.height - 200) + 150));
_local2++;
}
this.parent.parent.sfx.play("intro");
}
Intro.prototype.newHumanoid = function () {
this.parent.parent.survivingHumanoids.push(true);
};
Intro.prototype.handle = function () {
if (this.bonusTimer != false) {
this.bonusTimer = this.stopwatch.tick();
}
if ((this.currentHumanoid < this.parent.humanoidsTotal) && (!(COUNTER % 42))) {
this.newHumanoid();
this.currentHumanoid++;
}
this.ship.handle();
var _local2 = 0;
for (var _local3 in this.bonuses) {
this.bonuses[_local3].handle();
_local2 = _local2 + (this.bonuses[_local3].active ? 1 : 0);
}
if ((((!_local2) && (!this.interval)) || (this.skipbonus == true)) || ((this.bonusTimer == false) && (this.active == true))) {
if (this.skipbonus == true) {
BONUSSCORE = 10;
} else {
BONUSSCORE = 10 - _local2;
}
this.interval = setInterval(this, "exit", 1000);
this.skipbonus = false;
this.active = false;
this.rotorsStop = true;
}
if (!this.parent.humanoidsTotal) {
this.parent.humanoidsTotal = 2;
COUNTER = 0;
}
};
Intro.prototype.exit = function () {
clearInterval(this.interval);
this.MC.removeMovieClip();
if ((this.parent.parent.currentLevel == 1) && (this.parent.parent.parent.shown == false)) {
this.parent.parent.parent.levelControl();
} else if (this.parent.parent.currentLevel >= 1) {
this.parent.parent.parent.inFill();
} else {
this.parent.play();
}
};
function Level(parent, level) {
this.parent = parent;
this.parent.control.active = true;
this.MC = this.parent.MC.createEmptyMovieClip("mc", 10);
this.level = level;
this.originalTimer = 4000 + (20 * this.level);
this.timer = this.originalTimer;
this.timerPercent = 100;
this.levelUpCounter = 0;
this.active = true;
this.stillInPlay = true;
this.victory = false;
this.skiplevel = false;
this.levelUpCounterMax = 50;
this.intervals = new Array();
this.intervals.push(setInterval(this, "RunPlayTime", 1000));
this.playTime = 0;
this.bigCharacterArr = new Array("bigblack", "bigred", "bigblue");
this.smlCharacterArr = new Array("smlblack", "smlred", "smlblue");
this.bigCharacter = this.bigCharacterArr[this.parent.ID];
this.smlCharacter = this.smlCharacterArr[this.parent.ID];
this.humanoidsTotal = this.level * 2;
if (this.level == 1) {
this.humanoidsTotal = 0;
}
this.intro = new Intro(this);
this.parent.flash();
COUNTER = 0;
}
Level.prototype.handle = function () {
if (this.intro) {
this.intro.handle();
return(undefined);
}
this.handleTimers();
if (!this.stillInPlay) {
this.outtro();
}
if (this.active) {
this.terrain.handle();
}
};
Level.prototype.play = function () {
this.terrain = new Terrain(this);
this.parent.hud.radar = new Radar(this.parent.hud);
this.parent.hud.MC.molcounter._visible = true;
this.parent.flash();
};
Level.prototype.outtro = function () {
this.levelUpCounter++;
if (this.levelUpCounter > 1) {
if (this.victory) {
this.timerPercent = MAX(0, (100 * this.timer) / this.originalTimer) + ((100 - MAX(0, (100 * this.timer) / this.originalTimer)) * (this.levelUpCounter / this.levelUpCounterMax));
this.parent.score = this.parent.score + (Math.round(this.timer / this.levelUpCounterMax) * BONUSSCORE);
}
}
if (this.levelUpCounter == this.levelUpCounterMax) {
this.active = false;
this.parent.parent.sfx.play("music_stop");
if (this.victory) {
this.parent.levelUp();
} else {
this.parent.gameOver();
}
}
};
Level.prototype.handleTimers = function () {
if ((!this.levelUpCounter) && (this.timer)) {
this.timer--;
if (this.timer <= 0) {
this.timer = 0;
}
}
this.timerPercent = MAX(0, (100 * this.timer) / this.originalTimer);
};
Level.prototype.RunPlayTime = function () {
this.playTime++;
};
Level.prototype.win = function () {
if (!this.stillInPlay) {
return(undefined);
}
this.victory = true;
this.stillInPlay = false;
this.skiplevel = false;
this.parent.parent.sfx.play("level_win", 100, 0);
this.parent.parent.sfx.play("music_stop", 100, 0);
};
Level.prototype.lose = function () {
if (!this.stillInPlay) {
return(undefined);
}
this.victory = false;
this.stillInPlay = false;
this.parent.parent.sfx.play("music_stop");
this.parent.parent.sfx.play("musicFadeOut");
};
function Radar(parent) {
this.parent = parent;
this.blips = new Array();
this.MC = this.parent.MC.attachMovie("radar", "radar", 1);
this.width = 350;
this.height = 35;
this.width2 = this.width / 2;
this.height2 = this.height / 2;
this.MC._x = (SCREENX - this.width) / 2;
this.MC._y = 10;
this.mask = this.MC.attachMovie("blank", "mask", 2);
this.mask._width = this.width;
this.mask._height = this.height;
this.MC.setMask(this.mask);
}
Radar.prototype.handle = function () {
if (!this.parent.parent.level.terrain) {
this.MC._visible = false;
return(undefined);
}
if (!this.scaleX) {
this.scaleX = this.width / this.parent.parent.level.terrain.width;
this.scaleY = this.height / this.parent.parent.level.terrain.height;
}
this.draw();
};
Radar.prototype.draw = function () {
this.MC._visible = true;
this.MC.blips = this.MC.createEmptyMovieClip("blips", 1);
for (var _local3 in this.blips) {
var _local2 = this.MC.blips.attachMovie("blip", "blip" + _local3, _local3);
_local2._x = this.width2 + ((this.blips[_local3].posX - this.parent.parent.level.terrain.ship.posX) * this.scaleX);
_local2._y = this.height - (this.blips[_local3].posY * this.scaleY);
if (this.blips[_local3].classs == "Alien") {
_local2.gotoAndStop(this.blips[_local3].classs + this.blips[_local3].type);
if ((this.blips[_local3].type == "mutant") && (COUNTER % 2)) {
_local2._visible = false;
}
} else {
_local2.gotoAndStop(this.blips[_local3].classs);
}
if (this.blips[_local3].classs == "Humanoid") {
if (this.blips[_local3].attacker && (COUNTER % 2)) {
_local2._visible = false;
}
_local2._y = _local2._y - 5;
}
}
this.blips = new Array();
};
function Alien(parent, number, posX, posY, type, character) {
this.classs = "Alien";
this.parent = parent;
this.number = number;
this.posX = posX;
this.posY = posY;
this.type = type;
this.life = 100;
this.health = 100;
this.hit = false;
this.character = character;
this.dx = 0;
this.dy = 0;
this.shotSpeed = 0;
this.shotFrequency = 0;
this.active = true;
this.attacking = (this.captured = false);
this.frame = 1;
var _local2 = 0;
this.mutantMove = 0;
this.MC = this.parent.MC.attachMovie(this.character, "alien" + this.number, this.number + 700);
this.MC.hitzone._visible = false;
this.setType();
}
Alien.prototype.setType = function () {
if (this.type == "lander") {
this.shotFrequency = 0;
this.shotSpeed = 5;
}
this.handle();
};
Alien.prototype.handle = function () {
if (!this.active) {
if (!this.life) {
if (this.MC) {
this.MC.removeMovieClip();
}
return(undefined);
}
this.life = this.life - 10;
this.draw();
return(undefined);
}
if (AWARDS.S == 1) {
STRENGTH = (MUTANTSTRENGTH = 1);
} else {
STRENGTH = 2;
MUTANTSTRENGTH = STRENGTH + 1;
}
if (this.mutantMove > 0) {
this.mutantMove--;
}
this.move();
this.shoot();
this.collision();
this.draw();
};
Alien.prototype.move = function () {
this.posX = this.posX + this.dx;
this.posY = this.posY + this.dy;
if (this.posX > (this.parent.ship.posX + this.parent.width2)) {
this.posX = this.posX - this.parent.width;
}
if (this.posX < (this.parent.ship.posX - this.parent.width2)) {
this.posX = this.posX + this.parent.width;
}
if (this.posY > this.parent.height) {
this.posY = this.parent.height;
this.dy = this.dy * -1;
}
if (this.posY < (this.parent.marginY * 3)) {
this.posY = this.parent.marginY * 3;
this.dy = this.dy * -1;
}
this.angleToShip = reverseTrig(-(this.posX - this.parent.ship.posX), this.posY - this.parent.ship.posY);
if (this.type == "lander") {
if (!this.attacking) {
if (random(50) < 5) {
this.dx = this.dx + (random(10) - 4.75);
this.dy = this.dy + (random(10) - 4.75);
if (this.dx == 0) {
this.dx = 1;
}
if (this.dy == 0) {
this.dy = 1;
}
this.dx = this.dx * 0.75;
this.dy = this.dy * 0.75;
}
for (var _local4 in this.parent.humanoids) {
var _local2 = this.parent.humanoids[_local4];
var dx = Math.abs(_local2.posX - this.posX);
if ((((!_local2.attacker) && (dx < 20)) && (this.posY > _local2.height)) && (_local2.posY == 0)) {
this.dy = 0;
this.attacking = _local2;
_local2.attacker = this;
break;
}
}
} else if (!this.captured) {
this.dx = 0;
this.dy = this.dy - 0.1;
if (this.posY < this.attacking.height) {
this.dy = 0;
this.posY = this.attacking.height;
this.captured = this.attacking;
}
} else {
this.captured.posY = this.posY - this.captured.height;
this.dy = this.dy + 0.025;
if (this.posY > (this.parent.height - this.parent.marginY)) {
this.head = this.captured.type;
this.captured.destroy();
this.type = "mutant";
this.health = 100;
}
}
}
if (this.type == "mutant") {
if ((this.mutantMove == 0) && (this.parent.numAlienTracker < this.parent.parent.parent.alienAttackers)) {
this.parent.numAlienTracker++;
var _local3 = this.angleToShip;
var _local6 = random(90) - 45;
_local3 = _local3 + _local6;
if (_local3 > 360) {
_local3 = 360;
} else if (_local3 < 0) {
_local3 = 0;
}
var _local5 = trig(_local3);
this.dx = this.dx + (_local5.x * 0.75);
this.dy = this.dy + ((-_local5.y) * 0.75);
this.dx = this.dx * 0.95;
this.dy = this.dy * 0.95;
} else if (this.parent.numAlienTracker >= this.parent.parent.parent.alienAttackers) {
if (random(100) < 5) {
this.dx = this.dx + (random(10) - 5);
}
this.dx = this.dx * 0.95;
this.dy = this.dy * 0.95;
} else {
this.dx = this.dx * 0.95;
this.dy = this.dy * 0.95;
}
}
};
Alien.prototype.shoot = function () {
if ((random(100) + 1) > this.shotFrequency) {
return(undefined);
}
var _local2 = trig(this.angleToShip);
this.parent.weaponry.newShot(this.posX, this.posY, _local2.x * this.shotSpeed, (-_local2.y) * this.shotSpeed);
};
Alien.prototype.collision = function () {
for (var _local2 in this.parent.weaponry.shots) {
myLaser = this.parent.weaponry.shots[_local2];
if (myLaser.active && (this.MC.hitzone.hitTest(myLaser.MC.hitzone))) {
this.hit = true;
if (this.type == "lander") {
this.health = this.health - (100 / STRENGTH);
}
if (this.type == "mutant") {
this.health = this.health - (100 / MUTANTSTRENGTH);
}
this.destroy();
this.parent.parent.parent.sfx.play("hit", 100, 0);
this.hitEffect = this.MC.attachMovie("hit", "hit" + this.number, this.number + 700);
this.hitEffect._rotation = random(360);
myLaser.destroy();
}
}
};
Alien.prototype.destroy = function () {
if (this.health <= 0) {
this.active = false;
this.attacking.attacker = false;
this.parent.parent.parent.sfx.play("die");
}
};
Alien.prototype.draw = function () {
this.MC._x = this.posX;
this.MC._y = SCREENY - this.posY;
this.MC.gotoAndStop(this.type);
if (this.life == 100) {
this.parent.parent.parent.hud.radar.blips.push(this);
this.frame++;
}
if (this.type == "lander") {
if (this.hit == true) {
if (hitcounter < 10) {
this.MC._rotation = random(50) - 25;
hitcounter++;
} else {
this.MC._rotation = 0;
hitcounter = 0;
this.hit = false;
}
}
}
if (this.type == "mutant") {
if (this.dx < 0) {
this.MC._xscale = -100;
} else {
this.MC._xscale = 100;
}
}
if ((!(COUNTER % 2)) && (this.life == 100)) {
var _local2 = this.parent.MC.attachMovie("smoke", "smoke" + this.parent.smoke, this.parent.smoke + 600);
_local2._x = this.posX;
_local2._y = SCREENY - this.posY;
_local2._rotation = random(20) - 10;
_local2._xscale = _local2._xscale - this.health;
_local2._yscale = _local2._yscale - this.health;
this.parent.smoke++;
if (this.parent.smoke > 50) {
this.parent.smoke = 1;
}
}
if (this.life < 100) {
var _local3 = new Color(this.MC);
_local3.setTransform(hiliteColorTransform);
this.MC._alpha = this.life;
this.MC._xscale = this.MC._xscale + (((100 - this.life) * this.MC._xscale) / 100);
this.MC._yscale = this.MC._yscale + (((100 - this.life) * this.MC._yscale) / 100);
}
};
function Humanoid(parent, number, x, y, character) {
this.classs = "Humanoid";
this.parent = parent;
this.number = number;
this.posX = x;
this.posY = y;
this.active = true;
this.life = 100;
this.attacker = false;
this.character = character;
this.frame = 1;
this.dx = random(4) - 2;
if (!this.dx) {
this.dx = 1;
}
this.dx = this.dx * 5;
this.MC = this.parent.MC.attachMovie(this.character, "humanoid" + this.number, this.number + 400);
this.height = this.MC.floormarker._y;
this.MC.floormarker._visible = false;
}
Humanoid.prototype.handle = function () {
if (!this.active) {
if (!this.life) {
if (this.MC) {
this.MC.removeMovieClip();
}
return(undefined);
}
this.life = this.life - 10;
this.draw();
return(undefined);
}
this.move();
this.draw();
};
Humanoid.prototype.move = function () {
if (!this.attacker) {
if (this.posY > 0) {
this.dy = this.dy - 0.5;
this.posY = this.posY + this.dy;
this.wasup = true;
} else {
this.posY = (this.dy = 0);
this.posX = this.posX + this.dx;
if (random(200) == 1) {
this.dx = this.dx * -1;
}
}
} else {
if ((this.prevY == 0) && (this.posY > 0)) {
this.parent.parent.parent.sfx.play("bom_pickup", 100, 0);
}
this.posX = this.attacker.posX;
}
if (this.parent.parent.intro) {
if (this.posX > this.parent.width) {
this.posX = this.parent.width;
this.dx = this.dx * -1;
}
if (this.posX < 0) {
this.posX = 0;
this.dx = this.dx * -1;
}
} else {
if (this.posX > (this.parent.ship.posX + this.parent.width2)) {
this.posX = this.posX - this.parent.width;
}
if (this.posX < (this.parent.ship.posX - this.parent.width2)) {
this.posX = this.posX + this.parent.width;
}
}
if (this.posY < 0) {
this.posY = 0;
}
this.prevY = this.posY;
};
Humanoid.prototype.destroy = function () {
this.active = false;
this.parent.parent.parent.survivingHumanoids[this.number] = false;
this.parent.parent.parent.sfx.play("matoran_die", 100, 0);
};
Humanoid.prototype.draw = function () {
if (this.life == 100) {
this.frame++;
this.MC._xscale = 100;
if (this.dx < 0) {
this.MC._xscale = -100;
}
}
this.MC._x = this.posX;
this.MC._y = (SCREENY - this.posY) - this.height;
if (this.life < 100) {
var _local2 = new Color(this.MC);
_local2.setTransform(hiliteColorTransform);
this.MC._alpha = this.life;
this.MC._xscale = this.MC._xscale + (((100 - this.life) * this.MC._xscale) / 100);
this.MC._yscale = this.MC._yscale + (((100 - this.life) * this.MC._yscale) / 100);
} else {
this.parent.parent.parent.hud.radar.blips.push(this);
if (this.frame > 8) {
this.frame = 1;
}
this.MC.anim.gotoAndStop(this.frame);
if (this.attacker) {
this.MC.anim.gotoAndStop(this.frame + 8);
}
if ((!this.attacker) && (this.posY == 0)) {
if (random(20) < 5) {
this.MC._y = this.MC._y + (random(10) - 5);
}
}
}
};
function Laser(parent, number, posX, posY, direction, dx) {
this.parent = parent;
this.number = number;
this.posX = posX;
this.posY = posY;
this.dx = dx;
this.direction = direction;
this.active = true;
this.life = 100;
this.lifespan = 10;
this.MC = this.parent.parent.MC.attachMovie("laser", "laser" + this.number, this.number + 100);
this.MC.hitzone._visible = false;
this.MC._xscale = 100 * direction;
if (random(2) == 1) {
this.MC._yscale = -100;
}
this.parent.parent.parent.parent.sfx.play("laser", 100, 0);
}
Laser.prototype.handle = function () {
if (!this.active) {
return(undefined);
}
if (this.lifespan) {
this.lifespan--;
} else {
this.destroy();
}
this.move();
this.draw();
};
Laser.prototype.destroy = function () {
this.active = false;
};
Laser.prototype.move = function () {
this.posX = this.posX + this.dx;
if (this.posX > (this.parent.parent.ship.posX + this.parent.parent.width2)) {
this.posX = this.posX - this.parent.parent.width;
}
if (this.posX < (this.parent.parent.ship.posX - this.parent.parent.width2)) {
this.posX = this.posX + this.parent.parent.width;
}
};
Laser.prototype.draw = function () {
this.MC._x = this.posX;
this.MC._y = SCREENY - this.posY;
};
function Shot(parent, number, posX, posY, direction, dx, dy) {
this.classs = "Shot";
this.parent = parent;
this.number = number;
this.posX = posX;
this.posY = posY;
this.dx = dx;
this.dy = dy;
this.direction = direction;
this.active = true;
this.life = 100;
this.MC = this.parent.parent.MC.attachMovie("shot", "shot" + this.number, this.number + 200);
if (AWARDS.S == 1) {
this.lifespan = 20;
this.MC.gotoAndStop(2);
} else {
this.lifespan = 12;
this.MC.gotoAndStop(1);
}
this.MC.hitzone._visible = false;
this.blast = this.MC.attachMovie("shotBlast", "shotblast" + this.number, this.number + 200);
this.MC._xscale = this.direction * 100;
this.parent.parent.parent.parent.sfx.play("skyblaster", 100, 0);
this.handle();
}
Shot.prototype.handle = function () {
if (!this.active) {
return(undefined);
}
if (this.lifespan) {
this.lifespan--;
} else {
this.destroy();
}
this.move();
this.draw();
};
Shot.prototype.destroy = function () {
this.active = false;
this.MC._visible = false;
};
Shot.prototype.move = function () {
this.posX = this.posX + (this.dx * this.direction);
this.posY = this.posY + this.dy;
if (this.posX > (this.parent.parent.ship.posX + this.parent.parent.width2)) {
this.posX = this.posX - this.parent.parent.width;
}
if (this.posX < (this.parent.parent.ship.posX - this.parent.parent.width2)) {
this.posX = this.posX + this.parent.parent.width;
}
};
Shot.prototype.collision = function () {
for (var _local2 in this.parent.parent.aliens) {
myAlien = this.parent.parent.aliens[_local2];
if (myAlien.active && (this.MC.hitTest(myAlien.MC.hitzone))) {
this.destroy();
myAlien.destroy();
this.parent.parent.parent.parent.sfx.play("hit", 100, 0);
}
}
};
Shot.prototype.draw = function () {
this.MC._x = this.posX;
this.MC._y = SCREENY - this.posY;
this.parent.parent.parent.parent.hud.radar.blips.push(this);
};
function Weaponry(parent) {
this.parent = parent;
this.MC = this.parent.parent.parent.hud.MC.attachMovie("weaponry", "weaponry", 5);
this.MC._x = 50;
this.MC._y = 50;
this.maxShots = 50;
this.currentShot = 0;
this.maxLasers = 5;
this.currentLaser = 0;
this.shots = new Array();
this.lasers = new Array();
}
Weaponry.prototype.handle = function () {
this.draw();
for (var _local2 in this.shots) {
this.shots[_local2].handle();
}
for (var _local2 in this.lasers) {
this.lasers[_local2].handle();
}
};
Weaponry.prototype.draw = function () {
};
Weaponry.prototype.newShot = function (posX, posY, direction, dx, dy) {
this.shots[this.currentShot] = new Shot(this, this.currentShot, posX, posY, direction, dx, dy);
this.currentShot++;
if (this.currentShot >= this.maxShots) {
this.currentShot = 0;
}
};
Weaponry.prototype.newLaser = function (posX, posY, direction, dx) {
this.lasers[this.currentLaser] = new Laser(this, this.currentLaser, posX, posY, direction, dx);
this.currentLaser++;
if (this.currentLaser >= this.maxLasers) {
this.currentLaser = 0;
}
};
function Terrain(parent) {
this.parent = parent;
this.MC = this.parent.MC.createEmptyMovieClip("terrain", 2);
this.MCbg = this.MC.createEmptyMovieClip("bg", 1);
this.MCmid = this.MC.createEmptyMovieClip("mid", 2);
this.MCfg = this.MC.createEmptyMovieClip("fg", 3000);
this.widthBg = 1000;
this.widthMid = 3000;
this.widthFg = 4000;
var _local3 = this.MCbg.attachMovie("bg", "bgL", 1);
var _local5 = this.MCbg.attachMovie("bg", "bgC", 2);
var _local4 = this.MCbg.attachMovie("bg", "bgR", 3);
_local3._x = -this.widthBg;
_local4._x = this.widthBg;
_local3 = this.MCmid.attachMovie("mid", "midL", 1);
_local5 = this.MCmid.attachMovie("mid", "midC", 2);
_local4 = this.MCmid.attachMovie("mid", "midR", 3);
_local3._x = -this.widthMid;
_local4._x = this.widthMid;
_local3 = this.MCfg.attachMovie("fg", "fgL", 1);
_local5 = this.MCfg.attachMovie("fg", "fgC", 2);
_local4 = this.MCfg.attachMovie("fg", "fgR", 3);
_local3._x = -this.widthFg;
_local4._x = this.widthFg;
this.marginY = 15;
this.width = this.widthMid;
this.height = 400;
this.width2 = this.width / 2;
this.height2 = this.height / 2;
this.posX = 0;
this.posY = 0;
this.dx = (this.dy = 0);
this.gas = 1;
this.smoke = 1;
this.ship = new Ship(this, 1, 2450, (SCREENY2 + random(100)) - 50, 39, 37, 38, 40, 32);
this.aliens = new Array();
var _local2 = 0;
while (_local2 < (((this.parent.level - 1) * (this.parent.level - 1)) + 2)) {
this.aliens.push(new Alien(this, _local2, random(this.width) - this.width2, this.height - this.marginY, "lander", this.parent.bigCharacter));
_local2++;
}
this.humanoids = new Array();
_local2 = 0;
while (_local2 < this.parent.humanoidsTotal) {
this.humanoids.push(new Humanoid(this, _local2, random(this.width) - this.width2, 0, this.parent.smlCharacter));
_local2++;
}
this.weaponry = new Weaponry(this);
}
Terrain.prototype.handle = function () {
this.ship.handle();
this.weaponry.handle();
this.move();
this.draw();
this.activeAliens = 0;
this.activeHumanoids = 0;
this.numAlienTracker = 0;
var _local2 = 0;
while (_local2 < this.aliens.length) {
this.aliens[_local2].handle();
this.activeAliens = this.activeAliens + (this.aliens[_local2].active ? 1 : 0);
_local2++;
}
for (_local2 in this.humanoids) {
this.humanoids[_local2].handle();
this.activeHumanoids = this.activeHumanoids + (this.humanoids[_local2].active ? 1 : 0);
}
if (this.parent.parent.hud.MC.molcounter.counter != Number(this.activeHumanoids)) {
this.parent.parent.hud.MC.molcounter.flash.gotoAndPlay(2);
this.parent.parent.hud.MC.molcounter.counter = Number(this.activeHumanoids);
}
if (!this.activeAliens) {
this.parent.win();
} else if (this.parent.skiplevel == true) {
this.activeAliens == false;
this.parent.win();
}
if (!this.activeHumanoids) {
this.parent.lose();
}
};
Terrain.prototype.move = function () {
this.posX = ((SCREENX2 - this.ship.posX) - (this.ship.dx * 2.5)) - this.ship.shunt;
};
Terrain.prototype.draw = function () {
this.MCbg._x = (-this.posX) + (this.posX * (this.widthBg / this.widthMid));
this.MCmid._x = (-this.posX) + (this.posX * (this.widthMid / this.widthMid));
this.MCfg._x = (-this.posX) + (this.posX * (this.widthFg / this.widthMid));
this.MC._x = this.posX;
this.MC._y = this.posY;
};
function Ship(parent, number, posX, posY, left, right, up, down, fire) {
this.classs = "Ship";
this.parent = parent;
this.number = number;
this.MC = this.parent.MC.attachMovie("ship" + this.number, "ship" + this.number, 501 + this.number);
this.MC.hitzone._visible = false;
this.posX = posX;
this.posY = posY;
this.width = 50;
this.height = 10;
this.prevX = this.posX;
this.prevY = this.posY;
this.dx = (this.dy = 0);
this.direction = 1;
this.speed = 0;
this.thrustX = 1.5;
this.thrustY = 1.5;
this.frictionX = 0.925;
this.frictionY = 0.9;
this.zap = 5;
this.shield = 10;
this.frame = random(10);
this.shunt = 0;
this.speed = 0;
this.control = new Control(this, left, right, up, down, fire);
}
Ship.prototype.handle = function () {
this.control.handle();
this.move();
this.collision();
this.draw();
if (AWARDS.S == 1) {
this.MC.gotoAndStop("reward");
} else {
this.MC.gotoAndStop("noreward");
}
if (this.shield) {
this.shield--;
} else if (this.zap) {
if (AWARDS.S == 1) {
this.zap--;
} else if (!this.control.FIRE) {
this.zap--;
}
} else if (this.control.FIRE) {
this.zap = 5;
this.parent.weaponry.newShot((this.posX + this.dx) + ((this.direction * this.width) * 0.1), this.posY, this.direction, 30, 0);
}
};
Ship.prototype.move = function () {
if (this.control.LEFT) {
this.dx = this.dx + this.thrustX;
this.direction = 1;
}
if (this.control.RIGHT) {
this.dx = this.dx - this.thrustX;
this.direction = -1;
}
if (((this.control.LEFT || (this.control.RIGHT)) || (this.control.UP)) || (this.control.DOWN)) {
this.frame = this.frame + 2;
}
if (this.control.UP) {
this.dy = this.dy + this.thrustY;
}
if (this.control.DOWN) {
this.dy = this.dy - this.thrustY;
}
this.shunt = this.shunt + (this.direction * 15);
this.shunt = this.shunt * 0.85;
this.dx = this.dx * this.frictionX;
this.dy = this.dy * this.frictionY;
this.prevX = this.posX;
this.prevY = this.posY;
this.posX = this.posX + this.dx;
this.posY = this.posY + this.dy;
if (this.parent.parent.intro) {
if (this.posX > this.parent.width) {
this.posX = this.parent.width;
this.dx = this.dx * -1;
}
if (this.posX < 0) {
this.posX = 0;
this.dx = this.dx * -1;
}
} else if (this.number == 1) {
if (this.posX > this.parent.width2) {
this.posX = this.posX - this.parent.width;
if (this.parent.ship2) {
this.parent.ship2.posX = this.parent.ship2.posX - this.parent.width;
}
}
if (this.posX < (-this.parent.width2)) {
this.posX = this.posX + this.parent.width;
if (this.parent.ship2) {
this.parent.ship2.posX = this.parent.ship2.posX + this.parent.width;
}
}
}
if (this.posY > (this.parent.height - this.parent.marginY)) {
this.posY = this.parent.height - this.parent.marginY;
this.dy = this.dy * -0.5;
}
if (this.posY < (this.parent.marginY * 3)) {
this.posY = this.parent.marginY * 3;
this.dy = this.dy * -0.5;
}
this.frame++;
if (this.frame > 15) {
this.frame = 1;
}
};
Ship.prototype.collision = function () {
if (this.shield) {
return(undefined);
}
for (var _local2 in this.parent.aliens) {
myAlien = this.parent.aliens[_local2];
if (myAlien.active && (this.MC.hitzone.hitTest(myAlien.MC.hitzone))) {
this.dx = this.dx * -1;
this.dx = this.dx + myAlien.dx;
myAlien.dx = myAlien.dx * -1;
this.dy = this.dy * -1;
this.dy = this.dy + myAlien.dy;
myAlien.dy = myAlien.dy * -1;
this.parent.parent.timer = this.parent.parent.timer - 20;
this.parent.parent.parent.sfx.play("rockcollision", 100, 0);
this.shield = 10;
myAlien.mutantMove = 30;
}
}
for (var _local2 in this.parent.bonuses) {
myBonus = this.parent.bonuses[_local2];
if (myBonus.active && (this.MC.hitzone.hitTest(myBonus.MC.hitzone))) {
myBonus.destroy();
this.parent.parent.parent.sfx.play("bonuspickup", 100, 0);
}
}
return(undefined);
if ("collision" != null) {
var _local2 = "collision";
myShot = this.parent.weaponry.shots[_local2];
if (myShot.active && (this.MC.hitzone.hitTest(myShot.MC))) {
myShot.destroy();
this.parent.parent.timer = this.parent.parent.timer - 20;
this.parent.parent.parent.sfx.play("rockcollision", 100, 0);
this.shield = 10;
}
// unexpected jump
}
};
Ship.prototype.draw = function () {
this.MC._visible = true;
this.MC._x = this.posX;
this.MC._y = SCREENY - this.posY;
this.MC._xscale = this.direction * 100;
this.MC.gotoAndStop(this.frame);
this.parent.parent.parent.hud.radar.blips.push(this);
var _local2 = new Color(this.MC);
if ((this.shield > 0) && (!(COUNTER % 3))) {
_local2.setTransform(hiliteColorTransform);
} else {
_local2.setTransform(resetColorTransform);
if ((this.parent.parent.stillInPlay == false) || (this.parent.rotorsStop == true)) {
this.parent.parent.parent.sfx.play("rotorsStop");
} else if (this.frame == 1) {
this.parent.parent.parent.sfx.play("rotors");
}
}
};
function Control(parent, left, right, up, down, fire) {
this.keyLEFT = left;
this.keyRIGHT = right;
this.keyUP = up;
this.keyDOWN = down;
this.keyFIRE = fire;
this.active = true;
}
Control.prototype.handle = function () {
this.LEFT = false;
this.RIGHT = false;
this.UP = false;
this.DOWN = false;
this.FIRE = false;
if (!this.active) {
return(undefined);
}
if (Key.isDown(this.keyLEFT)) {
this.LEFT = true;
}
if (Key.isDown(this.keyRIGHT)) {
this.RIGHT = true;
}
if (Key.isDown(this.keyUP)) {
this.UP = true;
}
if (Key.isDown(this.keyDOWN)) {
this.DOWN = true;
}
if (Key.isDown(this.keyFIRE)) {
this.FIRE = true;
}
};
function Hud(parent) {
this.parent = parent;
this.MC = this.parent.MC.attachMovie("hud", "hud", 1000);
this.MC.messageUp.stop();
this.displayScore = 0;
}
Hud.prototype.handle = function () {
this.radar.handle();
if (this.parent.score < this.displayScore) {
this.displayScore = 0;
}
if (this.displayScore < (this.parent.score - 10)) {
this.displayScore = this.displayScore + 10;
}
if (this.displayScore < this.parent.score) {
this.displayScore++;
}
if (this.MC.DebugDisp._visible == true) {
this.MC.DebugDisp.readout = (((("V: " + GAMEVERSION) + ", FPS: ") + this.parent.fps) + ", Time: ") + this.parent.level.playTime;
}
this.MC.readout = this.parent.fps;
this.MC.score = this.displayScore;
this.MC.level = this.parent.currentLevel;
this.MC.timer.countdown.gotoAndStop(Math.ceil(this.parent.level.timerPercent));
this.MC.night._visible = false;
};
Hud.prototype.showMessage = function (message) {
this.MC.messageUp.gotoAndPlay(2);
this.MC.messageUp.play();
this.MC.messageUp.message.message = message;
};
function SFX(parent) {
this.parent = parent;
this.MC = this.parent.MC.attachMovie("soundFX", "soundFX", 1000);
this.buffer = new Array();
}
SFX.prototype.handle = function () {
var _local2 = this.buffer.shift();
if (_local2.length) {
this.fire(_local2);
}
};
SFX.prototype.play = function (what) {
this.buffer.push(String(what));
};
SFX.prototype.fire = function (what) {
this.MC.gotoAndPlay(what);
};
function Game(parent) {
this.parent = parent;
this.score = 0;
this.MC = _root.createEmptyMovieClip("Game", 1);
this.mask = this.MC.attachMovie("blank", "blank", 9999);
this.mask._width = SCREENX;
this.mask._height = SCREENY;
this.flasher = this.MC.attachMovie("flash", "flash", 9997);
this.flasher._width = SCREENX;
this.flasher._height = SCREENY;
this.MC.setMask(this.mask);
this.hud = new Hud(this);
this.sfx = this.parent.sfx;
this.ID = 0;
this.gameOverCounter = 0;
this.alienAttackers = 0;
this.cheated = false;
this.comms = new LoadVars();
this.comms.onLoad = function () {
var _local5 = decrypt(this.output, SEED);
var _local4 = _local5.split("&");
var _local3 = 0;
while (_local3 <= _local4.length) {
var _local2 = _local4[_local3].split("=");
if (_local2[0].length) {
this[_local2[0]] = unescape(_local2[1]);
}
_local3++;
}
this.output = "";
};
this.survivingHumanoids = new Array();
this.currentLevel = 0;
this.levelUp();
}
Game.prototype.handle = function () {
COUNTER++;
if (Key.isDown(70) && (Key.isDown(84))) {
if (!CHEATMODE) {
this.sfx.play("cheater", 100, 0);
}
CHEATMODE = true;
this.crackcount = 20;
this.hud.MC.cheats.gotoAndPlay(2);
}
if (CHEATMODE && (!this.crackcount)) {
if (Key.isDown(51)) {
this.sfx.play("cheater", 100, 0);
this.level.timer = this.level.originalTimer;
this.crackcount = 20;
}
if (Key.isDown(66)) {
this.sfx.play("cheater");
this.level.intro.skipbonus = true;
this.crackcount = 20;
}
if (Key.isDown(76)) {
this.sfx.play("cheater", 100, 0);
this.level.skiplevel = true;
this.crackcount = 20;
}
if (Key.isDown(83)) {
this.sfx.play("cheater", 100, 0);
AWARDS.S = 1;
this.crackcount = 20;
}
if (Key.isDown(71)) {
this.sfx.play("cheater", 100, 0);
if (AWARDS.S != 1) {
AWARDS.S = 1;
}
this.level.stillInPlay = false;
this.level.victory = false;
this.parent.sfx.play("music_stop");
this.parent.totalScore = GOLDTARGET;
this.cheated = true;
this.parent.tally();
this.crackcount = 20;
}
if (Key.isDown(68)) {
this.sfx.play("cheater", 100, 0);
this.level.stillInPlay = false;
this.level.victory = false;
this.parent.sfx.play("music_stop");
this.gameOver();
this.crackcount = 20;
}
}
if (this.crackcount) {
this.crackcount--;
}
this.fps = this.calcFPS();
if (CHEATMODE == true) {
if (this.hud.MC.DebugDisp._visible != true) {
this.hud.MC.DebugDisp._visible = true;
}
} else if (this.hud.MC.DebugDisp._visible != false) {
this.hud.MC.DebugDisp._visible = false;
}
if (this.parent.state == "gameOver") {
this.realGameOver();
}
this.hud.handle();
this.level.handle();
};
Game.prototype.calcFPS = function () {
this.currentTime = getTimer();
this.frameDuration = this.currentTime - this.previousTime;
this.previousTime = this.currentTime;
return(int(1000 / this.frameDuration));
};
Game.prototype.commsSync = function (write) {
trace("PING");
var _local2 = (((("http://" + HTTP_HOST) + "/flashcomms.php?vid=") + VID) + "&dc=") + random(100000);
if (write) {
_local2 = _local2 + ("&input=" + escape(encrypt(this.comms.toString(), SEED)));
}
this.comms.load(_local2);
};
Game.prototype.flash = function () {
this.flasher.gotoAndPlay(1);
};
Game.prototype.gameOver = function () {
if (this.cheated != true) {
trace("Game Over");
this.parent.state = "gameOver";
this.parent.sfx.play("level_failed");
}
};
Game.prototype.realGameOver = function () {
if (this.gameOverCounter < 60) {
this.gameOverCounter++;
return(undefined);
}
trace(this.gameOverCounter);
this.gameOverCounter = 0;
this.parent.tally();
};
Game.prototype.levelUp = function () {
this.currentLevel++;
this.alienAttackers++;
if (this.currentLevel > 1) {
this.parent.tally();
} else {
this.level = new Level(this, this.currentLevel);
}
};
Game.prototype.newLevelUp = function () {
if (this.currentLevel > 3) {
this.ID = random(3);
} else {
this.ID = this.currentLevel - 1;
}
trace(this.ID);
this.parent.sfx.play("titleStop");
this.parent.sfx.play("titleFadeOut");
this.level = new Level(this, this.currentLevel);
this.parent.state = "hidden";
};
Game.prototype.logger = function (what) {
if (!HTTP_HOST.length) {
return(undefined);
}
var _local2 = (((("http://" + HTTP_HOST) + "/logger.php?act=log_") + what) + "&dc=") + random(100000);
this.comms.load(_local2);
};
function Panel() {
this.MC = _root.attachMovie("panel", "panel", 2);
this.MC.parent = this;
this.mask = this.MC.attachMovie("blank", "blank", 9999);
this.mask._width = SCREENX;
this.mask._height = SCREENY;
this.MC.setMask(this.mask);
this.counter = 0;
this.state = "splash";
this.instructionsPage = 1;
this.instructionsPages = 4;
this.message = "";
this.sfx = new SFX(this);
this.shown = false;
this.inFillCounter = 0;
}
Panel.prototype.handle = function () {
this.counter++;
this.draw();
this.game.handle();
this.sfx.handle();
};
Panel.prototype.draw = function () {
this.MC._visible = true;
_quality = "high";
if (this.state == "hidden") {
this.MC._visible = false;
this.MC.gotoAndStop("spare");
_quality = "medium";
}
this.MC.gotoAndStop(this.state);
if (this.state == "gameOver") {
this.MC.gameOverPic.gotoAndStop(this.game.level.bigCharacter);
}
if (this.state == "bonusscreen") {
this.contInFill();
}
if (this.state == "instructions") {
this.MC.gotoAndStop(this.state + this.instructionsPage);
}
this.MC.message = this.message;
};
Panel.prototype.tally = function () {
this.state = "tally";
this.MC.gotoAndStop(this.state);
this.sfx.play("title");
var _local3 = this.getGameScores();
this.totalScore = this.totalScore + _local3[3];
trace((this.totalScore + " ") + SILVERTARGET);
this.tallyInt = setInterval(this, "tallyScores", 500, _local3);
this.MC.tallyBox.inc = 0;
var _local2 = 1;
while (_local2 < 4) {
this.MC.tallyBox["tallyStrip" + _local2].icon.gotoAndStop(_local2);
this.MC.tallyBox["tallyStrip" + _local2].text = "0";
_local2++;
}
};
Panel.prototype.webLink = function () {
backToSite(TEAMID);
};
Panel.prototype.tallyScores = function (scores) {
if ((this.MC.tallyBox.inc > 3) || (this.MC.tallyBox.inc == undefined)) {
this.MC.tallyBox.total.text = this.totalScore;
clearInterval(this.tallyInt);
} else if (this.MC.tallyBox.inc < 3) {
this.MC.tallyBox["tallyStrip" + (this.MC.tallyBox.inc + 1)].text = scores[this.MC.tallyBox.inc];
}
this.MC.tallyBox.inc++;
};
Panel.prototype.getGameScores = function () {
var _local4 = BONUSSCORE;
var _local2 = int(this.game.level.playTime / 60);
trace("time " + _local2);
var _local5 = int(60 * ((this.game.level.playTime / 60) - _local2));
var _local6 = (_local2 + ":") + _local5;
var _local3 = this.game.level.terrain.activeHumanoids;
var _local7 = int(((_local4 * 100) * _local3) - this.game.level.playTime);
return(new Array(_local4, _local3, _local6, _local7));
};
Panel.prototype.pressSplash = function () {
this.state = "splash";
this.MC.gotoAndStop(this.state);
this.MC.silverReward.gotoAndStop(1);
this.MC.silverReward.image.gotoAndStop(AWARDS.S + 1);
this.MC.silverReward.text = "+" + SILVERTARGET;
this.MC.goldReward.gotoAndStop(2);
this.MC.goldReward.image.gotoAndStop(AWARDS.G + 1);
this.MC.goldReward.text = "+" + GOLDTARGET;
this.sfx.play("scoreStop");
this.sfx.play("title");
};
Panel.prototype.pressReward = function () {
clearInterval(this.tallyInt);
if (this.totalScore >= SILVERTARGET) {
this.state = "reward";
this.MC.gotoAndStop(this.state);
if ((this.totalScore >= GOLDTARGET) && (AWARDS.S == 1)) {
this.MC.code = GOLDCODE;
this.MC.reward.gotoAndStop(2);
this.MC.reward.image.gotoAndStop(2);
this.MC.reward.text = this.totalScore;
AWARDS.G = 1;
_root.kvEvent(472);
} else if (AWARDS.S == 1) {
this.sfx.play("scoreStop");
this.sfx.play("scoreFadeOut");
this.pressSplash();
} else {
this.MC.code = SILVERCODE;
this.MC.reward.gotoAndStop(1);
this.MC.reward.image.gotoAndStop(2);
this.MC.reward.text = this.totalScore;
AWARDS.S = 1;
_root.kvEvent(471);
}
} else if (this.game.level.victory == false) {
this.sfx.play("scoreStop");
this.sfx.play("scoreFadeOut");
this.pressSplash();
}
};
Panel.prototype.pressDelayPoints = function () {
if (this.interval == undefined) {
this.interval = setInterval(this, "pressPoints", 1000);
}
};
Panel.prototype.pressPoints = function () {
clearInterval(this.interval);
this.interval = undefined;
this.sfx.play("score");
var _local2;
if ((this.totalScore >= GOLDTARGET) && (AWARDS.S == 1)) {
_local2 = 100;
} else if (this.totalScore >= SILVERTARGET) {
_local2 = 50;
} else {
_local2 = 10;
}
this.state = "points";
this.MC.gotoAndStop(this.state);
this.MC.points = "+" + _local2;
this.submitScore(_local2);
};
Panel.prototype.submitScore = function (pts) {
this.teamScore = pts;
prepHighScores(this.savedHiScore);
};
Panel.prototype.savedHiScore = function (status) {
trace(status);
};
Panel.prototype.inFill = function () {
this.state = "bonusscreen";
this.MC.gotoAndStop(this.state);
this.MC.inFillPicture.gotoAndStop(this.game.level.bigCharacter);
this.sfx.play("introStop");
this.sfx.play("music_start");
};
Panel.prototype.contInFill = function () {
if (this.inFillCounter < 50) {
this.inFillCounter++;
return(undefined);
}
this.inFillCounter = 0;
this.game.level.play();
this.state = "hidden";
};
Panel.prototype.startGame = function () {
this.sfx.play("titleStop");
this.state = "hidden";
this.counter = 0;
this.totalScore = 0;
this.game = new Game(this);
};
Panel.prototype.levelControl = function () {
this.sfx.play("introStop");
this.sfx.play("music_start");
this.shown = true;
this.state = "levelcontrol";
};
Panel.prototype.pressPlay = function () {
this.state = "bonuscontrol";
this.shown = false;
CHEATMODE = false;
};
Panel.prototype.pressInstructions = function () {
this.state = "instructions";
this.instructionsPage = 1;
};
Panel.prototype.pressNext = function () {
if (this.instructionsPage < this.instructionsPages) {
this.instructionsPage++;
}
};
Panel.prototype.pressPrevious = function () {
if (this.instructionsPage > 1) {
this.instructionsPage--;
}
};
Panel.prototype.pressContinue = function () {
if (this.state == "submitting") {
return(undefined);
}
this.state = "submitting";
trace("I submit score!");
};
fscommand ("allowscale", false);
fscommand ("showmenu", false);
fscommand ("trapallkeys", true);
_quality = "medium";
HTTP_HOST = _level0.http_host;
if (!HTTP_HOST.length) {
HTTP_HOST = "myhttphost";
}
VID = _level0.vid;
if (!VID.length) {
VID = "madeupvid";
}
if (!_level0.xmlurl.length) {
_level0.xmlurl = "dialogue.xml";
}
SEED = VID.substr(VID.length - 1, 1);
RAD = (Math.PI/180);
SCREENX = 500;
SCREENY = 400;
SCREENX2 = SCREENX / 2;
SCREENY2 = SCREENY / 2;
CHEATMODE = false;
COUNTER = 0;
BONUSSCORE = 0;
FPS = 20;
GAMEVERSION = "1.0";
SHAREID = "phantoka";
SHAREPATH = "/";
TEAMID = 0;
GID = 0;
SILVERTARGET = 11000;
GOLDTARGET = 25000;
SILVERCODE = "OPO612";
GOLDCODE = "OAU867";
SO = SharedObject.getLocal(SHAREID, SHAREPATH, false);
STATE = SO.data.STATE;
if (SO.data.AWARDS[TEAMID][GID] == undefined) {
AWARDS = new Object({S:0, G:0});
} else {
AWARDS = new Object({S:SO.data.AWARDS[TEAMID][GID].S, G:SO.data.AWARDS[TEAMID][GID].G});
}
initiateTrig();
initDialogue();
panel = new Panel();
panel.pressSplash();
onEnterFrame = function () {
panel.handle();
};
stop();
Symbol 40 MovieClip [smoke] Frame 16
this.removeMovieClip();
Symbol 51 MovieClip Frame 1
setInterval(this, "rotate", 25);
this.rotate = function () {
this.anim._rotation = this.anim._rotation + 0.1;
};
Symbol 81 Button
on (release, keyPress "<Space>") {
parent.pressPlay();
}
Symbol 89 Button
on (release) {
parent.webLink();
}
Symbol 96 MovieClip Frame 6
stop();
Symbol 101 Button
on (release, keyPress "<Space>") {
parent.startGame();
}
Symbol 140 Button
on (release, keyPress "<Space>") {
parent.game.level.play();
parent.state = "hidden";
}
Symbol 188 MovieClip [flash56] Frame 6
stop();
Symbol 188 MovieClip [flash56] Frame 16
stop();
Symbol 196 Button
on (release, keyPress "<Space>") {
if ((parent.game.currentLevel > 5) || (parent.game.level.victory == false)) {
parent.sfx.play("titleStop");
parent.sfx.play("titleFadeOut");
parent.pressDelayPoints();
} else {
parent.game.newLevelUp();
}
}
Symbol 212 Button
on (release, keyPress "<Space>") {
parent.pressReward();
}
Symbol 217 MovieClip Frame 1
stop();
Symbol 237 Button
on (release) {
getURL ("http://www.bioniclestory.com/", "_blank");
}
Symbol 238 MovieClip [panel] Frame 12
parent.game.level.intro = null;
Symbol 238 MovieClip [panel] Frame 13
parent.game.level.intro = null;
Symbol 257 MovieClip [soundFX] Frame 1
stop();
Symbol 257 MovieClip [soundFX] Frame 10
play();
Symbol 257 MovieClip [soundFX] Frame 19
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 20
play();
Symbol 257 MovieClip [soundFX] Frame 28
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 29
play();
Symbol 257 MovieClip [soundFX] Frame 38
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 39
play();
Symbol 257 MovieClip [soundFX] Frame 48
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 49
play();
Symbol 257 MovieClip [soundFX] Frame 58
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 59
play();
Symbol 257 MovieClip [soundFX] Frame 68
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 69
play();
Symbol 257 MovieClip [soundFX] Frame 78
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 79
play();
Symbol 257 MovieClip [soundFX] Frame 88
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 89
play();
Symbol 257 MovieClip [soundFX] Frame 98
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 99
play();
Symbol 257 MovieClip [soundFX] Frame 108
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 109
play();
Symbol 257 MovieClip [soundFX] Frame 118
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 119
play();
Symbol 257 MovieClip [soundFX] Frame 128
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 129
play();
Symbol 257 MovieClip [soundFX] Frame 138
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 139
play();
Symbol 257 MovieClip [soundFX] Frame 148
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 149
play();
Symbol 257 MovieClip [soundFX] Frame 158
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 159
play();
Symbol 257 MovieClip [soundFX] Frame 168
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 169
play();
Symbol 257 MovieClip [soundFX] Frame 178
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 179
play();
Symbol 257 MovieClip [soundFX] Frame 189
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 190
play();
Symbol 257 MovieClip [soundFX] Frame 199
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 200
play();
Symbol 257 MovieClip [soundFX] Frame 209
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 210
play();
Symbol 257 MovieClip [soundFX] Frame 219
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 220
play();
Symbol 257 MovieClip [soundFX] Frame 229
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 230
play();
Symbol 257 MovieClip [soundFX] Frame 239
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 240
play();
Symbol 257 MovieClip [soundFX] Frame 249
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 250
play();
Symbol 257 MovieClip [soundFX] Frame 259
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 260
play();
Symbol 257 MovieClip [soundFX] Frame 270
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 271
play();
Symbol 257 MovieClip [soundFX] Frame 279
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 280
play();
Symbol 257 MovieClip [soundFX] Frame 289
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 290
play();
Symbol 257 MovieClip [soundFX] Frame 299
gotoAndStop (1);
Symbol 257 MovieClip [soundFX] Frame 300
play();
Symbol 257 MovieClip [soundFX] Frame 309
gotoAndStop (1);
Symbol 259 MovieClip [flash] Frame 20
stop();
Symbol 260 MovieClip Frame 101
stop();
Symbol 268 MovieClip Frame 1
stop();
Symbol 273 MovieClip Frame 1
stop();
Symbol 273 MovieClip Frame 14
if (Number(_root.panel.game.level.terrain.activeHumanoids) < 2) {
gotoAndPlay (2);
} else {
gotoAndStop (1);
}
Symbol 310 MovieClip [laser] Frame 18
this.removeMovieClip();
Symbol 500 MovieClip [shotBlast] Frame 2
this.removeMovieClip();
Symbol 505 MovieClip Frame 2
if (_parent.flashing == false) {
gotoAndPlay (1);
}
Symbol 506 MovieClip Frame 1
this.flashing = false;
Symbol 509 MovieClip Frame 2
if (_parent.flashing == false) {
gotoAndPlay (1);
}
Symbol 510 MovieClip Frame 1
this.flashing = false;