Combined Code
frame 1 {
_global.hp = 99;
_global.maxhp = 100;
_global.cash = 0;
_global.exp = 0;
_global.lvl = 1;
_global.px = 25;
_global.py = 41;
_level0._x = -px + 4;
_level0._y = -py + 4;
_global.magic = 0;
_global.boat = 0;
_global.shield = 0;
_global.stone = 0;
_global.sword = 0;
_global.monsternumber = new Array();
_global.monstercount = 0;
var soundpowerup = new Sound(this);
soundpowerup.attachSound('powerup.mp3');
var soundplayerhit = new Sound(this);
soundplayerhit.attachSound('playerhit.mp3');
var soundmusic_start = new Sound(this);
soundmusic_start.attachSound('music_start.mp3');
var soundmusic_death = new Sound(this);
soundmusic_death.attachSound('music_death.mp3');
var soundmonsterhit = new Sound(this);
soundmonsterhit.attachSound('monsterhit.mp3');
var soundmagic = new Sound(this);
soundmagic.attachSound('magic.mp3');
var soundgold = new Sound(this);
soundgold.attachSound('gold.mp3');
var soundenterdungeon = new Sound(this);
soundenterdungeon.attachSound('enterdungeon.mp3');
var sounddrink = new Sound(this);
sounddrink.attachSound('drink.mp3');
var sounddooropen = new Sound(this);
sounddooropen.attachSound('dooropen.mp3');
var sounddead = new Sound(this);
sounddead.attachSound('dead.mp3');
var soundbossdead = new Sound(this);
soundbossdead.attachSound('bossdead.mp3');
var soundlevelup = new Sound(this);
soundlevelup.attachSound('levelup.mp3');
var map = new flash.display.BitmapData(128, 64, false, 13421772);
map = flash.display.BitmapData.loadBitmap('mainmap');
var mc = this.createEmptyMovieClip('mc', 10);
mc.attachBitmap(map, 10);
var mapthings = new flash.display.BitmapData(128, 64, false, 13421772);
mapthings = flash.display.BitmapData.loadBitmap('mainmapthings');
var mc2 = this.createEmptyMovieClip('mc2', 11);
mc2.attachBitmap(map, 11);
var spritesheet = new flash.display.BitmapData(8, 8, false, 13421772);
spritesheet = flash.display.BitmapData.loadBitmap('sprites');
var mc3 = this.createEmptyMovieClip('mc3', 20);
mc3.attachBitmap(spritesheet, 20);
mc3._x = px - 40;
mc3._y = py - 4;
_global.cell = new Array();
var cx = 0;
while (cx < 128) {
_global.cell[cx] = new Array();
var cy = 0;
while (cy < 64) {
cell[cx][cy] = map.getPixel(cx, cy);
++cy;
}
++cx;
}
monster = function (monsternumber, x, y, lvl) {
this.lvl = lvl;
this.x = x;
this.y = y;
};
_global.things = new Array();
var cx = 0;
while (cx < 128) {
_global.things[cx] = new Array();
var cy = 0;
while (cy < 64) {
things[cx][cy] = mapthings.getPixel(cx, cy);
if (things[cx][cy] == 16711680) {
enemy = 'monster' + monstercount;
++monstercount;
this[enemy] = new monster(monstercount, cx, cy, 3);
things[cx][cy] = 0;
}
if (things[cx][cy] == 16711932) {
enemy = 'monster' + monstercount;
++monstercount;
this[enemy] = new monster(monstercount, cx, cy, 8);
things[cx][cy] = 0;
}
++cy;
}
++cx;
}
checklevel = function (exp) {
if (exp == 4) {
++exp;
++lvl;
maxhp = 110;
soundlevelup.start();
}
if (exp == 8) {
++exp;
++lvl;
maxhp = 120;
soundlevelup.start();
}
if (exp == 16) {
++exp;
++lvl;
maxhp = 130;
soundlevelup.start();
}
if (exp == 32) {
++exp;
++lvl;
maxhp = 140;
soundlevelup.start();
}
if (exp == 48) {
++exp;
++lvl;
maxhp = 150;
soundlevelup.start();
}
};
drawMap = function () {
var v2 = 0;
_level0._x = -px + 4;
_level0._y = -py + 4;
if (px < 4) {
_level0._x = 0;
}
if (py < 4) {
_level0._y = 0;
}
var v5 = 0;
var v4 = 0;
while (v4 < 128) {
var v1 = 0;
while (v1 < 64) {
v2 = cell[v4][v1];
map.setPixel(v4, v1, v2);
map.setPixel(px, py, 16777215);
if (things[v4][v1] != 0) {
map.setPixel(v4, v1, things[v4][v1]);
}
++v1;
}
++v4;
}
var v3 = 0;
while (v3 < monstercount) {
if (_level0['monster' + v3].lvl <= 1) {
v2 = '0x660000';
}
if (_level0['monster' + v3].lvl == 2) {
v2 = '0x660000';
}
if (_level0['monster' + v3].lvl == 3) {
v2 = '0xAA0000';
}
if (_level0['monster' + v3].lvl == 4) {
v2 = '0xAA0000';
}
if (_level0['monster' + v3].lvl == 5) {
v2 = '0xCC0000';
}
if (_level0['monster' + v3].lvl == 6) {
v2 = '0xFF0000';
}
if (_level0['monster' + v3].lvl == 7) {
v2 = '0xFF0066';
}
if (_level0['monster' + v3].lvl == 8) {
v2 = '0xFF00FF';
}
if (_level0['monster' + v3].lvl >= 9) {
v2 = '0x000000';
}
map.setPixel(_level0['monster' + v3].x, _level0['monster' + v3].y, v2);
++v3;
}
if (hp <= 10) {
v2 = '0xFF0000';
}
if (hp > 10) {
v2 = '0xff6600';
}
if (hp > 20) {
v2 = '0xffaa00';
}
if (hp > 30) {
v2 = '0xffdd00';
}
if (hp > 40) {
v2 = '0xFFFF00';
}
if (hp > 50) {
v2 = '0xDDFF00';
}
if (hp > 60) {
v2 = '0xAAFF00';
}
if (hp > 70) {
v2 = '0x66FF00';
}
if (hp > 80) {
v2 = '0x00FF00';
}
if (px > 4) {
xpix = px - 4;
} else {
xpix = 0;
}
if (py > 4) {
ypix = py - 4;
} else {
ypix = 0;
}
map.setPixel(xpix, ypix, v2);
if (magic > 0) {
v2 = Math.random() * 16777215;
map.setPixel(xpix + 8, ypix, v2);
}
};
teleport = function () {
var v1 = [{'tx': 34, 'ty': 41, 'tx2': 1, 'ty2': 8}, {'tx': 0, 'ty': 8, 'tx2': 35, 'ty2': 41}, {'tx': 35, 'ty': 38, 'tx2': 94, 'ty2': 45}, {'tx': 94, 'ty': 46, 'tx2': 36, 'ty2': 38}, {'tx': 29, 'ty': 42, 'tx2': 28, 'ty2': 13}, {'tx': 28, 'ty': 14, 'tx2': 30, 'ty2': 42}, {'tx': 27, 'ty': 43, 'tx2': 45, 'ty2': 13}, {'tx': 45, 'ty': 14, 'tx2': 27, 'ty2': 42}, {'tx': 23, 'ty': 41, 'tx2': 50, 'ty2': 13}, {'tx': 49, 'ty': 13, 'tx2': 24, 'ty2': 41}, {'tx': 22, 'ty': 37, 'tx2': 23, 'ty2': 61}, {'tx': 23, 'ty': 62, 'tx2': 23, 'ty2': 37}, {'tx': 20, 'ty': 39, 'tx2': 43, 'ty2': 62}, {'tx': 44, 'ty': 62, 'tx2': 20, 'ty2': 40}, {'tx': 39, 'ty': 39, 'tx2': 56, 'ty2': 61}, {'tx': 57, 'ty': 62, 'tx2': 40, 'ty2': 39}, {'tx': 41, 'ty': 42, 'tx2': 70, 'ty2': 62}, {'tx': 71, 'ty': 62, 'tx2': 42, 'ty2': 42}, {'tx': 43, 'ty': 39, 'tx2': 88, 'ty2': 60}, {'tx': 88, 'ty': 61, 'tx2': 44, 'ty2': 39}, {'tx': 20, 'ty': 29, 'tx2': 116, 'ty2': 45}, {'tx': 116, 'ty': 46, 'tx2': 20, 'ty2': 30}, {'tx': 21, 'ty': 23, 'tx2': 115, 'ty2': 61}, {'tx': 115, 'ty': 62, 'tx2': 22, 'ty2': 23}, {'tx': 24, 'ty': 26, 'tx2': 97, 'ty2': 61}, {'tx': 97, 'ty': 62, 'tx2': 25, 'ty2': 26}, {'tx': 34, 'ty': 20, 'tx2': 76, 'ty2': 14}, {'tx': 77, 'ty': 14, 'tx2': 34, 'ty2': 21}, {'tx': 41, 'ty': 21, 'tx2': 119, 'ty2': 13}, {'tx': 119, 'ty': 14, 'tx2': 42, 'ty2': 21}, {'tx': 38, 'ty': 24, 'tx2': 13, 'ty2': 61}, {'tx': 13, 'ty': 62, 'tx2': 39, 'ty2': 24}, {'tx': 43, 'ty': 31, 'tx2': 6, 'ty2': 43}, {'tx': 6, 'ty': 44, 'tx2': 44, 'ty2': 31}, {'tx': 31, 'ty': 31, 'tx2': 70, 'ty2': 45}];
for (var v2 in v1) {
if (px == v1[v2].tx && py == v1[v2].ty) {
px = v1[v2].tx2;
py = v1[v2].ty2;
soundenterdungeon.start();
}
}
};
pressurepads = function () {
var v1 = [{'tx': 29, 'ty': 7, 'tx2': 34, 'ty2': 5}, {'tx': 14, 'ty': 49, 'tx2': 2, 'ty2': 56}, {'tx': 27, 'ty': 55, 'tx2': 23, 'ty2': 50}, {'tx': 50, 'ty': 61, 'tx2': 59, 'ty2': 52}, {'tx': 88, 'ty': 49, 'tx2': 87, 'ty2': 55}, {'tx': 114, 'ty': 50, 'tx2': 119, 'ty2': 57}, {'tx': 52, 'ty': 40, 'tx2': 71, 'ty2': 37}, {'tx': 125, 'ty': 33, 'tx2': 117, 'ty2': 37}, {'tx': 122, 'ty': 2, 'tx2': 106, 'ty2': 8}, {'tx': 53, 'ty': 18, 'tx2': 75, 'ty2': 46}, {'tx': 51, 'ty': 5, 'tx2': 61, 'ty2': 5}, {'tx': 60, 'ty': 29, 'tx2': 53, 'ty2': 27}, {'tx': 62, 'ty': 23, 'tx2': 71, 'ty2': 46}];
for (var v2 in v1) {
if (px == v1[v2].tx && py == v1[v2].ty) {
cell[v1[v2].tx2][v1[v2].ty2] = 8355711;
cell[v1[v2].tx][v1[v2].ty] = 8355711;
sounddooropen.start();
}
}
};
movemonsters = function () {
var v3 = 0;
while (v3 < monstercount) {
var v4 = 0;
var v2 = _level0['monster' + v3].x;
var v1 = _level0['monster' + v3].y;
if (v2 < px + 4 && v2 > px - 4 && (v1 < py + 4 && v1 > py - 4)) {
if (v2 == px && (v1 == py + 1 || v1 == py - 1) || v1 == py && (v2 == px + 1 || v2 == px - 1)) {
hitDamage = (random(3) + 5) * _level0['monster' + v3].lvl;
if (shield == 1) {
hitDamage = Math.ceil(hitDamage / 2);
}
hp -= hitDamage;
soundmonsterhit.start();
if (hp < 1) {
gameOver();
sounddead.start();
}
} else {
if (v4 == 0 && v2 < px) {
if (map.getPixel(v2 + 1, v1) != 0) {
++_level0['monster' + v3].x;
v4 = 1;
}
}
if (v4 == 0 && v2 > px) {
if (map.getPixel(v2 - 1, v1) != 0) {
--_level0['monster' + v3].x;
v4 = 1;
}
}
if (v4 == 0 && v1 < py) {
if (map.getPixel(v2, v1 + 1) != 0) {
++_level0['monster' + v3].y;
v4 = 1;
}
}
if (v4 == 0 && v1 > py) {
if (map.getPixel(v2, v1 - 1) != 0) {
--_level0['monster' + v3].y;
v4 = 1;
}
}
}
}
++v3;
}
};
magicmonsters = function () {
soundmagic.start();
var v1 = 0;
while (v1 < monstercount) {
var v4 = 0;
var v3 = _level0['monster' + v1].x;
var v2 = _level0['monster' + v1].y;
if (v3 < px + 4 && v3 > px - 4 && (v2 < py + 4 && v2 > py - 4)) {
_level0['monster' + v1].lvl = Math.ceil(_level0['monster' + v1].lvl / 2);
soundmagic.start();
}
++v1;
}
};
nextturn = function () {
specialItems();
pressurepads();
teleport();
movemonsters();
};
drink = function (x, y) {
if (hp < 90) {
cell[x][y] = 8355711;
hp += 10;
sounddrink.start();
}
};
passable = function (x, y) {
var v6 = cell[x][y];
var v1 = 0;
while (v1 < monstercount) {
var v3 = _level0['monster' + v1].x;
var v2 = _level0['monster' + v1].y;
if (x == v3 && y == v2) {
if (sword == 1) {
hitDamage = 2;
} else {
hitDamage = 1;
}
_level0['monster' + v1].lvl -= hitDamage;
soundplayerhit.start();
if (_level0['monster' + v1].lvl < 1) {
++exp;
checklevel(exp);
_level0['monster' + v1].x = 101;
_level0['monster' + v1].y = 53;
}
movemonsters();
return 0;
break;
}
++v1;
}
if (x == 31 && y == 31) {
if (stone == 0 || cash < 16) {
return 0;
}
}
if (x == 93 && y == 25) {
if (hp < maxhp) {
hp = maxhp;
showSprite('beer');
sounddrink.start();
}
}
if (x == 97 && y == 21) {
if (magic < 1) {
magic += 1;
showSprite('magic');
soundmagic.start();
}
}
switch (v6) {
case 0:
return 0;
break;
case 16777215:
return 0;
break;
case 15488:
return 0;
break;
case 18378:
if (boat == 0) {
return 0;
break;
} else {
return 1;
break;
}
case 5665535:
drink(x, y);
return 0;
break;
case 34816:
return 0;
break;
case 9523520:
return 0;
break;
case 13738646:
return 0;
break;
case 6118749:
return 0;
break;
default:
return 1;
}
};
look = function (x, y) {
var v1 = things[x][y];
switch (v1) {
case 16776960:
return 1;
break;
case 64767:
return 2;
break;
default:
return 0;
}
};
powerup = function () {
++_global.magic;
soundmagic.start();
};
gameOver = function (x) {
if (x == 'win') {
mc3._x = px - 85;
mc3._y = py - 4;
} else {
mc3._x = px - 31;
mc3._y = py - 4;
}
Key.removeListener(keyListener);
};
gameOverWin = function () {
Key.removeListener(keyListener);
};
specialItems = function () {
if (px == 71 && py == 55) {
if (boat == 0) {
_global.boat = 1;
showSprite('boat');
soundpowerup.start();
}
}
if (px == 5 && py == 20) {
if (sword == 0) {
_global.sword = 1;
showSprite('sword');
soundpowerup.start();
}
}
if (px == 124 && py == 20) {
if (shield == 0) {
_global.shield = 1;
showSprite('shield');
soundpowerup.start();
}
}
if (px == 106 && py == 12) {
if (stone == 0) {
_global.stone = 1;
showSprite('stone');
soundpowerup.start();
}
}
if (px == 71 && py == 47) {
soundmusic_death.start();
gameOver('win');
}
};
showSprite = function (x) {
switch (x) {
case 'beer':
mc3._x = px - 49;
mc3._y = py - 4;
break;
case 'magic':
mc3._x = px - 58;
mc3._y = py - 4;
break;
case 'sword':
mc3._x = px - 13;
mc3._y = py - 4;
break;
case 'shield':
mc3._x = px - 22;
mc3._y = py - 4;
break;
case 'boat':
mc3._x = px - 4;
mc3._y = py - 4;
break;
case 'stone':
mc3._x = px - 76;
mc3._y = py - 4;
break;
case 'goldpile':
mc3._x = px - 67;
mc3._y = py - 4;
break;
case 'sunset':
mc3._x = px - 85;
mc3._y = py - 4;
}
Key.removeListener(keyListener);
Key.addListener(startkeyListener);
};
keyListener = new Object();
keyListener.onKeyDown = function () {
switch (Key.getCode()) {
case 37:
if (passable(px - 1, py) == 1) {
px -= 1;
nextturn();
}
break;
case 39:
if (passable(px + 1, py) == 1) {
px += 1;
nextturn();
}
break;
case 38:
if (passable(px, py - 1) == 1) {
py -= 1;
nextturn();
}
break;
case 40:
if (passable(px, py + 1) == 1) {
py += 1;
nextturn();
}
break;
case 32:
if (magic > 0) {
--magic;
magicmonsters();
}
nextturn();
}
if (look(px, py) == 1) {
things[px][py] = 0;
++cash;
soundgold.start();
}
if (look(px, py) == 2) {
things[px][py] = 0;
}
drawMap();
};
startkeyListener = new Object();
startkeyListener.onKeyDown = function () {
mc3._x = 0;
mc3._y = 70;
drawMap();
Key.removeListener(startkeyListener);
Key.addListener(keyListener);
};
Key.addListener(startkeyListener);
}