Frame 1
function makeMenu() {
var _local3 = _root.attachMovie("menu", "menu", _root.getNextHighestDepth());
_local3._x = 1000;
_local3._y = 200;
_local3.x = new Number(1000);
_local3.onEnterFrame = function () {
var _local2 = Stage.width - this.x;
this.x = this.x + (_local2 / 10);
this._x = Math.floor(this.x);
};
}
var loadGear = _root.attachMovie("loadGear", "loadGear", _root.getNextHighestDepth());
loadGear._x = Stage.width - 30;
loadGear._y = Stage.height - (Stage.height / 3);
var loadBar = _root.attachMovie("loadBar", "loadBar", _root.getNextHighestDepth());
loadBar._x = Stage.width - 133;
loadBar._y = Stage.height - (Stage.height / 4);
var vx = -5;
loadBar.onEnterFrame = function () {
var _local3 = _root._framesloaded / _root._totalframes;
this.bar._xscale = _local3 * 100;
_root.loadGear._rotation = _root.loadGear._rotation + 5;
if (_local3 == 1) {
delete this.onEnterFrame;
this.onEnterFrame = function () {
_root.vx = _root.vx + 0.5;
this._x = this._x + _root.vx;
_root.loadGear._x = _root.loadGear._x + _root.vx;
_root.loadGear._rotation = _root.loadGear._rotation + (5 - (_root.vx * 2));
if (this._x > 1000) {
_root.gotoAndStop("MENU");
removeMovieClip(this);
}
};
}
};
_quality = "LOW";
stop();
Frame 13
function makeSoundIcon(isOn) {
var _local3 = attachMovie("soundIcon", "soundIcon", _root.getNextHighestDepth());
_local3.onEnterFrame = function () {
this._alpha = this._alpha - 3;
if (this._alpha < 0) {
removeMovieClip(this);
}
};
if (!isOn) {
_local3.gotoAndStop("OFF");
} else {
_local3.gotoAndStop("ON");
}
}
var pickup = new Sound();
pickup.attachSound("pickup.wav");
var soundSwitch = new Sound();
soundSwitch.attachSound("switch.wav");
var soundGunPlasma = new Sound();
soundGunPlasma.attachSound("gun_plasma.wav");
var soundExplode = new Sound();
soundExplode.attachSound("explode.wav");
var soundSword = new Sound();
soundSword.attachSound("sword.wav");
var soundHit = new Sound();
soundHit.attachSound("hit.wav");
var soundPowerup = new Sound();
soundPowerup.attachSound("powerup.wav");
var soundBeep = new Sound();
soundBeep.attachSound("beep.wav");
var sound = true;
var soundListener = new Object();
soundListener.onKeyDown = function () {
if (Key.getCode() == 87) {
if (sound) {
sound = false;
makeSoundIcon(false);
} else {
sound = true;
makeSoundIcon(true);
}
}
};
Key.addListener(soundListener);
Frame 45
var doorF1_Town = new Array();
doorF1_Town = [[1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 2, 0], [501, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 2, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0]];
var doorF1_D1 = new Array();
doorF1_D1 = [[0, 0, 8, 8, 8, 8, 8, 8], [0, 0, 8, 7, 7, 7, 7, 8], [0, 6, 7, 0, 0, 0, 6, 7], [0, 0, 0, 0, 0, 0, 0, 502], [0, 6, 8, 0, 0, 0, 6, 8], [0, 0, 8, 8, 8, 8, 8, 8], [0, 0, 7, 7, 7, 7, 7, 7]];
var doorF1_F2 = new Array();
doorF1_F2 = [[1, 1, 504, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 2, 0, 0, 1], [0, 0, 0, 0, 0]];
var doorD1_F1 = new Array();
doorD1_F1 = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 3, 0, 0, 0, 1, 3, 0], [5, 503, 0, 0, 0, 0, 0, 0], [1, 3, 0, 0, 0, 1, 3, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]];
var doorF2_F1 = new Array();
doorF2_F1 = [[0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 2, 0, 0, 1], [1, 1, 505, 1, 1]];
var doorF2_D2 = new Array();
doorF2_D2 = [[0, 0, 8, 8, 8, 8, 8, 8], [0, 0, 8, 7, 7, 7, 7, 8], [0, 6, 7, 0, 0, 0, 6, 7], [0, 0, 0, 0, 0, 0, 0, 506], [0, 6, 8, 0, 0, 0, 6, 8], [0, 0, 8, 8, 8, 8, 8, 8], [0, 0, 7, 7, 7, 7, 7, 7]];
var doorD2_F2 = new Array();
doorD2_F2 = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 3, 0, 0, 0, 1, 3, 0], [5, 507, 0, 0, 0, 0, 0, 0], [1, 3, 0, 0, 0, 1, 3, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]];
var doorF3_town = new Array();
doorF3_town = [[0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 2, 0, 0, 1], [1, 1, 509, 1, 1]];
var doorD3_F3 = new Array();
doorD3_F3 = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 3, 0, 4, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 3, 513, 4, 1, 0], [0, 1, 1, 5, 1, 1, 0]];
var doorF3_D3 = new Array();
doorF3_D3 = [[1, 1, 512, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 2, 0, 0, 1], [0, 0, 0, 0, 0]];
var doorF4_Town = new Array();
doorF4_Town = [[0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 2, 1], [0, 0, 0, 0, 0, 0, 515], [0, 0, 0, 0, 0, 2, 1], [0, 0, 0, 6, 1, 1, 1]];
var doorF4_D4 = new Array();
doorF4_D4 = [[1, 1, 1, 1, 0], [6, 5, 0, 0, 0], [516, 0, 0, 0, 0], [6, 5, 0, 0, 0], [1, 1, 2, 0, 0]];
var doorD4_F4 = new Array();
doorD4_F4 = [[0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [0, 1, 3, 0, 4, 1], [0, 0, 0, 0, 517, 5], [0, 1, 3, 0, 4, 1], [0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1]];
var doorD5_Town = new Array();
doorD5_Town = [[0, 1, 1, 5, 1, 1, 0], [0, 1, 4, 519, 3, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 3, 0, 4, 1, 0], [0, 0, 0, 0, 0, 0, 0]];
var bossRoom = new Array();
bossRoom = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 300, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
var house = new Array();
house = [[5, 1, 2, 6, 1, 6, 5, 5, 5], [5, 3, 4, 0, 0, 0, 5, 5, 5], [5, 0, 0, 0, 0, 0, 2, 1, 5], [5, 5, 5, 0, 5, 0, 0, 0, 5], [5, 2, 1, 0, 5, 0, 0, 0, 5], [5, 0, 0, 0, 5, 0, 0, 0, 5], [5, 0, 0, 0, 5, 0, 0, 0, 5], [5, 3, 4, 0, 5, 0, 0, 0, 5], [5, 5, 5, 5, 5, 5, 510, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]];
var town = new Array();
town = [[0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 508, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0], [7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0], [7, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 3, 0, 0], [7, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 3, 0, 0], [7, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 3, 3, 3], [7, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 0, 1, 0, 0, 3], [7, 0, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3], [7, 0, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 3], [7, 0, 1, 1, 2, 2, 2, 1, 1, 2, 2, 5, 2, 2, 2, 2, 1, 1, 1, 0, 0, 3], [7, 0, 1, 1, 2, 2, 2, 1, 1, 2, 2, 4, 2, 2, 2, 2, 1, 1, 0, 0, 0, 500], [7, 0, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 2, 1, 1, 0, 0, 0, 3], [10, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 3], [8, 0, 1, 1, 1, 5, 5, 5, 5, 5, 5, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 3], [514, 0, 1, 1, 1, 5, 5, 5, 5, 5, 5, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 3], [8, 0, 1, 1, 1, 4, 6, 4, 511, 6, 4, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 3], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3], [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 3], [7, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 3], [7, 0, 0, 8, 0, 9, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 3, 0], [0, 11, 11, 8, 518, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 3, 3, 0]];
function makeRandomMap(mapName, w, h, basicFill, tileSet) {
_root[mapName] = new Object();
_root[mapName].tileSet = tileSet;
_root[mapName].width = w;
_root[mapName].height = h;
_root[mapName].map = new Array();
i = 0;
while (i < h) {
j = 0;
while (j < w) {
_root[mapName].map.push(basicFill);
j++;
}
i++;
}
_root[mapName].enemyList = new Array();
_root[mapName].containerList = new Array();
_root[mapName].getTile = function (x, y) {
if ((((x >= 0) && (x < this.width)) && (y >= 0)) && (y < this.height)) {
return(this.map[(y * this.width) + x]);
}
return(1);
};
_root[mapName].setTile = function (x, y, val) {
this.map[(y * this.width) + x] = val;
};
_root[mapName].getRandomTile = function (tx, ty, bx, by, val) {
var _local5 = false;
var _local6 = 0;
var _local7;
var _local3;
var _local2;
while (_local5 == false) {
_local3 = Math.round(Math.random() * (bx - tx)) + tx;
_local2 = Math.round(Math.random() * (by - ty)) + ty;
_local7 = this.getTile(_local3, _local2);
_local6++;
if (_local7 == val) {
var _local4 = new Array();
_local4 = [_local3, _local2];
return(_local4);
}
if (_local6 > 5000) {
var _local4 = new Array();
_local4 = [_local3, _local2];
return(_local4);
}
}
};
}
function addNoise(map, amount, val) {
i = 0;
while (i < map.height) {
j = 0;
while (j < map.width) {
if (Math.random() < amount) {
map.setTile(j, i, val);
}
j++;
}
i++;
}
}
function drawLines(map, interval, numLines, minLength, maxLength, val) {
var _local11 = Math.floor(map.width / interval);
var _local12 = Math.floor(map.height / interval);
var _local4;
var _local3;
var _local8;
var _local2;
var _local1;
var _local6;
i = 0;
while (i < numLines) {
_local4 = Math.floor(Math.random() * _local11) * interval;
_local3 = Math.floor(Math.random() * _local12) * interval;
_local6 = Math.random();
if (_local6 < 0.25) {
_local2 = 1;
_local1 = 0;
} else if ((_local6 >= 0.25) && (_local6 < 0.5)) {
_local2 = -1;
_local1 = 0;
} else if ((_local6 >= 0.5) && (_local6 < 0.75)) {
_local2 = 0;
_local1 = 1;
} else {
_local2 = 0;
_local1 = -1;
}
_local8 = (Math.random() * (maxLength - minLength)) + minLength;
j = 0;
while (j < _local8) {
map.setTile(_local4, _local3, val);
if ((map.getTile(_local4 + _local2, _local3 + _local1) != val) && (map.getTile(_local4 + _local2, _local3 + _local1) != null)) {
_local4 = _local4 + _local2;
_local3 = _local3 + _local1;
} else {
break;
}
j++;
}
i++;
}
}
function addLandmark(map, landmark, minX, maxX, minY, maxY) {
var _local8 = landmark[0].length;
var _local9 = landmark.length;
var _local6 = map.getRandomTile(minX, minY, maxX - _local8, maxY - _local9, 0);
var _local5;
var _local4;
if ((minX == map.width) && (maxX == map.width)) {
_local6[0] = map.width - _local8;
}
if ((minY == map.height) && (maxY == map.height)) {
_local6[1] = map.height - _local9;
}
y = 0;
while (y < _local9) {
x = 0;
while (x < _local8) {
_local5 = x + _local6[0];
_local4 = y + _local6[1];
map.setTile(_local5, _local4, landmark[y][x]);
if (landmark[y][x] >= 500) {
var _local2 = _root["door" + (landmark[y][x] - 500)];
_local2.pos[0] = _local5;
_local2.pos[1] = _local4;
}
x++;
}
y++;
}
}
function getLine(map, startX, startY, dirX, dirY, val) {
var _local1 = 0;
var _local3 = startX;
var _local2 = startY;
while (_local1 >= 0) {
if (map.getTile(_local3 + dirX, _local2 + dirY) == val) {
_local3 = _local3 + dirX;
_local2 = _local2 + dirY;
_local1++;
continue;
}
return(_local1);
}
}
function addContainer(map, type) {
var _local3 = map.getRandomTile(0, 0, map.width, map.height, 0);
map.containerList.push(new Object());
var _local2 = map.containerList[map.containerList.length - 1];
_local2.xtile = _local3[0];
_local2.ytile = _local3[1];
_local2.contType = type;
_local2.collected = false;
}
function addBoss(map, type) {
map.boss = new Object();
map.boss.xtile = 0;
map.boss.ytile = 0;
map.boss.xtileStart = 0;
map.boss.ytileStart = 0;
map.boss.alive = true;
map.boss.hp = 6;
map.boss.tpe = type;
var _local3 = 1;
var _local5 = 1;
var _local4 = 1;
map.boss.mv = new Array();
if ((type == "PLASMA") || (type == "FINAL")) {
map.boss.mv = [[-1, 0], [-1, -3], [-1, -3], [0, -3], [2, -3], [2, -3], [2, 0], [2, 3], [2, 3], [0, 3], [-1, 3], [-1, 3]];
map.boss.mvSpeed = 35;
map.boss.speed = 2;
map.boss.gun = plasmaGun;
}
if (type == "SNIPER") {
map.boss.mv = [[-1, 0], [-1, -3], [-1, -3], [0, -3], [2, -3], [2, -3], [2, 0], [2, 3], [2, 3], [0, 3], [-1, 3], [-1, 3]];
map.boss.mvSpeed = 25;
map.boss.speed = 5;
map.boss.gun = sniperGun;
_local5 = 1.7;
_local4 = 1.6;
}
if (type == "GRENADE") {
map.boss.mv = [[-1, -3], [2, -3], [2, -1], [-1, -1], [-1, 1], [2, 1], [2, 3], [-1, 3], [-1, 0]];
map.boss.mvSpeed = 50;
map.boss.speed = 5;
map.boss.gun = grenadeGun;
_local3 = 1.9;
}
if (type == "FTHROWER") {
map.boss.mv = [[-1, -3], [-1, -2], [-1, -1], [-1, 0], [-1, 1], [-1, 2], [-1, 3], [2, -3], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2], [2, 3]];
map.boss.mvSpeed = 20;
map.boss.speed = 5;
map.boss.gun = fthrowerGun;
_local5 = 1.7;
_local3 = 1.1;
_local4 = 0.9;
}
map.boss.colour = new flash.geom.ColorTransform();
map.boss.colour.redMultiplier = _local3;
map.boss.colour.greenMultiplier = _local5;
map.boss.colour.blueMultiplier = _local4;
}
function addEnemySquad(map, type, min, max, spread) {
var _local10 = Math.round(Math.random() * (max - min)) + min;
var _local2 = map.getRandomTile(0, 0, map.width, map.height, 0);
var _local4;
i = 0;
while (i < _local10) {
map.enemyList.push(new Object());
var _local5 = map.enemyList.length - 1;
en = map.enemyList[_local5];
en.enType = type;
_local4 = map.getRandomTile(_local2[0] - spread, _local2[1] - spread, _local2[0] + spread, _local2[1] + spread, 0);
en.xtileStart = _local4[0];
en.ytileStart = _local4[1];
if (en.enType == "ROLYPOLY") {
en.hpStart = game.rolyPolyHP;
en.plasDrop = game.rolyPolyDrop;
var _local9 = getLine(map, en.xtileStart, en.ytileStart, 1, 0, 0);
var _local7 = getLine(map, en.xtileStart, en.ytileStart, -1, 0, 0);
var _local8 = getLine(map, en.xtileStart, en.ytileStart, 0, 1, 0);
var _local6 = getLine(map, en.xtileStart, en.ytileStart, 0, -1, 0);
if ((_local9 + _local7) < (_local8 + _local6)) {
if (Math.random() < 0.5) {
en.vxStart = 1 * game.rolyPolySpeed;
} else {
en.vxStart = -1 * game.rolyPolySpeed;
}
en.vyStart = 0;
} else {
en.vxStart = 0;
if (Math.random() < 0.5) {
en.vyStart = 1 * game.rolyPolySpeed;
} else {
en.vyStart = -1 * game.rolyPolySpeed;
}
}
en.speed = game.rolyPolySpeed;
en.damage = game.rolyPolyDamage;
en.width = 8;
en.height = 8;
en.xSubTile = 0;
en.ySubTile = 0;
}
if (en.enType == "THUMPER") {
en.hpStart = game.thumperHP;
en.plasDrop = game.thumperDrop;
var _local9 = getLine(map, en.xtileStart, en.ytileStart, 1, 0, 0);
var _local7 = getLine(map, en.xtileStart, en.ytileStart, -1, 0, 0);
var _local8 = getLine(map, en.xtileStart, en.ytileStart, 0, 1, 0);
var _local6 = getLine(map, en.xtileStart, en.ytileStart, 0, -1, 0);
if ((_local9 + _local7) > (_local8 + _local6)) {
if (Math.random() < 0.5) {
en.vxStart = 1 * game.thumperSpeed;
} else {
en.vxStart = -1 * game.thumperSpeed;
}
en.vyStart = 0;
} else {
en.vxStart = 0;
if (Math.random() < 0.5) {
en.vyStart = 1 * game.thumperSpeed;
} else {
en.vyStart = -1 * game.thumperSpeed;
}
}
en.speed = game.thumperSpeed;
en.damage = game.thumperDamage;
en.width = 10;
en.height = 10;
en.xSubTile = 0;
en.ySubTile = 0;
}
if (en.enType == "SKITTER") {
en.hpStart = game.skitterHP;
en.plasDrop = game.skitterDrop;
en.gun = game.skitterGun;
dir = Math.random();
if (dir < 0.25) {
en.vxStart = 1 * game.skitterSpeed;
en.vyStart = 0;
} else if ((dir >= 0.25) && (dir < 0.5)) {
en.vxStart = -1 * game.skitterSpeed;
en.vyStart = 0;
} else if ((dir >= 0.5) && (dir < 0.75)) {
en.vxStart = 0;
en.vyStart = 1 * game.skitterSpeed;
} else {
en.vxStart = 0;
en.vyStart = -1 * game.skitterSpeed;
}
en.speed = game.skitterSpeed;
en.width = 8;
en.height = 8;
en.xSubTile = 0;
en.ySubTile = 0;
}
if (en.enType == "GRANMA") {
en.xtileStart = 3;
en.ytileStart = 3;
en.hpStart = 1;
en.plasDrop = 0;
en.speed = 5;
en.stun = 0;
en.width = 8;
en.height = 8;
en.vxStart = 0;
en.vyStart = 0;
en.xSubTile = 0;
en.ySubTile = 0;
}
if (en.enType == "ENDBOSSGLOATER") {
en.xtileStart = 6;
en.ytileStart = 15;
en.hpStart = 1;
en.plasDrop = 0;
en.speed = 5;
en.stun = 0;
en.width = 8;
en.height = 8;
en.vxStart = 0;
en.vyStart = 0;
en.xSubTile = 0;
en.ySubTile = 0;
}
i++;
}
}
function buildMap(map) {
removeMovieClip(tileHolder);
_root.createEmptyMovieClip("tileHolder", _root.getNextHighestDepth());
i = 0;
while (i < map.height) {
j = 0;
while (j < map.width) {
tileName = (("t_" + i) + "_") + j;
tileHolder.attachMovie("tile", tileName, tileHolder.getNextHighestDepth());
tileHolder[tileName]._x = j * game.tileW;
tileHolder[tileName]._y = i * game.tileH;
if (map.getTile(j, i) == 0) {
tileHolder[tileName].walkable = true;
} else {
tileHolder[tileName].walkable = false;
}
tileHolder[tileName].gotoAndStop(setTile(map, j, i));
j++;
}
i++;
}
mapWidth = map.width * game.tileW;
mapHeight = map.height * game.tileH;
game.containerList = new Array();
game.containerList = map.containerList;
tileHolder.createEmptyMovieClip("contHolder", tileHolder.getNextHighestDepth());
var _local3;
i = 0;
while (i < game.containerList.length) {
_local3 = game.containerList[i];
if (_local3.contType == "HP") {
_local3.collected = false;
}
if (!_local3.collected) {
tileHolder.contHolder.attachMovie("container", "c_" + i, tileHolder.contHolder.getNextHighestDepth());
_local3.clip = tileHolder.contHolder["c_" + i];
_local3.x = _local3.xtile * game.tileW;
_local3.y = _local3.ytile * game.tileH;
_local3.clip._x = _local3.x;
_local3.clip._y = _local3.y;
_local3.xSubTile = Math.floor(_local3.x / game.subTileW);
_local3.ySubTile = Math.floor(_local3.y / game.subTileH);
tileHolder[(("t_" + _local3.ytile) + "_") + _local3.xtile].walkable = false;
if (_local3.contType == "HP") {
_local3.clip.gotoAndStop("HP");
}
if (_local3.contType == "HPUP") {
_local3.clip.gotoAndStop("HPUP");
}
if (_local3.contType == "PLUP") {
_local3.clip.gotoAndStop("PLUP");
}
}
i++;
}
game.enemyList = new Array();
game.enemyList = map.enemyList;
tileHolder.createEmptyMovieClip("enemyHolder", tileHolder.getNextHighestDepth());
i = 0;
while (i < game.enemyList.length) {
if (game.enemyList[i].enType == "ROLYPOLY") {
tileHolder.enemyHolder.attachMovie("mc_rolyPoly", "e_" + i, tileHolder.enemyHolder.getNextHighestDepth());
}
if (game.enemyList[i].enType == "THUMPER") {
tileHolder.enemyHolder.attachMovie("mc_thumper", "e_" + i, tileHolder.enemyHolder.getNextHighestDepth());
}
if (game.enemyList[i].enType == "SKITTER") {
tileHolder.enemyHolder.attachMovie("mc_skitter", "e_" + i, tileHolder.enemyHolder.getNextHighestDepth());
}
if (game.enemyList[i].enType == "GRANMA") {
tileHolder.enemyHolder.attachMovie("mc_granny", "e_" + i, tileHolder.enemyHolder.getNextHighestDepth());
}
if ((game.enemyList[i].enType == "ENDBOSSGLOATER") && (bossShow)) {
tileHolder.enemyHolder.attachMovie("mc_finalBoss", "e_" + i, tileHolder.enemyHolder.getNextHighestDepth());
}
game.enemyList[i].id = i;
game.enemyList[i].hp = game.enemyList[i].hpStart;
game.enemyList[i].alive = true;
game.enemyList[i].stun = 0;
game.enemyList[i].behave = 0;
game.enemyList[i].vxFunc = game.enemyList[i].vxStart;
game.enemyList[i].vyFunc = game.enemyList[i].vyStart;
game.enemyList[i].vx = game.enemyList[i].vxStart;
game.enemyList[i].vy = game.enemyList[i].vyStart;
game.enemyList[i].clip = tileHolder.enemyHolder["e_" + i];
game.enemyList[i].xtile = game.enemyList[i].xtileStart;
game.enemyList[i].ytile = game.enemyList[i].ytileStart;
game.enemyList[i].x = (game.enemyList[i].xtile * game.tileW) + (game.subTileW / 2);
game.enemyList[i].y = (game.enemyList[i].ytile * game.tileH) + (game.subTileH / 2);
game.enemyList[i].clip._x = game.enemyList[i].x;
game.enemyList[i].clip._y = game.enemyList[i].y;
if ((game.enemyList[i].enType == "GRANMA") && (!firstRun)) {
game.enemyList[i].xtile = 6;
game.enemyList[i].ytile = 4;
game.enemyList[i].x = (game.enemyList[i].xtile * game.tileW) + (game.subTileW / 2);
game.enemyList[i].y = (game.enemyList[i].ytile * game.tileH) + (game.subTileH / 2);
game.enemyList[i].clip._x = game.enemyList[i].x;
game.enemyList[i].clip._y = game.enemyList[i].y;
game.enemyList[i].vx = 0;
game.enemyList[i].vy = 0;
game.enemyList[i].behave = 10;
}
if (game.enemyList[i].enType == "ENDBOSSGLOATER") {
game.enemyList[i].x = (game.enemyList[i].xtile * game.tileW) + (game.subTileW / 2);
game.enemyList[i].y = (game.enemyList[i].ytile * game.tileH) + (game.subTileH / 2);
game.enemyList[i].clip._x = game.enemyList[i].x;
game.enemyList[i].clip._y = game.enemyList[i].y;
game.enemyList[i].vx = 0;
game.enemyList[i].vy = 0;
game.enemyList[i].behave = 0;
game.enemyList[i].clip.gotoAndStop("SITNOSMASH");
}
if ((game.enemyList[i].enType == "ENDBOSSGLOATER") && (!bossShow)) {
game.enemyList[i].x = 0;
game.enemyList[i].y = 0;
game.enemyList[i].clip._x = game.enemyList[i].x;
game.enemyList[i].clip._y = game.enemyList[i].y;
game.enemyList[i].vx = 0;
game.enemyList[i].vy = 0;
game.enemyList[i].behave = 0;
game.enemyList[i].clip.gotoAndStop("SITNOSMASH");
}
if (DEBUG) {
game.enemyList[i].tile = tileHolder.enemyHolder.attachMovie("subTile", "e_t_" + i, tileHolder.enemyHolder.getNextHighestDepth());
}
tileName = (("t_" + game.enemyList[i].ytile) + "_") + game.enemyList[i].xtile;
if (!tileHolder[tileName].walkable) {
game.enemyList[i].alive = false;
removeMovieClip(game.enemyList[i].clip);
}
i++;
}
tileHolder.createEmptyMovieClip("particleHolder", tileHolder.getNextHighestDepth());
game.particleList = new Array();
tileHolder.attachMovie("mc_player", "playerClip", tileHolder.getNextHighestDepth());
player.clip = tileHolder.playerClip;
player.x = (player.xtile * game.tileW) + (game.tileW / 2);
player.y = (player.ytile * game.tileH) + (game.tileH / 2);
player.vx = 0;
player.vy = 0;
player.clip._x = player.x;
player.clip._y = player.y;
if (player.facingX == -1) {
player.clip.gotoAndStop("LEFT");
} else if (player.facingX == 1) {
player.clip.gotoAndStop("RIGHT");
} else if (player.facingY == -1) {
player.clip.gotoAndStop("UP");
} else if (player.facingY == 1) {
player.clip.gotoAndStop("DOWN");
}
if ((map.boss != null) && (map.boss.alive)) {
boss = map.boss;
if (boss.tpe != "FINAL") {
boss.clip = tileHolder.attachMovie("mc_boss", "clip", tileHolder.getNextHighestDepth());
} else {
boss.clip = tileHolder.attachMovie("mc_finalBoss", "clip", tileHolder.getNextHighestDepth());
boss.trans = 0;
}
boss.clip.transform.colorTransform = boss.colour;
boss.clip._visible = false;
boss.clip.stop();
boss.x = (boss.xtile * game.tileW) + 16;
boss.y = (boss.ytile * game.tileH) + 16;
boss.vx = 0;
boss.vy = 0;
boss.clip._x = boss.x;
boss.clip._y = boss.y;
boss.width = 48;
boss.height = 16;
boss.xSubTile = 0;
boss.ySubTile = 0;
boss.enType = "BOSS";
boss.stun = 0;
boss.behave = 0;
boss.mvId = 0;
boss.killMode = false;
boss.hp = 6;
} else {
boss = null;
}
displayBars();
var fadeSpeed;
if (firstRun) {
fadeSpeed = 1;
} else {
fadeSpeed = 7;
}
var _local5 = _root.attachMovie("mapTrans", "trans", _root.getNextHighestDepth());
_local5.onEnterFrame = function () {
this._alpha = this._alpha - fadeSpeed;
if (this._alpha <= 0) {
removeMovieClip(this);
}
};
}
function setTile(map, x, y) {
var _local7 = (("t_" + y) + "_") + x;
var _local2 = map.getTile(x, y);
var _local13 = map.getTile(x - 1, y - 1);
var _local8 = map.getTile(x, y - 1);
var _local12 = map.getTile(x + 1, y - 1);
var _local4 = map.getTile(x - 1, y);
var _local5 = map.getTile(x + 1, y);
var _local14 = map.getTile(x - 1, y + 1);
var _local6 = map.getTile(x, y + 1);
var _local15 = map.getTile(x + 1, y + 1);
if (_local2 >= 500) {
var _local11 = _root["door" + (_local2 - 500)];
tileHolder[_local7].walkable = true;
tileHolder[_local7].door = _local11;
if (_local11.lockType == "NONE") {
if (map.tileSet == "DUNGEON") {
return("D_DOOR_O");
}
if (map.tileSet == "HOUSE") {
return("H_DOOR");
}
if ((map.tileSet == "TOWN") || (map.tileSet == "FOREST")) {
if (_local8 == 5) {
return("T_HOUSE_DOOR");
}
if (_local6 == 0) {
return("F_EXIT_N");
}
if (_local8 == 0) {
return("F_EXIT_S");
}
if (_local5 == 0) {
return("F_EXIT_W");
}
if (_local4 == 0) {
return("F_EXIT_E");
}
}
} else {
if (_local11.locked == true) {
tileHolder[_local7].walkable = false;
tileHolder[_local7].light = tileHolder[_local7].attachMovie("light", "light", tileHolder[_local7].getNextHighestDepth());
tileHolder[_local7].light.gotoAndStop(_local11.lockType);
return("D_DOOR");
}
return("D_DOOR_O");
}
}
if (_local2 == 300) {
if (map.boss != null) {
map.boss.xtile = x;
map.boss.ytile = y;
map.boss.xtileStart = x;
map.boss.ytileStart = y;
}
tileHolder[_local7].boss = true;
tileHolder[_local7].walkable = true;
return("D_FLOOR_BOSS_LL");
}
if (map.tileSet == "DUNGEON") {
if (_local2 == 0) {
if (_local4 == 300) {
tileHolder[_local7].boss = true;
if ((map.boss != null) && (map.boss.alive)) {
map.boss.glowTile = tileHolder[_local7].attachMovie("glowMc", "glowTile", tileHolder[_local7].getNextHighestDepth());
}
return("D_FLOOR_BOSS_LR");
}
if (_local6 == 300) {
tileHolder[_local7].boss = true;
return("D_FLOOR_BOSS_UL");
}
if (_local14 == 300) {
tileHolder[_local7].boss = true;
return("D_FLOOR_BOSS_UR");
}
if (((_local4 == 1) && (_local5 == 0)) && (_local13 == 1)) {
return("D_FLOOR_SHAD_R");
}
if (((_local4 == 0) && (_local5 == 1)) && (_local12 == 1)) {
return("D_FLOOR_SHAD_L");
}
if ((_local4 == 1) && (_local5 == 1)) {
return("D_FLOOR_SHAD_B");
}
return("D_FLOOR_BASIC");
}
if (_local2 == 1) {
if ((((_local4 == 0) && (_local5 == 0)) && (_local8 == 0)) && (_local6 == 0)) {
return("D_WALL_STATUE");
}
if ((_local6 == 0) && (_local8 == 0)) {
return("D_WALL_BARS");
}
if (_local6 != 1) {
return("D_WALL_BASIC");
}
return("D_WALL_INSIDE");
}
if (_local2 == 3) {
return("D_GATE_SIDE_E");
}
if (_local2 == 4) {
return("D_GATE_SIDE_W");
}
if (_local2 == 5) {
if (_local6 >= 500) {
return("D_EXIT_N");
}
if (_local8 >= 500) {
return("D_EXIT_S");
}
if (_local4 >= 500) {
return("D_EXIT_E");
}
if (_local5 >= 500) {
return("D_EXIT_W");
}
}
} else if (map.tileSet == "FOREST") {
if (_local2 == 0) {
return("F_GRASS");
}
if (_local2 == 5) {
return("F_DOORWAY_R");
}
if (_local2 == 6) {
return("F_DOORWAY_L");
}
if (_local2 == 7) {
return("D_WALL_BASIC");
}
if (_local2 == 8) {
return("D_WALL_INSIDE");
}
if (_local2 == 1) {
if ((_local4 == 0) && (_local5 == 1)) {
return("F_CLIFF_CL");
}
if ((_local5 == 0) && (_local4 == 1)) {
return("F_CLIFF_CR");
}
if (((((((_local8 == 0) && (_local6 == 0)) || ((_local8 == 2) && (_local6 == 2))) || ((_local8 == 0) && (_local6 == 2))) || ((_local8 == 2) && (_local6 == 0))) || ((_local8 == 1) && (_local6 == 0))) || ((_local8 == 0) && (_local6 == 1))) {
return("F_CLIFF_UD");
}
return("F_CLIFF");
}
if (_local2 == 2) {
return("F_TREE");
}
} else if (map.tileSet == "TOWN") {
if (_local2 == 0) {
return("F_GRASS");
}
if (_local2 == 1) {
tileHolder[_local7].walkable = true;
if (_local4 == 0) {
return("T_DIRT_W");
}
if (_local5 == 0) {
return("T_DIRT_E");
}
if (_local8 == 0) {
return("T_DIRT_N");
}
if (_local6 == 0) {
return("T_DIRT_S");
}
return("T_DIRT");
}
if (_local2 == 2) {
tileHolder[_local7].walkable = true;
if ((_local8 == 1) && (_local4 == 1)) {
return("T_BURNED_NW");
}
if ((_local8 == 1) && (_local5 == 1)) {
return("T_BURNED_NE");
}
if ((_local6 == 1) && (_local4 == 1)) {
return("T_BURNED_SW");
}
if ((_local6 == 1) && (_local5 == 1)) {
return("T_BURNED_SE");
}
if (_local8 == 1) {
return("T_BURNED_N");
}
if (_local6 == 1) {
return("T_BURNED_S");
}
if (_local4 == 1) {
return("T_BURNED_W");
}
if (_local5 == 1) {
return("T_BURNED_E");
}
tileHolder[_local7].walkable = false;
return("T_BURNED");
}
if (_local2 == 3) {
if ((_local4 == 0) && (_local5 == 3)) {
return("F_CLIFF_CL");
}
if ((_local5 == 0) && (_local4 == 3)) {
return("F_CLIFF_CR");
}
if (((_local8 == 0) && (_local6 == 0)) || ((_local8 == 1) && (_local6 == 0))) {
return("F_CLIFF_UD");
}
return("F_CLIFF");
}
if (_local2 == 4) {
return("T_HOUSE_WALL");
}
if (_local2 == 5) {
return("T_HOUSE_ROOF");
}
if (_local2 == 6) {
return("T_HOUSE_WINDOW");
}
if (_local2 == 7) {
return("F_CLIFF_R");
}
if (_local2 == 8) {
return("D_GATE_SIDE_E");
}
if (_local2 == 9) {
return("D_GATE_SIDE_W");
}
if (_local2 == 10) {
return("F_CLIFF_CR");
}
if (_local2 == 11) {
return("F_CLIFF_UD");
}
} else {
if (_local2 == 0) {
if (((_local4 == 5) && (_local5 == 5)) || ((_local4 == 1) && (_local5 == 5))) {
return("H_FLOOR_SHAD_B");
}
if (((_local4 == 1) || (_local4 == 5)) || (_local4 == 2)) {
return("H_FLOOR_SHAD_L");
}
if (((_local5 == 1) || (_local5 == 5)) || (_local5 == 2)) {
return("H_FLOOR_SHAD_R");
}
return("H_FLOOR");
}
if (_local2 == 1) {
return("H_WALL");
}
if (_local2 == 2) {
return("H_BOOKS");
}
if (_local2 == 3) {
return("H_BED1");
}
if (_local2 == 4) {
return("H_BED2");
}
if (_local2 == 5) {
return("H_BLACK");
}
if (_local2 == 6) {
return("H_WINDOW");
}
}
}
function displayBars() {
removeMovieClip(_root.barHolder);
_root.createEmptyMovieClip("barHolder", _root.getNextHighestDepth());
barHolder._x = Stage.width;
var _local2 = 0;
while (_local2 < player.maxHp) {
barPiece = barHolder.attachMovie("bar_hp", "hp_" + _local2, barHolder.getNextHighestDepth());
if (_local2 < player.hp) {
barPiece.gotoAndStop(1);
} else {
barPiece.gotoAndStop(2);
}
barPiece._x = (_local2 + 1) * -16;
_local2++;
}
if (player.gunList.length > 0) {
_local2 = 0;
while (_local2 < player.maxPl) {
barPiece = barHolder.attachMovie("bar_pl", "pl_" + _local2, barHolder.getNextHighestDepth());
if (_local2 < player.pl) {
barPiece.gotoAndStop(1);
} else {
barPiece.gotoAndStop(2);
}
barPiece._x = (_local2 + 1) * -16;
barPiece._y = 16;
_local2++;
}
var _local3 = barHolder.attachMovie("pixelGuns", "gun", barHolder.getNextHighestDepth());
_local3.gotoAndStop(player.gun.sprite);
_local3._x = 0;
_local3._y = 32;
var barPiece;
}
}
function displayText(words) {
var _local3 = _root.attachMovie("textbox", "textbox", _root.getNextHighestDepth());
_local3._x = 90;
_local3._y = 250;
_local3.words = new String(words);
_local3.currentText = new String("");
_local3.i = new Number(0);
_local3.style = new TextFormat();
_local3.style.font = "04b03";
_local3.style.size = 16;
_local3.tf = _local3.createTextField(tf, _local3.getNextHighestDepth(), 15, 10, 280, 100);
_local3.tf.selectable = false;
_local3.tf.wordWrap = true;
_local3.tf.embedFonts = true;
_local3.tf.setTextFormat(_local3.style);
_local3.arrowPic._visible = false;
run = false;
_local3.onEnterFrame = function () {
if (this.i < this.words.length) {
this.currentText = this.currentText + this.words.charAt(this.i++);
if (Key.isDown(90)) {
this.currentText = this.currentText + this.words.charAt(this.i++);
}
this.tf.text = this.currentText;
this.tf.setTextFormat(this.style);
if (_root.sound) {
soundBeep.start();
}
} else {
this.arrowPic._visible = true;
if (Key.isDown(90)) {
_root.run = true;
if (sound) {
soundSwitch.start();
}
removeMovieClip(this);
}
}
};
}
function endGame() {
control = false;
var _local3 = _root.attachMovie("mapTrans", "trans", _root.getNextHighestDepth());
_local3._alpha = 0;
_local3.texts = new Array();
_local3.texts = ["KINGDOM OF MACHINES.", "MADE IN 2007 BY ISAAC WILLIAMS FOR BAIM RMIT.", "THANKS TO ALL FOR YOUR SUPPORT!"];
_local3.tId = 0;
_local3.onEnterFrame = function () {
this._alpha = this._alpha + 2;
if (this._alpha >= 100) {
if (_root.run) {
if (this.tId == this.texts.length) {
removeMovieClip(_root.barHolder);
removeMovieClip(_root.tileHolder);
_root.gotoAndStop("MENU");
removeMovieClip(this);
} else {
_root.displayText(this.texts[this.tId].toString());
this.tId++;
}
}
}
};
}
function loadMap(map) {
control = false;
var _local3 = _root.attachMovie("mapTrans", "trans", _root.getNextHighestDepth());
_local3._alpha = 0;
_local3.toLoad = map;
_local3.onEnterFrame = function () {
this._alpha = this._alpha + 20;
if (this._alpha >= 100) {
_root.run = true;
_root.control = true;
_root.buildMap(this.toLoad);
removeMovieClip(this);
}
};
}
function playBossFX() {
boss.killMode = true;
var _local1 = 0;
while (_local1 < 20) {
pType = "SMOKE" + Math.floor((Math.random() * 3) + 1);
vx = (Math.random() * 20) - 10;
vy = (Math.random() * 5) - 2.5;
addParticle(pType, boss.x, boss.y + 30, vx, vy, 0.95, 0, 60, true);
_local1++;
}
shakeScreen(20, 30);
if (sound) {
soundExplode.start();
}
}
function addParticle(type, x, y, vx, vy, fric, dam, lifetime, hitWalls) {
var _local1 = new Object();
game.particleList.push(_local1);
_local1.clip = tileHolder.particleHolder.attachMovie("particles", "p_" + game.particleList.length, tileHolder.particleHolder.getNextHighestDepth());
_local1.clip.gotoAndStop(type);
_local1.x = x;
_local1.y = y;
_local1.vx = vx;
_local1.vy = vy;
_local1.fric = fric;
_local1.dam = dam;
_local1.life = lifetime;
_local1.hitWalls = hitWalls;
_local1.width = 4;
_local1.height = 4;
}
function killOb(ob) {
ob.alive = false;
removeMovieClip(ob.clip);
removeMovieClip(ob.tile);
var _local5;
var _local4;
var _local3;
var _local6 = Math.floor(Math.random() * 5);
var _local1 = 0;
while (_local1 < _local6) {
_local5 = "PART" + Math.floor((Math.random() * 5) + 1);
_local4 = (Math.random() * 10) - 5;
_local3 = (Math.random() * 10) - 5;
addParticle(_local5, ob.x, ob.y, _local4, _local3, 0.95, 0, 40, false);
_local1++;
}
_local1 = 0;
while (_local1 < 4) {
_local5 = "SMOKE" + Math.floor((Math.random() * 3) + 1);
_local4 = (Math.random() * 10) - 5;
_local3 = (Math.random() * 10) - 5;
addParticle(_local5, ob.x, ob.y, _local4, _local3, 0.95, 0, 15, true);
_local1++;
}
if (player.gunList.length > 0) {
var _local7 = Math.floor(Math.random() * ob.plasDrop) + Math.floor(ob.plasDrop / 3);
_local1 = 0;
while (_local1 < _local7) {
_local4 = (Math.random() * 10) - 5;
_local3 = (Math.random() * 10) - 5;
addParticle("PLASMADROP", ob.x, ob.y, _local4, _local3, 0.9, -1, 200, false);
_local1++;
}
}
if (sound) {
soundExplode.start();
}
}
function applyDamage(ob, from, damage) {
if (ob.stun <= 0) {
var _local2 = Math.floor((damage / 2) + 1) + game.kickMod;
var _local4 = (Math.random() * _local2) + _local2;
var _local3 = (Math.random() * _local2) + _local2;
if (ob.x > from.x) {
ob.vx = ob.vx + _local4;
} else {
ob.vx = ob.vx - _local4;
}
if (ob.y > from.y) {
ob.vy = ob.vy + _local3;
} else {
ob.vy = ob.vy - _local3;
}
ob.hp = ob.hp - damage;
ob.stun = 30;
if (sound) {
soundHit.start();
}
if (ob == player) {
displayBars();
shakeScreen(5, 5);
if (player.hp <= 0) {
player.xtile = 2;
player.ytile = 5;
player.hp = player.maxHp;
loadMap(homeMap);
run = false;
}
}
if (ob == boss) {
if (ob.hp <= 0) {
boss.alive = false;
}
}
}
}
function shakeScreen(mag, dur) {
var _local3 = _root.createEmptyMovieClip("shaker", _root.getNextHighestDepth());
_local3.mag = mag;
_local3.dur = dur;
_local3.durPassed = 0;
_local3.onEnterFrame = function () {
this.durPassed++;
if (this.durPassed < this.dur) {
this.mag = this.mag * 0.9;
_root.xOff = Math.floor(((Math.random() * this.mag) * 2) - this.mag);
_root.yOff = Math.floor(((Math.random() * this.mag) * 2) - this.mag);
} else {
_root.xOff = 0;
_root.yOff = 0;
removeMovieClip(this);
}
};
}
function testDoorParticle(ob, wall) {
if ((wall.door == null) || (!wall.door.locked)) {
return(undefined);
}
if ((wall.door.lockType == "PLASMA") && (ob.dam == 1)) {
unlockDoor(wall);
}
if ((wall.door.lockType == "SNIPER") && (ob.dam == 2)) {
unlockDoor(wall);
}
if ((wall.door.lockType == "GRENADE") && (ob.dam == 3)) {
unlockDoor(wall);
}
if ((wall.door.lockType == "FTHROWER") && (ob.dam == 5)) {
unlockDoor(wall);
}
}
function unlockDoor(wall) {
wall.door.locked = false;
wall.walkable = true;
removeMovieClip(wall.light);
wall.gotoAndStop("D_DOOR_O");
if (sound) {
soundExplode.start();
}
shakeScreen(3, 10);
}
function getMyCorners(x, y, ob) {
ob.downY = Math.floor(((y + ob.height) - 1) / game.tileH);
ob.upY = Math.floor((y - ob.height) / game.tileH);
ob.leftX = Math.floor((x - ob.width) / game.tileW);
ob.rightX = Math.floor(((x + ob.width) - 1) / game.tileW);
ob.upleft = tileHolder[(("t_" + ob.upY) + "_") + ob.leftX].walkable;
ob.downleft = tileHolder[(("t_" + ob.downY) + "_") + ob.leftX].walkable;
ob.upright = tileHolder[(("t_" + ob.upY) + "_") + ob.rightX].walkable;
ob.downright = tileHolder[(("t_" + ob.downY) + "_") + ob.rightX].walkable;
}
function moveOb(ob, vx, vy) {
getMyCorners(ob.x, ob.y + vy, ob);
ob.xtile = Math.floor(ob.x / game.tileW);
ob.ytile = Math.floor(ob.y / game.tileH);
if (ob.life != null) {
testDoorParticle(ob, tileHolder[(("t_" + ob.ytile) + "_") + ob.xtile]);
}
if (vy < -0.1) {
if (ob.upleft && (ob.upright)) {
ob.y = ob.y + vy;
} else {
ob.y = (ob.ytile * game.tileH) + ob.height;
if (ob.enType != null) {
ob.vy = ob.vy * -1;
}
if (ob.hitWalls) {
if (ob.life != null) {
ob.life = 0;
testDoorParticle(ob, tileHolder[(("t_" + (ob.ytile - 1)) + "_") + ob.xtile]);
}
} else if (ob.life > 0) {
ob.vy = ob.vy * -0.8;
}
}
}
if (vy > 0.1) {
if (ob.downleft && (ob.downright)) {
ob.y = ob.y + vy;
} else {
ob.y = ((ob.ytile + 1) * game.tileH) - ob.height;
if (ob.enType != null) {
ob.vy = ob.vy * -1;
}
if (ob.hitWalls) {
if (ob.life != null) {
ob.life = 0;
testDoorParticle(ob, tileHolder[(("t_" + (ob.ytile + 1)) + "_") + ob.xtile]);
}
} else if (ob.life > 0) {
ob.vy = ob.vy * -0.8;
}
}
}
getMyCorners(ob.x + vx, ob.y, ob);
if (vx < -0.1) {
if (ob.downleft && (ob.upleft)) {
ob.x = ob.x + vx;
} else {
ob.x = (ob.xtile * game.tileW) + ob.width;
if (ob.enType != null) {
ob.vx = ob.vx * -1;
}
if (ob.hitWalls) {
if (ob.life != null) {
ob.life = 0;
testDoorParticle(ob, tileHolder[(("t_" + ob.ytile) + "_") + (ob.xtile - 1)]);
}
} else if (ob.life > 0) {
ob.vx = ob.vx * -0.8;
}
}
}
if (vx > 0.1) {
if (ob.upright && (ob.downright)) {
ob.x = ob.x + vx;
} else {
ob.x = ((ob.xtile + 1) * game.tileW) - ob.width;
if (ob.enType != null) {
ob.vx = ob.vx * -1;
}
if (ob.hitWalls) {
if (ob.life != null) {
ob.life = 0;
testDoorParticle(ob, tileHolder[(("t_" + ob.ytile) + "_") + (ob.xtile + 1)]);
}
} else if (ob.life > 0) {
ob.vx = ob.vx * -0.8;
}
}
}
ob.xSubTile = Math.floor(ob.x / game.subTileW);
ob.ySubTile = Math.floor(ob.y / game.subTileH);
var _local5 = Math.floor(ob.x / game.tileW);
var _local4 = Math.floor(ob.y / game.tileH);
if (DEBUG) {
ob.tile._x = ob.xSubTile * game.subTileW;
ob.tile._y = ob.ySubTile * game.subTileH;
}
if (ob.stun > 0) {
ob.stun--;
if (ob != player) {
ob.vx = ob.vx * 0.9;
ob.vy = ob.vy * 0.9;
if (ob.stun == 1) {
ob.vx = ob.vxFunc;
ob.vy = ob.vyFunc;
}
}
if (((Math.floor(ob.stun / 4) % 2) == 0) && (ob.stun > 2)) {
ob.clip.transform.colorTransform = whiteFlash;
whiteFlash.rgb = 16777215 /* 0xFFFFFF */;
} else {
ob.clip.transform.colorTransform = noFlash;
if (ob.enType == "BOSS") {
ob.clip.transform.colorTransform = ob.colour;
}
}
}
ob.clip._x = Math.floor(ob.x);
ob.clip._y = Math.floor(ob.y);
}
function controlPlayer() {
if (control) {
if (Key.isDown(37)) {
leftKey = true;
} else {
leftKey = false;
}
if (Key.isDown(39)) {
rightKey = true;
} else {
rightKey = false;
}
if (Key.isDown(38)) {
upKey = true;
} else {
upKey = false;
}
if (Key.isDown(40)) {
downKey = true;
} else {
downKey = false;
}
} else {
leftKey = false;
rightKey = false;
upKey = false;
downKey = false;
}
var _local3;
if (player.recharge < 0) {
shooting = true;
} else {
shooting = false;
}
if ((((((!shooting) && (!attacking)) && (leftKey)) || (((!shooting) && (!attacking)) && (rightKey))) || (((!shooting) && (!attacking)) && (upKey))) || (((!shooting) && (!attacking)) && (downKey))) {
if (leftKey) {
player.clip.gotoAndStop("LEFT");
player.facingX = -1;
player.facingY = 0;
} else if (rightKey) {
player.clip.gotoAndStop("RIGHT");
player.facingX = 1;
player.facingY = 0;
} else if (upKey) {
player.clip.gotoAndStop("UP");
player.facingX = 0;
player.facingY = -1;
} else if (downKey) {
player.clip.gotoAndStop("DOWN");
player.facingX = 0;
player.facingY = 1;
}
_local3 = player.speed;
player.clip.anim.gotoAndStop("WALK");
} else if (player.recharge < 0) {
player.clip.anim.gotoAndStop("SHOOT");
_local3 = 0;
} else if (attacking) {
player.clip.anim.gotoAndStop("ATTACK");
_local3 = 0;
i = 0;
while (i < game.enemyList.length) {
if (en.stun <= 0) {
if ((((player.xSubTile + player.facingX) == game.enemyList[i].xSubTile) && ((player.ySubTile + player.facingY) == game.enemyList[i].ySubTile)) && (game.enemyList[i].alive)) {
if (game.enemyList[i].enType == "GRANMA") {
attacking = false;
soundSword.stop();
player.clip.anim.gotoAndStop("STOP");
if (player.hp == player.maxHp) {
displayText("GRANMA: OFF YOU GO THEN!!");
} else {
displayText("GRANMA: UH OH! DID YOU HIT YOUR HEAD? LET ME BANDAGE THAT.");
player.hp = player.maxHp;
displayBars();
}
break;
}
applyDamage(game.enemyList[i], player, 1);
}
}
i++;
}
i = 0;
while (i < game.containerList.length) {
cont = game.containerList[i];
pX = player.x + (player.facingX * game.subTileW);
tX = Math.floor(pX / game.tileW);
pY = player.y + (player.facingY * game.subTileH);
tY = Math.floor(pY / game.tileH);
if ((tX == cont.xtile) && (tY == cont.ytile)) {
tileHolder[(("t_" + cont.ytile) + "_") + cont.xtile].walkable = true;
if (cont.clip._visible) {
if (cont.contType == "HP") {
var _local2 = Math.floor(Math.random() * 5) + 1;
i = 0;
while (i < _local2) {
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
addParticle("HPDROP", cont.x + (game.tileW / 2), cont.y + (game.tileH / 2), vx, vy, 0.9, -2, 1000, false);
i++;
}
}
if (cont.contType == "HPUP") {
vx = (Math.random() * 2) - 1;
vy = (Math.random() * 2) - 1;
addParticle("HPUPDROP", cont.x + (game.tileW / 2), cont.y + (game.tileH / 2), vx, vy, 0.9, -50, 10000, false);
}
if (cont.contType == "PLUP") {
vx = (Math.random() * 2) - 1;
vy = (Math.random() * 2) - 1;
addParticle("PLUPDROP", cont.x + (game.tileW / 2), cont.y + (game.tileH / 2), vx, vy, 0.9, -51, 10000, false);
}
var i = 0;
while (i < 8) {
pType = "SMOKE" + Math.floor((Math.random() * 3) + 1);
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
addParticle(pType, cont.x + (game.tileW / 2), cont.y + (game.tileH / 2), vx, vy, 0.95, 0, 15, true);
i++;
}
if (sound) {
soundExplode.start();
}
}
cont.collected = true;
cont.clip._visible = false;
}
i++;
}
if ((boss != null) && (boss.killMode)) {
var _local1;
i = 0;
while (i < 5) {
_local1 = -2 + i;
if (((player.xSubTile + player.facingX) == (boss.xSubTile + _local1)) && ((player.ySubTile + player.facingY) == (boss.ySubTile - 1))) {
applyDamage(boss, player, 1);
}
i++;
}
i = 0;
while (i < 5) {
_local1 = -2 + i;
if (((player.xSubTile + player.facingX) == (boss.xSubTile + _local1)) && ((player.ySubTile + player.facingY) == boss.ySubTile)) {
applyDamage(boss, player, 1);
}
i++;
}
i = 0;
while (i < 5) {
_local1 = -2 + i;
if (((player.xSubTile + player.facingX) == (boss.xSubTile + _local1)) && ((player.ySubTile + player.facingY) == (boss.ySubTile + 1))) {
applyDamage(boss, player, 1);
}
i++;
}
}
} else {
_local3 = 0;
player.clip.anim.gotoAndStop("STOP");
}
var _local5 = (player.facingX * _local3) - player.vx;
var _local4 = (player.facingY * _local3) - player.vy;
player.vx = player.vx + (_local5 / 4);
player.vy = player.vy + (_local4 / 4);
}
var DEBUG = false;
var run = true;
var control = false;
var firstRun = true;
var bossShow = true;
var finishedGame = false;
if (DEBUG) {
control = true;
firstRun = false;
bossShow = false;
}
var whiteFlash = (new flash.geom.ColorTransform());
whiteFlash.rgb = 16777215 /* 0xFFFFFF */;
var yellowFlash = (new flash.geom.ColorTransform());
yellowFlash.rgb = 16777062 /* 0xFFFF66 */;
var noFlash = (new flash.geom.ColorTransform());
var game = new Object();
game.tileW = 64;
game.tileH = 64;
game.subTileW = 32;
game.subTileH = 32;
game.driftSpeed = 0.2;
game.kickMod = 3;
game.friction = 0.9;
game.walkWidth = Stage.width / 4;
game.walkHeight = Stage.width / 4;
game.visX = 7;
game.visY = 6;
var leftKey = false;
var rightKey = false;
var upKey = false;
var downKey = false;
var attacking = false;
var shooting = false;
var xOff = 0;
var yOff = 0;
var mapWidth = 0;
var mapHeight = 0;
var boss;
var gunOrdered = ["GRENADE", "SNIPER", "FTHROWER"];
var gunMixed = new Array();
while (gunOrdered.length > 0) {
var cutAt = Math.floor(Math.random() * gunOrdered.length);
gun = gunOrdered.splice(cutAt, 1);
gunMixed.push(gun.toString());
}
plasmaGun = new Object();
plasmaGun.damage = 1;
plasmaGun.bulletSpeed = 6;
plasmaGun.bulletFric = 1;
plasmaGun.sprite = "PLASMA";
plasmaGun.bulletLife = 50;
plasmaGun.shootSpeed = 0;
plasmaGun.drain = 1;
plasmaGun.hitWalls = true;
grenadeGun = new Object();
grenadeGun.damage = -5;
grenadeGun.bulletSpeed = 10;
grenadeGun.bulletFric = 0.95;
grenadeGun.sprite = "GRENADE";
grenadeGun.bulletLife = 60;
grenadeGun.shootSpeed = 20;
grenadeGun.drain = 2;
grenadeGun.hitWalls = true;
sniperGun = new Object();
sniperGun.damage = 2;
sniperGun.bulletSpeed = 10;
sniperGun.bulletFric = 1;
sniperGun.sprite = "SNIPER";
sniperGun.bulletLife = 40;
sniperGun.shootSpeed = 20;
sniperGun.drain = 2;
sniperGun.hitWalls = true;
fthrowerGun = new Object();
fthrowerGun.damage = 5;
fthrowerGun.bulletSpeed = 15;
fthrowerGun.bulletFric = 0.83;
fthrowerGun.sprite = "FTHROWER";
fthrowerGun.bulletLife = 30;
fthrowerGun.shootSpeed = 20;
fthrowerGun.drain = 2;
fthrowerGun.hitWalls = true;
teleportGun = new Object();
teleportGun.damage = -10;
teleportGun.bulletSpeed = 25;
teleportGun.bulletFric = 0.96;
teleportGun.sprite = "TELEPORT";
teleportGun.bulletLife = 50;
teleportGun.shootSpeed = 50;
teleportGun.drain = 3;
teleportGun.hitWalls = false;
game.rolyPolyHP = 1;
game.rolyPolySpeed = 2;
game.rolyPolyDrop = 2;
game.rolyPolyDamage = 1;
game.thumperHP = 4;
game.thumperSpeed = 2;
game.thumperDrop = 4;
game.thumperDamage = 1;
game.skitterHP = 2;
game.skitterSpeed = 4;
game.skitterDrop = 3;
game.skitterGun = plasmaGun;
var door0 = new Object();
var door1 = new Object();
var door2 = new Object();
var door3 = new Object();
var door4 = new Object();
var door5 = new Object();
var door6 = new Object();
var door7 = new Object();
var door8 = new Object();
var door9 = new Object();
var door10 = new Object();
var door11 = new Object();
var door12 = new Object();
var door13 = new Object();
var door14 = new Object();
var door15 = new Object();
var door16 = new Object();
var door17 = new Object();
var door18 = new Object();
var door19 = new Object();
door0.playerGo = [door1, 1, 0];
door0.pos = [0, 0];
door0.locked = false;
door0.lockType = "NONE";
door1.playerGo = [door0, -1, 0];
door1.pos = [0, 0];
door1.locked = false;
door1.lockType = "NONE";
door2.playerGo = [door3, 1, 0];
door2.pos = [0, 0];
door2.locked = false;
door2.lockType = "NONE";
door3.playerGo = [door2, -1, 0];
door3.pos = [0, 0];
door3.locked = false;
door3.lockType = "NONE";
door4.playerGo = [door5, 0, -1];
door4.pos = [0, 0];
door4.locked = true;
door4.lockType = "PLASMA";
door5.playerGo = [door4, 0, 1];
door5.pos = [0, 0];
door5.locked = false;
door5.lockType = "PLASMA";
door6.playerGo = [door7, 1, 0];
door6.pos = [0, 0];
door6.locked = true;
door6.lockType = "PLASMA";
door7.playerGo = [door6, -1, 0];
door7.pos = [0, 0];
door7.locked = false;
door7.lockType = "PLASMA";
door8.playerGo = [door9, 0, -1];
door8.pos = [0, 0];
door8.locked = true;
door8.lockType = gunMixed[0].toString();
door9.playerGo = [door8, 0, 1];
door9.pos = [0, 0];
door9.locked = false;
door9.lockType = gunMixed[0].toString();
door10.playerGo = [door11, 0, 1];
door10.pos = [0, 0];
door10.locked = false;
door10.lockType = "NONE";
door11.playerGo = [door10, 0, -1];
door11.pos = [0, 0];
door11.locked = false;
door11.lockType = "NONE";
door12.playerGo = [door13, 0, -1];
door12.pos = [0, 0];
door12.locked = true;
door12.lockType = gunMixed[0].toString();
door13.playerGo = [door12, 0, 1];
door13.pos = [0, 0];
door13.locked = false;
door13.lockType = gunMixed[0].toString();
door14.playerGo = [door15, -1, 0];
door14.pos = [0, 0];
door14.locked = true;
door14.lockType = gunMixed[1].toString();
door15.playerGo = [door14, 1, 0];
door15.pos = [0, 0];
door15.locked = false;
door15.lockType = gunMixed[1].toString();
door16.playerGo = [door17, -1, 0];
door16.pos = [0, 0];
door16.locked = true;
door16.lockType = gunMixed[1].toString();
door17.playerGo = [door16, 1, 0];
door17.pos = [0, 0];
door17.locked = false;
door17.lockType = gunMixed[1].toString();
door18.playerGo = [door19, 0, 1];
door18.pos = [0, 0];
door18.locked = true;
door18.lockType = gunMixed[2].toString();
door19.playerGo = [door18, 0, -1];
door19.pos = [0, 0];
door19.locked = false;
door19.lockType = gunMixed[2].toString();
makeRandomMap("homeMap", 9, 9, 0, "HOUSE");
addLandmark(homeMap, house, 0, 0, 0, 0);
addEnemySquad(homeMap, "GRANMA", 1, 1, 0);
makeRandomMap("townMap", 22, 21, 0, "TOWN");
addLandmark(townMap, town, 0, 0, 0, 0);
addEnemySquad(townMap, "ROLYPOLY", 2, 3, 5);
addEnemySquad(townMap, "ROLYPOLY", 2, 3, 5);
addEnemySquad(townMap, "ENDBOSSGLOATER", 1, 1, 0);
makeRandomMap("mapF1", 20, 20, 0, "FOREST");
addNoise(mapF1, 0.1, 2);
drawLines(mapF1, 8, 5, 3, 6, 1);
drawLines(mapF1, 4, 5, 2, 3, 1);
addLandmark(mapF1, doorF1_Town, 0, 0, 0, mapF1.height);
addLandmark(mapF1, doorF1_D1, mapF1.width, mapF1.width, 4, mapF1.height);
addLandmark(mapF1, doorF1_F2, 4, mapF1.width - 4, 0, 0);
addContainer(mapF1, "HP");
addContainer(mapF1, "HP");
addContainer(mapF1, "HPUP");
addEnemySquad(mapF1, "ROLYPOLY", 2, 3, 5);
addEnemySquad(mapF1, "ROLYPOLY", 4, 6, 5);
makeRandomMap("mapD1", 30, 30, 1, "DUNGEON");
addBoss(mapD1, "PLASMA");
drawLines(mapD1, 16, 20, 15, 25, 0);
drawLines(mapD1, 8, 20, 5, 15, 0);
drawLines(mapD1, 4, 50, 7, 12, 0);
drawLines(mapD1, 3, 30, 5, 8, 0);
addLandmark(mapD1, doorD1_F1, 0, 0, 0, mapD1.height);
addLandmark(mapD1, bossRoom, Math.floor(mapD1.width / 3) * 2, mapD1.width, 0, mapD1.height);
addContainer(mapD1, "HP");
addContainer(mapD1, "HP");
addContainer(mapD1, "HP");
addContainer(mapD1, "HP");
addContainer(mapD1, "HPUP");
addEnemySquad(mapD1, "ROLYPOLY", 2, 3, 5);
addEnemySquad(mapD1, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapD1, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapD1, "THUMPER", 2, 3, 5);
makeRandomMap("mapF2", 15, 35, 0, "FOREST");
addNoise(mapF2, 0.1, 2);
drawLines(mapF2, 8, 5, 3, 6, 1);
drawLines(mapF2, 4, 5, 2, 3, 1);
addLandmark(mapF2, doorF2_F1, 0, mapF2.width, mapF2.height, mapF2.height);
addLandmark(mapF2, doorF2_D2, mapF2.width, mapF2.width, 0, mapF2.height);
addEnemySquad(mapF2, "ROLYPOLY", 2, 3, 5);
addEnemySquad(mapF2, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapF2, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapF2, "THUMPER", 2, 3, 5);
addEnemySquad(mapF2, "THUMPER", 3, 4, 5);
addContainer(mapF2, "HP");
addContainer(mapF2, "HP");
addContainer(mapF2, "PLUP");
makeRandomMap("mapD2", 35, 20, 1, "DUNGEON");
addBoss(mapD2, gunMixed[0].toString());
drawLines(mapD2, 16, 20, 15, 25, 0);
drawLines(mapD2, 8, 20, 5, 15, 0);
drawLines(mapD2, 4, 50, 7, 12, 0);
drawLines(mapD2, 3, 30, 5, 8, 0);
addLandmark(mapD2, doorD2_F2, 0, 0, 0, mapD2.height);
addLandmark(mapD2, bossRoom, Math.floor(mapD2.width / 3) * 2, mapD2.width, 0, mapD2.height);
addEnemySquad(mapD2, "ROLYPOLY", 5, 6, 5);
addEnemySquad(mapD2, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapD2, "ROLYPOLY", 5, 6, 5);
addEnemySquad(mapD2, "THUMPER", 5, 6, 5);
addEnemySquad(mapD2, "THUMPER", 5, 6, 5);
addEnemySquad(mapD2, "THUMPER", 5, 6, 5);
addContainer(mapD2, "HP");
addContainer(mapD2, "HP");
addContainer(mapD2, "HP");
addContainer(mapD2, "HP");
addContainer(mapD2, "HPUP");
addContainer(mapD2, "PLUP");
makeRandomMap("mapF3", 40, 15, 0, "FOREST");
addNoise(mapF3, 0.1, 2);
drawLines(mapF3, 8, 5, 3, 6, 1);
drawLines(mapF3, 4, 5, 2, 3, 1);
drawLines(mapF3, 16, 10, 20, 30, 0);
addLandmark(mapF3, doorF3_town, 30, mapF3.width, mapF3.height, mapF3.height);
addLandmark(mapF3, doorF3_D3, 0, 20, 0, 0);
addContainer(mapF3, "HP");
addContainer(mapF3, "HP");
addContainer(mapF3, "PLUP");
addEnemySquad(mapF3, "THUMPER", 5, 6, 5);
addEnemySquad(mapF3, "THUMPER", 5, 6, 5);
addEnemySquad(mapF3, "THUMPER", 5, 6, 5);
addEnemySquad(mapF3, "SKITTER", 3, 5, 5);
makeRandomMap("mapD3", 20, 20, 1, "DUNGEON");
addBoss(mapD3, gunMixed[1].toString());
drawLines(mapD3, 8, 60, 5, 15, 0);
drawLines(mapD3, 4, 50, 7, 12, 0);
drawLines(mapD3, 3, 30, 5, 8, 0);
addLandmark(mapD3, doorD3_F3, 0, mapD3.width, mapD3.height, mapD3.height);
addLandmark(mapD3, bossRoom, 8, 12, 0, 10);
addContainer(mapD3, "HP");
addContainer(mapD3, "HP");
addContainer(mapD3, "HP");
addContainer(mapD3, "HPUP");
addEnemySquad(mapD3, "THUMPER", 5, 6, 5);
addEnemySquad(mapD3, "SKITTER", 3, 5, 5);
addEnemySquad(mapD3, "SKITTER", 3, 5, 5);
makeRandomMap("mapF4", 20, 10, 0, "FOREST");
addNoise(mapF4, 0.15, 2);
drawLines(mapF4, 4, 5, 2, 3, 1);
addLandmark(mapF4, doorF4_Town, mapF4.width, mapF4.width, 0, mapF4.height);
addLandmark(mapF4, doorF4_D4, 0, 0, 0, mapF4.height);
addContainer(mapF4, "HPUP");
addContainer(mapF4, "PLUP");
makeRandomMap("mapD4", 20, 25, 1, "DUNGEON");
addBoss(mapD4, gunMixed[2].toString());
drawLines(mapD4, 8, 60, 5, 15, 0);
drawLines(mapD4, 4, 50, 7, 12, 0);
drawLines(mapD4, 3, 30, 5, 8, 0);
addLandmark(mapD4, doorD4_F4, mapD4.width, mapD4.width, 0, mapD4.height);
addLandmark(mapD4, bossRoom, 0, mapD4.width / 2, 0, mapD4.height);
addEnemySquad(mapD4, "ROLYPOLY", 3, 3, 5);
addEnemySquad(mapD4, "THUMPER", 3, 3, 5);
addEnemySquad(mapD4, "THUMPER", 3, 3, 5);
addEnemySquad(mapD4, "SKITTER", 3, 4, 5);
addEnemySquad(mapD4, "SKITTER", 3, 4, 5);
makeRandomMap("mapD5", 70, 30, 1, "DUNGEON");
addBoss(mapD5, "FINAL");
drawLines(mapD5, 16, 80, 20, 35, 0);
drawLines(mapD5, 8, 80, 10, 20, 0);
drawLines(mapD5, 4, 80, 10, 15, 0);
drawLines(mapD5, 3, 50, 5, 10, 0);
addLandmark(mapD5, doorD5_Town, 0, 20, 0, 0);
addLandmark(mapD5, bossRoom, 50, mapD5.width, 0, mapD5.height);
addEnemySquad(mapD5, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapD5, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapD5, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapD5, "ROLYPOLY", 4, 6, 5);
addEnemySquad(mapD5, "THUMPER", 5, 7, 5);
addEnemySquad(mapD5, "THUMPER", 5, 7, 5);
addEnemySquad(mapD5, "THUMPER", 5, 7, 5);
addEnemySquad(mapD5, "SKITTER", 3, 4, 5);
addEnemySquad(mapD5, "SKITTER", 3, 4, 5);
addEnemySquad(mapD5, "SKITTER", 3, 4, 5);
addEnemySquad(mapD5, "SKITTER", 3, 4, 5);
addContainer(mapD5, "HPUP");
addContainer(mapD5, "PLUP");
addContainer(mapD5, "HP");
addContainer(mapD5, "HP");
addContainer(mapD5, "HP");
addContainer(mapD5, "HP");
addContainer(mapD5, "HP");
door0.mapTo = mapF1;
door1.mapTo = townMap;
door2.mapTo = mapD1;
door3.mapTo = mapF1;
door4.mapTo = mapF2;
door5.mapTo = mapF1;
door6.mapTo = mapD2;
door7.mapTo = mapF2;
door8.mapTo = mapF3;
door9.mapTo = townMap;
door10.mapTo = townMap;
door11.mapTo = homeMap;
door12.mapTo = mapD3;
door13.mapTo = mapF3;
door14.mapTo = mapF4;
door15.mapTo = townMap;
door16.mapTo = mapD4;
door17.mapTo = mapF4;
door18.mapTo = mapD5;
door19.mapTo = townMap;
var player = new Object();
player.maxHp = 3;
player.hp = player.maxHp;
player.maxPl = 3;
player.pl = player.maxPl;
player.stun = 0;
player.charge = 0;
player.xtile = 3;
player.ytile = 6;
player.xSubTile = 0;
player.ySubTile = 0;
player.speed = 7;
player.facingX = new Number();
player.facingY = new Number();
player.vx = 0;
player.vy = 0;
player.height = 12;
player.width = 12;
if (DEBUG) {
player.tile = tileHolder.attachMovie("subTile", "playerSubTile", tileHolder.getNextHighestDepth());
}
player.x = (player.xtile * game.tileW) + (game.tileW / 2);
player.y = (player.ytile * game.tileH) + (game.tileH / 2);
tileHolder._x = (Stage.width / 2) - (tileSize / 2);
tileHolder._y = (Stage.height / 2) - (tileSize / 2);
player.recharge = 0;
player.gunList = new Array();
player.currentGun = 0;
if (DEBUG) {
player.maxHp = 10;
player.hp = player.maxHp;
player.maxPl = 10;
player.pl = player.maxPl;
player.gunList.push(plasmaGun);
player.gunList.push(grenadeGun);
player.gunList.push(fthrowerGun);
player.gunList.push(sniperGun);
}
player.gun = player.gunList[0];
loadMap(homeMap);
_root.onEnterFrame = function () {
if (run) {
controlPlayer();
player.recharge++;
moveOb(player, player.vx, player.vy);
var _local11 = (("t_" + player.ytile) + "_") + player.xtile;
if (tileHolder[_local11].door != null) {
var _local14 = tileHolder[_local11].door.playerGo[0];
player.xtile = _local14.pos[0] + tileHolder[_local11].door.playerGo[1];
player.ytile = _local14.pos[1] + tileHolder[_local11].door.playerGo[2];
loadMap(tileHolder[_local11].door.mapTo);
run = false;
}
if ((player.x > (Stage.width / 2)) && (player.x < (mapWidth - (Stage.width / 2)))) {
tileHolder._x = ((Stage.width / 2) - player.clip._x) + xOff;
} else if (player.x < ((Stage / width) / 2)) {
tileHolder._x = 0;
} else if (player.x > (mapWidth - (Stage.width / 2))) {
tileHolder._x = Stage.width - mapWidth;
}
if ((player.y > (Stage.height / 2)) && (player.y < (mapHeight - (Stage.height / 2)))) {
tileHolder._y = ((Stage.height / 2) - player.clip._y) + yOff;
} else if (player.y < (Stage.height / 2)) {
tileHolder._y = 0;
} else if (player.y > (mapHeight - (Stage.height / 2))) {
tileHolder._y = Stage.height - mapHeight;
}
if (((tileHolder[_local11].boss != null) && (!boss.clip._visible)) && (boss.alive)) {
boss.clip._visible = true;
boss.clip.play();
removeMovieClip(boss.glowTile);
if (sound) {
soundSwitch.start();
}
if (boss.tpe == "FINAL") {
displayText("WARLORD: I SEE YOUVE COME ALL THIS WAY JUST TO DIE!! AND TO THINK YOU COULD HAVE BEEN PLAYING OUTSIDE!!");
}
}
if ((boss != null) && (boss.killMode)) {
moveOb(boss, boss.vx, boss.vy);
boss.behave++;
if (boss.stun <= 0) {
var _local16 = ((boss.mv[boss.mvId][0] * game.tileW) + (boss.xtileStart * game.tileW)) + 16;
var _local15 = ((boss.mv[boss.mvId][1] * game.tileH) + (boss.ytileStart * game.tileH)) + 16;
var _local7 = _local16 - boss.x;
var _local6 = _local15 - boss.y;
if (Math.sqrt(_local7 * _local7) < boss.speed) {
boss.vx = _local7 / 20;
} else {
if (_local7 < 0) {
boss.vx = -boss.speed;
}
if (_local7 > 0) {
boss.vx = boss.speed;
}
}
if (Math.sqrt(_local6 * _local6) < boss.speed) {
boss.vy = _local6 / 20;
} else {
if (_local6 < 0) {
boss.vy = -boss.speed;
}
if (_local6 > 0) {
boss.vy = boss.speed;
}
}
if (boss.behave > boss.mvSpeed) {
boss.mvId++;
if (boss.mvId >= (boss.mv.length - 1)) {
boss.mvId = 0;
}
if (Math.sqrt(boss.vx * boss.vx) < Math.sqrt(boss.vy * boss.vy)) {
if (_local7 > 0) {
_local7 = -boss.gun.bulletSpeed;
} else {
_local7 = boss.gun.bulletSpeed;
}
_local6 = 0;
} else {
if (_local6 > 0) {
_local6 = -boss.gun.bulletSpeed;
} else {
_local6 = boss.gun.bulletSpeed;
}
_local7 = 0;
}
if ((boss.tpe == "GRENADE") || ((boss.tpe == "FINAL") && (boss.randomNum == 1))) {
addParticle(boss.gun.sprite, boss.x, boss.y, 0, 0, boss.gun.bulletFric, -31, boss.gun.bulletLife, boss.gun.hitWalls);
} else {
addParticle(boss.gun.sprite, boss.x, boss.y, _local7, _local6, boss.gun.bulletFric, -30, boss.gun.bulletLife, boss.gun.hitWalls);
}
if (sound) {
soundGunPlasma.start();
}
boss.behave = 0;
}
if (boss.vy == 0) {
_local6 = ((boss.ySubTile * 32) + 16) - boss.y;
boss.y = boss.y + (_local6 / 20);
}
if (game.enemyList[i].vx == 0) {
_local7 = ((boss.xSubTile * 32) + 16) - boss.x;
boss.x = boss.x + (_local7 / 20);
}
var _local4;
i = 0;
while (i < 5) {
_local4 = -2 + i;
if ((player.xSubTile == (boss.xSubTile + _local4)) && (player.ySubTile == (boss.ySubTile - 1))) {
applyDamage(player, boss, 1);
}
i++;
}
i = 0;
while (i < 5) {
_local4 = -2 + i;
if ((player.xSubTile == (boss.xSubTile + _local4)) && (player.ySubTile == boss.ySubTile)) {
applyDamage(player, boss, 1);
}
i++;
}
i = 0;
while (i < 5) {
_local4 = -2 + i;
if ((player.xSubTile == (boss.xSubTile + _local4)) && (player.ySubTile == (boss.ySubTile + 1))) {
applyDamage(player, boss, 1);
}
i++;
}
if ((!boss.alive) && (boss.tpe != "FINAL")) {
shakeScreen(128, 60);
var _local12 = Math.floor(Math.random() * 10) + 4;
var i = 0;
while (i < _local12) {
pType = "PART" + Math.floor((Math.random() * 5) + 1);
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
addParticle(pType, boss.x, boss.y, vx, vy, 0.95, 0, 40, false);
i++;
}
var i = 0;
while (i < 20) {
pType = "SMOKE" + Math.floor((Math.random() * 3) + 1);
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
addParticle(pType, boss.x, boss.y, vx, vy, 0.95, 0, 30, false);
pType = "EXPLODE1";
vx = (Math.random() * 8) - 4;
vy = (Math.random() * 8) - 4;
addParticle(pType, boss.x, boss.y, vx, vy, 0.97, 3, 30, true);
i++;
}
var _local10 = Math.floor(Math.random() * 2) + 2;
i = 0;
while (i < _local10) {
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
addParticle("HPDROP", boss.x, boss.y, vx, vy, 0.9, -2, 1000, false);
i++;
}
var _local13 = Math.floor(Math.random() * 3) + 2;
i = 0;
while (i < _local13) {
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
addParticle("PLASMADROP", boss.x, boss.y, vx, vy, 0.9, -1, 200, false);
i++;
}
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
if (boss.tpe == "PLASMA") {
addParticle("GUNDROP", boss.x, boss.y, vx, vy, 0.9, -1000, 100000, false);
}
if (boss.tpe == "SNIPER") {
addParticle("GUNDROP", boss.x, boss.y, vx, vy, 0.9, -1001, 100000, false);
}
if (boss.tpe == "GRENADE") {
addParticle("GUNDROP", boss.x, boss.y, vx, vy, 0.9, -1002, 100000, false);
}
if (boss.tpe == "FTHROWER") {
addParticle("GUNDROP", boss.x, boss.y, vx, vy, 0.9, -1003, 100000, false);
}
if (sound) {
soundExplode.start();
}
removeMovieClip(boss.clip);
boss.killMode = false;
if (boss.tpe == "DEADDEADDEAD") {
boss.behave = 0;
finishedGame = true;
}
} else if ((!boss.alive) && (boss.tpe == "FINAL")) {
shakeScreen(32, 60);
boss.clip.gotoAndPlay("TRANSFORM");
boss.killMode = false;
boss.randomNum = Math.floor(Math.random() * 3);
if (boss.randomNum == 0) {
boss.mv = [[-1, 0], [-1, -3], [-1, -3], [0, -3], [2, -3], [2, -3], [2, 0], [2, 3], [2, 3], [0, 3], [-1, 3], [-1, 3]];
boss.mvSpeed = 25;
boss.speed = 5;
boss.gun = sniperGun;
} else if (boss.randomNum == 1) {
boss.mv = [[-1, -3], [2, -3], [2, -1], [-1, -1], [-1, 1], [2, 1], [2, 3], [-1, 3], [-1, 0]];
boss.mvSpeed = 50;
boss.speed = 5;
boss.gun = grenadeGun;
} else {
boss.mv = [[-1, -3], [-1, -2], [-1, -1], [-1, 0], [-1, 1], [-1, 2], [-1, 3], [2, -3], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2], [2, 3]];
boss.mvSpeed = 20;
boss.speed = 5;
boss.gun = fthrowerGun;
}
boss.trans++;
boss.hp = 6 + boss.trans;
boss.alive = true;
if (boss.trans > 3) {
boss.alive = false;
boss.tpe = "DEADDEADDEAD";
}
}
}
}
if ((boss.tpe == "DEADDEADDEAD") && (!boss.killMode)) {
boss.behave++;
if (boss.behave > 120) {
player.xtile = 6;
player.ytile = 5;
loadMap(homeMap);
run = false;
}
}
var _local9;
i = 0;
while (i < game.enemyList.length) {
var _local7 = player.x - game.enemyList[i].x;
var _local6 = player.y - game.enemyList[i].y;
_local9 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
if ((_local9 < 500) && (game.enemyList[i].alive)) {
moveOb(game.enemyList[i], game.enemyList[i].vx, game.enemyList[i].vy);
if (game.enemyList[i].stun <= 0) {
if (game.enemyList[i].vy == 0) {
_local6 = ((game.enemyList[i].ySubTile * 32) + 16) - game.enemyList[i].y;
game.enemyList[i].y = game.enemyList[i].y + (_local6 / 20);
}
if (game.enemyList[i].vx == 0) {
_local7 = ((game.enemyList[i].xSubTile * 32) + 16) - game.enemyList[i].x;
game.enemyList[i].x = game.enemyList[i].x + (_local7 / 20);
}
if (game.enemyList[i].hp <= 0) {
game.enemyList[i].id = i;
killOb(game.enemyList[i]);
}
}
var _local5 = Math.sqrt(game.enemyList[i].vx * game.enemyList[i].vx);
var _local8 = Math.sqrt(game.enemyList[i].vy * game.enemyList[i].vy);
if (game.enemyList[i].enType == "ROLYPOLY") {
if (_local5 > _local8) {
game.enemyList[i].clip.gotoAndStop("LR");
} else {
game.enemyList[i].clip.gotoAndStop("UD");
}
if (game.enemyList[i].stun <= 0) {
if ((player.xSubTile == game.enemyList[i].xSubTile) && (player.ySubTile == game.enemyList[i].ySubTile)) {
applyDamage(player, game.enemyList[i], game.enemyList[i].damage);
}
}
}
if (game.enemyList[i].enType == "THUMPER") {
if (game.enemyList[i].stun <= 0) {
if (game.enemyList[i].vx < 0) {
_local7 = -1;
} else if (game.enemyList[i].vx > 0) {
_local7 = 1;
} else {
_local7 = 0;
}
if (game.enemyList[i].vy < 0) {
_local6 = -1;
} else if (game.enemyList[i].vy > 0) {
_local6 = 1;
} else {
_local6 = 0;
}
if ((player.xSubTile == game.enemyList[i].xSubTile) && (player.ySubTile == game.enemyList[i].ySubTile)) {
applyDamage(player, game.enemyList[i], game.enemyList[i].damage);
}
if ((player.xSubTile == (game.enemyList[i].xSubTile + _local7)) && (player.ySubTile == (game.enemyList[i].ySubTile + _local6))) {
applyDamage(player, game.enemyList[i], game.enemyList[i].damage);
}
if ((player.xSubTile == (game.enemyList[i].xSubTile - _local7)) && (player.ySubTile == (game.enemyList[i].ySubTile - _local6))) {
applyDamage(player, game.enemyList[i], game.enemyList[i].damage);
}
if ((_local6 == 0) && (_local7 == -1)) {
game.enemyList[i].clip.gotoAndStop("LEFT");
}
if ((_local6 == 0) && (_local7 == 1)) {
game.enemyList[i].clip.gotoAndStop("RIGHT");
}
if ((_local6 == -1) && (_local7 == 0)) {
game.enemyList[i].clip.gotoAndStop("UP");
}
if ((_local6 == 1) && (_local7 == 0)) {
game.enemyList[i].clip.gotoAndStop("DOWN");
}
}
}
if (game.enemyList[i].enType == "SKITTER") {
if (game.enemyList[i].stun <= 0) {
game.enemyList[i].behave++;
if ((game.enemyList[i].behave > 40) && (game.enemyList[i].behave < 60)) {
if (game.enemyList[i].vxFunc == 1) {
game.enemyList[i].clip.gotoAndStop("STAND_RIGHT");
} else if (game.enemyList[i].vxFunc == -1) {
game.enemyList[i].clip.gotoAndStop("STAND_LEFT");
} else if (game.enemyList[i].vyFunc == -1) {
game.enemyList[i].clip.gotoAndStop("STAND_UP");
} else if (game.enemyList[i].vyFunc == 1) {
game.enemyList[i].clip.gotoAndStop("STAND_DOWN");
}
game.enemyList[i].vxFunc = 0;
game.enemyList[i].vyFunc = 0;
game.enemyList[i].vx = game.enemyList[i].vx * 0.8;
game.enemyList[i].vy = game.enemyList[i].vy * 0.8;
}
if (game.enemyList[i].behave > 60) {
dir = Math.random();
if (dir < 0.25) {
game.enemyList[i].vxFunc = 1 * game.skitterSpeed;
game.enemyList[i].vyFunc = 0;
} else if ((dir >= 0.25) && (dir < 0.5)) {
game.enemyList[i].vxFunc = -1 * game.skitterSpeed;
game.enemyList[i].vyFunc = 0;
} else if ((dir >= 0.5) && (dir < 0.75)) {
game.enemyList[i].vxFunc = 0;
game.enemyList[i].vyFunc = 1 * game.skitterSpeed;
} else {
game.enemyList[i].vxFunc = 0;
game.enemyList[i].vyFunc = -1 * game.skitterSpeed;
}
game.enemyList[i].vx = game.enemyList[i].vxFunc;
game.enemyList[i].vy = game.enemyList[i].vyFunc;
game.enemyList[i].behave = Math.floor(Math.random() * 10);
dir = Math.random();
if (dir < 0.25) {
shootX = 1 * game.enemyList[i].gun.bulletSpeed;
shootY = 0;
game.enemyList[i].clip.gotoAndStop("WALK_RIGHT");
} else if ((dir >= 0.25) && (dir < 0.5)) {
shootX = -1 * game.enemyList[i].gun.bulletSpeed;
shootY = 0;
game.enemyList[i].clip.gotoAndStop("WALK_LEFT");
} else if ((dir >= 0.5) && (dir < 0.75)) {
shootX = 0;
shootY = 1 * game.enemyList[i].gun.bulletSpeed;
game.enemyList[i].clip.gotoAndStop("WALK_DOWN");
} else {
shootX = 0;
shootY = -1 * game.enemyList[i].gun.bulletSpeed;
game.enemyList[i].clip.gotoAndStop("WALK_UP");
}
addParticle(game.enemyList[i].gun.sprite, game.enemyList[i].x, game.enemyList[i].y, shootX, shootY, game.enemyList[i].gun.bulletFric, -30, game.enemyList[i].gun.bulletLife, game.enemyList[i].gun.hitWalls);
}
if ((player.xSubTile == game.enemyList[i].xSubTile) && (player.ySubTile == game.enemyList[i].ySubTile)) {
applyDamage(player, game.enemyList[i], 1);
}
}
}
if (game.enemyList[i].enType == "GRANMA") {
if ((game.enemyList[i].ytile < 5) && (game.enemyList[i].behave == 0)) {
game.enemyList[i].vx = 0;
game.enemyList[i].vy = 2;
game.enemyList[i].clip.gotoAndStop("WALK");
_root.control = false;
player.vx = 0;
player.vy = 0;
} else if ((game.enemyList[i].behave >= 0) && (game.enemyList[i].behave <= 5)) {
if (game.enemyList[i].behave == 0) {
game.enemyList[i].vx = 0;
game.enemyList[i].vy = 0;
game.enemyList[i].clip.gotoAndStop("STAND");
displayText("GRANMA: I THOUGHT YOU WOULD NEVER WAKE UP, DEAR!");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 1) {
game.enemyList[i].clip.gotoAndStop("STAND");
displayText("GRANMA: A ROBOT WARLORD DESTROYED THE ENTIRE TOWN WHILE YOU WERE ASLEEP.");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 2) {
game.enemyList[i].clip.gotoAndStop("STAND");
displayText("GRANMA: YOUD BETTER GO CLEAN UP THE MESS. GET RID OF THE WARLORD TOO, SINCE YOURE GOING OUT ANYWAY.");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 3) {
game.enemyList[i].clip.gotoAndStop("SWORD");
displayText("GRANMA: HERE, TAKE YOUR GRANDFATHERS OLD SWORD FROM THE WAR. YOULL NEED IT.");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 4) {
game.enemyList[i].clip.gotoAndStop("STAND");
displayText("GRANMA: STEAL SOME MORE FIREPOWER FROM THE ROBOTS, TOO. TRY IN THE FOREST TO THE EAST FIRST.");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 5) {
game.enemyList[i].clip.gotoAndStop("STAND");
displayText("GRANMA: GOOD LUCK! COME BACK HERE IF YOU NEED SOME HELP FROM YOUR OLD GRANDMA!");
game.enemyList[i].behave++;
_root.control = true;
_root.firstRun = false;
}
} else if (finishedGame) {
if (game.enemyList[i].behave == 10) {
game.enemyList[i].vx = 0;
game.enemyList[i].vy = 0;
game.enemyList[i].clip.gotoAndStop("STAND");
displayText("GRANMA: OH! YOUVE DEFEATED THE WARLORD! GOOD JOB!");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 11) {
game.enemyList[i].behave = 7;
endGame();
}
} else {
game.enemyList[i].clip.gotoAndStop("STAND");
}
}
if ((game.enemyList[i].enType == "ENDBOSSGLOATER") && (bossShow)) {
if ((game.enemyList[i].behave < 5) && (game.enemyList[i].ytile < 19)) {
control = false;
player.vx = 0;
player.vy = 0;
if (game.enemyList[i].behave == 0) {
displayText("WARLORD: OH LOOK! A TINY LITTLE MAN! YOUVE COME TO FIGHT ME HAVE YOU?");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 1) {
displayText("WARLORD: YOU ARE HARDLY WORTH MY TIME... IN FACT, IM SURE MY MINIONS WILL ENJOY THE BATTLE.");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 2) {
displayText("WARLORD: YOULL HAVE TO FIGHT MY FOUR LIEUTENANTS AND TAKE THEIR GUNS BEFORE YOU CAN REACH MY BASE!");
game.enemyList[i].behave++;
} else if (game.enemyList[i].behave == 3) {
displayText("WARLORD: HEHEHAHA!! HAVE FUN, TINY TINY LITTLE MAN!");
game.enemyList[i].behave = 10;
}
} else if (game.enemyList[i].ytile < 19) {
control = false;
player.vx = 0;
player.vy = 0;
game.enemyList[i].vy = 3;
} else {
removeMovieClip(game.enemyList[i].clip);
game.enemyList[i].alive = false;
bossShow = false;
control = true;
}
}
}
i++;
}
var _local2;
i = 0;
while (i < game.particleList.length) {
_local2 = game.particleList[i];
_local2.vx = _local2.vx * _local2.fric;
_local2.vy = _local2.vy * _local2.fric;
moveOb(_local2, _local2.vx, _local2.vy);
_local2.life--;
var _local3;
if ((_local2.dam > 0) || (_local2.dam == -5)) {
j = 0;
while (j < game.enemyList.length) {
_local3 = game.enemyList[j];
if (((((_local3.xSubTile == _local2.xSubTile) && (_local3.ySubTile == _local2.ySubTile)) && (_local3.stun <= 0)) && (_local3.alive)) && (_local3.enType != "GRANMA")) {
if (_local2.dam != -5) {
applyDamage(_local3, _local2, _local2.dam);
if (_local2.hitWalls) {
_local2.life = 0;
}
} else if (_local2.hitWalls) {
_local2.life = 0;
}
}
j++;
}
if (((boss != null) && (boss.killMode)) && (boss.alive)) {
if ((((_local2.x > (boss.x - 64)) && (_local2.x < (boss.x + 64))) && (_local2.y > (boss.y - 48))) && (_local2.y < (boss.y + 48))) {
applyDamage(boss, _local2, _local2.dam);
_local2.life = 0;
}
}
}
if (_local2.vy > _local2.vx) {
var _local6 = ((_local2.ySubTile * 32) + 16) - _local2.y;
_local2.y = _local2.y + (_local6 / 30);
} else {
var _local7 = ((_local2.xSubTile * 32) + 16) - _local2.x;
_local2.x = _local2.x + (_local7 / 30);
}
if (_local2.life <= 0) {
if (_local2.dam == -5) {
k = 0;
while (k < 5) {
pType = "SMOKE" + Math.floor((Math.random() * 3) + 1);
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
addParticle(pType, _local2.x, _local2.y, vx, vy, 0.95, 0, 20, true);
pType = "EXPLODE1";
vx = (Math.random() * 8) - 4;
vy = (Math.random() * 8) - 4;
addParticle(pType, _local2.x, _local2.y, vx, vy, 0.97, 3, 30, true);
k++;
}
if (sound) {
soundExplode.start();
}
}
if (_local2.dam == -10) {
k = 0;
while (k < 4) {
pType = "SMOKE" + Math.floor((Math.random() * 3) + 1);
vx = (Math.random() * 10) - 5;
vy = (Math.random() * 10) - 5;
addParticle(pType, _local2.x, _local2.y, vx, vy, 0.95, 0, 20, true);
k++;
}
player.x = _local2.x;
player.y = _local2.y;
player.vx = 0;
player.vy = 0;
}
if (_local2.dam == -31) {
k = 0;
while (k < 5) {
pType = "SMOKE" + Math.floor((Math.random() * 3) + 1);
vx = (Math.random() * 8) - 4;
vy = (Math.random() * 8) - 4;
addParticle(pType, _local2.x, _local2.y, vx, vy, 0.95, 0, 20, true);
pType = "EXPLODE1";
vx = (Math.random() * 6) - 3;
vy = (Math.random() * 6) - 3;
addParticle(pType, _local2.x, _local2.y, vx, vy, 0.97, -30, 15, true);
k++;
}
}
game.particleList.splice(i, 1);
removeMovieClip(_local2.clip);
_local2 = null;
}
if ((player.xSubTile == _local2.xSubTile) && (player.ySubTile == _local2.ySubTile)) {
tPart = true;
} else {
tPart = false;
}
if ((_local2.dam == -1) && (tPart == true)) {
if (player.pl < player.maxPl) {
player.pl++;
}
displayBars();
_local2.life = 0;
if (sound) {
pickup.start();
}
} else if ((_local2.dam == -2) && (tPart == true)) {
if (player.hp < player.maxHp) {
player.hp++;
}
displayBars();
_local2.life = 0;
if (sound) {
pickup.start();
}
} else if ((_local2.dam == -50) && (tPart == true)) {
player.hp++;
player.maxHp++;
displayBars();
_local2.life = 0;
if (sound) {
soundPowerup.start();
}
displayText("MAXIMUM HEALTH INCREASED!");
} else if ((_local2.dam == -51) && (tPart == true)) {
player.pl++;
player.maxPl++;
displayBars();
_local2.life = 0;
if (sound) {
soundPowerup.start();
}
displayText("MAXIMUM PLASMA AMMO INCREASED!!");
} else if ((_local2.dam == -30) && (tPart == true)) {
applyDamage(player, _local2, 1);
} else if ((_local2.dam == -1000) && (tPart == true)) {
player.gunList.push(plasmaGun);
player.gun = player.gunList[player.gunList.length - 1];
_local2.life = 0;
displayBars();
if (sound) {
soundPowerup.start();
}
displayText("YOU GOT THE PLASMA PISTOL! PRESS THE X KEY TO SHOOT. USE IT TO UNLOCK BLUE DOORS.");
} else if ((_local2.dam == -1001) && (tPart == true)) {
player.gunList.push(sniperGun);
player.gun = player.gunList[player.gunList.length - 1];
_local2.life = 0;
displayBars();
if (sound) {
soundPowerup.start();
}
displayText("YOU GOT THE SNIPER ATTACHMENT! USE IT TO OPEN YELLOW DOORS.");
} else if ((_local2.dam == -1002) && (tPart == true)) {
player.gunList.push(grenadeGun);
player.gun = player.gunList[player.gunList.length - 1];
_local2.life = 0;
displayBars();
if (sound) {
soundPowerup.start();
}
displayText("YOU GOT THE GRENADE ATTACHMENT! USE IT TO OPEN RED DOORS.");
} else if ((_local2.dam == -1003) && (tPart == true)) {
player.gunList.push(fthrowerGun);
player.gun = player.gunList[player.gunList.length - 1];
_local2.life = 0;
displayBars();
if (sound) {
soundPowerup.start();
}
displayText("YOU GOT THE FLAME THROWER ATTACHMENT! USE IT TO OPEN GREEN DOORS.");
}
i++;
}
}
};
var keyListener = new Object();
keyListener.onKeyDown = function () {
if (run && (control)) {
if (Key.getCode() == 90) {
if (!attacking) {
attacking = true;
if (sound) {
soundSword.start();
}
}
}
if (((Key.getCode() == 88) && (player.recharge > player.gun.shootSpeed)) && ((player.pl - player.gun.drain) >= 0)) {
var _local2 = player.facingX * player.gun.bulletSpeed;
var _local1 = player.facingY * player.gun.bulletSpeed;
player.recharge = -10;
var _local4 = player.facingX * 16;
var _local3 = (player.facingY * 16) - 6;
addParticle(player.gun.sprite, player.x + _local4, player.y + _local3, _local2, _local1, player.gun.bulletFric, player.gun.damage, player.gun.bulletLife, player.gun.hitWalls);
player.pl = player.pl - player.gun.drain;
displayBars();
if (sound) {
soundGunPlasma.start();
}
}
if (Key.getCode() == 83) {
player.currentGun++;
if (player.currentGun >= player.gunList.length) {
player.currentGun = 0;
}
player.gun = player.gunList[player.currentGun];
displayBars();
if (sound) {
soundSwitch.start();
}
}
if (Key.getCode() == 65) {
player.currentGun--;
if (player.currentGun < 0) {
player.currentGun = player.gunList.length - 1;
}
player.gun = player.gunList[player.currentGun];
displayBars();
if (sound) {
soundSwitch.start();
}
}
}
};
Key.addListener(keyListener);
stop();
Symbol 48 Button
on (press) {
_root.gotoAndStop("GAME");
}
on (rollOver) {
if (_root.sound) {
_root.pickup.start();
}
}
Symbol 51 Button
on (press) {
_root.gotoAndStop("CONTROLS");
}
on (rollOver) {
if (_root.sound) {
_root.pickup.start();
}
}
Symbol 58 Button
on (press) {
if (_root.sound) {
_root.sound = false;
_root.makeSoundIcon(false);
} else {
_root.sound = true;
_root.makeSoundIcon(true);
}
}
on (rollOver) {
if (_root.sound) {
_root.pickup.start();
}
}
Symbol 62 MovieClip [menu] Frame 45
stop();
Symbol 68 Button
on (press) {
_root.gotoAndStop("MENU");
}
on (rollOver) {
if (_root.sound) {
_root.pickup.start();
}
}
Symbol 99 MovieClip Frame 12
_root.attacking = false;
Symbol 107 MovieClip Frame 45
stop();
Symbol 131 MovieClip Frame 17
stop();
Symbol 138 MovieClip Frame 16
stop();
Symbol 145 MovieClip Frame 16
stop();
Symbol 154 MovieClip Frame 20
stop();
Symbol 217 MovieClip Frame 12
_root.attacking = false;
Symbol 249 MovieClip Frame 12
_root.attacking = false;
Symbol 253 MovieClip [mc_player] Frame 1
stop();
Symbol 478 MovieClip [mc_boss] Frame 52
_root.playBossFX();
stop();
Symbol 483 MovieClip [mc_finalBoss] Frame 52
_root.playBossFX();
stop();
Symbol 483 MovieClip [mc_finalBoss] Frame 61
stop();
Symbol 483 MovieClip [mc_finalBoss] Frame 70
_root.playBossFX();
Symbol 483 MovieClip [mc_finalBoss] Frame 102
_root.boss.killMode = true;
gotoAndStop ("SIT");