Combined Code
movieClip 84 Blood3 {
frame 40 {
_parent.removeMovieClip();
}
}
movieClip 165 Blood1 {
frame 40 {
_parent.removeMovieClip();
}
}
movieClip 246 Blood2 {
frame 40 {
_parent.removeMovieClip();
}
}
movieClip 327 Blood4 {
frame 40 {
_parent.removeMovieClip();
}
}
movieClip 328 blood {
}
movieClip 330 {
}
movieClip 331 spike3 {
}
movieClip 333 {
}
movieClip 335 {
}
movieClip 336 spike {
}
movieClip 338 spike4 {
}
movieClip 339 yy7 {
}
movieClip 340 yy8 {
}
frame 1 {
function onEnterFrame() {
if (this._currentframe == 1) {
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded / bytes_total;
loader._xscale = getPercent * 100;
if (bytes_loaded == bytes_total && thePlay._x < 0) {
if (domain == 'jaludo.com' || domain == 'media.jaludo.com') {
gotoAndStop(2);
}
loader._x = 1000;
outer._x = 1000;
thePlay._x = Stage.width / 2;
thePlay.onRollOver = function () {
thePlay.gotoAndStop(2);
};
thePlay.onRollOut = function () {
thePlay.gotoAndStop(1);
};
thePlay.onReleaseOutside = function () {
thePlay.gotoAndStop(1);
};
thePlay.onRelease = function () {
gotoAndStop(2);
};
thePlay2._x = Stage.width / 2;
thePlay2.onRollOver = function () {
thePlay2.gotoAndStop(2);
};
thePlay2.onRollOut = function () {
thePlay2.gotoAndStop(1);
};
thePlay2.onReleaseOutside = function () {
thePlay2.gotoAndStop(1);
};
thePlay2.onRelease = function () {
muted2 = true;
var v1 = new Sound();
v1.attachSound('mech1.mp3');
v1.setVolume(0);
gotoAndStop(2);
};
}
}
}
function goToThisURL() {
getURL('http://armorgames.com', '_blank');
}
function createContextMenu(menu) {
_root.menu = menu;
}
stop();
var myMenu = new ContextMenu();
myMenu.hideBuiltInItems();
var mainItem = new ContextMenuItem('Play More Games', goToThisURL);
myMenu.customItems.push(mainItem);
createContextMenu(myMenu);
urlStart = _url.indexOf('://') + 3;
urlEnd = _url.indexOf('/', urlStart);
domain = _url.substring(urlStart, urlEnd);
LastDot = domain.lastIndexOf('.') - 1;
domEnd = domain.lastIndexOf('.', LastDot) + 1;
domain = domain.substring(domEnd, domain.length);
if (domain == 'armorgames.com' || domain == 'www.armorgames.com') {
} else {
_root._x = -2000;
}
}
movieClip 343 {
}
movieClip 347 {
}
instance of movieClip 347 {
onClipEvent (release) {
getURL('http://armorgames.com', '_BLANK');
}
}
// unknown tag 88 length 99
movieClip 352 {
}
movieClip 355 {
}
movieClip 362 {
}
movieClip 365 {
frame 1 {
stop();
}
}
movieClip 368 {
frame 1 {
stop();
}
}
movieClip 371 {
}
// unknown tag 88 length 94
movieClip 378 {
}
movieClip 384 {
}
movieClip 387 {
frame 1 {
_root.stop();
gotoAndPlay(2);
}
frame 225 {
_root.nextFrame();
}
}
instance of movieClip 387 {
onClipEvent (release) {
getURL('http://armorgames.com', '_BLANK');
}
}
frame 3 {
function resetValues() {
money = 200;
xp = 0;
levelsUnlocked = 1;
level = 1;
framesPlayed = 0;
arrowTechnology = 1;
skillTechnology = 0;
companionsOwned = 0;
kills = 0;
itemsOwned = new Array(9, 19, 23, 0);
shopItems = new Array(10, 24, 20);
companionBows = new Array(-1, -1, -1, -1);
companionArrows = new Array(-1, -1, -1, -1);
companionArmors = new Array(-1, -1, -1, -1);
companionBoots = new Array(-1, -1, -1, -1);
companionSkills = new Array(-1, -1, -1, -1);
companionLevels = new Array(1, 1, 1, 1);
companionXps = new Array(0, 0, 0, 0);
awardsOwned = new Array(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
}
function loadGame() {
if (sObject.data.arrowTechnology != undefined) {
arrowTechnology = sObject.data.arrowTechnology;
}
if (sObject.data.skillTechnology != undefined) {
skillTechnology = sObject.data.skillTechnology;
}
if (sObject.data.companionsOwned != undefined) {
companionsOwned = sObject.data.companionsOwned;
}
if (sObject.data.framesPlayed != undefined) {
framesPlayed = sObject.data.framesPlayed;
}
if (sObject.data.money != undefined) {
money = sObject.data.money;
}
if (sObject.data.xp != undefined) {
xp = sObject.data.xp;
}
if (sObject.data.kills != undefined) {
kills = sObject.data.kills;
}
if (sObject.data.Level != undefined) {
level = sObject.data.Level;
}
if (sObject.data.levelsUnlocked != undefined) {
levelsUnlocked = sObject.data.levelsUnlocked;
}
i = 0;
while (i < 1000) {
if (sObject.data.itemsOwned[i] != undefined) {
itemsOwned[i] = sObject.data.itemsOwned[i];
}
++i;
}
i = 0;
while (i < 1000) {
if (sObject.data.shopItems[i] != undefined) {
shopItems[i] = sObject.data.shopItems[i];
}
++i;
}
i = 0;
while (i < companionBows.length) {
if (sObject.data.companionBows[i] != undefined) {
companionBows[i] = sObject.data.companionBows[i];
}
++i;
}
i = 0;
while (i < companionArrows.length) {
if (sObject.data.companionArrows[i] != undefined) {
companionArrows[i] = sObject.data.companionArrows[i];
}
++i;
}
i = 0;
while (i < companionArmors.length) {
if (sObject.data.companionArmors[i] != undefined) {
companionArmors[i] = sObject.data.companionArmors[i];
}
++i;
}
i = 0;
while (i < companionBoots.length) {
if (sObject.data.companionBoots[i] != undefined) {
companionBoots[i] = sObject.data.companionBoots[i];
}
++i;
}
i = 0;
while (i < companionSkills.length) {
if (sObject.data.companionSkills[i] != undefined) {
companionSkills[i] = sObject.data.companionSkills[i];
}
++i;
}
i = 0;
while (i < companionLevels.length) {
if (sObject.data.companionLevels[i] != undefined) {
companionLevels[i] = sObject.data.companionLevels[i];
}
++i;
}
i = 0;
while (i < companionXps.length) {
if (sObject.data.companionXps[i] != undefined) {
companionXps[i] = sObject.data.companionXps[i];
}
++i;
}
i = 0;
while (i < awardsOwned.length) {
if (sObject.data.awardsOwned[i] != undefined) {
awardsOwned[i] = sObject.data.awardsOwned[i];
}
++i;
}
}
function saveGame() {
if (!survivalMode) {
sObject.data.arrowTechnology = arrowTechnology;
sObject.data.skillTechnology = skillTechnology;
sObject.data.companionsOwned = companionsOwned;
sObject.data.framesPlayed = framesPlayed;
sObject.data.money = money;
sObject.data.kills = kills;
sObject.data.levelsUnlocked = levelsUnlocked;
sObject.data.xp = xp;
sObject.data.Level = level;
sObject.data.itemsOwned = itemsOwned;
sObject.data.shopItems = shopItems;
sObject.data.companionArmors = companionArmors;
sObject.data.companionBoots = companionBoots;
sObject.data.companionArrows = companionArrows;
sObject.data.companionBows = companionBows;
sObject.data.companionSkills = companionSkills;
sObject.data.companionLevels = companionLevels;
sObject.data.companionXps = companionXps;
sObject.data.awardsOwned = awardsOwned;
sObject.flush();
}
}
function awardWait() {
if (awardk._currentframe == 1) {
if (awardQueueID.length != 0) {
giveAward(awardQueueType[0], awardQueueGroup[0], awardQueueID[0]);
awardQueueType.splice(0, 1);
awardQueueGroup.splice(0, 1);
awardQueueID.splice(0, 1);
}
}
}
function giveAward(awardID) {
if (awardk._currentframe == 1 && !awardsOwned[awardID - 1]) {
if (awardQueueID[0] == awardID) {
awardQueueID.splice(0, 1);
}
money += awardAmounts[awardID - 1];
awardk.aname.awardName.htmlText = bold(awardNames[awardID - 1]);
awardk.aname.costTxt.htmlText = bold(awardAmounts[awardID - 1]);
awardsOwned[awardID - 1] = true;
saveGame();
awardk.gotoAndPlay(2);
} else {
awardQueueID.push(awardID);
}
}
function manageAwardQueue() {
if (awardQueueID.length > 0) {
giveAward(awardQueueID[0]);
}
}
function createPart() {
part = attachMovie('part1', 'part' + depth, depth++);
part._alpha = 50 + random(51);
part._rotation = random(360);
part._yscale = 10 + random(10);
part._xscale = part._yscale;
part._x = -part._width / 2;
part._y = random(Stage.height - 200) + 40;
part.xSpeed = 5 + Math.random() * 3;
part.ySpeed = 2 - Math.random() * 4;
parts.push(part);
}
function partManagement() {
partDelay -= 1;
if (partDelay <= 0) {
createPart();
partDelay = partDelayConst;
}
p = parts.length - 1;
while (p >= 0) {
part = parts[p];
part._x += part.xSpeed;
part._y += part.ySpeed;
if (part._x >= Stage.width + part._width / 2) {
removePart();
}
--p;
}
}
function createButton(button) {
button.gotoAndStop(1);
button.onRollOver = function () {
button.gotoAndStop(2);
};
button.onRollOut = function () {
button.gotoAndStop(1);
};
button.onReleaseOutside = function () {
button.gotoAndStop(1);
};
}
function removePart() {
part.removeMovieClip();
parts.splice(p, 1);
}
function clearParts() {
p = parts.length - 1;
while (p >= 0) {
part = parts[p];
removePart();
--p;
}
}
function onEnterFrame() {
partManagement();
mBG._x = -Math.floor(20 * _xmouse / 800);
mBG._y = -Math.floor(15 * _ymouse / 600);
manageAwardQueue();
c1._x += Math.ceil((400 - c1._x) / 16);
s1._y += Math.ceil((543 - s1._y) / 16);
o1._y += Math.ceil((543 - o1._y) / 16);
c2._y += Math.ceil((543 - c2._y) / 16);
m1._y += Math.ceil((543 - m1._y) / 16);
}
stop();
mr1.onRelease = function () {
getURL('http://armorgames.com/play/3642/medieval-rampage', '_BLANK');
};
mr2.onRelease = function () {
getURL('http://armorgames.com/play/4379/medieval-rampage-2', '_BLANK');
};
mr3.onRelease = function () {
getURL('http://armorgames.com/play/15638/medieval-rampage-3', '_BLANK');
};
itemsPerLevel = new Array(11, 12, 25, 13, 14, 26, 21, 15, 16, 27, 17, 28, 22, 18, 29);
sObject = SharedObject.getLocal('saveFile');
resetValues();
loadGame();
trace(itemsOwned);
var mech1 = new Sound();
mech1.attachSound('mech1.mp3');
if (muted2) {
mech1.setVolume(0);
} else {
mech1.setVolume(100);
}
companionItems = new Array(companionBows, companionArrows, companionArmors, companionBoots, companionSkills);
awardQueueType = new Array();
awardQueueGroup = new Array();
awardQueueID = new Array();
awardNames = new Array('Newbie', 'Beginner', 'Medium', 'Advanced', 'Pro', 'Veteran', 'Legendary', 'Coin', 'Loot', 'Treasure', 'Riches', 'Conquer', 'Final Path', 'Slayer', 'Bloodshed', 'Carnage', 'Annihilation', 'Scavenger', 'Collector', 'Trader', 'Merchant', 'Everything', 'Automation', 'Mechanized', 'Trainer', 'Assistant', 'Unit', 'Army', 'Battalion', 'Legion', 'Started', 'In The Fray', 'Addicted');
awardDescriptions = new Array('Reach Level 2', 'Reach Level 3', 'Reach Level 4', 'Reach Level 5', 'Reach Level 6', 'Reach Level 7', 'Reach Level 8', 'Save $100', 'Save $1000', 'Save $5000', 'Save $20000', 'Unlock Conquer', 'Unlock Final Path', 'Get 100 Kills', 'Get 500 Kills', 'Get 2000 Kills', 'Get 10000 Kills', '3 Unique Items', '5 Unique Items', '7 Unique Items', '10 Unique Items', '15 Unique Items', 'Unlock 5 Techs', 'Unlock 10 Techs', '1 Merc Level 2', '2 Merc Level 2', '1 Merc Level 3', '1 Merc Level 5', '2 Merc Level 4', '3 Merc Level 4', 'Play for 5 Minutes', 'Play for 15 Minutes', 'Play for 60 Minutes');
awardQueueID = new Array();
awardAmounts = new Array(50, 100, 200, 400, 600, 900, 1500, 10, 50, 100, 500, 100, 1000, 30, 150, 400, 1200, 30, 60, 100, 200, 500, 150, 600, 50, 100, 200, 350, 600, 1000, 20, 50, 150);
parts = new Array();
depth = 100;
partDelay = 0;
partDelayConst = 7;
createButton(c1);
createButton(s1);
createButton(o1);
createButton(c2);
createButton(m1);
m1.onRelease = function () {
getURL('http://www.armorgames.com/', '_BLANK');
};
c1.onRelease = function () {
clearParts();
gotoAndStop(4);
};
survivalMode = false;
s1.onRelease = function () {
survivalMode = true;
gotoAndStop(4);
};
o1.onRelease = function () {
clearParts();
gotoAndStop(6);
};
c2.onRelease = function () {
clearParts();
gotoAndStop(5);
};
}
movieClip 389 {
}
movieClip 393 {
}
movieClip 394 {
}
movieClip 396 {
}
movieClip 398 {
}
movieClip 400 {
}
movieClip 403 {
}
movieClip 406 {
}
movieClip 409 {
}
movieClip 414 part1 {
frame 1 {
stop();
}
}
movieClip 420 {
}
movieClip 422 {
}
movieClip 423 {
frame 1 {
stop();
}
}
movieClip 426 {
}
instance of movieClip 426 {
onClipEvent (release) {
getURL('http://armorgames.com', '_BLANK');
}
}
movieClip 429 {
}
movieClip 432 {
}
movieClip 435 {
}
movieClip 438 {
}
movieClip 441 {
}
movieClip 445 {
frame 1 {
stop();
}
}
frame 4 {
function createPart() {
part = attachMovie('part1', 'part' + depth, depth++);
part.gotoAndStop(partFrames[bg._currentframe - 1]);
part._rotation = random(360);
if (part._currentframe == 1) {
part._alpha = 40 + random(41);
}
part._yscale = 10 + random(10);
part._xscale = part._yscale;
part._x = -part._width / 2;
part._y = random(Stage.height + 400 - 40) + 20 - 200;
part.xSpeed = 5 + Math.random() * 3;
part.ySpeed = 2 - Math.random() * 4;
if (part._currentframe == 4) {
part.xSpeed = 25 + Math.random() * 3;
part.ySpeed = 10 - Math.random() * 4;
part._rotation = Math.atan2(part.ySpeed, part.xSpeed) * 180 / Math.PI;
}
parts.push(part);
}
function partManagement() {
partDelay -= 1;
if (partDelay <= 0) {
if (bg._currentframe != 4 && bg._currentframe != 8 && _quality == 'HIGH') {
createPart();
}
partDelay = partDelayConst;
if (partFrames[bg._currentframe - 1] == 4) {
partDelay = 0;
}
}
p = parts.length - 1;
while (p >= 0) {
part = parts[p];
part._x += part.xSpeed;
part._y += part.ySpeed;
if (part._x >= Stage.width + part._width / 2) {
removePart();
}
--p;
}
}
function manageStarting() {
if (!hasStarted) {
toStartDelay -= 1;
if (toStartDelay <= 0) {
hasStarted = true;
gamePause = false;
storyTime.removeMovieClip();
}
}
}
function calcXpToLevel(levelNum) {
return Math.floor(70 * Math.pow(2, (levelNum + 10) / 2) - 3167);
}
function bold(item) {
return '<b>' + item + ' </b>';
}
function createCiv(num) {
civ = attachMovie('civs', 'civs' + depth, depth++);
civ._x = char._x + random(400) - 200;
civ._y = char._y + random(400) - 200;
civ.dir = random(360);
civ.walkTime = random(50);
civ.waitTime = random(50);
civ.walking = true;
civ.gotoAndStop(civTypes[num]);
civilians.push(civ);
}
function manageCivilians() {
c = civilians.length - 1;
while (c >= 0) {
civ = civilians[c];
if (civ.walking) {
civ.walkTime -= 1;
if (civ._x > bg._x + bg.rb._width / 2 + 200) {
civ.dir = 180;
}
if (civ._x < bg._x + bg.rb._width / 2 - 200) {
civ.dir = 0;
}
if (civ._y > bg._y + bg.rb._height / 2 + 200) {
civ.dir = -90;
}
if (civ._y < bg._y + bg.rb._height / 2 - 200) {
civ.dir = 90;
}
civ._x += Math.cos(civ.dir * Math.PI / 180) * 2;
civ._y += Math.sin(civ.dir * Math.PI / 180) * 2;
civ._rotation = civ.dir;
civ.c1.gotoAndStop(2);
if (civ.walkTime <= 0) {
civ.waitTime = random(50);
civ.walking = false;
}
} else {
civ.waitTime -= 1;
civ.c1.gotoAndStop(1);
if (civ.waitTime <= 0) {
civ.walkTime = random(50);
civ.walking = true;
civ.dir = random(360);
}
}
while (bg.obstacles.hitTest(civ._x + 15, civ._y, true)) {
civ._x -= 0.1;
civ.walkTime = 0;
}
while (bg.obstacles.hitTest(civ._x - 15, civ._y, true)) {
civ._x += 0.1;
civ.walkTime = 0;
}
while (bg.obstacles.hitTest(civ._x, civ._y + 15, true)) {
civ._y -= 0.1;
civ.walkTime = 0;
}
while (bg.obstacles.hitTest(civ._x, civ._y - 15, true)) {
civ._y += 0.1;
civ.walkTime = 0;
}
--c;
}
}
function createStatsScreen() {
gamePause = true;
statsScreen = attachMovie('statsScreen', 'statsScreen', 912343);
statsScreen._x = Stage.width / 2;
statsScreen._y = Stage.height / 2;
createButton(statsScreen.btt);
statsScreen.btt.onRelease = function () {
gamePause = false;
statsScreen.removeMovieClip();
};
statsScreen.luTxt.htmlText = bold(levelsUnlocked);
statsScreen.tkTxt.htmlText = bold(kills);
statsScreen.mTxt.htmlText = bold('$' + money);
statsScreen.xTxt.htmlText = bold(xp);
statsScreen.lTxt.htmlText = bold(level);
statsScreen.tpTxt.htmlText = bold(Math.floor(framesPlayed / 30) + ' Secs');
statsScreen.uiTxt.htmlText = bold(calcUniqueItems());
statsScreen.tTxt.htmlText = bold(skillTechnology + arrowTechnology);
statsScreen.dTxt.htmlText = bold(actualDamage);
}
function createLevelComplete(won) {
gamePause = true;
levelComplete = attachMovie('levelComplete', 'levelComplete', 911229);
levelComplete._x = Stage.width / 2;
levelComplete._y = Stage.height / 2;
createButton(levelComplete.btt);
levelComplete.btt.onRelease = function () {
gamePause = false;
levelComplete.removeMovieClip();
};
if (won) {
levelComplete.lc.gotoAndStop(1);
levelComplete.lfTxt.htmlText = bold('SUCCESS');
} else {
levelComplete.lc.gotoAndStop(2);
levelComplete.lfTxt.htmlText = bold('FAILURE');
}
levelComplete.kTxt.htmlText = bold(kills - preKills);
levelComplete.meTxt.htmlText = bold('$' + (money - preMoney));
levelComplete.xeTxt.htmlText = bold(xp - preXp);
levelComplete.rTxt.htmlText = bold(onWave);
}
function awardsEarned() {
ae = 0;
a = 0;
while (a < awardsOwned.length) {
if (awardsOwned[a]) {
ae += 1;
}
++a;
}
return ae;
}
function updateStats() {
if (toEnd) {
endTimer -= 1;
if (endTimer <= 0) {
toEnd = false;
endTimer = 20;
explosions[0].removeMovieClip();
explosions.splice(e, 1);
hBar._alpha = 0;
rings._alpha = 0;
health = maxHealth;
bg.gotoAndStop(4);
decideShopItems();
createLevelComplete(true);
game1.stop();
realShop.start(0, 10000);
bgFore.gotoAndStop(2);
orb._y = -1000;
orbHealth = 0;
clearScreen();
char._x = bg._x + bg._width / 2;
char._y = bg._y + bg._height / 2;
shopItems.push(itemsPerLevel[onLevel - 1]);
if (onLevel == levelsUnlocked) {
levelsUnlocked += 1;
if (levelsUnlocked == 6) {
giveAward(12);
}
if (levelsUnlocked == 11) {
giveAward(13);
}
}
if (levelsUnlocked == 1) {
bgFore.theArrow1._alpha = 100;
} else {
bgFore.theArrow1._alpha = 0;
}
if (onLevel == 15) {
removeGame();
gotoAndStop(7);
}
managePortalBgs();
saveGame();
}
}
orb.hBar.hIn._xscale = (orbHealth / orbHealthMax) * 100;
uiTop.killsTxt.htmlText = bold(killsThisWave + '/' + enemiesThisWave);
if (survivalMode) {
uiTop.killsTxt.htmlText = bold(killsThisWave);
}
uiTop.achievementsTxt.htmlText = bold(awardsEarned() + '/' + 33);
uiTop.damageTxt.htmlText = bold(actualDamage);
if (companionArrows[0] == 5) {
uiTop.damageTxt.htmlText = bold(Math.round(actualDamage * 1.3));
}
uiTop.moneyTxt.htmlText = bold(money);
uiBot.timeTxt.htmlText = Math.ceil(abilityTimer / 30) + ' Seconds';
if (abilityTimer <= 0) {
uiBot.timeTxt.htmlText = 'Ready';
}
if (companionSkills[0] == 29) {
uiBot.skillTxt.htmlText = bold('Freeze');
uiBot.skillImg.gotoAndStop(1);
uiBot.skillImg._alpha = 100;
}
if (companionSkills[0] == 30) {
uiBot.skillTxt.htmlText = bold('Grow');
uiBot.skillImg.gotoAndStop(2);
uiBot.skillImg._alpha = 100;
}
if (companionSkills[0] == 31) {
uiBot.skillTxt.htmlText = bold('Explode');
uiBot.skillImg.gotoAndStop(3);
uiBot.skillImg._alpha = 100;
}
if (companionSkills[0] < 29) {
uiBot.skillTxt.htmlText = '';
uiBot.skillImg.gotoAndStop(1);
uiBot.skillImg._alpha = 0;
}
hBar.levelTxt.htmlText = bold(level);
hBar.inBar._xscale = (health / maxHealth) * 100;
framesPlayed += 1;
if (framesPlayed >= 9000) {
giveAward(31);
}
if (framesPlayed >= 27000) {
giveAward(32);
}
if (framesPlayed >= 108000) {
giveAward(33);
}
if (health <= 0) {
hBar._alpha = 0;
rings._alpha = 0;
bgFore.gotoAndStop(2);
if (levelsUnlocked == 1) {
bgFore.theArrow1._alpha = 100;
} else {
bgFore.theArrow1._alpha = 0;
}
bg.gotoAndStop(4);
decideShopItems();
createLevelComplete(false);
game1.stop();
realShop.start(0, 10000);
orb._y = -1000;
orbHealth = 0;
clearScreen();
clearScreen();
health = 100;
char._x = bg._x + bg._width / 2;
char._y = bg._y + bg._height / 2;
c = 0;
while (c < 5) {
createCiv(c);
++c;
}
if (survivalMode) {
removeGame();
gotoAndStop(8);
}
managePortalBgs();
saveGame();
}
if (abilityTimer <= 0 && companionSkills[0] > 1 && bg._currentframe != 4) {
uiBot.timeTxt.htmlText = 'Ready!';
spacer._x = char._x;
spacer._y = char._y - 60;
} else {
spacer._x = -1000;
}
if (companionSkills[0] < 20) {
uiBot.timeTxt.htmlText = '';
}
uiBot.levelTxt.htmlText = bold('Level ' + level);
uiBot.xpBar._xscale = ((xp - calcXpToLevel(level)) / (calcXpToLevel(level + 1) - calcXpToLevel(level))) * 100;
if (xp >= calcXpToLevel(level + 1)) {
level += 1;
if (level == 2) {
giveAward(1);
}
if (level == 3) {
giveAward(2);
}
if (level == 4) {
giveAward(3);
}
if (level == 5) {
giveAward(4);
}
if (level == 6) {
giveAward(5);
}
if (level == 7) {
giveAward(6);
}
if (level == 8) {
giveAward(7);
}
maxHealth = calcHealthTotal();
gamePause = true;
createLevelUp();
damage = calcTrueDamage();
}
actualDamage = Math.round(damage);
uiBot.xpTxt.htmlText = xp + '/' + calcXpToLevel(level + 1);
}
function moveEverything(xer, yer) {
l = lasers.length - 1;
while (l >= 0) {
laser = lasers[l];
laser._x -= xer;
laser._y -= yer;
--l;
}
g = groundSpots.length - 1;
while (g >= 0) {
groundSpot = groundSpots[g];
groundSpot._x -= xer;
groundSpot._y -= yer;
--g;
}
c = civilians.length - 1;
while (c >= 0) {
civ = civilians[c];
civ._x -= xer;
civ._y -= yer;
--c;
}
e = exers.length - 1;
while (e >= 0) {
exer = exers[e];
exer._x -= xer;
exer._y -= yer;
if (exer._x == undefined || exer._y == undefined) {
exer.removeMovieClip();
exers.splice(e, 1);
}
--e;
}
p = parts.length - 1;
while (p >= 0) {
part = parts[p];
part._x -= xer;
part._y -= yer;
--p;
}
orb._x -= xer;
orb._y -= yer;
c = companions.length - 1;
while (c >= 0) {
companion = companions[c];
companion._x -= xer;
companion._y -= yer;
companion.hBar._x -= xer;
companion.hBar._y -= yer;
companion.Shadow._x -= xer;
companion.Shadow._y -= yer;
--c;
}
c = coins.length - 1;
while (c >= 0) {
coin = coins[c];
coin._x -= xer;
coin._y -= yer;
--c;
}
e = explosions.length - 1;
while (e >= 0) {
explosion = explosions[e];
explosion._x -= xer;
explosion._y -= yer;
--e;
}
b = bloods.length - 1;
while (b >= 0) {
blood = bloods[b];
blood._x -= xer;
blood._y -= yer;
--b;
}
a = arrows.length - 1;
while (a >= 0) {
ar = arrows[a];
ar._x -= xer;
ar._y -= yer;
--a;
}
e = enemies.length - 1;
while (e >= 0) {
en = enemies[e];
en._x -= xer;
en._y -= yer;
en.spawnSpot._x -= xer;
en.spawnSpot._y -= yer;
--e;
}
p = particles.length - 1;
while (p >= 0) {
pa = particles[p];
pa._x -= xer;
pa._y -= yer;
--p;
}
}
function createDragon() {
dragon = attachMovie('dragon', 'dragon' + highDepth, highDepth++);
dragon._yscale = 40;
dragon._xscale = 40;
dragon.Type = 1;
if (onLevel > 5) {
dragon.Type = 2;
dragon.gotoAndStop(11);
}
if (onLevel > 10) {
dragon.Type = 3;
dragon.gotoAndStop(21);
}
dragon.State = 1;
dragon.revertDelay = 90;
dragon.walkSpeed = 5;
dragon.flySpeed = 10;
dragon.xSpeed = 0;
dragon.ySpeed = 0;
dragon.healthMax = dragonHealthMaxes[dragon.Type - 1];
dragon.health = dragon.healthMax;
dragon.dIn.gotoAndStop(4);
dragons.push(dragon);
}
function dragonManagement() {
if (dragons.length < dragonMax && gameMode == 5 && !dragonKilled) {
createDragon();
}
d = dragons.length - 1;
while (d >= 0) {
dragon = dragons[d];
if (hypot(dragon._x, dragon._y, char._x, char._y) >= 400) {
theArrow._alpha = 100;
theArrow._rotation = Math.atan2(dragon._y - char._y, dragon._x - char._x) * 180 / Math.PI;
theArrow._x = char._x;
theArrow._y = char._y;
} else {
theArrow._alpha = 0;
}
if (hypot(dragon, char) <= 150 && dragon.State != 3) {
if (Math.abs((dragon._rotation - Math.atan2(char._y - dragon._y, char._x - dragon._x) * 180 / Math.PI) % 360) <= 90) {
dragon.State = 3;
dragon.dIn.gotoAndStop(2);
}
}
if (hypot(dragon, char) <= 250 && dragon.State != 3) {
if (Math.abs((dragon._rotation - Math.atan2(char._y - dragon._y, char._x - dragon._x) * 180 / Math.PI) % 360) <= 30) {
dragon.State = 3;
dragon.dIn.gotoAndStop(3);
}
}
hud.bh.tBar._xscale = (dragon.health / dragon.healthMax) * 100;
if (dragon.State != 3) {
if (hypot(dragon, char) < 500) {
dragon.State = 4;
} else {
if (dragon.State != 2) {
dragon.State = 1;
}
}
}
if (dragon.State == 1 && random(30) == 0) {
dragon.State = 2;
dir = (random(360) / 180) * Math.PI;
if (random(2) == 0) {
dragon.xSpeed = Math.cos(dir) * dragon.walkSpeed;
dragon.ySpeed = Math.sin(dir) * dragon.walkSpeed;
dragon.dIn.gotoAndStop(1);
} else {
dragon.xSpeed = Math.cos(dir) * dragon.flySpeed;
dragon.ySpeed = Math.sin(dir) * dragon.flySpeed;
dragon.dIn.gotoAndStop(6);
}
dragon._rotation = dir * 180 / Math.PI;
}
if (dragon.State == 2) {
dragon._x += dragon.xSpeed;
dragon._y += dragon.ySpeed;
if (dragon._y <= bg._y + dragon._height / 2) {
dragon.ySpeed *= -1;
dragon._y = bg._y + dragon._height / 2;
dragon._rotation = Math.atan2(dragon.ySpeed, dragon.xSpeed) * 180 / Math.PI;
}
if (dragon._y >= bg._y + bg.rb._height - dragon._height / 2) {
dragon.ySpeed *= -1;
dragon._y = bg._y + bg.rb._height - dragon._height / 2;
dragon._rotation = Math.atan2(dragon.ySpeed, dragon.xSpeed) * 180 / Math.PI;
}
if (dragon._x <= bg._x + dragon._width / 2) {
dragon.xSpeed *= -1;
dragon._x = bg._x + dragon._width / 2;
dragon._rotation = Math.atan2(dragon.ySpeed, dragon.xSpeed) * 180 / Math.PI;
}
if (dragon._x >= bg._x + bg.rb._width - dragon._width / 2) {
dragon.xSpeed *= -1;
dragon._x = bg._x + bg.rb._width - dragon._width / 2;
dragon._rotation = Math.atan2(dragon.ySpeed, dragon.xSpeed) * 180 / Math.PI;
}
dragon.revertDelay -= 1;
if (dragon.revertDelay <= 0) {
dragon.State = 1;
dragon.revertDelay = 90;
dragon.dIn.gotoAndStop(4);
}
}
if (dragon.State == 3) {
if (dragon.dIn.d1._currentframe == 13) {
if (char.hitTest(dragon.dIn.d1.hBox)) {
testAgainst(3);
}
}
if (dragon.dIn._currentframe == 4) {
dragon.State = 1;
}
}
if (dragon.State == 4) {
dragon.dIn.gotoAndStop(6);
tempRot = dragon._rotation;
qx2 = char._x - dragon._x;
qy2 = char._y - dragon._y;
radians = Math.atan2(qy2, qx2);
tempTurn = radians * 180 / Math.PI;
diffRot = (tempRot - tempTurn) % 360;
if (diffRot > 180) {
diffRot -= 360;
} else {
if (diffRot < -180) {
diffRot += 360;
}
}
if (Math.abs(diffRot) < 5) {
tempRot = tempTurn;
} else {
if (diffRot < 0) {
tempRot += 5;
} else {
tempRot -= 5;
}
}
dragon._rotation = tempRot;
dragon._x += Math.cos(dragon._rotation * Math.PI / 180) * 10;
dragon._y += Math.sin(dragon._rotation * Math.PI / 180) * 10;
}
--d;
}
}
function removeDragon() {
dragonKilled = true;
dragon.removeMovieClip();
dragons.splice(d, 1);
}
function charMovement() {
xDir = 0;
yDir = 0;
if (Key.isDown(39) || Key.isDown(68)) {
xDir = 1;
}
if (Key.isDown(37) || Key.isDown(65)) {
xDir = -1;
}
if (Key.isDown(38) || Key.isDown(87)) {
yDir = -1;
}
if (Key.isDown(40) || Key.isDown(83)) {
yDir = 1;
}
if (orb._currentframe == 2) {
giantTimer = 0;
}
giantTimer -= 1;
if (giantTimer > 0) {
char._yscale = 150;
char._xscale = 150;
tDark.gotoAndStop(2);
} else {
char._yscale = 100;
char._xscale = 100;
tDark.gotoAndStop(1);
}
abilityTimer -= 1;
if (Key.isDown(32) && abilityTimer <= 0 && bg._currentframe != 4 && bg._currentframe != 8 && companionSkills[0] != -1) {
abilityTimer = abilityMax;
e = enemies.length - 1;
while (e >= 0) {
enemy = enemies[e];
if (companionSkills[0] == 29) {
enemy.isFrozen = true;
enemy.freezeTimer = 75;
}
if (companionSkills[0] == 31) {
exer = attachMovie('explosion', 'explosion' + depth, depth++);
exer._x = enemy._x;
exer._y = enemy._y;
exers.push(exer);
enemy.igniteTimer = 75;
enemy.isIgnited = true;
damageToDo = 300;
enemy.health -= damageToDo;
enemy.timeSinceHit = 0;
dola = attachMovie('dola', 'dola' + highDepth, highDepth++);
dola._x = enemy._x - 20 + random(40);
dola._y = enemy._y - 40 + random(20);
dola.d1.moneyTxt.htmlText = damageToDo;
if (enemy.health <= 0) {
kills += 1;
killsThisWave += 1;
if (ar.from == char) {
xp += xps[onLevel - 1];
} else {
ar.from.xp += xps[onLevel - 1];
companionXps[ar.from.num] += xps[onLevel - 1];
if (ar.from.xp >= calcXpToLevel(ar.from.Level + 1)) {
ar.from.Level += 1;
companionLevels[ar.from.num] += 1;
calcCompLevels();
}
}
shake = 5;
if (enemy.Type <= 17) {
createCoin();
}
removeEnemy();
}
}
if (companionSkills[0] == 30) {
giantTimer = giantMax;
}
--e;
}
}
theDir = Math.atan2(yDir, xDir);
if (xDir != 0 || yDir != 0) {
if (bg._currentframe != 4 && bg._currentframe != 8) {
xSpeed += Math.cos(theDir) * speed;
ySpeed += Math.sin(theDir) * speed;
} else {
xSpeed += Math.cos(theDir) * 3;
ySpeed += Math.sin(theDir) * 3;
}
char.charIn.q.play();
char.charIn.w.play();
} else {
char.charIn.q.stop();
char.charIn.w.stop();
}
xSpeed *= friction;
ySpeed *= friction;
char._x += xSpeed;
char._y += ySpeed;
while (bg.obstacles.hitTest(char._x + 15, char._y, true)) {
char._x -= 0.1;
}
while (bg.obstacles.hitTest(char._x - 15, char._y, true)) {
char._x += 0.1;
}
while (bg.obstacles.hitTest(char._x, char._y + 15, true)) {
char._y -= 0.1;
}
while (bg.obstacles.hitTest(char._x, char._y - 15, true)) {
char._y += 0.1;
}
while (orb.orbBase.hitTest(char._x + 15, char._y, true)) {
char._x -= 0.1;
}
while (orb.orbBase.hitTest(char._x - 15, char._y, true)) {
char._x += 0.1;
}
while (orb.orbBase.hitTest(char._x, char._y + 15, true)) {
char._y -= 0.1;
}
while (orb.orbBase.hitTest(char._x, char._y - 15, true)) {
char._y += 0.1;
}
xChange = bg._x;
yChange = bg._y;
bg._x -= char._x - Stage.width / 2;
bg._y -= char._y - Stage.height / 2;
if (bg._currentframe == 4) {
bg._x = Math.floor(bg._x);
bg._y = Math.floor(bg._y);
}
char._x = Stage.width / 2;
char._y = Stage.height / 2;
if (bg._x >= 0) {
char._x -= bg._x;
bg._x = 0;
}
if (bg._y >= 0) {
char._y -= bg._y;
bg._y = 0;
}
if (bg._x <= Stage.width - bg.rb._width) {
char._x -= bg._x - (Stage.width - bg.rb._width);
bg._x = Stage.width - bg.rb._width;
}
if (bg._y <= Stage.height - bg.rb._height) {
char._y -= bg._y - (Stage.height - bg.rb._height);
bg._y = Stage.height - bg.rb._height;
}
if (char._x >= bg._x + bg.rb._width - 10) {
char._x = bg._x + bg.rb._width - 10;
}
if (char._y >= bg._y + bg.rb._height - 10) {
char._y = bg._y + bg.rb._height - 10;
}
if (char._x <= bg._x + 10) {
char._x = bg._x + 10;
}
if (char._y <= bg._y + 10) {
char._y = bg._y + 10;
}
xChange -= bg._x;
yChange -= bg._y;
moveEverything(xChange, yChange);
if (bg._currentframe != 4 && bg._currentframe != 8) {
char._rotation = Math.atan2(_ymouse - char._y, _xmouse - char._x) * 180 / Math.PI;
} else {
if (Math.abs(xSpeed) > 0.2 || Math.abs(ySpeed) > 0.2) {
char._rotation = Math.atan2(ySpeed, xSpeed) * 180 / Math.PI;
}
}
hBar._x = char._x;
hBar._y = char._y - 40;
pShadow._x = char._x;
pShadow._y = char._y;
rings._x = char._x;
rings._y = char._y;
bgFore._x = bg._x;
bgFore._y = bg._y + 1;
ps._alpha = 0;
if (bg._currentframe == 8) {
portals = new Array(bg.p1, bg.p2, bg.p3, bg.p4, bg.p5, bg.p6, bg.p7, bg.p8, bg.p9, bg.p10, bg.p11, bg.p12, bg.p13, bg.p14, bg.p15);
pInfos = new Array(bg.v1, bg.v2, bg.v3, bg.v4, bg.v5, bg.v6, bg.v7, bg.v8, bg.v9, bg.v10, bg.v11, bg.v12, bg.v13, bg.v14, bg.v15);
p = 0;
while (p < levelsUnlocked - 1) {
pInfos[p].gotoAndStop(2);
pInfos[p].levelTxt.htmlText = bold(p + 1);
if (portals[p].hitTest(char._x, char._y, true)) {
ps._alpha = 100;
portals[p].toChange.gotoAndStop(2);
if (Key.isDown(32)) {
onLevel = p + 1;
createPrepScreen();
}
} else {
portals[p].toChange.gotoAndStop(1);
}
++p;
}
}
if (bg._currentframe == 4) {
if (bg.se2.hitTest(char._x, char._y, true)) {
if (Key.isDown(32)) {
createBuyScreen();
}
ps._alpha = 100;
}
if (bg.se3.hitTest(char._x, char._y, true)) {
if (Key.isDown(32)) {
fromHome = false;
createPrepScreen();
}
ps._alpha = 100;
}
if (bg.se4.hitTest(char._x, char._y, true)) {
if (Key.isDown(32)) {
createLevelSelect();
}
ps._alpha = 100;
}
if (bg.se5.hitTest(char._x, char._y, true)) {
if (Key.isDown(32)) {
createResearchScreen();
}
ps._alpha = 100;
}
if (bg.se6.hitTest(char._x, char._y, true)) {
if (Key.isDown(32)) {
shopType = ARMORBOOTSHOP;
itemType = ARMOR;
buySell = 0;
createShop();
}
ps._alpha = 100;
}
if (bg.se7.hitTest(char._x, char._y, true)) {
if (Key.isDown(32)) {
createAchievements();
}
ps._alpha = 100;
}
if (bg.se8.hitTest(char._x, char._y, true)) {
if (Key.isDown(32)) {
createStatsScreen();
}
ps._alpha = 100;
}
if (bg.se9.hitTest(char._x, char._y, true)) {
if (Key.isDown(32)) {
fromHome = true;
createPrepScreen();
}
ps._alpha = 100;
}
}
}
function shooting() {
shotDelay -= 1;
if (shotDelay <= 0 && mDown && bg._currentframe != 4 && bg._currentframe != 8) {
shotDelay = 10;
if (companionArrows[0] == 3) {
shotDelay = 7;
}
if (giantTimer > 0) {
shotDelay = 2;
}
char.charIn.t.o.gotoAndPlay(2);
char.charIn.t.o.wepTrails.r.gotoAndPlay(2);
aShot.start();
createArrow(char, true);
}
}
function enemyExplosion() {
n = 0;
while (n < 5) {
createEpper(explosionParts[n]);
++n;
}
}
function createEpper(obj) {
epa = attachMovie(obj, 'expd' + depth, depth++);
epa._x = enemy._x;
epa._y = enemy._y;
epa._rotation = Math.random() * 360;
epa.isGood = false;
epa.from = null;
epa.xSpeed = Math.cos(epa._rotation * Math.PI / 180) * (5 + Math.random());
epa.ySpeed = Math.sin(epa._rotation * Math.PI / 180) * (5 + Math.random());
arrows.push(epa);
}
function createArrow(fromObj, isGood) {
if (isGood) {
ar = attachMovie('arrow', 'arrow' + depth, depth++);
if (fromObj == char) {
ar.Type = 1 + companionArrows[0];
} else {
ar.Type = 1 + companionArrows[fromObj.num + 1];
}
ar.gotoAndStop(ar.Type);
if (ar.Type == -1) {
ar.Type = 1;
}
} else {
ar.Type = 1;
if (fromObj.Type == 5) {
ar = attachMovie('arrow', 'arrow' + depth, depth++);
ar._yscale = 75;
ar._xscale = 75;
} else {
ar = attachMovie('spell', 'arrow' + depth, depth++);
ar.gotoAndStop(1);
}
}
ar.shockDelay = 0;
ar.isGood = isGood;
ar._x = fromObj._x;
ar._y = fromObj._y;
if (!isGood) {
if (fromObj.Type == 5) {
ar._x = fromObj._x + random(20) - 10;
ar._y = fromObj._y + random(20) - 10;
}
}
ar.shotDelay = 3;
ar.from = fromObj;
arrows.push(ar);
ar._rotation = fromObj._rotation;
if (fromObj.Type == 2) {
ar._rotation += 72 * fromObj.onShot;
fromObj.onShot += 1;
}
ar.xSpeed = Math.cos(ar._rotation * Math.PI / 180) * 25;
ar.ySpeed = Math.sin(ar._rotation * Math.PI / 180) * 25;
if (!isGood) {
ar.xSpeed = Math.cos(ar._rotation * Math.PI / 180) * 10;
ar.ySpeed = Math.sin(ar._rotation * Math.PI / 180) * 10;
if (fromObj.Type == 5) {
ar.xSpeed = Math.cos(ar._rotation * Math.PI / 180) * (10 + (Math.random() * 2 - 1));
ar.ySpeed = Math.sin(ar._rotation * Math.PI / 180) * (10 + (Math.random() * 2 - 1));
}
if (fromObj.Type == 11) {
ar.xSpeed = Math.cos(ar._rotation * Math.PI / 180) * 40;
ar.ySpeed = Math.sin(ar._rotation * Math.PI / 180) * 40;
}
}
}
function createParticles2(xVal, yVal, amount) {
p = 0;
while (p < amount) {
particle = attachMovie('particle2', 'particle' + highDepth, highDepth++);
particle._yscale = random(60) + 20;
particle._xscale = particle._yscale;
particle._alpha = random(100);
particle.Speed = 1 + Math.random() * 10;
particle.Dir = Math.PI * Math.random() * 2;
particle.xSpeed = Math.cos(particle.Dir) * particle.Speed;
particle.ySpeed = Math.sin(particle.Dir) * particle.Speed;
particle._rotation = particle.Dir * 180 / Math.PI;
particle._x = xVal;
particle._y = yVal;
particle.Type = 2;
particle.timeDelay = 10 + random(10);
particles.push(particle);
++p;
}
}
function createYPart(xVal, yVal, amount) {
p = 0;
while (p < amount) {
particle = attachMovie('yparticle', 'particle' + highDepth, highDepth++);
particle._yscale = random(80) + 10;
particle._xscale = particle._yscale;
particle._alpha = 50 + random(50);
particle.Speed = 10 + Math.random() * 10;
particle.Dir = Math.PI * Math.random() * 2;
particle.xSpeed = Math.cos(particle.Dir) * particle.Speed;
particle.ySpeed = Math.sin(particle.Dir) * particle.Speed;
particle._rotation = particle.Dir * 180 / Math.PI;
particle._x = xVal;
particle._y = yVal;
particle.Type = 3;
particle.timeDelay = 10 + random(10);
particles.push(particle);
++p;
}
}
function particleManagement() {
p = particles.length - 1;
while (p >= 0) {
particle = particles[p];
particle._x += particle.xSpeed;
particle._y += particle.ySpeed;
particle.ySpeed *= 0.85;
particle.xSpeed = particle.ySpeed;
if (particle.Type == 1) {
particle._alpha -= (100 - particle._alpha) / 10 + 1;
if (particle._alpha <= 0) {
removeParticle();
}
}
if (particle.Type == 2) {
particle.timeDelay -= 1;
if (particle.timeDelay <= 0) {
removeParticle();
}
}
if (particle.Type == 3) {
particle._alpha -= 3;
particle._yscale -= 2.5;
particle._xscale = particle._yscale;
if (particle._alpha <= 0) {
removeParticle();
}
}
--p;
}
}
function removeParticle() {
particle.removeMovieClip();
particles.splice(p, 1);
}
function hypot(theX, theY, theX2, theY2) {
return Math.sqrt((theX - theX2) * (theX - theX2) + (theY - theY2) * (theY - theY2));
}
function manageArrows() {
a = arrows.length - 1;
while (a >= 0) {
ar = arrows[a];
if (ar._x >= 0 && ar._x <= Stage.width && ar._y >= 0 && ar._y <= stageHeight && _quality == 'HIGH') {
if (random(3) == 0) {
createParticles2(ar._x, ar._y, 1);
}
}
ar._x += ar.xSpeed;
ar._y += ar.ySpeed;
if (ar.Type == 8) {
ar.shotDelay -= 1;
if (ar.shotDelay <= 0) {
ar.shotDelay = 3;
createGroundSpot(true);
}
}
ar.shockDelay -= 1;
if (ar.Type == 6 && ar._x != undefined && ar.isGood && ar.shockDelay <= 0) {
ar.shockDelay = 4;
e = enemies.length - 1;
while (e >= 0) {
enemy = enemies[e];
if (hypot(enemy._x, enemy._y, ar._x, ar._y) < 120) {
theLaser = createEmptyMovieClip('laser' + depth, depth++);
theLaser.lineStyle(3, 16777215);
theLaser.moveTo(enemy._x, enemy._y);
theLaser.lineTo(ar._x, ar._y);
lasers.push(theLaser);
damageToDo = 4;
enemy.health -= damageToDo;
enemy.timeSinceHit = 0;
dola = attachMovie('dola', 'dola' + highDepth, highDepth++);
dola._x = enemy._x - 20 + random(40);
dola._y = enemy._y - 40 + random(20);
dola.d1.moneyTxt.htmlText = damageToDo;
if (enemy.health <= 0) {
kills += 1;
killsThisWave += 1;
if (ar.from == char) {
xp += xps[onLevel - 1];
} else {
ar.from.xp += xps[onLevel - 1];
companionXps[ar.from.num] += xps[onLevel - 1];
if (ar.from.xp >= calcXpToLevel(ar.from.Level + 1)) {
ar.from.Level += 1;
companionLevels[ar.from.num] += 1;
calcCompLevels();
}
}
shake = 5;
if (enemy.Type <= 17) {
createCoin();
}
removeEnemy();
}
}
--e;
}
}
if (ar.hitTest(dragon)) {
damageToDo = Math.round(actualDamage * 0.8 + Math.random() * (actualDamage * 0.4));
if (ar.Type == 5) {
damageToDo = Math.round(damageToDo * 1.4);
}
dreagon.health -= damageToDo;
dola = attachMovie('dola', 'dola' + highDepth, highDepth++);
dola._x = dragon._x - 20 + random(40);
dola._y = dragon._y - 40 + random(20);
dola.d1.moneyTxt.htmlText = damageToDo;
dragon.gotoAndPlay(dragon._currentframe + 1);
removeArrow();
shake = 1;
if (dragon.health <= 0) {
hud.bh.tBar._xscale = 0;
explosion = attachMovie('explosion', 'explosion' + highDepth, highDepth++);
explosion._x = dragon._x;
explosion._y = dragon._y;
er = explosion.attachMovie('enemyReward', 'enemyReward' + highDepth, highDepth++);
er.r1.moneyTxt.htmlText = bold(1000);
enemyRewards.push(explosion);
removeDragon();
}
} else {
if (ar.hitTest(orb.ta)) {
damageToDo = Math.round(actualDamage * 0.8 + Math.random() * (actualDamage * 0.4));
if (ar.Type == 5) {
damageToDo = Math.round(damageToDo * 1.4);
}
orbHealth -= damageToDo;
if (orbHealth <= 0 && !toEnd) {
orbHealth = 0;
toEnd = true;
endTimer = 20;
orb.gotoAndStop(1);
explosion = attachMovie('explosion', 'explosion' + highDepth, highDepth++);
explosion._x = orb._x;
explosion._y = orb._y;
explosions.push(explosion);
}
dola = attachMovie('dola', 'dola' + highDepth, highDepth++);
dola._x = orb._x - 20 + random(40);
dola._y = orb._y - 40 + random(20);
dola.d1.moneyTxt.htmlText = damageToDo;
orb.orb.gotoAndPlay(2);
removeArrow();
shake = 1;
} else {
if (ar._x >= bg._x + bg._width || ar._x < bg._x || ar._y > bg._y + bg._height || ar._y < bg._y) {
removeArrow();
}
}
}
if (ar._x != undefined) {
if (char.charIn.enBody2.hitTest(ar._x, ar._y, true) && !ar.isGood) {
health -= damageByLevel[onLevel - 1];
char.charIn.gotoAndPlay(2);
rFlash.gotoAndPlay(2);
removeArrow();
} else {
c = companions.length - 1;
while (c >= 0) {
companion = companions[c];
if (companion.charIn.enBody2.hitTest(ar._x, ar._y, true) && !ar.isGood) {
companion.charIn.gotoAndPlay(2);
companion.health -= Math.floor(damageByLevel[onLevel - 1] / 2);
if (companion.health <= 0) {
removeCompanion();
}
removeArrow();
}
--c;
}
}
}
--a;
}
}
function removeArrow() {
ar.removeMovieClip();
arrows.splice(a, 1);
}
function removeGroundSpot() {
groundSpot.removeMovieClip();
groundSpots.splice(g, 1);
}
function removeGame() {
clearScreen();
spacer.removeMovieClip();
levelComplete.removeMovieClip();
pShadow.removeMovieClip();
waver.removeMovieClip();
controls.removeMovieClip();
awardk.removeMovieClip();
pbtn.removeMovieClip();
mbtn.removeMovieClip();
ibtn.removeMovieClip();
qbtn.removeMovieClip();
char.removeMovieClip();
hBar.removeMovieClip();
orb.removeMovieClip();
theReward.removeMovieClip();
uiTop.removeMovieClip();
uiBot.removeMovieClip();
ps.removeMovieClip();
bgFore.removeMovieClip();
c = civilians.length - 1;
while (c >= 0) {
civilians[c].removeMovieClip();
civilians.splice(c, 1);
--c;
}
}
function clearScreen() {
p = parts.length - 1;
while (p >= 0) {
parts[p].removeMovieClip();
parts.splice(p, 1);
--p;
}
l = lasers.length - 1;
while (l >= 0) {
lasers[l].removeMovieClip();
lasers.splice(l, 1);
--l;
}
g = groundSpots.length - 1;
while (g >= 0) {
groundSpot = groundSpots[g];
removeGroundSpot();
--g;
}
c = companions.length - 1;
while (c >= 0) {
companion = companions[c];
removeCompanion();
--c;
}
e = enemies.length - 1;
while (e >= 0) {
enemy = enemies[e];
removeEnemy();
--e;
}
p = particles.length - 1;
while (p >= 0) {
particle = particles[p];
removeParticle();
--p;
}
a = arrows.length - 1;
while (a >= 0) {
ar = arrows[a];
removeArrow();
--a;
}
c = coins.length - 1;
while (c >= 0) {
coin = coins[c];
removeCoin();
--c;
}
b = bloods.length - 1;
while (b >= 0) {
blood = bloods[b];
blood.removeMovieClip();
bloods.splice(b, 1);
--b;
}
}
function managePortalBgs() {
thePortals = new Array(bg.p1, bg.p2, bg.p3, bg.p4, bg.p5, bg.p6, bg.p7, bg.p8, bg.p9, bg.p10, bg.p11, bg.p12, bg.p13, bg.p14, bg.p15);
p = thePortals.length - 1;
while (p >= 0) {
if (p > levelsUnlocked - 1) {
thePortals[p]._alpha = 0;
} else {
thePortals[p]._alpha = 100;
}
--p;
}
}
function createEnemy(eType) {
enShadow = attachMovie('shadow', 'shadow' + depth, depth++);
enemy = attachMovie('allEn', 'enemy' + depth, depth++);
enemy.ina.gotoAndStop(eType);
enemy.toBeHit = 0;
enemy.inGround = false;
if (eType == 4) {
enemy.groundSpot = attachMovie('groundSpot', 'groundSpot' + lowDepth, lowDepth++);
}
enFire = attachMovie('fire', 'fire' + depth, depth++);
enemy.fire = enFire;
enemy.fire._rotation = 90;
enemy.fire._alpha = 0;
enemy.isIgnited = false;
enemy.isFrozen = false;
enemy.igniteTimer = 0;
enemy.freezeTimer = 0;
enemy.shotsLeft = 3;
enemy.Type = eType;
enemy._alpha = 0;
enemy.Speed = 0.4 + Math.random() * 0.2;
enemy.shotDelay = random(50);
if (enemy.Type == 12) {
enemy.shotDelay = random(1000);
}
enemy.xSpeed = 0;
enemy.ySpeed = 0;
enemy._yscale = 1;
enemy._xscale = 1;
enemy.spawned = false;
enemy.healthMax = Math.floor(levelHealthMultipliers[onLevel - 1] * relativeHealths[enemy.Type - 1] * 2.5);
if (survivalMode) {
enemy.healthMax = Math.ceil(enemy.healthMax / 2);
}
enemy.health = enemy.healthMax;
enemy.Shadow = enShadow;
do {
enemy._x = random(bg.rb._width) + bg._x;
enemy._y = random(bg.rb._height - 100) + bg._y;
} while (enemy.hitTest(char) || enemy.hitTest(orb) || bg.obstacles.hitTest(enemy._x, enemy._y, true));
if (enemy.Type == 3) {
eDir = Math.atan2(char._y - enemy._y, char._x - enemy._x);
enemy.xSpeed = Math.cos(eDir) * 4;
enemy.ySpeed = Math.sin(eDir) * 4;
}
if (eType == 18) {
enemy.ina.gotoAndStop(12);
}
if (eType == 19) {
enemy.ina.gotoAndStop(9);
enemy._x = realEn._x + random(60) - 30;
enemy._y = realEn._y + random(60) - 30;
}
if (enemy.Type == 12) {
enemy.health = enemy.healthMax;
}
if (enemy.Type == 16) {
enemy._x = realEn._x + Math.cos(realEn._rotation * Math.PI / 180) * 25;
enemy._y = realEn._y + Math.cos(realEn._rotation * Math.PI / 180) * 25;
}
enemy.createLine = false;
enemy.hBar = attachMovie('hBar', 'hBar' + highDepth, highDepth++);
enemy.spawnSpot = attachMovie('spawnSpot', 'spawnSpot' + lowDepth, lowDepth++);
enemy.spawnSpot._x = enemy._x;
enemy.spawnSpot._y = enemy._y;
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
enemy.Shadow._alpha = 0;
enemy.hBar._x = enemy._x;
enemy.hBar._y = enemy._y - 40;
enemy.hBar._alpha = 0;
enemy.timeSinceHit = 100;
enemy.Shadow._x = enemy._x;
enemy.Shadow._y = enemy._y;
enemies.push(enemy);
}
function trueEnemyLength() {
totEns = 0;
b = enemies.length - 1;
while (b >= 0) {
if (enemies[b].Type <= 17) {
totEns += 1;
}
--b;
}
return totEns;
}
function createGroundSpot(isGood) {
gSpot = attachMovie('groundSpot', 'groundSpot' + lowDepth, lowDepth++);
if (!isGood) {
gSpot._x = enemy._x;
gSpot._y = enemy._y;
gSpot.isGood = isGood;
gSpot.timeLeft = 200;
} else {
gSpot._x = ar._x;
gSpot._y = ar._y;
gSpot.isGood = isGood;
gSpot.timeLeft = 30;
}
groundSpots.push(gSpot);
}
function manageGroundSpots() {
toBeHit -= 1;
g = groundSpots.length - 1;
while (g >= 0) {
groundSpot = groundSpots[g];
e = enemies.length - 1;
while (e >= 0) {
enemy = enemies[e];
if (groundSpot.hitTest(enemy._x, enemy._y, true) && groundSpot.timeLeft > 5 && groundSpot.isGood) {
if (enemy.toBeHit <= 0) {
enemy.toBeHit = 5;
damageToDo = 300;
enemy.health -= damageToDo;
enemy.timeSinceHit = 0;
dola = attachMovie('dola', 'dola' + highDepth, highDepth++);
dola._x = enemy._x - 20 + random(40);
dola._y = enemy._y - 40 + random(20);
dola.d1.moneyTxt.htmlText = damageToDo;
if (enemy.health <= 0) {
kills += 1;
killsThisWave += 1;
xp += xps[onLevel - 1];
shake = 5;
if (enemy.Type <= 17) {
createCoin();
}
removeEnemy();
}
}
}
--e;
}
if (groundSpot.hitTest(char._x, char._y, true) && groundSpot.timeLeft > 75 && !groundSpot.isGood) {
if (toBeHit <= 0) {
toBeHit = 5;
if (_quality != 'LOW') {
blood = attachMovie('blood', 'blood' + highDepth, highDepth++);
blood._yscale = 80;
blood._xscale = 80;
blood.gotoAndStop(random(4) + 1);
blood._x = char._x;
blood._y = char._y;
blood._rotation = random(360);
bloods.push(blood);
}
enemy.ina.ina.gotoAndStop(2);
enemy.inGround = false;
char.charIn.gotoAndPlay(2);
health -= 30;
}
}
groundSpot.timeLeft -= 1;
if (!groundSpot.isGood) {
groundSpot._alpha = groundSpot.timeLeft;
} else {
groundSpot._alpha = groundSpot.timeLeft * 20;
}
if (groundSpot.timeLeft <= 0) {
groundSpot.removeMovieClip();
groundSpots.splice(g, 1);
}
--g;
}
}
function calcCompLevels() {
level2s = 0;
level3s = 0;
level4s = 0;
level5s = 0;
n = 0;
while (n < companions.length) {
if (companions[n].Level >= 2) {
level2s += 1;
}
if (companions[n].Level >= 3) {
level3s += 1;
}
if (companions[n].Level >= 4) {
level4s += 1;
}
if (companions[n].Level >= 5) {
level5s += 1;
}
++n;
}
if (level2s >= 1) {
giveAward(25);
}
if (level2s >= 2) {
giveAward(26);
}
if (level3s >= 1) {
giveAward(27);
}
if (level5s >= 1) {
giveAward(28);
}
if (level4s >= 2) {
giveAward(29);
}
if (level4s >= 3) {
giveAward(30);
}
}
function enemyManagement() {
if (bg._currentframe != 4 && bg._currentframe != 8) {
if (!survivalMode) {
if (!createdWave) {
trueWave = onWave;
if (trueWave > 4) {
trueWave = 4;
}
extraToAdd = extraEnemies[trueWave - 1];
e = 0;
while (e < waveSizes[trueWave - 1]) {
createdWave = true;
createEnemy(levelWaves[onLevel - 1][trueWave - 1][random(levelWaves[onLevel - 1][trueWave - 1].length)]);
++e;
}
orbTimer = 200;
}
eLength = trueEnemyLength();
if (eLength < waveSizes[trueWave - 1] && extraToAdd > 0) {
extraToAdd -= 1;
createEnemy(levelWaves[onLevel - 1][trueWave - 1][random(levelWaves[onLevel - 1][trueWave - 1].length)]);
}
if (enemies.length == 0 && !toEnd) {
orb.gotoAndStop(2);
if (levelsUnlocked == 1) {
orb.dto._alpha = 100;
} else {
orb.dto._alpha = 0;
}
orbTimer -= 1;
if (orbTimer <= 0) {
orb.gotoAndStop(1);
orb.dto._alpha = 0;
onWave += 1;
waver.gotoAndPlay(2);
waver.w1.waveTxt.htmlText = bold('Wave ' + onWave);
killsThisWave = 0;
createdWave = false;
}
}
}
}
e = enemies.length - 1;
while (e >= 0) {
enemy = enemies[e];
if (!enemy.spawned) {
enemy._alpha += 3;
enemy.Shadow._alpha += 3;
enemy._yscale += 3;
enemy._xscale = enemy._yscale;
if (enemy.Type == 19) {
enemy._yscale = 50;
enemy._xscale = 50;
enemy.spawnSpot._alpha = 0;
}
if ((enemy.Type == 18 || enemy.Type == 19) && enemy._xscale > 30) {
enemy.spawned = true;
enemy._alpha = 100;
enemy.Shadow._alpha = 100;
}
if (enemy._xscale >= 100) {
enemy.spawned = true;
enemy._alpha = 100;
enemy.Shadow._alpha = 100;
}
} else {
if (enemy.Type == 1) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
}
if (enemy.Type == 2) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
enemy.shotDelay -= 1;
if (enemy.shotDelay <= 0) {
enemy.shotsLeft -= 1;
enemy.shotDelay = 100;
if (enemy.shotsLeft > 0) {
enemy.shotDelay = 10;
enemy.onShot = 0;
createArrow(enemy, false);
createArrow(enemy, false);
createArrow(enemy, false);
createArrow(enemy, false);
createArrow(enemy, false);
enemy.ina.ina.gotoAndStop(2);
} else {
enemy.shotsLeft = 3;
}
}
}
if (enemy.Type == 3) {
enemy._x += enemy.xSpeed;
enemy._y += enemy.ySpeed;
if (enemy.isFrozen) {
enemy._x -= enemy.xSpeed / 1.5;
enemy._y -= enemy.ySpeed / 1.5;
}
enemy._rotation = Math.atan2(enemy.ySpeed, enemy.xSpeed) * 180 / Math.PI;
if (enemy._x + 15 >= bg._x + bg._width) {
enemy.xSpeed *= -1;
enemy._x = bg._x + bg._width - 15;
}
if (enemy._x - 15 < bg._x) {
enemy.xSpeed *= -1;
enemy._x = bg._x + 15;
}
if (enemy._y + 15 >= bg._y + bg._height) {
enemy.ySpeed *= -1;
enemy._y = bg._y + bg._height - 15;
}
if (enemy._y - 15 < bg._y) {
enemy.ySpeed *= -1;
enemy._y = bg._y + 15;
}
}
if (enemy.Type == 4) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
enemy.shotDelay -= 1;
enemy.groundSpot._x = enemy._x;
enemy.groundSpot._y = enemy._y;
if (enemy.shotDelay <= 0) {
enemy.inGround = !enemy.inGround;
enemy.shotDelay = random(100);
}
if (enemy.inGround) {
enemy.groundSpot._alpha = 50;
enemy._alpha = 0;
} else {
enemy.groundSpot._alpha = 0;
enemy._alpha = 100;
}
}
if (enemy.Type == 5) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
enemy.shotDelay -= 1;
if (enemy.shotDelay <= 0) {
enemy.shotDelay = 80 - random(10);
createArrow(enemy, false);
createArrow(enemy, false);
createArrow(enemy, false);
}
}
if (enemy.Type == 6) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
closestArrow = 0;
closestDist = 999999;
a = arrows.length - 1;
while (a >= 0) {
ar = arrows[a];
if (hypot(ar._x, ar._y, enemy._x, enemy._y) < closestDist) {
closestArrow = a;
closestDist = hypot(ar._x, ar._y, enemy._x, enemy._y);
}
--a;
}
if (closestDist < 150) {
dodgeDir = Math.atan2(enemy._y - arrows[closestArrow]._y, enemy._x - arrows[closestArrow]._x);
enemy._x += Math.cos(dodgeDir) * 5;
enemy._y += Math.sin(dodgeDir) * 5;
}
}
if (enemy.Type == 7) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
}
if (enemy.Type == 8) {
tempRot = enemy._rotation;
tempTurn = 0;
newRad = Math.atan2(char._y - enemy._y, char._x - enemy._x);
tempTurn = newRad * 180 / Math.PI;
diffRot = (tempRot - tempTurn) % 360;
if (diffRot > 180) {
diffRot -= 360;
} else {
if (diffRot < -180) {
diffRot += 360;
}
}
if (Math.abs(diffRot) < 0.5) {
tempRot = tempTurn;
} else {
if (diffRot < 0) {
tempRot += 2;
} else {
tempRot -= 2;
}
}
enemy._rotation = tempRot;
enemy._x += Math.cos(enemy._rotation * Math.PI / 180) * 6.5;
enemy._y += Math.sin(enemy._rotation * Math.PI / 180) * 6.5;
if (enemy.isFrozen) {
enemy._x -= Math.cos(enemy._rotation * Math.PI / 180) * 4.5;
enemy._y -= Math.sin(enemy._rotation * Math.PI / 180) * 4.5;
}
}
if (enemy.Type == 9) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
}
if (enemy.Type == 10) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
enemy.shotDelay -= 1;
if (enemy.shotDelay <= 0) {
enemy.shotDelay = 80;
createArrow(enemy, false);
}
}
if (enemy.Type == 11) {
if (enemy.shotDelay > -50) {
tempRot = enemy._rotation;
tempTurn = 0;
newRad = Math.atan2(char._y - enemy._y, char._x - enemy._x);
tempTurn = newRad * 180 / Math.PI;
diffRot = (tempRot - tempTurn) % 360;
if (diffRot > 180) {
diffRot -= 360;
} else {
if (diffRot < -180) {
diffRot += 360;
}
}
if (Math.abs(diffRot) < 0.5) {
tempRot = tempTurn;
} else {
if (diffRot < 0) {
tempRot += 0.5;
} else {
tempRot -= 0.5;
}
}
enemy._rotation = tempRot;
}
enemy.shotDelay -= 1;
if (enemy.shotDelay <= 0) {
enemy.createLine = true;
}
if (enemy.createLine) {
enemy.theItem.removeMovieClip();
theItem = createEmptyMovieClip('laser' + depth, depth++);
enemy.theItem = theItem;
if (enemy.shotDelay > -50) {
theItem._alpha = 50;
} else {
theItem._alpha = 100;
}
theItem.lineStyle(3, 16777215);
dir = enemy._rotation * Math.PI / 180;
theItem.moveTo(enemy._x + Math.cos(dir) * 40, enemy._y + Math.sin(dir) * 40);
theItem.lineTo(enemy._x + Math.cos(dir) * 1000, enemy._y + Math.sin(dir) * 1000);
}
if (enemy.shotDelay == -70) {
enemy.ina.ina.gotoAndStop(2);
}
if (enemy.shotDelay <= -80) {
enemy.shotDelay = 50;
createArrow(enemy, false);
enemy.createLine = false;
enemy.theItem.removeMovieClip();
}
}
if (enemy.Type == 12) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
enemy.shotDelay -= 1;
if (enemy.shotDelay <= 0) {
enemy.shotDelay = random(1000);
enemy.ina.ina.gotoAndStop(2);
realEn = enemy;
createEnemy(18);
enemy = realEn;
}
}
if (enemy.Type == 13) {
eDir = Math.atan2(char._y - enemy._y, char._x - enemy._x);
enemy.xSpeed += Math.cos(eDir) * enemy.Speed;
enemy.ySpeed += Math.sin(eDir) * enemy.Speed;
enemy.xSpeed *= 0.95;
enemy.ySpeed *= 0.95;
enemy._rotation = Math.atan2(enemy.ySpeed, enemy.xSpeed) * 180 / Math.PI;
enemy._x += enemy.xSpeed;
enemy._y += enemy.ySpeed;
if (enemy.isFrozen) {
enemy._x -= enemy.xSpeed / 1.5;
enemy._y -= enemy.ySpeed / 1.5;
}
}
if (enemy.Type == 14) {
tempRot = enemy._rotation;
tempTurn = 0;
newRad = Math.atan2(char._y - enemy._y, char._x - enemy._x);
tempTurn = newRad * 180 / Math.PI;
diffRot = (tempRot - tempTurn) % 360;
if (diffRot > 180) {
diffRot -= 360;
} else {
if (diffRot < -180) {
diffRot += 360;
}
}
if (Math.abs(diffRot) < 0.5) {
tempRot = tempTurn;
} else {
if (diffRot < 0) {
tempRot += 2;
} else {
tempRot -= 2;
}
}
enemy._rotation = tempRot;
enemy._x += Math.cos(enemy._rotation * Math.PI / 180) * 2.5;
enemy._y += Math.sin(enemy._rotation * Math.PI / 180) * 2.5;
if (enemy.isFrozen) {
enemy._x -= Math.cos(enemy._rotation * Math.PI / 180) * 2;
enemy._y -= Math.sin(enemy._rotation * Math.PI / 180) * 2;
}
enemy.shotDelay -= 1;
if (enemy.shotDelay <= 0) {
enemy.shotDelay = 30;
createGroundSpot(false);
}
}
if (enemy.Type == 15) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
enemy.shotDelay -= 1;
if (enemy.shotDelay <= 0) {
exer = attachMovie('explosion', 'explosion' + depth, depth++);
exer._x = enemy._x;
exer._y = enemy._y;
exers.push(exer);
eX = random(300) - 150;
eY = random(300) - 150;
exer._yscale = 30;
exer._xscale = 30;
enemy._x += eX;
enemy._y += eY;
enemy.shotDelay = 30 + random(30);
}
}
if (enemy.Type == 16) {
tempRot = enemy._rotation;
tempTurn = 0;
newRad = Math.atan2(char._y - enemy._y, char._x - enemy._x);
tempTurn = newRad * 180 / Math.PI;
diffRot = (tempRot - tempTurn) % 360;
if (diffRot > 180) {
diffRot -= 360;
} else {
if (diffRot < -180) {
diffRot += 360;
}
}
if (Math.abs(diffRot) < 0.5) {
tempRot = tempTurn;
} else {
if (diffRot < 0) {
tempRot += 1.3;
} else {
tempRot -= 1.3;
}
}
enemy._rotation = tempRot;
enemy._x += Math.cos(enemy._rotation * Math.PI / 180) * 1.5;
enemy._y += Math.sin(enemy._rotation * Math.PI / 180) * 1.5;
if (enemy.isFrozen) {
enemy._x -= Math.cos(enemy._rotation * Math.PI / 180) * 1;
enemy._y -= Math.sin(enemy._rotation * Math.PI / 180) * 1;
}
if (hypot(char._x, char._y, enemy._x, enemy._y) < 200) {
enemy._x += Math.cos(enemy._rotation * Math.PI / 180) * 5;
enemy._y += Math.sin(enemy._rotation * Math.PI / 180) * 5;
if (enemy.isFrozen) {
enemy._x -= Math.cos(enemy._rotation * Math.PI / 180) * 4;
enemy._y -= Math.sin(enemy._rotation * Math.PI / 180) * 4;
}
}
}
if (enemy.Type == 17) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
if (hypot(enemy._x, enemy._y, char._x, char._y) > 250) {
enemy._x += Math.cos(enemy._rotation * Math.PI / 180) * 2;
enemy._y += Math.sin(enemy._rotation * Math.PI / 180) * 2;
if (enemy.isFrozen) {
enemy._x -= Math.cos(enemy._rotation * Math.PI / 180) * 1.5;
enemy._y -= Math.sin(enemy._rotation * Math.PI / 180) * 1.5;
}
}
if (hypot(enemy._x, enemy._y, char._x, char._y) < 200) {
enemy._x -= Math.cos(enemy._rotation * Math.PI / 180) * 2;
enemy._y -= Math.sin(enemy._rotation * Math.PI / 180) * 2;
if (enemy.isFrozen) {
enemy._x += Math.cos(enemy._rotation * Math.PI / 180) * 1.5;
enemy._y += Math.sin(enemy._rotation * Math.PI / 180) * 1.5;
}
}
enemy.shotDelay -= 1;
if (enemy.shotDelay == 10) {
enemy.ina.ina.gotoAndStop(2);
}
if (enemy.shotDelay <= 0) {
enemy.shotDelay = 50 + random(30);
createArrow(enemy, false);
}
}
if (enemy.Type == 18) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
}
if (enemy.Type == 19) {
enemy._rotation = Math.atan2(char._y - enemy._y, char._x - enemy._x) * 180 / Math.PI;
}
if (enemy.Type == 2 || enemy.Type == 4 || enemy.Type == 6 || enemy.Type == 7 || enemy.Type == 19 || enemy.Type == 18 || enemy.Type == 15 || enemy.Type == 12 || enemy.Type == 11 || enemy.Type == 9 || enemy.Type == 5 || enemy.Type == 1) {
enemy._x += Math.cos(enemy._rotation * Math.PI / 180) * enSpeeds[enemy.Type - 1];
enemy._y += Math.sin(enemy._rotation * Math.PI / 180) * enSpeeds[enemy.Type - 1];
if (enemy.isFrozen) {
enemy._x -= Math.cos(enemy._rotation * Math.PI / 180) * enSpeeds[enemy.Type - 1] / 1.5;
enemy._y -= Math.sin(enemy._rotation * Math.PI / 180) * enSpeeds[enemy.Type - 1] / 1.5;
}
}
if (enemy._x >= bg._x + bg.rb._width - 10) {
enemy._x = bg._x + bg.rb._width - 10;
}
if (enemy._y >= bg._y + bg.rb._height - 10) {
enemy._y = bg._y + bg.rb._height - 10;
}
if (enemy._x <= bg._x + 10) {
enemy._x = bg._x + 10;
}
if (enemy._y <= bg._y + 10) {
enemy._y = bg._y + 10;
}
if (enemy.ina.ina.target2.hitTest(char.charIn.abox) && enemy.ina.ina._currentframe == 1) {
enemy.gotoAndPlay(2);
if (_quality != 'LOW') {
blood = attachMovie('blood', 'blood' + highDepth, highDepth++);
blood._yscale = 80;
blood._xscale = 80;
blood.gotoAndStop(random(4) + 1);
blood._x = char._x;
blood._y = char._y;
blood._rotation = random(360);
bloods.push(blood);
}
enemy.ina.ina.gotoAndStop(2);
enemy.inGround = false;
char.charIn.gotoAndPlay(2);
rFlash.gotoAndPlay(2);
health -= damageByLevel[onLevel - 1];
}
c = companions.length - 1;
while (c >= 0) {
companion = companions[c];
if (enemy.ina.ina.target2.hitTest(companion.charIn.abox) && enemy.ina.ina._currentframe == 1) {
enemy.gotoAndPlay(2);
if (_quality != 'LOW') {
blood = attachMovie('blood', 'blood' + highDepth, highDepth++);
blood._yscale = 80;
blood._xscale = 80;
blood.gotoAndStop(random(4) + 1);
blood._x = companion._x;
blood._y = companion._y;
blood._rotation = enemy._rotation;
bloods.push(blood);
}
enemy.ina.ina.gotoAndStop(2);
enemy.inGround = false;
companion.charIn.gotoAndPlay(2);
companion.health -= damageByLevel[onLevel - 1];
if (companion.health <= 0) {
removeCompanion();
}
}
--c;
}
while (bg.obstacles.hitTest(enemy._x + 15, enemy._y, true)) {
enemy._x -= 0.1;
if (enemy.Type == 3) {
eDir = Math.atan2(char._y - enemy._y, char._x - enemy._x);
enemy.xSpeed = Math.cos(eDir) * 4;
enemy.ySpeed = Math.sin(eDir) * 4;
}
}
while (bg.obstacles.hitTest(enemy._x - 15, enemy._y, true)) {
enemy._x += 0.1;
if (enemy.Type == 3) {
eDir = Math.atan2(char._y - enemy._y, char._x - enemy._x);
enemy.xSpeed = Math.cos(eDir) * 4;
enemy.ySpeed = Math.sin(eDir) * 4;
}
}
while (bg.obstacles.hitTest(enemy._x, enemy._y + 15, true)) {
enemy._y -= 0.1;
if (enemy.Type == 3) {
eDir = Math.atan2(char._y - enemy._y, char._x - enemy._x);
enemy.xSpeed = Math.cos(eDir) * 4;
enemy.ySpeed = Math.sin(eDir) * 4;
}
}
while (bg.obstacles.hitTest(enemy._x, enemy._y - 15, true)) {
enemy._y += 0.1;
if (enemy.Type == 3) {
eDir = Math.atan2(char._y - enemy._y, char._x - enemy._x);
enemy.xSpeed = Math.cos(eDir) * 4;
enemy.ySpeed = Math.sin(eDir) * 4;
}
}
while (orb.orbBase.hitTest(enemy._x + enemy._width / 2, enemy._y, true)) {
enemy._x -= 0.1;
}
while (orb.orbBase.hitTest(enemy._x - enemy._width / 2, enemy._y, true)) {
enemy._x += 0.1;
}
while (orb.orbBase.hitTest(enemy._x, enemy._y + enemy._height / 2, true)) {
enemy._y -= 0.1;
}
while (orb.orbBase.hitTest(enemy._x, enemy._y - enemy._height / 2, true)) {
enemy._y += 0.1;
}
enemy.fire._x = enemy._x;
enemy.fire._y = enemy._y - 80;
enemy.igniteTimer -= 1;
enemy.freezeTimer -= 1;
if (enemy.igniteTimer > 0) {
enemy.fire._alpha = 100;
if (enemy.igniteTimer % 20 == 0) {
damageToDo = 2;
enemy.health -= damageToDo;
enemy.timeSinceHit = 0;
dola = attachMovie('dola', 'dola' + highDepth, highDepth++);
dola._x = enemy._x - 20 + random(40);
dola._y = enemy._y - 40 + random(20);
dola.d1.moneyTxt.htmlText = damageToDo;
if (enemy.health <= 0) {
kills += 1;
killsThisWave += 1;
if (ar.from == char) {
xp += xps[onLevel - 1];
} else {
ar.from.xp += xps[onLevel - 1];
companionXps[ar.from.num] += xps[onLevel - 1];
if (ar.from.xp >= calcXpToLevel(ar.from.Level + 1)) {
ar.from.Level += 1;
companionLevels[ar.from.num] += 1;
calcCompLevels();
}
}
shake = 5;
if (enemy.Type <= 17) {
createCoin();
}
removeEnemy();
}
}
} else {
enemy.isIgnited = false;
enemy.fire._alpha = 0;
}
if (enemy.freezeTimer > 0) {
enemy.ina.iced.gotoAndStop(2);
} else {
enemy.ina.iced.gotoAndStop(1);
enemy.isFrozen = false;
}
enemy.hBar._x = enemy._x;
enemy.hBar._y = enemy._y - 40;
enemy.timeSinceHit += 1;
if (enemy.timeSinceHit < 50) {
enemy.hBar._alpha = 100;
} else {
enemy.hBar._alpha -= 5;
}
enemy.hBar.hIn._xscale = (enemy.health / enemy.healthMax) * 100;
a = arrows.length - 1;
while (a >= 0) {
ar = arrows[a];
if (enemy.ina.ina.target2.hitTest(ar.center) && ar.isGood && !enemy.inGround) {
shake = 1;
if (ar.Type == 2) {
enemy.isIgnited = true;
enemy.igniteTimer = 90;
}
if (ar.Type == 3) {
enemy.isFrozen = true;
enemy.freezeTimer = 120;
}
enemy.timeSinceHit = 0;
enemy._x += Math.cos(ar._rotation * Math.PI / 180) * 5;
enemy._y += Math.sin(ar._rotation * Math.PI / 180) * 5;
if (_quality != 'LOW') {
blood = attachMovie('blood', 'blood' + highDepth, highDepth++);
blood._yscale = 80;
blood._xscale = 80;
blood.gotoAndStop(random(4) + 1);
blood._x = enemy._x;
blood._y = enemy._y;
blood._rotation = ar._rotation;
bloods.push(blood);
}
if (ar.from == char) {
trace(ar.Type);
damageToDo = Math.round(actualDamage * 0.8 + Math.random() * (actualDamage * 0.4));
if (ar.Type == 5) {
damageToDo = Math.round(damageToDo * 1.4);
}
if (ar.Type == 7) {
if (random(100) < 50) {
ddamageToDo *= 2;
}
}
} else {
damageToDo = Math.round(ar.from.actualDamage * 0.8 + Math.random() * (ar.from.actualDamage * 0.4));
if (ar.Type == 5) {
damageToDo = Math.round(damageToDo * 1.4 / 5);
}
if (ar.Type == 7) {
if (random(100) < 20) {
ddamageToDo *= 2;
}
}
}
enemy.health -= damageToDo;
aHit.start();
dola = attachMovie('dola', 'dola' + highDepth, highDepth++);
dola._x = enemy._x - 20 + random(40);
dola._y = enemy._y - 40 + random(20);
dola.d1.moneyTxt.htmlText = damageToDo;
enemy.gotoAndPlay(2);
if (enemy.health <= 0) {
kills += 1;
killsThisWave += 1;
if (ar.from == char) {
xp += xps[onLevel - 1];
} else {
ar.from.xp += xps[onLevel - 1];
companionXps[ar.from.num] += xps[onLevel - 1];
if (ar.from.xp >= calcXpToLevel(ar.from.Level + 1)) {
ar.from.Level += 1;
companionLevels[ar.from.num] += 1;
calcCompLevels();
}
}
shake = 5;
if (enemy.Type <= 17) {
createCoin();
}
removeEnemy();
}
removeArrow();
}
--a;
}
}
enemy.Shadow._x = enemy._x;
enemy.Shadow._y = enemy._y;
--e;
}
}
function createCoin() {
if (random(30) == 1) {
coin = attachMovie('itemPickup', 'coin' + lowDepth, lowDepth++);
coin.isSpec = true;
} else {
coin = attachMovie('coin', 'coin' + lowDepth, lowDepth++);
coin.gotoAndStop(moneyFrames[onLevel - 1]);
coin._yscale = 50;
coin._xscale = 50;
coin.isSpec = false;
}
coin.fromEnemy = enemy.Type;
coin._x = enemy._x;
coin._y = enemy._y;
coins.push(coin);
}
function checkMoneyAward() {
if (money >= 100) {
giveAward(8);
}
if (money >= 1000) {
giveAward(9);
}
if (money >= 5000) {
giveAward(10);
}
if (money >= 20000) {
giveAward(11);
}
}
function calcItemReward() {
iAmount = calcUniqueItems();
if (iAmount >= 3) {
giveAward(18);
}
if (iAmount >= 5) {
giveAward(19);
}
if (iAmount >= 7) {
giveAward(20);
}
if (iAmount >= 10) {
giveAward(21);
}
if (iAmount >= 15) {
giveAward(22);
}
}
function calcUniqueItems() {
theList = new Array();
i = 0;
while (i < itemsOwned.length) {
isFound = false;
t = 0;
while (t < theList.length) {
if (theList[t] == itemsOwned[i]) {
isFound = true;
}
++t;
}
if (itemTypes[itemsOwned[i]] == BOOT || itemTypes[itemsOwned[i]] == ARMOR || itemTypes[itemsOwned[i]] == BOW) {
if (!isFound) {
theList.push(itemsOwned[i]);
}
}
++i;
}
return theList.length;
}
function coinManagement() {
c = coins.length - 1;
while (c >= 0) {
coin = coins[c];
if (coin.hitTest(char.charIn.abox)) {
createYPart(coin._x, coin._y, 10);
if (!coin.isSpec) {
dola = attachMovie('dola2', 'dola' + highDepth, highDepth++);
dola._x = coin._x;
dola._y = coin._y;
dola.d1.moneyTxt.htmlText = '$' + moneyValues[onLevel - 1];
money += moneyValues[onLevel - 1];
checkMoneyAward();
} else {
itemToGet = random(onLevel);
itemsOwned.push(itemsPerLevel[itemToGet]);
if (survivalMode) {
if (itemTypes[itemsOwned[itemsOwned.length - 1]] == BOW) {
if (itemsOwned[itemsOwned.length - 1] > companionBows[0]) {
companionBows[0] = itemsOwned[itemsOwned.length - 1];
}
}
if (itemTypes[itemsOwned[itemsOwned.length - 1]] == ARMOR) {
if (itemsOwned[itemsOwned.length - 1] > companionArmors[0]) {
health += itemAmounts[itemsOwned[itemsOwned.length - 1]] - itemAmounts[companionArmors[0]];
companionArmors[0] = itemsOwned[itemsOwned.length - 1];
}
}
if (itemTypes[itemsOwned[itemsOwned.length - 1]] == BOOT) {
if (itemsOwned[itemsOwned.length - 1] > companionBoots[0]) {
companionBoots[0] = itemsOwned[itemsOwned.length - 1];
}
}
maxHealth = calcHealthTotal();
speed = calcSpeed();
damage = calcTrueDamage();
}
calcItemReward();
theReward.gotoAndPlay(2);
theReward.rew.nameTxt.htmlText = bold(itemNames[itemsPerLevel[itemToGet]]);
theReward.rew.img.gotoAndStop(itemsPerLevel[itemToGet] + 1);
}
removeCoin();
}
--c;
}
}
function removeCoin() {
coin.removeMovieClip();
coins.splice(c, 1);
}
function shaker() {
if (shake == 0) {
} else {
if (shake == 1) {
shake += 1;
_root._x += 2;
_root._y += 2;
} else {
if (shake == 2) {
shake += 1;
_root._y -= 3;
_root._x -= 3;
} else {
if (shake == 3) {
shake = 0;
_root._x = 0;
_root._y = 0;
}
}
}
}
if (shake == 5) {
shake = 6;
_root._x += 4;
_root._y += 2;
} else {
if (shake == 6) {
shake = 7;
_root._x -= 7;
_root._y -= 1;
} else {
if (shake == 7) {
shake = 8;
_root._x += 7;
_root._y -= 6;
} else {
if (shake == 8) {
shake = 0;
_root._x = 0;
_root._y = 0;
}
}
}
}
}
function removeEnemy() {
if (enemy.Type == 7) {
enemyExplosion();
}
if (kills >= 100) {
giveAward(14);
}
if (kills >= 500) {
giveAward(15);
}
if (kills >= 2000) {
giveAward(16);
}
if (kills >= 10000) {
giveAward(17);
}
if (enemy.Type == 9) {
realEn = enemy;
createEnemy(19);
enemy = realEn;
realEn = enemy;
createEnemy(19);
enemy = realEn;
realEn = enemy;
createEnemy(19);
enemy = realEn;
}
enemy.groundSpot.removeMovieClip();
enemy.fire.removeMovieClip();
enemy.theItem.removeMovieClip();
enemy.Shadow.removeMovieClip();
enemy.hBar.removeMovieClip();
enemy.spawnSpot.removeMovieClip();
enemy.removeMovieClip();
enemies.splice(e, 1);
}
function createInventory() {
if (inventorying == false) {
inventorying = true;
playerPause = true;
inventory = attachMovie('inventory', 'inventory', 960700);
inventory._x = Stage.width + Stage.width / 2;
inventory._y = Stage.height / 2;
itemsToDisplay = itemsOwned.length;
itemsDisplayed = 0;
inventory.backBtn.onRelease = function () {
inventory.removeMovieClip();
inventorying = false;
playerPause = false;
};
i = 0;
while (i < 11) {
j = 0;
while (j < 11) {
itemsDisplayed += 1;
if (itemsDisplayed <= itemsToDisplay) {
anItem = inventory.attachMovie('anItem', 'anItem' + depth, depth++);
anItem.img.gotoAndStop(itemsOwned[i * 11 + j] + 1);
anItem._x = -198.5 + j * 40;
anItem._y = -190.5 + i * 40;
}
++j;
}
++i;
}
}
}
function manageInventory() {
if (inventorying) {
inventory._x += Math.floor((Stage.width / 2 - inventory._x) / 8) - 1;
if (inventory._x <= Stage.width / 2) {
inventory._x = Stage.width / 2;
}
}
if (!playerPause) {
inventorying = false;
}
}
function createLevelUp() {
allowedToPress = false;
levelingUp = true;
gamePause = true;
levelUp = attachMovie('levelUp', 'levelUp', 700600);
levelUp._x = -Stage.width / 2;
levelUp._y = Stage.height / 2;
levelUp.levelTxt.htmlText = bold(level);
levelUp.multTxt.htmlText = bold('X 1.2');
levelUp.damageTxt.htmlText = bold(actualDamage + ' => ' + Math.round(damage * 1.2));
}
function manageLevelUp() {
if (levelingUp) {
levelUp._x += Math.ceil((Stage.width / 2 - levelUp._x) / 8);
if (levelUp._x >= Stage.width / 2) {
levelUp._x = Stage.width / 2;
}
levelUp.onPress = function () {
allowedToPress = true;
};
levelUp.onRelease = function () {
if (levelUp._x >= Stage.width / 2 && allowedToPress) {
levelUp.removeMovieClip();
levelingUp = false;
gamePause = false;
}
};
}
}
function changeArmor(archer, frame) {
archer.charIn.t.o.q.gotoAndStop(frame);
archer.charIn.t.o.w.gotoAndStop(frame);
archer.charIn.t.o.e.gotoAndStop(frame);
archer.charIn.t.o.r.gotoAndStop(frame);
archer.charIn.hat.gotoAndStop(frame);
archer.charIn.w.w.gotoAndStop(frame);
archer.charIn.q.f.gotoAndStop(frame);
archer.charIn.q.d.gotoAndStop(frame);
}
function createCompanion() {
companion = attachMovie('char', 'companion' + highDepth, highDepth++);
companion.Shadow = attachMovie('shadow', 'shadow' + depth, depth++);
companion.hBar = attachMovie('healthBar', 'hBar' + highDepth, highDepth++);
companion.num = companions.length;
companion.Name = companionNames[companion.num];
companion.hBar.nameTxt.htmlText = companion.Name;
companion.hBar.inBar.gotoAndStop(2);
companion.hBar.backer.gotoAndStop(2);
companion.weaponUsed = companionBows[companion.num + 1] - 8;
companion.frozen = false;
companion.frozenDelay = 0;
if (companionArmors[companion.num + 1] != -1) {
changeArmor(companion, companionArmors[companion.num + 1] - 23);
} else {
changeArmor(companion, 1);
}
companion.charIn.t.o.bow.gotoAndStop(companionBows[companion.num + 1] - 8);
companion.healthMax = 50;
if (companionArmors[companion.num + 1] != -1) {
companion.healthMax += itemAmounts[companionArmors[companion.num + 1]];
}
companion.shotDelay = 0;
companion.xp = companionXps[companion.num];
companion.Level = companionLevels[companions.length];
companion.health = companion.healthMax;
companion._x = Stage.width / 2 + 100;
companion._y = Stage.height / 2;
companion.hBar._x = companion._x;
companion.hBar._y = companion._y - 40;
companion.Shadow._x = companion._x;
companion.Shadow._y = companion._y;
companion.Location = 1;
companion.xSpeed = 0;
companion.ySpeed = 0;
companion.actualDamage = 2;
if (companionBows[companion.num + 1] != -1) {
companion.actualDamage = Math.floor(itemAmounts[companionBows[companion.num + 1]] / 2);
}
companion.Speed = 3;
if (companionBoots[companion.num + 1] != -1) {
companion.Speed = itemAmounts[companionBoots[companion.num + 1]];
}
companions.push(companion);
}
function hypot(theX, theY, theX2, theY2) {
return Math.sqrt((theX - theX2) * (theX - theX2) + (theY - theY2) * (theY - theY2));
}
function findClosestEnemy(theObj) {
if (enemies.length == 0) {
return -1;
}
theDist = 9999999;
choice = 0;
e = enemies.length - 1;
while (e >= 0) {
enemy = enemies[e];
if (hypot(enemy._x, enemy._y, theObj._x, theObj._y) < theDist) {
theDist = hypot(enemy._x, enemy._y, theObj._x, theObj._y);
choice = e;
}
--e;
}
return choice;
}
function companionManagement() {
c = companions.length - 1;
while (c >= 0) {
companion = companions[c];
companion.hBar.inBar._xscale = (companion.health / companion.healthMax) * 100;
companion.shotDelay -= 1;
j = findClosestEnemy(companion);
if (j != -1) {
companion._rotation = Math.atan2(enemies[j]._y - companion._y, enemies[j]._x - companion._x) * 180 / Math.PI;
if (companion.shotDelay <= 0) {
companion.shotDelay = 10;
companion.charIn.t.o.gotoAndPlay(2);
companion.charIn.t.o.wepTrails.r.gotoAndPlay(2);
aShot.start();
createArrow(companion, true);
}
}
if (j != -1 && hypot(enemies[j]._x, enemies[j]._y, companion._x, companion._y) < 120) {
if (hypot(enemies[j]._x, enemies[j]._y, companion._x, companion._y) < 90) {
dir = Math.atan2(companion._y - enemies[j]._y, companion._x - enemies[j]._x);
companion.xSpeed = Math.cos(dir) * companion.Speed;
companion.ySpeed = Math.sin(dir) * companion.Speed;
}
} else {
targetX = char._x;
targetY = char._y;
if (companion.num == 0) {
targetX += 100;
}
if (companion.num == 1) {
targetX -= 100;
}
if (companion.num == 2) {
targetY += 100;
}
if (hypot(companion._x, companion._y, targetX, targetY) > 15) {
dir = Math.atan2(targetY - companion._y, targetX - companion._x);
companion.xSpeed = Math.cos(dir) * companion.Speed;
companion.ySpeed = Math.sin(dir) * companion.Speed;
}
}
companion.hBar.levelTxt.htmlText = bold(companion.Level);
companion._x += companion.xSpeed;
companion._y += companion.ySpeed;
while (orb.orbBase.hitTest(companion._x + 15, companion._y, true)) {
companion._x -= 0.1;
}
while (orb.orbBase.hitTest(companion._x - 15, companion._y, true)) {
companion._x += 0.1;
}
while (orb.orbBase.hitTest(companion._x, companion._y + 15, true)) {
companion._y -= 0.1;
}
while (orb.orbBase.hitTest(companion._x, companion._y - 15, true)) {
companion._y += 0.1;
}
while (bg.obstacles.hitTest(companion._x + 15, companion._y, true)) {
companion._x -= 0.1;
}
while (bg.obstacles.hitTest(companion._x - 15, companion._y, true)) {
companion._x += 0.1;
}
while (bg.obstacles.hitTest(companion._x, companion._y + 15, true)) {
companion._y -= 0.1;
}
while (bg.obstacles.hitTest(companion._x, companion._y - 15, true)) {
companion._y += 0.1;
}
cc = coins.length - 1;
while (cc >= 0) {
coin = coins[cc];
if (coin.hitTest(companion.charIn.abox)) {
createYPart(coin._x, coin._y, 10);
if (!coin.isSpec) {
dola = attachMovie('dola2', 'dola' + highDepth, highDepth++);
dola._x = coin._x;
dola._y = coin._y;
dola.d1.moneyTxt.htmlText = '$' + moneyValues[onLevel - 1];
money += moneyValues[onLevel - 1];
checkMoneyAward();
} else {
itemToGet = random(onLevel);
itemsOwned.push(itemsPerLevel[itemToGet]);
calcItemReward();
theReward.gotoAndPlay(2);
theReward.rew.nameTxt.htmlText = bold(itemNames[itemsPerLevel[itemToGet]]);
theReward.rew.img.gotoAndStop(itemsPerLevel[itemToGet] + 1);
}
coin.removeMovieClip();
coins.splice(cc, 1);
}
--cc;
}
companion.Shadow._x = companion._x;
companion.Shadow._y = companion._y;
companion.hBar._x = companion._x;
companion.hBar._y = companion._y - 40;
--c;
}
}
function removeCompanion() {
companion.hBar.removeMovieClip();
companion.Shadow.removeMovieClip();
companion.removeMovieClip();
companions.splice(c, 1);
}
function manageSurvival() {
if (survivalMode) {
timeToNewEnemy -= 1;
if (timeToNewEnemy <= 0) {
survivalPart += 1;
timeToNewEnemy = 900;
onLevel = survivalPart - 1;
}
createEnSur -= 1;
if (createEnSur <= 0 && enemies.length <= onLevel + 10) {
createEnSur = survivalEnemyDelays[survivalPart - 2];
createEnemy(enemyLinkToOrder[random(survivalPart)]);
}
}
}
function bloodManagement() {
b = bloods.length - 1;
while (b >= 0) {
blood = bloods[b];
if (blood._x == undefined) {
blood.removeMovieClip();
bloods.splice(b, 1);
}
--b;
}
}
function laserManagement() {
l = lasers.length - 1;
while (l >= 0) {
laser = lasers[l];
laser._alpha -= 20;
if (laser._alpha <= 0) {
laser.removeMovieClip();
lasers.splice(l, 1);
}
--l;
}
}
function onEnterFrame() {
if (!gamePause && !playerPause) {
bloodManagement();
partManagement();
charMovement();
shooting();
laserManagement();
enemyManagement();
companionManagement();
manageGroundSpots();
manageArrows();
coinManagement();
particleManagement();
manageCivilians();
}
manageSurvival();
manageStarting();
manageAwardQueue();
manageInventory();
manageLevelUp();
shaker();
updateStats();
wasMDown = mDown;
}
function alphaHover(button) {
button.onRollOver = function () {
button._alpha = 75;
};
button.onRollOut = function () {
button._alpha = 100;
};
}
function pauseStuff() {
if (playerPause) {
ps = attachMovie('pauseScreen', 'pauseScreen', 822345);
ps._x = Stage.width / 2;
ps._y = Stage.height / 2;
ps.ctu.onRelease = function () {
ps.removeMovieClip();
playerPause = false;
};
ps.qtm.onRelease = function () {
ps.removeMovieClip();
removeGame();
gotoAndStop(3);
};
} else {
ps.removeMovieClip();
}
}
function createLevelSelect() {
levelSelect = attachMovie('levelSelect', 'levelSelect', 911332);
levelSelect._x = Stage.width / 2;
levelSelect._y = Stage.height / 2;
createButton(levelSelect.b1);
levelSelect.b1.onRelease = function () {
levelSelect.removeMovieClip();
};
portals = new Array(levelSelect.p1, levelSelect.p2, levelSelect.p3, levelSelect.p4, levelSelect.p5, levelSelect.p6, levelSelect.p7, levelSelect.p8, levelSelect.p9, levelSelect.p10, levelSelect.p11, levelSelect.p12, levelSelect.p13, levelSelect.p14, levelSelect.p15);
pInfos = new Array(levelSelect.v1, levelSelect.v2, levelSelect.v3, levelSelect.v4, levelSelect.v5, levelSelect.v6, levelSelect.v7, levelSelect.v8, levelSelect.v9, levelSelect.v10, levelSelect.v11, levelSelect.v12, levelSelect.v13, levelSelect.v14, levelSelect.v15);
p = 0;
while (p < levelsUnlocked) {
pInfos[p].gotoAndStop(2);
pInfos[p].levelTxt.htmlText = bold(p + 1);
createPortalButton(portals[p], p);
++p;
}
}
function createPortalButton(button, num) {
button.onRollOver = function () {
button.toChange.gotoAndStop(2);
};
button.onRollOut = function () {
button.toChange.gotoAndStop(1);
};
button.onReleaseOutside = function () {
button.toChange.gotoAndStop(1);
};
button.onRelease = function () {
levelSelect.removeMovieClip();
fromHome = false;
createPrepScreen();
onLevel = num + 1;
};
}
function createPrepScreen() {
prepScreen = attachMovie('prepScreen', 'prepScreen', 911223);
prepScreen._x = Stage.width / 2;
prepScreen._y = Stage.height / 2;
gamePause = true;
if (levelsUnlocked == 1 || fromHome) {
prepScreen.red._alpha = 0;
}
prepScreen.theArrow1._alpha = 0;
prepScreen.theArrow2._alpha = 0;
if (companionsOwned <= 2) {
prepScreen.c4._y = -1000;
}
if (companionsOwned <= 1) {
prepScreen.c3._y = -1000;
}
if (companionsOwned <= 0) {
prepScreen.c2._y = -1000;
}
createButton(prepScreen.lArrow);
createButton(prepScreen.rArrow);
createButton(prepScreen.btt);
createButton(prepScreen.red);
prepScreen.btt.onRelease = function () {
gamePause = false;
prepScreen.removeMovieClip();
};
prepScreen.red.onRelease = function () {
if (!fromHome && (prepScreen.c1.alert1._alpha < 50 && prepScreen.c1.alert2._alpha < 50 && prepScreen.c1.alert3._alpha < 50 && prepScreen.c1.alert4._alpha < 50 && prepScreen.c1.alert5._alpha < 50) || levelsUnlocked > 1) {
if (companionArmors[0] != -1) {
changeArmor(char, companionArmors[0] - 22);
} else {
changeArmor(char, 1);
}
c = 0;
while (c < companionsOwned) {
createCompanion();
++c;
}
controls.removeMovieClip();
c = civilians.length - 1;
while (c >= 0) {
civ = civilians[c];
civ.removeMovieClip();
civilians.splice(c, 1);
--c;
}
bgFore.gotoAndStop(1);
maxHealth = calcHealthTotal();
speed = calcSpeed();
damage = calcTrueDamage();
preMoney = money;
preXp = xp;
orb.gotoAndStop(1);
orb.dto._alpha = 0;
orb._x = bg._x + bg.rb._width / 2;
orb._y = bg._y + bg.rb._height / 2;
prepScreen.removeMovieClip();
bg.gotoAndStop(theBgNums[(onLevel - 1) % 5]);
realShop.stop();
game1.start(0, 10000);
onWave = 1;
killsThisWave = 0;
extraToAdd = 0;
createdWave = false;
gamePause = false;
orbTimer = 0;
trueWave = 1;
hBar._alpha = 100;
rings._alpha = 100;
health = maxHealth;
orbHealthMax = orbHealths[onLevel - 1];
orbHealth = orbHealthMax;
char.charIn.t.o.bow.gotoAndStop(companionBows[0] - 8);
saveGame();
}
};
theCs = new Array(prepScreen.c1, prepScreen.c2, prepScreen.c3, prepScreen.c4);
c = 0;
while (c < theCs.length) {
theCs[c].nameTxt.htmlText = bold(companionNames[c - 1]);
theCs[c].boxes = new Array();
theCs[c].boxBgs = new Array();
theCs[c].alerts = new Array();
theCs[c].alerts.push(theCs[c].alert1);
theCs[c].alerts.push(theCs[c].alert2);
theCs[c].alerts.push(theCs[c].alert3);
theCs[c].alerts.push(theCs[c].alert4);
theCs[c].alerts.push(theCs[c].alert5);
theCs[c].boxBgs.push(theCs[c].d1);
theCs[c].boxBgs.push(theCs[c].d2);
theCs[c].boxBgs.push(theCs[c].d3);
theCs[c].boxBgs.push(theCs[c].d4);
theCs[c].boxes.push(theCs[c].b1);
theCs[c].boxes.push(theCs[c].a1);
theCs[c].boxes.push(theCs[c].a2);
theCs[c].boxes.push(theCs[c].b2);
if (c == 0) {
theCs[c].boxes.push(theCs[c].s1);
theCs[c].boxBgs.push(theCs[c].d5);
}
theCs[c].a1._alpha = 0;
theCs[c].a2._alpha = 0;
theCs[c].b1._alpha = 0;
theCs[c].b2._alpha = 0;
theCs[c].s1._alpha = 0;
++c;
}
c = 0;
while (c < theCs.length) {
b = 0;
while (b < theCs[c].boxes.length) {
createSButton(theCs[c].boxBgs[b], theCs[c].boxes[b], c, b);
++b;
}
++c;
}
if (prepScreen.c1.alert1._alpha < 50 && prepScreen.c1.alert2._alpha < 50 && prepScreen.c1.alert3._alpha < 50 && prepScreen.c1.alert4._alpha < 50 && prepScreen.c1.alert5._alpha < 50 || levelsUnlocked > 1) {
prepScreen.red._alpha = 100;
}
if (fromHome) {
prepScreen.red._alpha = 0;
}
prepScreen.p1._alpha = 0;
prepScreen.p2._alpha = 0;
prepScreen.p3._alpha = 0;
}
function calcTrueDamage() {
if (companionBows[0] != -1) {
baseDamage = itemAmounts[companionBows[0]];
} else {
baseDamage = 5;
}
d = 1;
while (d < level) {
baseDamage *= 1.2;
++d;
}
return baseDamage;
}
function bold(item) {
return '<b>' + item + '<b>';
}
function updatePrepScreenStats() {
theCs2 = new Array(prepScreen.c1, prepScreen.c2, prepScreen.c3, prepScreen.c4);
q = 0;
while (q < theCs.length) {
cer = theCs2[q];
if (q == 0) {
if (companionItems[0][q] != -1) {
cer.dTxt.htmlText = bold(itemAmounts[companionItems[0][q]]);
} else {
cer.dTxt.htmlText = bold(5);
}
if (companionItems[2][q] != -1) {
cer.aTxt.htmlText = bold(50 + itemAmounts[companionItems[2][q]]);
} else {
cer.aTxt.htmlText = bold(50);
}
if (companionItems[3][q] != -1) {
cer.sTxt.htmlText = bold(itemAmounts[companionItems[3][q]]);
} else {
cer.sTxt.htmlText = bold(3);
}
} else {
if (companionItems[0][q] != -1) {
cer.dTxt.htmlText = bold(Math.ceil(itemAmounts[companionItems[0][q]] / 3));
} else {
cer.dTxt.htmlText = bold(2);
}
if (companionItems[2][q] != -1) {
cer.aTxt.htmlText = bold(50 + itemAmounts[companionItems[2][q]]);
} else {
cer.aTxt.htmlText = bold(50);
}
if (companionItems[3][q] != -1) {
cer.sTxt.htmlText = bold(itemAmounts[companionItems[3][q]]);
} else {
cer.sTxt.htmlText = bold(3);
}
}
cer.lTxt.htmlText = bold(companionLevels[q - 1]);
if (q == 0) {
cer.lTxt.htmlText = bold(level);
}
++q;
}
}
function findMax(theArr) {
max = -1;
m = 0;
while (m < theArr.length) {
if (theArr[m] > max) {
max = theArr[m];
}
++m;
}
return max;
}
function createSButton(button, image, num, num2) {
button.onRollOver = function () {
button.gotoAndStop(2);
};
button.onRollOut = function () {
button.gotoAndStop(1);
};
button.onReleaseOutside = function () {
button.gotoAndStop(1);
};
if (companionItems[num2][num] != -1) {
theCs[num].boxes[num2]._alpha = 100;
theCs[num].boxes[num2].gotoAndStop(companionItems[num2][num] + 1);
} else {
theCs[num].boxes[num2]._alpha = 0;
}
itemOptions = new Array();
itemOptions.push(-1);
i = itemsOwned.length - 1;
while (i >= 0) {
if (itemTypes[itemsOwned[i]] == num2 + 1) {
itemOptions.push(itemsOwned[i]);
}
--i;
}
theCs[num].alerts[num2]._alpha = 0;
if (findMax(itemOptions) > companionItems[num2][num]) {
theCs[num].alerts[num2]._alpha = 100;
}
updatePrepScreenStats();
button.onRelease = function () {
itemOptions = new Array();
itemOptions.push(-1);
i = itemsOwned.length - 1;
while (i >= 0) {
if (itemTypes[itemsOwned[i]] == num2 + 1) {
itemOptions.push(itemsOwned[i]);
}
--i;
}
if (levelsUnlocked == 1 && findMax(itemOptions) != companionItems[num2][num]) {
prepScreen.theArrow1._alpha = 100;
}
c = companionItems[num2].length - 1;
while (c >= 0) {
iIn = findIndexInItemOptions(itemOptions, companionItems[num2][c]);
if (num != c && itemOptions[iIn] != -1) {
itemOptions.splice(iIn, 1);
}
--c;
}
itemIndex = findIndexInItemOptions(itemOptions, companionItems[num2][num]);
if (itemIndex != -1) {
prepScreen.p2._alpha = 100;
prepScreen.p2.gotoAndStop(itemOptions[itemIndex] + 1);
if (itemOptions[itemIndex] == -1) {
prepScreen.p2._alpha = 0;
}
leftItem = itemIndex - 1;
if (leftItem <= -1) {
leftItem = itemOptions.length - 1;
}
rightItem = itemIndex + 1;
if (rightItem > itemOptions.length - 1) {
rightItem = 0;
}
prepScreen.p1.gotoAndStop(itemOptions[leftItem] + 1);
prepScreen.p3.gotoAndStop(itemOptions[rightItem] + 1);
if (itemOptions[leftItem] != -1) {
prepScreen.p1._alpha = 100;
} else {
prepScreen.p1._alpha = 0;
}
if (itemOptions[rightItem] != -1 && itemOptions.length > 2) {
prepScreen.p3._alpha = 100;
} else {
prepScreen.p3._alpha = 0;
}
prepScreen.lArrow.onRelease = function () {
prepScreen.theArrow1._alpha = 0;
rightItem = itemIndex;
itemIndex = leftItem;
companionItems[num2][num] = itemOptions[leftItem];
theCs[num].boxes[num2].gotoAndStop(companionItems[num2][num] + 1);
if (companionItems[num2][num] == -1) {
theCs[num].boxes[num2]._alpha = 0;
} else {
theCs[num].boxes[num2]._alpha = 100;
}
leftItem -= 1;
if (leftItem <= -1) {
leftItem = itemOptions.length - 1;
}
prepScreen.p2._alpha = 100;
prepScreen.p2.gotoAndStop(itemOptions[itemIndex] + 1);
if (itemOptions[itemIndex] == -1) {
prepScreen.p2._alpha = 0;
}
prepScreen.p1.gotoAndStop(itemOptions[leftItem] + 1);
prepScreen.p3.gotoAndStop(itemOptions[rightItem] + 1);
if (itemOptions[leftItem] != -1) {
prepScreen.p1._alpha = 100;
} else {
prepScreen.p1._alpha = 0;
}
if (itemOptions[rightItem] != -1 && itemOptions.length > 2) {
prepScreen.p3._alpha = 100;
} else {
prepScreen.p3._alpha = 0;
}
if (findMax(itemOptions) == companionItems[num2][num]) {
theCs[num].alerts[num2]._alpha = 0;
}
if (levelsUnlocked == 1 && (prepScreen.c1.alert1._alpha < 50 && prepScreen.c1.alert2._alpha < 50 && prepScreen.c1.alert3._alpha < 50 && prepScreen.c1.alert4._alpha < 50 && prepScreen.c1.alert5._alpha < 50)) {
prepScreen.theArrow2._alpha = 100;
prepScreen.red._alpha = 100;
}
if (fromHome) {
prepScreen.theArrow2._alpha = 0;
prepScreen.red._alpha = 0;
}
updatePrepScreenStats();
};
prepScreen.rArrow.onRelease = function () {
prepScreen.theArrow1._alpha = 0;
leftItem = itemIndex;
itemIndex = rightItem;
companionItems[num2][num] = itemOptions[rightItem];
theCs[num].boxes[num2].gotoAndStop(companionItems[num2][num] + 1);
if (companionItems[num2][num] == -1) {
theCs[num].boxes[num2]._alpha = 0;
} else {
theCs[num].boxes[num2]._alpha = 100;
}
rightItem += 1;
if (rightItem > itemOptions.length - 1) {
rightItem = 0;
}
prepScreen.p2._alpha = 100;
prepScreen.p2.gotoAndStop(itemOptions[itemIndex] + 1);
if (itemOptions[itemIndex] == -1) {
prepScreen.p2._alpha = 0;
}
prepScreen.p1.gotoAndStop(itemOptions[leftItem] + 1);
prepScreen.p3.gotoAndStop(itemOptions[rightItem] + 1);
if (itemOptions[leftItem] != -1) {
prepScreen.p1._alpha = 100;
} else {
prepScreen.p1._alpha = 0;
}
if (itemOptions[rightItem] != -1 && itemOptions.length > 2) {
prepScreen.p3._alpha = 100;
} else {
prepScreen.p3._alpha = 0;
}
if (findMax(itemOptions) == companionItems[num2][num]) {
theCs[num].alerts[num2]._alpha = 0;
}
updatePrepScreenStats();
};
} else {
prepScreen.p2._alpha = 0;
}
};
}
function removePrepScreen() {
prepScreen.removeMovieClip();
preping = false;
}
function findIndexInItemOptions(theArr, lookingFor) {
a = 0;
while (a < theArr.length) {
if (theArr[a] == lookingFor) {
return a;
}
++a;
}
return -1;
}
function bold(item) {
return '<b>' + item + '</b>';
}
function calcHealthTotal() {
hTotal = 50;
if (companionArmors[0] == -1) {
return hTotal;
}
hTotal += itemAmounts[companionArmors[0]];
return hTotal;
}
function calcSpeed() {
speeder = 3;
if (companionBoots[0] != -1) {
speeder = itemAmounts[companionBoots[0]];
}
return speeder;
}
function createResearchScreen() {
gamePause = true;
researchScreen = attachMovie('researchScreen', 'researchScreen', 911211);
researchScreen._x = Stage.width / 2;
researchScreen._y = Stage.height / 2;
researchArrows = new Array(researchScreen.a1, researchScreen.a2, researchScreen.a3, researchScreen.a4, researchScreen.a5, researchScreen.a6, researchScreen.a7, researchScreen.a8);
researchSkills = new Array(researchScreen.s1, researchScreen.s2, researchScreen.s3);
researchCompanions = new Array(researchScreen.merc1, researchScreen.merc2, researchScreen.merc3);
a = 0;
while (a < researchArrows.length) {
researchArrows[a].gotoAndStop(a + 1);
if (arrowTechnology > a) {
researchArrows[a]._alpha = 100;
} else {
researchArrows[a]._alpha = 10;
}
++a;
}
s = 0;
while (s < researchSkills.length) {
researchSkills[s].gotoAndStop(s + 30);
if (skillTechnology > s) {
researchSkills[s]._alpha = 100;
} else {
researchSkills[s]._alpha = 10;
}
++s;
}
c = 0;
while (c < researchCompanions.length) {
if (companionsOwned > c) {
researchCompanions[c]._alpha = 100;
} else {
researchCompanions[c]._alpha = 0;
}
++c;
}
researchScreen.moneyTxt.htmlText = bold('$' + money);
researchScreen.arrowCostTxt.htmlText = bold('$' + arrowCosts[arrowTechnology]);
researchScreen.skillCostTxt.htmlText = bold('$' + skillCosts[skillTechnology]);
researchScreen.compCostTxt.htmlText = bold('$' + companionCosts[companionsOwned]);
researchScreen.descTxt.htmlText = 'Hello, I\'m Aria. You can use my alchemy to help your battle needs at a cost!';
createButton(researchScreen.b1);
createButton(researchScreen.b2);
createButton(researchScreen.b3);
researchScreen.b1.onRollOver = function () {
researchScreen.b1.gotoAndStop(2);
researchScreen.infoBox.descTxt.htmlText = itemDescs[arrowTechnology];
};
researchScreen.b2.onRollOver = function () {
researchScreen.b2.gotoAndStop(2);
researchScreen.infoBox.descTxt.htmlText = itemDescs[skillTechnology + 29];
};
researchScreen.b3.onRollOver = function () {
researchScreen.b3.gotoAndStop(2);
researchScreen.infoBox.descTxt.htmlText = 'Hire a mercenary to assist you in combat';
};
researchScreen.b1.onRelease = function () {
if (money >= arrowCosts[arrowTechnology] && arrowTechnology < 8) {
money -= arrowCosts[arrowTechnology];
itemsOwned.push(arrowTechnology);
itemsOwned.push(arrowTechnology);
itemsOwned.push(arrowTechnology);
itemsOwned.push(arrowTechnology);
arrowTechnology += 1;
researchArrows[arrowTechnology - 1]._alpha = 100;
if (arrowTechnology + skillTechnology >= 5) {
giveAward(23);
}
if (arrowTechnology + skillTechnology >= 5) {
giveAward(24);
}
}
researchScreen.moneyTxt.htmlText = bold('$' + money);
researchScreen.arrowCostTxt.htmlText = bold('$' + arrowCosts[arrowTechnology]);
if (arrowTechnology == 8) {
researchScreen.arrowCostTxt.htmlText = bold('$MAXED');
}
};
researchScreen.b2.onRelease = function () {
if (money >= skillCosts[skillTechnology] && skillTechnology < 3) {
money -= skillCosts[skillTechnology];
skillTechnology += 1;
researchSkills[skillTechnology - 1]._alpha = 100;
itemsOwned.push(skillTechnology + 28);
if (arrowTechnology + skillTechnology >= 5) {
giveAward(23);
}
if (arrowTechnology + skillTechnology >= 5) {
giveAward(24);
}
}
researchScreen.moneyTxt.htmlText = bold('$' + money);
researchScreen.skillCostTxt.htmlText = bold('$' + skillCosts[skillTechnology]);
if (skillTechnology == 3) {
researchScreen.skillCostTxt.htmlText = bold('$MAXED');
}
};
researchScreen.b3.onRelease = function () {
if (money >= companionCosts[companionsOwned] && companionsOwned < 3) {
money -= companionCosts[companionsOwned];
companionsOwned += 1;
researchCompanions[companionsOwned - 1]._alpha = 100;
}
researchScreen.moneyTxt.htmlText = bold('$' + money);
researchScreen.compCostTxt.htmlText = bold('$' + companionCosts[companionsOwned]);
if (companionsOwned == 3) {
researchScreen.compCostTxt.htmlText = bold('$MAXED');
}
};
if (arrowTechnology == 8) {
researchScreen.arrowCostTxt.htmlText = bold('$MAXED');
}
if (skillTechnology == 3) {
researchScreen.skillCostTxt.htmlText = bold('$MAXED');
}
if (companionsOwned == 3) {
researchScreen.compCostTxt.htmlText = bold('$MAXED');
}
createButton(researchScreen.backBtn);
researchScreen.backBtn.onRelease = function () {
researchScreen.removeMovieClip();
gamePause = false;
};
}
function createAchievements() {
achievementScreen = attachMovie('achievementScreen', 'achievementScreen', 912112);
gamePause = true;
achievementScreen._x = Stage.width / 2;
achievementScreen._y = Stage.height / 2;
aButs = new Array(achievementScreen.a1, achievementScreen.a2, achievementScreen.a3, achievementScreen.a4, achievementScreen.a5, achievementScreen.a6, achievementScreen.a7, achievementScreen.a8, achievementScreen.a9, achievementScreen.a10, achievementScreen.a11, achievementScreen.a12, achievementScreen.a13, achievementScreen.a14, achievementScreen.a15, achievementScreen.a16, achievementScreen.a17, achievementScreen.a18, achievementScreen.a19, achievementScreen.a20, achievementScreen.a21, achievementScreen.a22, achievementScreen.a23, achievementScreen.a24, achievementScreen.a25, achievementScreen.a26, achievementScreen.a27, achievementScreen.a28, achievementScreen.a29, achievementScreen.a30, achievementScreen.a31, achievementScreen.a32, achievementScreen.a33);
a = 0;
while (a < aButs.length) {
aButs[a].isOwned.gotoAndStop(awardsOwned[a] ? 2 : 1);
aButs[a].nameTxt.htmlText = bold(awardNames[a]);
aButs[a].descTxt.htmlText = awardDescriptions[a];
aButs[a].costTxt.htmlText = bold('$' + awardAmounts[a]);
++a;
}
createButton(achievementScreen.backBtn);
achievementScreen.backBtn.onRelease = function () {
achievementScreen.removeMovieClip();
gamePause = false;
};
}
function findShopIndexs() {
totalMade = 0;
indexi = new Array();
i = 0;
while (i < buyAndSellArrays[buySell].length) {
if (itemTypes[buyAndSellArrays[buySell][i]] == BOW || itemTypes[buyAndSellArrays[buySell][i]] == ARMOR || itemTypes[buyAndSellArrays[buySell][i]] == BOOT) {
if (totalMade % 6 == 0) {
indexi.push(i);
}
totalMade += 1;
}
++i;
}
return indexi;
}
function decideShopItems() {
shopItems = new Array(10, 11, 12, 13, 24, 25, 19, 20);
if (levelsUnlocked >= 6) {
shopItems = new Array(12, 13, 14, 15, 25, 26, 20, 21);
}
if (levelsUnlocked >= 11) {
shopItems = new Array(15, 16, 17, 18, 27, 28, 21, 22);
}
}
function createBuyScreen() {
gamePause = true;
buyScreen = attachMovie('buyScreen', 'buyScreen', 911287);
buyScreen._x = Stage.width / 2;
buyScreen._y = Stage.height / 2;
buyScreen.moneyTxt.htmlText = bold('$' + money);
buyButtons = new Array(buyScreen.b1, buyScreen.b2, buyScreen.b3, buyScreen.b4, buyScreen.a1, buyScreen.a2, buyScreen.bb1, buyScreen.bb2);
b = 0;
while (b < buyButtons.length) {
buyButtons[b].nameTxt.htmlText = bold(itemNames[shopItems[b]]);
buyButtons[b].descTxt.htmlText = bold(itemDescs[shopItems[b]]);
buyButtons[b].costTxt.htmlText = bold('$' + itemCosts[shopItems[b]]);
buyButtons[b].itemImg.gotoAndStop(shopItems[b] + 1);
createBButton(buyButtons[b].b1, b);
++b;
}
createButton(buyScreen.backBtn);
buyScreen.backBtn.onRelease = function () {
buyScreen.removeMovieClip();
gamePause = false;
};
}
function createBButton(buttona, num) {
createButton(buttona);
buttona.onRelease = function () {
if (money >= itemCosts[shopItems[num]]) {
money -= itemCosts[shopItems[num]];
itemsOwned.push(shopItems[num]);
buyScreen.moneyTxt.htmlText = bold('$' + money);
buyScreen.aMe.ame.gotoAndStop(3);
buyScreen.aMe.gotoAndPlay(2);
} else {
buyScreen.aMe.ame.gotoAndStop(1);
buyScreen.aMe.gotoAndPlay(2);
}
};
}
function createShop() {
gamePause = true;
buyAndSellArrays = new Array(itemsOwned, shopItems);
shop = attachMovie('shop', 'shop', 911222);
tIn = findShopIndexs();
if (tIn.length <= 1) {
shop.lrs._alpha = 0;
shop.lArrow._alpha = 0;
shop.rArrow._alpha = 0;
} else {
createButton(shop.lArrow);
createButton(shop.rArrow);
shop.lArrow.onRelease = function () {
tIn = findShopIndexs();
shopIndex -= 1;
if (shopIndex < 0) {
shopIndex = tIn.length - 1;
}
removeShop();
createShop();
};
shop.rArrow.onRelease = function () {
tIn = findShopIndexs();
shopIndex += 1;
if (shopIndex > tIn.length - 1) {
shopIndex = 0;
}
removeShop();
createShop();
};
}
shop.moneyTxt.htmlText = bold('$' + money);
shop.nameTxt.htmlText = bold('BOB\'S BOWS AND ARROWS');
shop.descTxt.htmlText = 'Hi, I\'m Bob. We have a wide selection of bows, arrows, and more Take your pick!';
if (shopType == BOWARROWSHOP) {
shop.selectPart.gotoAndStop(1);
shop.shopKeeper.gotoAndStop(1);
shop.bg.gotoAndStop(1);
}
if (shopType == SKILLSHOP) {
shop.selectPart.gotoAndStop(3);
shop.shopKeeper.gotoAndStop(3);
shop.bg.gotoAndStop(1);
}
if (shopType == ARMORBOOTSHOP) {
shop.selectPart.gotoAndStop(2);
shop.shopKeeper.gotoAndStop(2);
shop.bg.gotoAndStop(1);
shop.nameTxt.htmlText = bold('PHIL\'S PAWN SHOP');
shop.descTxt.htmlText = 'Hey, I\'m Phil. I\'m out of stock, but I\'m looking to buy some fine equipment.';
}
shop._x = Stage.width / 2;
shop._y = Stage.height / 2;
if (buySell == 0) {
arrayOfItems = new Array();
r = 0;
while (r < companionBows.length) {
if (companionBows[r] != -1) {
arrayOfItems.push(companionBows[r]);
}
++r;
}
r = 0;
while (r < companionArmors.length) {
if (companionArmors[r] != -1) {
arrayOfItems.push(companionArmors[r]);
}
++r;
}
r = 0;
while (r < companionBoots.length) {
if (companionBoots[r] != -1) {
arrayOfItems.push(companionBoots[r]);
}
++r;
}
matchingArray = new Array(itemsOwned.length);
i = itemsOwned.length - 1;
while (i >= 0) {
matchingArray[i] = false;
a = arrayOfItems.length - 1;
while (a >= 0) {
if (itemsOwned[i] == arrayOfItems[a]) {
arrayOfItems.splice(a, 1);
matchingArray[i] = true;
break;
}
--a;
}
--i;
}
}
createButton(shop.selectPart.b1);
shop.selectPart.b1.onRelease = function () {
buySell = 1;
itemType = BOW;
if (shop.selectPart._currentframe == 2) {
itemType = ARMOR;
}
if (shop.selectPart._currentframe == 3) {
itemType = SKILL;
}
removeShop();
createShop();
};
createButton(shop.selectPart.a1);
shop.selectPart.a1.onRelease = function () {
buySell = 1;
itemType = ARROW;
if (shop.selectPart._currentframe == 2) {
itemType = BOOT;
}
if (shop.selectPart._currentframe == 3) {
itemType = SKILL;
}
removeShop();
createShop();
};
createButton(shop.selectPart.b2);
shop.selectPart.b2.onRelease = function () {
buySell = 0;
itemType = BOW;
if (shop.selectPart._currentframe == 2) {
itemType = ARMOR;
}
if (shop.selectPart._currentframe == 3) {
itemType = SKILL;
}
removeShop();
createShop();
};
createButton(shop.selectPart.a2);
shop.selectPart.a2.onRelease = function () {
buySell = 0;
itemType = ARROW;
if (shop.selectPart._currentframe == 2) {
itemType = BOOT;
}
if (shop.selectPart._currentframe == 3) {
itemType = SKILL;
}
removeShop();
createShop();
};
createButton(shop.backBtn);
shop.backBtn.onRelease = function () {
removeShop();
gamePause = false;
};
trueI = 0;
theIndi = findShopIndexs();
i = theIndi[shopIndex];
while (i < buyAndSellArrays[buySell].length) {
if (itemTypes[buyAndSellArrays[buySell][i]] == BOW || itemTypes[buyAndSellArrays[buySell][i]] == ARMOR || itemTypes[buyAndSellArrays[buySell][i]] == BOOT) {
shopBox = shop.attachMovie('shopBox', 'shopBox' + depth, depth++);
shopBox.ie._alpha = 0;
if (matchingArray[i] && buySell == 0) {
shopBox.ie._alpha = 100;
}
totalMade += 1;
createButton(shopBox.b1);
shopBoxClick(shopBox.b1, i);
if (buySell == 0) {
shopBox.b1.bs.gotoAndStop(2);
}
shopBox._x = 195;
shopBox._y = -224 + trueI * 80;
shopBox.itemImg.gotoAndStop(buyAndSellArrays[buySell][i] + 1);
shopBox.nameTxt.htmlText = bold(itemNames[buyAndSellArrays[buySell][i]]);
shopBox.descTxt.htmlText = itemDescs[buyAndSellArrays[buySell][i]];
shopBox.costTxt.htmlText = bold('$' + itemCosts[buyAndSellArrays[buySell][i]]);
if (buySell == 0) {
shopBox.costTxt.htmlText = bold('$' + Math.ceil(itemCosts[buyAndSellArrays[buySell][i]] / 3));
}
trueI += 1;
if (trueI == 6) {
break;
}
}
++i;
}
}
function removeShop() {
shop.removeMovieClip();
}
function shopBoxClick(button, num) {
button.onRelease = function () {
if (buySell == 0) {
if (levelsUnlocked != 1) {
money += Math.ceil(itemCosts[buyAndSellArrays[buySell][num]] / 3);
if (matchingArray[num]) {
if (itemTypes[buyAndSellArrays[buySell][num]] == BOW) {
b = companionBows.length - 1;
while (b >= 0) {
if (buyAndSellArrays[buySell][num] == companionBows[b]) {
companionBows[b] = -1;
break;
}
--b;
}
}
if (itemTypes[buyAndSellArrays[buySell][num]] == ARMOR) {
b = companionArmors.length - 1;
while (b >= 0) {
if (buyAndSellArrays[buySell][num] == companionArmors[b]) {
companionArmors[b] = -1;
break;
}
--b;
}
}
if (itemTypes[buyAndSellArrays[buySell][num]] == BOOT) {
b = companionBoots.length - 1;
while (b >= 0) {
if (buyAndSellArrays[buySell][num] == companionBoots[b]) {
companionBoots[b] = -1;
break;
}
--b;
}
}
}
checkMoneyAward();
buyAndSellArrays[1].push(buyAndSellArrays[buySell][num]);
buyAndSellArrays[buySell].splice(num, 1);
} else {
shop.aMe.ame.gotoAndStop(2);
shop.aMe.gotoAndPlay(2);
}
}
if (buySell == 1 && money >= itemCosts[buyAndSellArrays[buySell][num]]) {
money -= itemCosts[buyAndSellArrays[buySell][num]];
buyAndSellArrays[0].push(buyAndSellArrays[buySell][num]);
buyAndSellArrays[buySell].splice(num, 1);
}
if (buySell == 1 && money < itemCosts[buyAndSellArrays[buySell][num]]) {
shop.aMe.ame.gotoAndStop(1);
shop.aMe.gotoAndPlay(2);
}
if (shop.aMe._currentframe != 2) {
removeShop();
createShop();
}
};
}
stop();
xSpeed = 0;
ySpeed = 0;
speed = 5;
friction = 0.6;
oldCharX = char._x;
oldCharY = char._y;
depth = 100000;
lowDepth = 10;
_quality = 'MEDIUM';
var realShop = new Sound();
realShop.attachSound('realShop.mp3');
var game1 = new Sound();
game1.attachSound('game1.mp3');
var game2 = new Sound();
game2.attachSound('game2.mp3');
var aShot = new Sound();
aShot.attachSound('ashot.mp3');
var aHit = new Sound();
aHit.attachSound('ahit.mp3');
ownBow1 = 1;
ownBow2 = 0;
ownBow3 = 0;
ownBow4 = 0;
ownBow5 = 0;
ownBow6 = 0;
ownBow7 = 0;
partDelay = 0;
partDelayConst = 11;
itemNames = new Array('Regular Arrows', 'Flame Arrows', 'Frost Arrows', 'Light Arrows', 'Dark Arrows', 'Electric Arrows', 'Acid Arrows', 'Explosive Arrows', 'Short Bow', 'Long Bow', 'Composite Bow', 'Cross Bow', 'Compound Bow', 'Dark CrossBow', 'Dark Compound', 'Light CrossyyBow', 'Ice Bow', 'Skeleton Bow', 'Nature Bow', 'Basic Armor', 'Enhanced Armor', 'Scaled Armor', 'Leather Armor', 'Emerald Armor', 'Sapphire Armor', 'Normal Boots', 'Protected Boots', 'Armored Boots', 'Dragon Boots', 'Freeze', 'Grow', 'Explode');
bg.gotoAndStop(2);
partFrames = new Array(2, 1, 1, 0, 3, 2, 4);
ps.swapDepths(900333);
bgFore.swapDepths(750345);
spacer.swapDepths(602331);
waver.swapDepths(750877);
char.swapDepths(600503);
hBar.swapDepths(600505);
theReward.swapDepths(750550);
uiTop.swapDepths(750500);
controls.swapDepths(750766);
uiBot.swapDepths(750501);
orb.swapDepths(600332);
bow.gotoAndStop(2);
enemiesThisWave = 30;
achievements = 0;
achievementsTotal = 100;
actualDamage = 10;
timeRem = 0;
gamePause = true;
toStartDelay = 680;
hasStarted = false;
storyTime.swapDepths(975333);
storyTime.skipBtn.onRelease = function () {
toStartDelay = 0;
hasStarted = true;
gamePause = false;
storyTime.removeMovieClip();
};
if (levelsUnlocked != 1 || survivalMode) {
toStartDelay = 0;
hasStarted = true;
gamePause = false;
storyTime.removeMovieClip();
}
orbHealths = new Array(300, 650, 900, 1200, 1500, 1800, 2100, 2500, 3700, 4500, 6000, 8000, 12000, 16000, 22000, 30000);
orbHealthMax = orbHealths[onLevel - 1];
orbHealth = orbHealthMax;
civilians = new Array();
civTypes = new Array(1, 1, 2, 2, 3);
abilityTimer = 0;
abilityMax = 500;
killsThisWave = 0;
aga.onRelease = function () {
if (!gamePause && !playerPause) {
getURL('http://www.armorgames.com/', '_BLANK');
}
};
xChange = 0;
yChange = 0;
coins = new Array();
bloods = new Array();
keyListener = new Object();
keyListener.onKeyDown = function () {
num = Key.getAscii();
if (num == 105) {
createInventory();
}
if (num == 112) {
}
if (num == 113) {
if (_quality == 'LOW') {
_quality = 'MEDIUM';
qualityLevel = 2;
} else {
if (_quality == 'MEDIUM') {
_quality = 'HIGH';
qualityLevel = 3;
} else {
_quality = 'LOW';
qualityLevel = 1;
}
}
}
};
Key.addListener(keyListener);
ps._alpha = 0;
dragons = new Array();
dragonHealthMaxes = new Array(1000, 2000, 5000);
dragonMax = 1;
dragonKilled = false;
giantTimer = 0;
giantMax = 100;
fromHome = false;
shotDelay = 0;
arType = 1;
arrows = new Array();
particles = new Array();
highDepth = 300100;
toEnd = false;
lasers = new Array();
damageByLevel = new Array(3, 4, 5, 7, 9, 11, 13, 15, 18, 22, 25, 30, 35, 40, 45, 50, 60, 70, 85, 100);
mDown = false;
wasMDown = false;
onMouseDown = function () {
mDown = true;
};
onMouseUp = function () {
mDown = false;
};
enemies = new Array();
onEnemyLevel = new Array(1, 4, 5, 5, 4, 2, 2, 3, 3, 2, 4, 4, 2, 5, 3, 1, 1);
trueOrder = new Array(16, 1, 17, 6, 13, 7, 10, 8, 15, 9, 11, 2, 5, 12, 14, 3, 4);
relativeHealths = new Array(15, 10, 15, 15, 10, 15, 20, 5, 20, 10, 10, 20, 5, 15, 20, 10, 10, 3, 3);
levelHealthMultipliers = new Array(1, 2, 3, 4, 5, 7, 8.5, 11, 14, 19, 23, 28, 35, 42, 50, 60, 75, 100);
level1Waves1 = new Array(16, 1);
level1Waves2 = new Array(16, 1);
level1Waves3 = new Array();
level1Waves3.push(1);
level1Waves4 = new Array(16, 1);
level1Waves = new Array(level1Waves1, level1Waves2, level1Waves3, level1Waves4);
level2Waves1 = new Array(6, 1);
level2Waves2 = new Array(6, 1, 16);
level2Waves3 = new Array(13, 6);
level2Waves4 = new Array(6, 13, 16);
level2Waves = new Array(level2Waves1, level2Waves2, level2Waves3, level2Waves4);
level3Waves1 = new Array(8, 13);
level3Waves2 = new Array(9, 8);
level3Waves3 = new Array(6, 13, 16, 9, 8);
level3Waves4 = new Array(9, 8);
level3Waves = new Array(level3Waves1, level3Waves2, level3Waves3, level3Waves4);
level4Waves1 = new Array();
level4Waves1.push(10);
level4Waves2 = new Array(10, 9, 16, 8);
level4Waves3 = new Array(10, 8);
level4Waves4 = new Array(1, 8);
level4Waves = new Array(level4Waves1, level4Waves2, level4Waves3, level4Waves4);
level5Waves1 = new Array(16, 10, 9);
level5Waves2 = new Array();
level5Waves2.push(4);
level5Waves3 = new Array(4, 8, 9);
level5Waves4 = new Array(4, 16, 13);
level5Waves = new Array(level5Waves1, level5Waves2, level5Waves3, level5Waves4);
level6Waves1 = new Array(17, 16);
level6Waves2 = new Array(1, 16, 17);
level6Waves3 = new Array(16, 13, 8);
level6Waves4 = new Array();
level6Waves4.push(16);
level6Waves = new Array(level6Waves1, level6Waves2, level6Waves3, level6Waves4);
level7Waves1 = new Array();
level7Waves1.push(7);
level7Waves2 = new Array(10, 6);
level7Waves3 = new Array(10, 6, 7);
level7Waves4 = new Array(7, 16, 10, 9);
level7Waves = new Array(level7Waves1, level7Waves2, level7Waves3, level7Waves4);
level8Waves1 = new Array(8, 9);
level8Waves2 = new Array(15, 8, 9);
level8Waves3 = new Array(15, 7, 10, 1, 6);
level8Waves4 = new Array(8, 9, 15);
level8Waves = new Array(level8Waves1, level8Waves2, level8Waves3, level8Waves4);
level9Waves1 = new Array(11, 2);
level9Waves2 = new Array(15, 11, 10, 6);
level9Waves3 = new Array(2, 9, 8, 4);
level9Waves4 = new Array(11, 2);
level9Waves = new Array(level9Waves1, level9Waves2, level9Waves3, level9Waves4);
level10Waves1 = new Array();
level10Waves1.push(3);
level10Waves2 = new Array(3, 11, 9);
level10Waves3 = new Array(3, 2, 8);
level10Waves4 = new Array(7, 4, 13, 15, 2);
level10Waves = new Array(level10Waves1, level10Waves2, level10Waves3, level10Waves4);
level11Waves1 = new Array(1, 16, 17);
level11Waves2 = new Array(6, 10, 9);
level11Waves3 = new Array(15, 7, 2);
level11Waves4 = new Array(11, 4, 13);
level11Waves = new Array(level11Waves1, level11Waves2, level11Waves3, level11Waves4);
level12Waves1 = new Array(5, 11);
level12Waves2 = new Array(5, 9, 7, 10);
level12Waves3 = new Array(5, 6);
level12Waves4 = new Array(5, 6, 2, 8, 15);
level12Waves = new Array(level12Waves1, level12Waves2, level12Waves3, level12Waves4);
level13Waves1 = new Array(8, 9, 15);
level13Waves2 = new Array(2, 6, 16, 17);
level13Waves3 = new Array(15, 3, 1);
level13Waves4 = new Array(8, 9, 15);
level13Waves = new Array(level13Waves1, level13Waves2, level13Waves3, level13Waves4);
level14Waves1 = new Array(11, 8, 1);
level14Waves2 = new Array(5, 16, 17);
level14Waves3 = new Array(2, 3);
level14Waves4 = new Array(2, 5, 11, 12);
level14Waves = new Array(level14Waves1, level14Waves2, level14Waves3, level14Waves4);
level15Waves1 = new Array(1, 4, 6);
level15Waves2 = new Array(13, 17, 9, 8);
level15Waves3 = new Array(10, 3);
level15Waves4 = new Array(17, 6, 13);
level15Waves = new Array(level15Waves1, level15Waves2, level15Waves3, level15Waves4);
levelWaves = new Array(level1Waves, level2Waves, level3Waves, level4Waves, level5Waves, level6Waves, level7Waves, level8Waves, level9Waves, level10Waves, level11Waves, level12Waves, level13Waves, level14Waves, level15Waves);
pShadow = attachMovie('shadow', 'shadow' + depth, depth++);
enemyMaxHealths = new Array(30, 40, 50, 65, 80, 100, 120, 150, 180, 220, 260, 300, 350, 400, 475, 550, 650, 100, 150);
createEnDelay = 0;
createEnDelayMax = 40;
waveSizes = new Array(6, 8, 10, 12);
extraEnemies = new Array(10, 10, 10, 10);
onWave = 1;
extraToAdd = 0;
createdWave = false;
orbTimer = 0;
trueWave = 1;
explosions = new Array();
explosionParts = new Array('expp1', 'expp2', 'expp3', 'expp4', 'expp5', 'expp6', 'expp7', 'expp8', 'expp9', 'expp10', 'expp11', 'expp12', 'expp13', 'expp14');
groundSpots = new Array();
toBeHit = 0;
exers = new Array();
enTypes = new Array();
enTypes.push(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
enSpeeds = new Array(3, 1, -1, 3, 1, 3, 3, 5, 1, -1, 1, 1, -1, -1, 3.5, 6, 6, 6, 3.5);
xps = new Array(10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200, 220);
moneyValues = new Array(5, 6, 7, 10, 15, 20, 25, 40, 60, 90, 120, 150, 200, 250, 300);
itemValues = new Array(8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28);
moneyFrames = new Array(1, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 11, 12, 5, 10);
itemsPerLevel = new Array(9, 23, 19, 10, 24, 20, 11, 12, 25, 13, 14, 26, 21, 15, 16, 27, 17, 28, 22, 18, 29);
shake = 0;
inventorying = false;
ibtn.onRelease = function () {
if (!gamePause && !playerPause) {
createInventory();
}
};
levelingUp = false;
allowedToPress = false;
companions = new Array();
companionNames = new Array('Syra', 'Kranis', 'Hikou');
enemyLinkToOrder = new Array(1, 11, 15, 16, 12, 3, 5, 7, 9, 6, 10, 13, 4, 14, 8, 0, 2);
survivalPart = 1;
timeToNewEnemy = 0;
survivalEnemyDelays = new Array(60, 56, 52, 48, 44, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12);
createEnSur = 0;
awardk.swapDepths(942204);
playerPause = false;
alphaHover(pbtn);
alphaHover(mbtn);
alphaHover(qbtn);
pbtn.swapDepths(850270);
mbtn.swapDepths(850271);
qbtn.swapDepths(850272);
ibtn.swapDepths(850273);
pbtn.onRelease = function () {
if (!gamePause && !inventorying) {
playerPause = !playerPause;
pauseStuff();
}
};
if (muted2) {
mech1.setVolume(0);
} else {
mech1.setVolume(100);
}
mbtn.onRelease = function () {
if (muted2) {
muted2 = !muted2;
mech1.setVolume(100);
} else {
muted2 = !muted2;
mech1.setVolume(0);
}
};
qualityLevel = 3;
qbtn.onRelease = function () {
if (_quality == 'LOW') {
_quality = 'MEDIUM';
qualityLevel = 2;
} else {
if (_quality == 'MEDIUM') {
_quality = 'HIGH';
qualityLevel = 3;
} else {
_quality = 'LOW';
qualityLevel = 1;
}
}
};
BOW = 1;
ARROW = 2;
ARMOR = 3;
BOOT = 4;
SKILL = 5;
itemsByLevel = new Array();
itemNames = new Array('Regular Arrows', 'Flame Arrows', 'Frost Arrows', 'Light Arrows', 'Dark Arrows', 'Electric Arrows', 'Acid Arrows', 'Explosive Arrows', 'Short Bow', 'Long Bow', 'Composite Bow', 'Cross Bow', 'Compound Bow', 'Dark Cross Bow', 'Dark Compount Bow', 'Light Cross Bow', 'Ice Bow', 'Skeleton Bow', 'Nature Bow', 'Normal Boots', 'Protected Boots', 'Armored Boots', 'Dragon Boots', 'Basic Armor', 'Enhanced Armor', 'Scaled Armor', 'Leather Armor', 'Emerald Armor', 'Sapphire Armor', 'Freeze', 'Grow', 'Explode');
itemTypes = new Array(ARROW, ARROW, ARROW, ARROW, ARROW, ARROW, ARROW, ARROW, BOW, BOW, BOW, BOW, BOW, BOW, BOW, BOW, BOW, BOW, BOW, BOOT, BOOT, BOOT, BOOT, ARMOR, ARMOR, ARMOR, ARMOR, ARMOR, ARMOR, SKILL, SKILL, SKILL);
itemCosts = new Array(0, 0, 0, 0, 0, 0, 0, 0, 20, 100, 250, 450, 800, 1500, 2750, 4000, 7000, 10000, 14000, 50, 400, 2000, 9000, 150, 600, 1500, 3800, 9000, 20000, 0, 0, 0);
itemDescs = new Array('No Effect', 'Ignites enemy for 2.5 seconds', 'Slows enemy for 2.5 seconds', 'Increases Speed by 30%', 'Increases Damage by 30%', 'Damages all Nearby Enemies', '50% change of critical hit', 'Creates Trail of Damaging Ground', 'Base Damage: 10', 'Base Damage: 12', 'Base Damage: 15', 'Base Damage: 18', 'Base Damage: 22', 'Base Damage: 27', 'Base Damage: 33', 'Base Damage: 40', 'Base Damage: 48', 'Base Damage: 57', 'Base Damage: 67', 'Movement Speed: 4', 'Movement Speed: 5', 'Movement Speed: 6', 'Movement Speed: 7', 'Base Armor: 100', 'Base Armor: 200', 'Base Armor: 350', 'Base Armor: 500', 'Base Armor: 650', 'Base Armor: 950', 'Freeze all enemy minions', 'Increase your attack speed temporarily', 'Ignite all enemies');
itemAmounts = new Array(0, 0, 0, 0, 0, 0, 0, 0, 10, 12, 15, 18, 22, 27, 33, 40, 48, 57, 67, 4, 5, 6, 7, 50, 150, 300, 450, 600, 900, 0, 0, 0);
itemSelectType = -1;
preKills = kills;
preMoney = money;
preXp = xp;
theBgNums = new Array(1, 2, 5, 6, 7);
if (companionArmors[0] != -1) {
changeArmor(char, companionArmors[0] - 23);
} else {
changeArmor(char, 1);
}
damage = calcTrueDamage();
speed = calcSpeed();
maxHealth = calcHealthTotal();
health = maxHealth;
buySell = 1;
itemType = BOW;
BOWARROWSHOP = 1;
SKILLSHOP = 2;
ARMORBOOTSHOP = 3;
shopType = BOWARROWSHOP;
arrowCosts = new Array(50, 200, 650, 1200, 1900, 3400, 6500, 10000);
skillCosts = new Array(250, 3000, 12000);
companionCosts = new Array(500, 4500, 15000);
shopIndex = 0;
matchingArray = new Array();
if (!survivalMode) {
hBar._alpha = 0;
rings._alpha = 0;
bgFore.gotoAndStop(2);
if (levelsUnlocked == 1) {
bgFore.theArrow1._alpha = 100;
} else {
bgFore.theArrow1._alpha = 0;
}
bg.gotoAndStop(4);
decideShopItems();
game1.stop();
realShop.start(0, 10000);
managePortalBgs();
onLevel = 1;
orb._y = -1000;
orbHealth = 0;
clearScreen();
health = maxHealth;
char._x = bg._x + bg._width / 2;
char._y = bg._y + bg._height / 2;
c = 0;
while (c < 5) {
createCiv(c);
++c;
}
} else {
bg.gotoAndStop(theBgNums[random(theBgNums.length)]);
onLevel = 1;
level = 1;
xp = 0;
orb.gotoAndStop(3);
kills = 0;
controls.removeMovieClip();
companionBows[0] = 9;
companionBoots[0] = 19;
companionArmors[0] = 23;
maxHealth = calcHealthTotal();
speed = calcSpeed();
damage = calcTrueDamage();
health = maxHealth;
createdWave = false;
gamePause = false;
}
}
movieClip 449 {
}
movieClip 455 {
}
movieClip 464 {
}
movieClip 466 {
}
movieClip 469 {
}
movieClip 474 {
}
movieClip 477 {
}
movieClip 482 {
}
movieClip 483 {
}
movieClip 484 {
}
movieClip 494 {
}
movieClip 499 {
}
movieClip 502 {
}
movieClip 505 {
}
movieClip 508 {
}
movieClip 511 {
}
movieClip 514 {
}
movieClip 517 {
}
movieClip 520 {
}
movieClip 523 {
}
movieClip 526 {
}
movieClip 529 {
}
movieClip 532 {
}
movieClip 535 {
}
movieClip 538 {
}
movieClip 541 {
}
movieClip 543 {
}
movieClip 545 {
}
movieClip 547 {
}
movieClip 549 {
}
movieClip 551 {
}
movieClip 554 {
}
movieClip 557 l31 {
}
movieClip 560 l32 {
}
movieClip 563 l34 {
}
movieClip 566 l33 {
}
movieClip 574 {
}
movieClip 575 {
}
movieClip 577 {
}
movieClip 580 {
}
movieClip 584 {
}
movieClip 595 {
}
movieClip 597 {
}
movieClip 599 {
}
movieClip 602 {
}
movieClip 603 {
frame 10 {
stop();
}
}
movieClip 604 {
frame 1 {
stop();
}
}
movieClip 606 {
}
movieClip 607 {
}
movieClip 608 generator {
frame 1 {
stop();
}
}
movieClip 612 {
frame 1 {
stop();
}
}
movieClip 615 {
frame 1 {
stop();
}
}
movieClip 618 {
frame 1 {
stop();
}
}
movieClip 619 {
frame 1 {
stop();
}
frame 3 {
stop();
}
}
movieClip 621 {
}
movieClip 624 {
frame 1 {
stop();
}
}
movieClip 634 {
frame 1 {
stop();
}
}
movieClip 635 {
}
movieClip 636 {
frame 1 {
stop();
}
}
movieClip 638 groundSpot {
}
movieClip 641 {
}
movieClip 644 {
}
movieClip 646 pauseScreen {
}
movieClip 649 {
frame 1 {
stop();
}
}
movieClip 655 {
}
movieClip 656 {
}
movieClip 664 {
}
movieClip 666 {
}
movieClip 668 levelSelect {
}
movieClip 671 {
}
movieClip 672 {
}
movieClip 673 {
}
movieClip 674 {
}
movieClip 681 {
}
movieClip 684 {
frame 1 {
stop();
}
}
movieClip 686 yy2 {
}
movieClip 688 yy4 {
}
movieClip 690 yy5 {
}
movieClip 692 yy1 {
}
movieClip 694 yy3 {
}
movieClip 696 yy6 {
}
movieClip 698 {
}
movieClip 699 {
}
movieClip 701 {
}
movieClip 702 {
}
movieClip 710 w6 {
}
movieClip 712 w7 {
}
movieClip 728 {
}
movieClip 732 {
}
movieClip 733 {
}
movieClip 736 {
}
movieClip 738 {
}
movieClip 739 {
}
movieClip 740 {
}
movieClip 755 allItems {
frame 1 {
stop();
}
frame 9 {
stop();
}
}
movieClip 757 {
}
movieClip 773 {
frame 1 {
stop();
}
}
movieClip 780 {
frame 1 {
stop();
}
}
movieClip 781 {
}
movieClip 794 {
frame 1 {
stop();
}
}
movieClip 807 {
frame 1 {
stop();
}
}
movieClip 814 {
frame 1 {
stop();
}
}
movieClip 822 {
frame 1 {
stop();
}
}
movieClip 824 {
}
movieClip 826 {
}
movieClip 828 {
}
movieClip 829 {
}
movieClip 830 {
}
movieClip 832 {
}
movieClip 834 {
}
movieClip 836 {
}
movieClip 838 {
}
movieClip 840 {
}
movieClip 841 spike8 {
}
movieClip 843 {
}
movieClip 844 arrow {
frame 1 {
stop();
}
}
movieClip 845 {
frame 1 {
stop();
}
}
movieClip 862 {
frame 1 {
stop();
}
}
movieClip 863 {
}
movieClip 864 {
frame 1 {
stop();
}
}
movieClip 865 {
frame 1 {
stop();
}
}
movieClip 866 {
frame 1 {
stop();
}
}
movieClip 867 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 880 {
frame 1 {
stop();
}
}
movieClip 881 {
}
movieClip 894 hat {
frame 1 {
stop();
}
}
movieClip 895 {
}
movieClip 896 {
}
movieClip 897 {
}
movieClip 898 {
frame 1 {
stop();
}
}
movieClip 900 {
}
movieClip 901 {
frame 1 {
stop();
}
frame 60 {
_parent.gotoAndStop(1);
}
}
movieClip 902 {
frame 1 {
stop();
}
}
movieClip 904 {
}
movieClip 905 {
}
movieClip 906 char {
frame 1 {
stop();
}
}
movieClip 909 {
}
movieClip 910 {
}
movieClip 919 {
frame 1 {
stop();
}
}
movieClip 920 researchScreen {
}
movieClip 923 {
}
movieClip 924 {
}
movieClip 927 {
frame 1 {
stop();
}
}
movieClip 931 {
}
movieClip 933 achievementScreen {
}
movieClip 935 {
}
movieClip 937 {
}
movieClip 938 {
}
movieClip 944 {
}
movieClip 947 {
frame 1 {
stop();
}
}
movieClip 954 {
frame 1 {
stop();
}
}
// unknown tag 88 length 63
movieClip 958 healthBar {
}
movieClip 961 {
}
movieClip 963 {
}
movieClip 964 {
}
movieClip 965 chest {
}
movieClip 966 itemPickup {
}
movieClip 970 {
}
movieClip 974 {
}
movieClip 978 {
}
movieClip 982 {
}
movieClip 986 {
}
movieClip 990 {
}
movieClip 994 {
}
movieClip 998 {
}
movieClip 1002 {
}
movieClip 1006 {
}
movieClip 1010 {
}
movieClip 1014 {
}
movieClip 1018 {
}
movieClip 1019 {
}
movieClip 1020 {
}
movieClip 1021 {
frame 1 {
stop();
}
}
movieClip 1025 {
}
movieClip 1029 {
}
movieClip 1033 {
}
movieClip 1037 {
}
movieClip 1041 {
}
movieClip 1045 {
}
movieClip 1049 {
}
movieClip 1053 {
}
movieClip 1057 {
}
movieClip 1058 civ2 {
}
movieClip 1059 {
}
movieClip 1060 {
frame 1 {
stop();
}
}
movieClip 1064 {
}
movieClip 1068 {
}
movieClip 1072 {
}
movieClip 1076 {
}
movieClip 1080 {
}
movieClip 1084 {
}
movieClip 1088 {
}
movieClip 1092 {
}
movieClip 1093 civ3 {
}
movieClip 1094 {
}
movieClip 1095 {
frame 1 {
stop();
}
}
movieClip 1096 civs {
}
movieClip 1099 {
}
// unknown tag 88 length 68
movieClip 1107 {
}
movieClip 1112 {
}
movieClip 1114 {
}
movieClip 1117 {
}
movieClip 1118 particle2 {
}
movieClip 1120 shadow {
}
movieClip 1121 {
}
movieClip 1123 {
}
movieClip 1125 {
}
movieClip 1158 {
}
movieClip 1159 {
}
movieClip 1160 {
}
movieClip 1209 {
frame 24 {
_parent.gotoAndStop(1);
}
}
movieClip 1248 {
frame 20 {
_parent.removeMovieClip();
}
}
movieClip 1249 enemy5 {
frame 1 {
stop();
}
}
movieClip 1250 {
}
movieClip 1281 {
}
movieClip 1282 {
}
movieClip 1283 {
}
movieClip 1334 {
frame 25 {
_parent.gotoAndStop(1);
}
}
movieClip 1369 {
frame 18 {
_parent.removeMovieClip();
}
}
movieClip 1370 enemy9 {
frame 1 {
stop();
}
}
movieClip 1401 {
}
movieClip 1442 {
frame 20 {
_parent.gotoAndStop(1);
}
}
movieClip 1463 {
frame 10 {
_parent.removeMovieClip();
}
}
movieClip 1464 enemy19 {
frame 1 {
stop();
}
}
movieClip 1495 {
}
movieClip 1536 {
frame 20 {
_parent.gotoAndStop(1);
}
}
movieClip 1567 {
frame 15 {
_parent.removeMovieClip();
}
}
movieClip 1569 canttouchthis {
}
movieClip 1570 enemy17 {
frame 1 {
stop();
}
}
movieClip 1601 {
}
movieClip 1622 {
frame 10 {
_parent.gotoAndStop(1);
}
}
movieClip 1643 {
frame 10 {
_parent.removeMovieClip();
}
}
movieClip 1644 enemy16 {
frame 1 {
stop();
}
}
movieClip 1675 {
}
movieClip 1710 {
frame 17 {
_parent.gotoAndStop(1);
}
}
movieClip 1741 {
frame 15 {
_parent.removeMovieClip();
}
}
movieClip 1742 enemy15 {
frame 1 {
stop();
}
}
movieClip 1773 {
}
movieClip 1814 {
frame 20 {
_parent.gotoAndStop(1);
}
}
movieClip 1815 {
frame 1 {
_parent.removeMovieClip();
}
}
movieClip 1816 enemy13 {
frame 1 {
stop();
}
}
movieClip 1877 {
}
movieClip 1908 {
frame 15 {
_parent.gotoAndStop(1);
}
}
movieClip 1929 {
frame 10 {
_parent.removeMovieClip();
}
}
movieClip 1930 enemy12 {
frame 1 {
stop();
}
frame 1 {
stop();
}
}
movieClip 1961 {
}
movieClip 1962 {
}
movieClip 1963 {
}
movieClip 2006 {
frame 21 {
_parent.gotoAndStop(1);
}
}
movieClip 2027 {
frame 10 {
_parent.removeMovieClip();
}
}
movieClip 2028 enemy11 {
frame 1 {
stop();
}
}
movieClip 2029 {
}
movieClip 2060 {
}
movieClip 2077 {
frame 10 {
_parent.gotoAndStop(1);
}
}
movieClip 2108 {
frame 15 {
_parent.removeMovieClip();
}
}
movieClip 2109 enemy14 {
frame 1 {
stop();
}
}
movieClip 2112 {
}
movieClip 2115 {
}
movieClip 2118 {
}
movieClip 2121 {
}
movieClip 2124 {
}
movieClip 2125 {
}
movieClip 2126 {
frame 18 {
_parent.gotoAndStop(1);
}
}
movieClip 2127 {
}
movieClip 2128 {
frame 1 {
stop();
}
frame 1 {
stop();
}
}
movieClip 2131 {
}
movieClip 2134 {
}
movieClip 2137 {
}
movieClip 2140 {
}
movieClip 2143 {
}
movieClip 2146 {
}
movieClip 2147 {
}
movieClip 2148 {
frame 18 {
_parent.gotoAndStop(1);
}
}
movieClip 2149 {
}
movieClip 2150 {
frame 1 {
stop();
}
frame 1 {
stop();
}
}
movieClip 2153 {
}
movieClip 2156 {
}
movieClip 2159 {
}
movieClip 2162 {
}
movieClip 2165 {
}
movieClip 2168 {
}
movieClip 2169 {
}
movieClip 2170 {
frame 17 {
_parent.gotoAndStop(1);
}
}
movieClip 2171 {
}
movieClip 2172 {
frame 1 {
stop();
}
frame 1 {
stop();
}
}
movieClip 2175 {
}
movieClip 2178 {
}
movieClip 2181 {
}
movieClip 2184 {
}
movieClip 2187 {
}
movieClip 2190 {
}
movieClip 2191 {
}
movieClip 2192 {
frame 18 {
_parent.gotoAndStop(1);
}
}
movieClip 2193 {
}
movieClip 2194 {
frame 1 {
stop();
}
frame 1 {
stop();
}
}
movieClip 2197 {
}
movieClip 2200 {
}
movieClip 2203 {
}
movieClip 2206 {
}
movieClip 2209 {
}
movieClip 2212 {
}
movieClip 2213 {
}
movieClip 2214 {
frame 18 {
_parent.gotoAndStop(1);
}
}
movieClip 2215 {
}
movieClip 2216 {
frame 1 {
stop();
}
frame 1 {
stop();
}
}
movieClip 2219 {
}
movieClip 2222 {
}
movieClip 2225 {
}
movieClip 2228 {
}
movieClip 2231 {
}
movieClip 2234 {
}
movieClip 2235 {
}
movieClip 2236 {
frame 18 {
_parent.gotoAndStop(1);
}
}
movieClip 2237 {
}
movieClip 2238 {
frame 1 {
stop();
}
frame 1 {
stop();
}
}
movieClip 2241 {
}
movieClip 2244 {
}
movieClip 2247 {
}
movieClip 2250 {
}
movieClip 2253 {
}
movieClip 2256 {
}
movieClip 2259 {
}
movieClip 2260 {
}
movieClip 2261 {
frame 18 {
_parent.gotoAndStop(1);
}
}
movieClip 2262 {
}
movieClip 2263 {
frame 1 {
stop();
}
frame 1 {
stop();
}
}
movieClip 2264 {
}
movieClip 2265 allEn {
frame 1 {
stop();
}
}
movieClip 2362 {
frame 48 {
_parent.removeMovieClip();
}
}
movieClip 2363 {
}
movieClip 2364 explosion {
}
movieClip 2367 {
}
movieClip 2369 {
}
movieClip 2371 {
}
movieClip 2372 coin {
frame 1 {
stop();
}
}
movieClip 2374 yparticle {
}
movieClip 2376 {
}
movieClip 2377 dola {
frame 50 {
this.removeMovieClip();
}
}
movieClip 2379 {
}
movieClip 2380 dola2 {
frame 50 {
this.removeMovieClip();
}
}
movieClip 2383 {
}
movieClip 2384 hBar {
}
movieClip 2386 {
}
movieClip 2388 {
}
movieClip 2390 {
}
movieClip 2392 {
}
movieClip 2393 spawnSpot {
frame 45 {
this.removeMovieClip();
}
}
movieClip 2395 {
}
movieClip 2396 {
}
movieClip 2399 {
}
movieClip 2400 {
frame 1 {
stop();
}
}
movieClip 2402 {
}
movieClip 2403 {
}
movieClip 2404 {
}
movieClip 2406 {
}
movieClip 2408 theMech {
frame 1 {
stop();
}
}
movieClip 2443 {
}
movieClip 2478 {
}
movieClip 2513 {
}
movieClip 2548 {
}
movieClip 2583 {
}
movieClip 2584 spell {
frame 1 {
stop();
}
}
movieClip 2591 {
frame 1 {
stop();
}
}
movieClip 2595 {
}
movieClip 2599 {
}
movieClip 2600 {
}
movieClip 2604 {
frame 1 {
stop();
}
}
movieClip 2607 {
frame 1 {
stop();
}
}
movieClip 2610 {
}
movieClip 2611 {
}
movieClip 2614 {
}
movieClip 2624 {
}
movieClip 2626 {
}
movieClip 2627 {
}
movieClip 2635 {
}
movieClip 2636 {
}
movieClip 2637 {
}
movieClip 2638 prepScreen {
}
movieClip 2640 {
frame 1 {
stop();
}
}
movieClip 2642 {
}
movieClip 2650 {
frame 1 {
stop();
}
frame 3 {
stop();
}
}
movieClip 2656 {
frame 1 {
stop();
}
}
movieClip 2658 {
}
movieClip 2662 {
frame 1 {
stop();
}
}
movieClip 2664 {
frame 1 {
stop();
}
}
movieClip 2665 shopBox {
}
movieClip 2679 {
}
movieClip 2681 {
frame 1 {
stop();
}
}
movieClip 2685 {
}
movieClip 2689 {
frame 1 {
stop();
}
}
movieClip 2690 {
frame 1 {
stop();
}
}
movieClip 2691 shop {
}
movieClip 2694 {
}
movieClip 2695 expp1 {
}
movieClip 2698 expp10 {
}
movieClip 2701 expp11 {
}
movieClip 2704 expp12 {
}
movieClip 2707 expp13 {
}
movieClip 2710 expp14 {
}
movieClip 2713 expp2 {
}
movieClip 2716 expp3 {
}
movieClip 2719 expp4 {
}
movieClip 2722 expp5 {
}
movieClip 2725 expp6 {
}
movieClip 2728 expp7 {
}
movieClip 2731 expp8 {
}
movieClip 2739 fire {
}
movieClip 2753 {
frame 1 {
stop();
}
}
movieClip 2754 levelComplete {
}
movieClip 2776 statsScreen {
}
// unknown tag 88 length 151
movieClip 2780 {
}
movieClip 2783 {
frame 1 {
stop();
}
}
// unknown tag 88 length 67
movieClip 2787 {
}
movieClip 2788 {
}
movieClip 2789 {
}
movieClip 2794 {
}
movieClip 2799 shopBoxer {
}
movieClip 2804 buyScreen {
}
movieClip 2806 {
}
movieClip 2808 {
}
movieClip 2810 {
}
movieClip 2812 {
}
movieClip 2814 {
}
movieClip 2816 {
}
movieClip 2817 {
frame 680 {
this.removeMovieClip();
}
}
movieClip 2819 {
}
movieClip 2821 {
}
movieClip 2822 {
}
movieClip 2827 {
}
movieClip 2829 {
}
movieClip 2831 {
}
movieClip 2834 {
}
// unknown tag 88 length 146
movieClip 2842 {
}
movieClip 2849 {
frame 1 {
stop();
}
frame 2 {
stop();
}
frame 3 {
stop();
}
}
movieClip 2850 {
}
movieClip 2859 levelUp {
}
movieClip 2861 {
}
movieClip 2865 reward {
}
movieClip 2866 rewardShow {
frame 1 {
stop();
}
}
movieClip 2888 {
}
movieClip 2889 inventory {
}
movieClip 2891 anItem {
}
movieClip 2893 {
}
movieClip 2894 {
frame 1 {
stop();
}
}
frame 5 {
createButton(b1);
b1.onRelease = function () {
clearParts();
gotoAndStop(3);
};
}
movieClip 2897 {
}
movieClip 2908 {
}
instance of movieClip 2908 {
onClipEvent (release) {
getURL('http://armorgames.com', '_BLANK');
}
}
frame 6 {
function bold(item) {
return '<b>' + item + '</b>';
}
function createBasicHover(button, num) {
button.onRollOver = function () {
button._alpha = 75;
descTxt.htmlText = bold(optDescs[num - 1]);
if (num == 2) {
descTxt.htmlText = bold('The game is currently ' + (muted2 ? 'MUTED' : 'NOT MUTED') + ', would you like to change that?');
}
if (num == 3) {
descTxt.htmlText = bold('The game is currently on ' + _quality + ' quality, click to change it');
}
};
button.onRollOut = function () {
button._alpha = 100;
};
}
finishTransition();
back.onRollOver = function () {
back._alpha = 75;
};
back.onRollOut = function () {
back._alpha = 100;
};
back.onRelease = function () {
createTransition(2);
};
wasHere = true;
createBasicHover(csbtn, 1);
createBasicHover(mubtn, 2);
createBasicHover(qubtn, 3);
mubtn.onRelease = function () {
muted2 = !muted2;
if (muted2) {
mech1.setVolume(0);
} else {
mech1.setVolume(100);
}
descTxt.htmlText = bold('The game is currently ' + (muted2 ? 'MUTED' : 'NOT MUTED') + ', would you like to change that?');
saveGame();
};
qubtn.onRelease = function () {
if (_quality == 'LOW') {
_quality = 'MEDIUM';
qualityLevel = 2;
} else {
if (_quality == 'MEDIUM') {
_quality = 'HIGH';
qualityLevel = 3;
} else {
_quality = 'LOW';
qualityLevel = 1;
}
}
descTxt.htmlText = bold('The game is currently on ' + _quality + ' quality, click to change it');
saveGame();
};
optDescs = new Array('THIS BUTTON WILL CLEAR ALL YOUR SAVED DATA, ARE YOU SURE YOU WANT TO CONTINUE?', 'THE GAME IS CURRENTLY MUTED, WOULD YOU LIKE TO UNMUTE?', 'THE GAME IS CURRENTLY ON LOW QUALITY, WOULD YOU LIKE TO CHANGE IT?', 'WARNING: ALL DATA WILL BE DELTED', '');
createButton(b1);
b1.onRelease = function () {
clearParts();
gotoAndStop(3);
};
csbtn.onRelease = function () {
aus._alpha = 100;
createBasicHover(aus.ybtn, 4);
createBasicHover(aus.nbtn, 5);
aus.ybtn.onRelease = function () {
aus._alpha = 0;
sObject.clear();
};
aus.nbtn.onRelease = function () {
aus._alpha = 0;
};
};
}
movieClip 2913 {
}
movieClip 2915 {
}
movieClip 2916 {
}
movieClip 2919 {
}
movieClip 2921 {
}
movieClip 2923 {
}
frame 7 {
function onEnterFrame() {
game1.stop();
realShop.stop();
}
createButton(b1);
b1.onRelease = function () {
clearParts();
gotoAndStop(3);
};
}
movieClip 2926 {
}
frame 8 {
function onEnterFrame() {}
createButton(survivalInfo.btt);
survivalInfo.btt.onRelease = function () {
gotoAndStop(3);
survivalInfo.removeMovieClip();
};
survivalInfo.kTxt.htmlText = bold(kills);
}
movieClip 2937 {
frame 1 {
stop();
}
}
movieClip 2938 survivalInfo {
}