Frame 1
function displayHelp() {
helpWindow._x = g_width / 2;
helpWindow._y = (g_ground / 2) + 100;
}
function saveData() {
trace("Saving Data");
myLocalSO.data.g_total_xp = g_total_xp;
if (myLocalSO.data.g_currentLevel < g_currentLevel) {
myLocalSO.data.g_currentLevel = g_currentLevel;
g_maxLevel = g_currentLevel + 1;
}
}
function calculateXPAward() {
g_long_award_xp = g_longs * g_long_xp;
g_mid_award_xp = g_mids * g_mid_xp;
g_short_award_xp = g_shorts * g_short_xp;
g_level_award_xp = g_level_xp * g_currentLevel;
g_house_award_xp = g_houses_alive * g_house_xp;
if (g_noPopLoss) {
g_zero_loss_award = Math.pow(g_currentLevel, 2);
} else {
g_zero_loss_award = 0;
}
if (g_noHouseLoss) {
g_allhouse_award = Math.floor(Math.pow(g_currentLevel, 2.5));
} else {
g_allhouse_award = 0;
}
g_awarded_xp = (((((g_level_award_xp + g_short_award_xp) + g_mid_award_xp) + g_long_award_xp) + g_house_award_xp) + g_allhouse_award) + g_zero_loss_award;
if (g_awarded_xp > 500) {
g_xp_msg = "Either you're cheating or you've been playing this game for too long.";
} else if (g_awarded_xp > 400) {
g_xp_msg = "Damn you're good";
} else if (g_awarded_xp > 300) {
g_xp_msg = "You're an expert";
} else if (g_awarded_xp > 200) {
g_xp_msg = "Nice shooting";
} else if (g_awarded_xp > 100) {
g_xp_msg = "Not Bad";
} else if (g_awarded_xp > 50) {
g_xp_msg = "Keep practicing";
} else {
g_xp_msg = "Remember: xp is only awarded for basic arrow critical hits";
}
g_xp = g_xp + g_awarded_xp;
g_total_xp = g_total_xp + g_awarded_xp;
saveData();
displayXPPage();
g_noPopLoss = true;
g_noHouseLoss = true;
}
function displayXPPage() {
xp_page._x = g_width / 2;
xp_page._y = g_ground / 2;
}
function resetGameVars() {
_root.g_maxbowpwr = 800;
_root.g_xp = g_total_xp;
_root.g_population = 20;
_root.g_multi_num = 1;
_root.g_fire_num = 0;
_root.g_ice_num = 0;
_root.g_bomb_num = 0;
_root.g_flak_num = 0;
_root.g_catapult_num = 0;
_root.g_archer_num = 0;
_root.g_piercer_num = 0;
_root.g_arrow_dmg = 10;
_root.g_blast_range = 150;
_root.g_blast_power = 5;
_root.g_catapult_cooldown = 30;
_root.g_archer_cooldown = 20;
_root.g_bow_loading = 1;
_root.g_fire_dot = 2;
}
function setPrevGameVars() {
_root.g_Pmaxbowpwr = g_maxbowpwr;
_root.g_PcurrentLevel = g_currentLevel;
_root.g_Pxp = g_xp;
_root.g_Ppopulation = g_population;
_root.g_Pmulti_num = g_multi_num;
_root.g_Pfire_num = g_fire_num;
_root.g_Pice_num = g_ice_num;
_root.g_Pbomb_num = g_bomb_num;
_root.g_Pflak_num = g_flak_num;
_root.g_Pcatapult_num = g_catapult_num;
_root.g_Parcher_num = g_archer_num;
_root.g_Ppiercer_num = g_piercer_num;
_root.g_Parrow_dmg = g_arrow_dmg;
_root.g_Pblast_range = g_blast_range;
_root.g_Pblast_power = g_blast_power;
_root.g_Pcatapult_cooldown = g_catapult_cooldown;
_root.g_Parcher_cooldown = g_archer_cooldown;
_root.g_Pbow_loading = g_bow_loading;
_root.g_Pfire_dot = g_fire_dot;
}
function initializeClipLevels() {
for (i in g_arrowLevels) {
g_arrowLevels[i] = false;
}
for (i in g_enemyLevels) {
g_enemyLevels[i] = false;
}
}
function checkoutEneLevel() {
taken = false;
do {
if (taken) {
trace(val + " taken - finding another !!!!!!!!!!!!!!!!!!!!");
}
val = (++g_enelvl) % g_eneLvlMax;
} while ((taken = g_enemyLevels[val]));
trace("Checking out: " + val);
g_enemyLevels[val] = true;
return(val);
}
function checkoutEneLevel2() {
found = false;
level = 0;
i = 0;
while ((i < g_enemyLevels.length) && (!found)) {
if ((found = !g_enemyLevels[i])) {
level = i;
}
i++;
}
g_enemyLevels[level] = true;
g_test_lastOut = level;
return(level);
}
function checkinEneLevel(level) {
g_enemyLevels[level] = false;
}
function toggleMode() {
g_arrowMode--;
if (g_arrowMode < 0) {
g_arrowMode = g_mode_bomb;
}
}
function shootGeneric(x, y, dx, dy, dmg, aoe, brange, bpwr, bouncy, piercing, nonArrow, xvar, yvar, target) {
dx = dx * g_boost;
dy = dy * g_boost;
radians = Math.atan(dy / dx);
power = Math.sqrt((dx * dx) + (dy * dy));
if (power > g_maxbowpwr) {
power = g_maxbowpwr;
if (dx < 0) {
dx = Math.cos(radians + Math.PI) * power;
dy = Math.sin(radians + Math.PI) * power;
} else {
dx = Math.cos(radians) * power;
dy = Math.sin(radians) * power;
}
}
dx = dx + random(xvar);
dy = dy + random(yvar);
addGeneric(x, y, dx, dy, dmg, aoe, brange, bpwr, bouncy, piercing, nonArrow, target);
}
function shoot() {
playSound("swoosh.wav");
dx = (-bow.dx) * g_boost;
dy = (-bow.dy) * g_boost;
radians = Math.atan(dy / dx);
power = Math.sqrt((dx * dx) + (dy * dy));
trace("Power: " + power);
if (power > g_maxbowpwr) {
power = g_maxbowpwr;
dx = Math.cos(radians) * power;
dy = Math.sin(radians) * power;
}
if (g_mode == "fire") {
addArrows(bow._x, bow._y, dx, dy, "fire_arrow", g_fire_num);
} else if (g_mode == "ice") {
addArrows(bow._x, bow._y, dx, dy, "ice_arrow", g_ice_num);
} else if (g_mode == "all") {
addMultiArrow(bow._x, bow._y, dx, dy);
} else if (g_mode == "normal") {
addArrows(bow._x, bow._y, dx, dy, "arrow", g_multi_num);
} else if (g_mode == "pierce") {
addArrows(bow._x, bow._y, dx, dy, "p_arrow", g_piercer_num);
} else if (g_mode == "bomb") {
addArrows(bow._x, bow._y, dx, dy, "bomb_arrow", g_bomb_num);
} else if (g_mode == "flak") {
addArrows(bow._x, bow._y, dx, dy, "flak_arrow", g_flak_num);
}
}
function getArrowClip() {
g_arrowLevel++;
if (g_arrowLevel > 100) {
g_arrowLevel = 0;
}
return(g_arrowLevel);
}
function addArrow(x, y, vx, vy) {
lvl = getArrowClip();
temp = arrowZone.attachMovie("arrow", "arrow_" + lvl, lvl);
temp.vx = vx;
temp.vy = vy;
temp._x = x;
temp._y = y;
temp.dead = false;
temp.dmg = 50;
temp.AoE = false;
g_arrows.push(temp);
}
function addBombArrow(x, y, vx, vy) {
lvl = getArrowClip();
temp = arrowZone.attachMovie("bomb_arrow", "bomb_arrow_" + lvl, lvl);
temp.vx = vx;
temp.vy = vy;
temp._x = x;
temp._y = y;
temp.dead = false;
temp.dmg = 50;
temp.blastRange = 100;
temp.blastPower = 50;
temp.AoE = true;
g_arrows.push(temp);
}
function addGeneric(x, y, vx, vy, dmg, aoe, brange, bpwr, bouncy, piercing, nonArrow, target) {
lvl = getArrowClip();
temp = arrowZone.attachMovie(target, "gen_arrow_" + lvl, lvl);
temp.aType = target;
temp.vx = vx;
temp.vy = vy;
temp._x = x;
temp._y = y;
temp.dead = false;
temp.bouncy = bouncy;
temp.piercing = piercing;
temp.nonArrow = nonArrow;
temp.dmg = dmg;
temp.blastRange = brange;
temp.blastPower = bpwr;
temp.AoE = aoe;
g_arrows.push(temp);
return(temp);
}
function getNextBloodNdx() {
g_bloodNdx++;
if (g_bloodNdx >= g_bloodMax) {
g_bloodNdx = 0;
}
return(g_bloodNdx);
}
function addBloods2(arr, dmg) {
speed_reduction = 5;
i = 0;
while (i < 10) {
vx = arr.vx / speed_reduction;
vy = arr.vy / speed_reduction;
lvl = getDebrisClipFG();
temp = fg.attachMovie("blood", "blood_" + lvl, lvl);
g_debris_fg[lvl] = temp;
sfactor = 8 * (1 + (random(150) / 100));
if (dmg > 1) {
dmg = 1;
}
temp._xscale = temp._xscale * (dmg * sfactor);
temp._yscale = temp._yscale * (dmg * sfactor);
temp._x = arr._x;
temp._y = arr._y;
temp.vx = vx + (random(100) / 100);
temp.vy = -(vy + (random(100) / 100));
temp.dead = false;
g_bloods.push(temp);
i++;
}
}
function addBloodsBleeding(xpos, ypos, dmg) {
speed_reduction = 5;
variance = 10;
x = xpos;
y = ypos;
vx = random(100);
vy = random(100);
total = 1;
degrees = -Math.ceil(total / 2);
rpd = 0.01745329;
theta = Math.atan(vy / vx);
d = Math.sqrt((vx * vx) + (vy * vy));
i = 0;
while (i < total) {
lvl = getNextBloodNdx();
temp = bloodZone.attachMovie("blood", "blood_" + lvl, lvl);
g_debris_bloods[lvl] = temp;
sfactorX = 2 * (1 + (random(30) / 100));
sfactorY = 2 * (1 + (random(30) / 100));
if (dmg > 1) {
dmg = 1;
}
temp._xscale = temp._xscale * (dmg * sfactorX);
temp._yscale = temp._yscale * (dmg * sfactorY);
temp._alpha = bloodOn * 100;
if (vx < 0) {
temp.vx = ((-vx) * random(300)) / 100;
temp.vy = (vy * random(300)) / 100;
} else {
temp.vx = (vx * random(300)) / 100;
temp.vy = ((-vy) * random(300)) / 100;
}
temp._x = x;
temp._y = y;
temp.dead = false;
g_bloods.push(temp);
degrees++;
i++;
}
}
function addBloods(arr, dmg) {
speed_reduction = 5;
variance = 10;
x = arr._x;
y = arr._y;
vx = arr.vx / speed_reduction;
vy = arr.vy / speed_reduction;
total = 1;
degrees = -Math.ceil(total / 2);
rpd = 0.01745329;
theta = Math.atan(vy / vx);
d = Math.sqrt((vx * vx) + (vy * vy));
i = 0;
while (i < total) {
lvl = getNextBloodNdx();
temp = bloodZone.attachMovie("blood", "blood_" + lvl, lvl);
g_debris_bloods[lvl] = temp;
sfactor = 2 * (1 + (random(150) / 100));
if (dmg > 1) {
dmg = 1;
}
temp._xscale = temp._xscale * (dmg * sfactor);
temp._yscale = temp._yscale * (dmg * sfactor);
temp._alpha = bloodOn * 100;
if (vx < 0) {
temp.vx = ((-vx) * random(100)) / 100;
temp.vy = (vy * random(100)) / 100;
} else {
temp.vx = (vx * random(100)) / 100;
temp.vy = ((-vy) * random(100)) / 100;
}
temp._x = x;
temp._y = y;
temp.dead = false;
g_bloods.push(temp);
degrees++;
i++;
}
}
function addArrows(x, y, vx, vy, arrType, total) {
g_bow_cooldown = g_bow_loading * total;
degrees = -Math.ceil(total / 2);
rpd = 0.01745329;
theta = Math.atan(vy / vx);
d = Math.sqrt((vx * vx) + (vy * vy));
arr = null;
i = 0;
while (i < total) {
curx = Math.cos(theta + ((2 * degrees) * rpd)) * d;
cury = Math.sin(theta + ((2 * degrees) * rpd)) * d;
vx = curx;
vy = cury;
if (bow.dx > 0) {
vx = -vx;
vy = -vy;
}
if (arrType == "bomb_arrow") {
arr = addGeneric(x, y, vx, vy, g_arrow_dmg, true, g_blast_range, g_blast_power, false, false, true, "bomb_arrow");
g_bow_cooldown = g_bow_cooldown + (g_bow_loading * 1.6);
} else if (arrType == "ice_arrow") {
arr = addGeneric(x, y, vx, vy, g_arrow_dmg, false, 0, 0, false, false, false, "ice_arrow");
} else if (arrType == "fire_arrow") {
arr = addGeneric(x, y, vx, vy, g_arrow_dmg, false, 0, 0, false, false, false, "fire_arrow");
} else if (arrType == "arrow") {
arr = addGeneric(x, y, vx, vy, g_arrow_dmg, false, 0, 0, false, false, false, "arrow");
} else if (arrType == "p_arrow") {
arr = addGeneric(x, y, vx, vy, g_arrow_dmg, false, 0, 0, false, true, false, "p_arrow");
} else if (arrType == "flak_arrow") {
arr = addGeneric(x, y, vx, vy, g_arrow_dmg, true, 200, g_blast_power, false, false, true, "flak_arrow");
g_detonateNum++;
g_bow_cooldown = g_bow_cooldown + (g_bow_loading * 1.6);
}
degrees++;
i++;
}
}
function addMultiArrow(x, y, vx, vy) {
total = 0;
degrees = -Math.ceil(total / 2);
rpd = 0.01745329;
theta = Math.atan(vy / vx);
d = Math.sqrt((vx * vx) + (vy * vy));
if (g_flak_num > 0) {
total++;
curx = Math.cos(theta + ((2 * degrees) * rpd)) * d;
cury = Math.sin(theta + ((2 * degrees) * rpd)) * d;
vx = curx;
vy = cury;
if (bow.dx > 0) {
vx = -vx;
vy = -vy;
}
arr = addGeneric(x, y, vx, vy, g_arrow_dmg, true, g_blast_range, g_blast_power, false, false, true, "flak_arrow");
g_detonateNum++;
degrees++;
}
if (g_bomb_num > 0) {
total++;
curx = Math.cos(theta + ((2 * degrees) * rpd)) * d;
cury = Math.sin(theta + ((2 * degrees) * rpd)) * d;
vx = curx;
vy = cury;
if (bow.dx > 0) {
vx = -vx;
vy = -vy;
}
addGeneric(x, y, vx, vy, g_arrow_dmg, true, g_blast_range, g_blast_power, false, false, true, "bomb_arrow");
degrees++;
}
if (g_piercer_num > 0) {
total++;
curx = Math.cos(theta + ((2 * degrees) * rpd)) * d;
cury = Math.sin(theta + ((2 * degrees) * rpd)) * d;
vx = curx;
vy = cury;
if (bow.dx > 0) {
vx = -vx;
vy = -vy;
}
addGeneric(x, y, vx, vy, g_arrow_dmg, false, 0, 0, false, true, false, "p_arrow");
degrees++;
}
if (g_multi_num > 0) {
total++;
curx = Math.cos(theta + ((2 * degrees) * rpd)) * d;
cury = Math.sin(theta + ((2 * degrees) * rpd)) * d;
vx = curx;
vy = cury;
if (bow.dx > 0) {
vx = -vx;
vy = -vy;
}
addGeneric(x, y, vx, vy, g_arrow_dmg, false, 0, 0, false, false, false, "arrow");
degrees++;
}
if (g_fire_num > 0) {
total++;
curx = Math.cos(theta + ((2 * degrees) * rpd)) * d;
cury = Math.sin(theta + ((2 * degrees) * rpd)) * d;
vx = curx;
vy = cury;
if (bow.dx > 0) {
vx = -vx;
vy = -vy;
}
addGeneric(x, y, vx, vy, g_arrow_dmg, false, 0, 0, false, false, false, "fire_arrow");
degrees++;
}
if (g_ice_num > 0) {
total++;
curx = Math.cos(theta + ((2 * degrees) * rpd)) * d;
cury = Math.sin(theta + ((2 * degrees) * rpd)) * d;
vx = curx;
vy = cury;
if (bow.dx > 0) {
vx = -vx;
vy = -vy;
}
addGeneric(x, y, vx, vy, g_arrow_dmg, false, 0, 0, false, false, false, "ice_arrow");
degrees++;
}
g_bow_cooldown = g_bow_loading * total;
}
function addMultiArrow2(x, y, vx, vy) {
degrees = -Math.ceil(g_multi_num / 2);
rpd = 0.01745329;
theta = Math.atan(vy / vx);
d = Math.sqrt((vx * vx) + (vy * vy));
numBombs = g_bomb_num;
numNorm = g_multi_num;
totalNum = numNorm + numBombs;
i = 0;
while (i < numBombs) {
curx = Math.cos(theta + ((2 * degrees) * rpd)) * d;
cury = Math.sin(theta + ((2 * degrees) * rpd)) * d;
addGeneric(x, y, vx, vy, dmg, aoe, brange, bpwr, bouncy, piercing, nonArrow, target);
degrees++;
i++;
}
}
function addEnemy(x, y, vx, vy, hp, entype) {
lvl = checkoutEneLevel();
temp = enemyZone.attachMovie(entype, "enemy_" + lvl, lvl);
temp.timeToShoot = getTimer() + 5000;
temp.lvl = lvl;
temp.fhight = y;
temp.dead = false;
temp.eType = entype;
temp.nextTime = 0;
temp.vx = vx;
temp.vy = vy;
temp._x = x;
temp._y = y;
temp.hp = hp;
temp.maxhp = hp;
g_enemies.push(temp);
}
function addObstruct(x, y, obtype, where) {
lvl = getTerrainClip();
temp = where.attachMovie(obtype, "obstruct_" + lvl, lvl);
temp._x = x;
temp._y = y;
temp.dead = false;
temp.oType = obtype;
g_obstructs.push(temp);
return(temp);
}
function stepBloods() {
offset = 10;
g_bcount = g_bloods.length;
for (i in g_bloods) {
cur = g_bloods[i];
t = elapsed;
vy0 = cur.vy;
vx0 = cur.vx;
y0 = cur._y;
x0 = cur._x;
cur.vy = (gravY * t) + vy0;
cur.vx = (gravX * t) + vx0;
cur._y = ((((0.5 * gravY) * t) * t) + (vy0 * t)) + y0;
cur._x = ((((0.5 * gravX) * t) * t) + (vx0 * t)) + x0;
radians = Math.atan(cur.vy / cur.vx);
if (cur.vx > 0) {
cur._rotation = (radians * 180) / Math.PI;
} else {
cur._rotation = ((radians * 180) / Math.PI) + 180;
}
cur.dead = (cur._y > (g_ground + offset)) || (ground.hitTest(cur._x, cur._y - offset, 1));
if (cur.dead) {
g_bloodDead++;
}
}
}
function stepArrows() {
g_arcount = g_arrows.length;
for (i in g_arrows) {
cur = g_arrows[i];
t = elapsed;
vy0 = cur.vy;
vx0 = cur.vx;
y0 = cur._y;
x0 = cur._x;
cur.prevX = cur._x;
cur.prevY = cur._y;
cur.vy = (gravY * t) + vy0;
cur.vx = (gravX * t) + vx0;
cur._y = ((((0.5 * gravY) * t) * t) + (vy0 * t)) + y0;
cur._x = ((((0.5 * gravX) * t) * t) + (vx0 * t)) + x0;
radians = Math.atan(cur.vy / cur.vx);
if (cur.vx > 0) {
cur._rotation = (radians * 180) / 3.14159;
} else {
cur._rotation = ((radians * 180) / 3.14159) + 180;
}
}
}
function stepEnemies() {
for (i in g_enemies) {
cur = g_enemies[i];
if ((cur.eType != "dragon_archer") && (cur.eType != "flying_enemy")) {
followTerrain(cur);
}
updateMaxes(cur._x - cur._width, cur._y - cur._height);
cur.step();
if ((cur.dead = cur._x < -50)) {
g_enemyDead++;
killPopulation(cur);
trace("killingPop!!");
} else {
if (cur.sick) {
cur.hp = cur.hp - (cur.sickDmg * elapsed);
checkEnemyDeath(cur);
}
house = getNextHouse();
if ((!house.dead) && (house.hitTest(cur._x, cur._y, 0))) {
house.dead = true;
g_noHouseLoss = false;
house.gotoAndPlay(2);
temp = house.attachMovie("smoker", "smoker_0", 0);
temp._y = temp._y - 20;
temp = house.attachMovie("war_flag2", "warflag_0", 1);
cur.dead = true;
g_enemyDead++;
cur.killedHouse = true;
killPopulationNum(10, cur._x, cur._y);
if (g_frontline > cur._x) {
g_frontline = cur._x;
}
}
if ((cur.hp < cur.maxHp) && (getTimer() > cur.nextTime)) {
addBloodsBleeding(cur._x + cur.critical._x, cur._y + cur.critical._y, cur.maxHp / 10);
cur.nextTime = getTimer() + 2000;
}
}
}
}
function getNextHouse() {
g_homeNdx++;
if (g_homeNdx >= g_homes.length) {
g_homeNdx = 0;
}
return(g_homes[g_homeNdx]);
}
function killPopulation(ene) {
if (ene.eType == "enemy") {
killPopulationNum(2, ene._x, ene._y);
} else if (ene.eType == "ogre") {
killPopulationNum(15, ene._x, ene._y);
} else if (ene.eType == "dragon_archer") {
killPopulationNum(18, ene._x, ene._y);
} else if (ene.eType == "flying_enemy") {
killPopulationNum(7, ene._x, ene._y);
} else if (ene.eType == "boss") {
killPopulationNum(100, ene._x, ene._y);
} else if (ene.eType == "enemy_archer") {
killPopulationNum(3, ene._x, ene._y);
} else if (ene.eType == "enemy_catapult") {
killPopulationNum(75, ene._x, ene._y);
}
}
function killPopulationNum(num, x, y) {
g_noPopLoss = false;
lvl = getPopsClip();
temp = pops.attachMovie("pop_killed", "pop_" + lvl, lvl);
temp._x = x;
temp._y = y;
killed = num + Math.floor((num * 0.05) * g_currentLevel);
temp.num = -killed;
newPop = g_population - killed;
if (newPop <= 0) {
g_population = 0;
gameOver();
} else {
g_population = newPop;
}
}
function gameOver() {
g_game_over = true;
pause = true;
g_key_listener.unloadMovie();
}
function tooClose(pos, range, array) {
close = false;
i = 0;
while ((i < array.length) && (!close)) {
close = Math.abs(array[i] - pos) < range;
i++;
}
trace("Returning CLOSE: " + close);
return(close);
}
function initObstructs() {
g_homes = new Array();
loadTerrain();
placeTower();
i = 0;
while (i < g_numHomes) {
do {
range = g_currentLevel * 80;
if (range > 1500) {
range = 1500;
}
homeXPos = random(range);
} while (tooClose(homeXPos, 150, g_homepositions));
g_homepositions.push(homeXPos);
home = addObstruct(homeXpos + 50, g_ground, "house", obstructZone);
g_homes.push(home);
i++;
}
g_homepositions.splice(0);
i = 0;
while (i < g_numObs) {
tree_num = random(g_trees.length);
do {
treePos = random(g_width);
} while (tooClose(treePos, 100, g_treepositions));
g_treepositions.push(treePos);
temp = addObstruct(treePos, g_ground, g_trees[tree_num], obstructZone);
sfactor = (random(200) + 10) / 100;
temp._xscale = temp._xscale * sfactor;
temp._yscale = temp._yscale * sfactor;
i++;
}
g_treepositions.splice(0);
for (i in g_obstructs) {
cur = g_obstructs[i];
while (ground.hitTest(cur._x, cur._y, 1) && (cur != ground)) {
cur._y--;
}
setObsMaxes(cur);
}
}
function setObsMaxes(obs) {
if ((obs._x + obs._width) > g_obsMax_x) {
g_obsMax_x = obs._x + obs._width;
}
if ((obs._x - obs._width) < g_obsMin_x) {
g_obsMin_x = obs._x - obs._width;
}
if ((obs._y + obs._height) > g_obsMax_y) {
g_obsMax_y = obs._y + obs._height;
}
if ((obs._y - obs._height) < g_obsMin_y) {
g_obsMin_y = obs._y - obs._height;
}
}
function killPopEnemyFire(arr) {
trace("Killing By Enemy Fire");
trace("arr.dead = " + arr.dead);
if (arr.aType == "cat_ammo1") {
killPopulationNum(20, arr._x + 50, arr._y);
} else if (arr.aType == "bomb_arrow") {
killPopulationNum(5, arr._x + 50, arr._y);
} else {
killPopulationNum(1, arr._x + 50, arr._y);
}
}
function testHit() {
for (i in g_arrows) {
curArrow = g_arrows[i];
if (curArrow._y > g_ground) {
groundCollision(curArrow);
} else if ((curArrow._x < 0) && (!curArrow.dead)) {
killPopEnemyFire(curArrow);
curArrow.dead = true;
g_arrowDead++;
} else {
if (((curArrow._y > g_max_height) && (curArrow._x > g_max_width)) && (curArrow._x < g_width)) {
j = 0;
while ((j < g_enemies.length) && (!curArrow.dead)) {
curEn = g_enemies[j];
midX = curArrow._x - ((curArrow._x - curArrow.prevX) / 2);
midY = curArrow._y - ((curArrow._y - curArrow.prevY) / 2);
midhit = curEn.hitzone.hitTest(midX, midY, 0);
if (curEn.hitzone.hitTest(curArrow._x, curArrow._y, 0) || (midhit)) {
if ((curEn.eType == "flying_enemy") && (random(2) == 0)) {
displayDodge(curArrow._x, curArrow._y);
} else {
enemyCollision(curArrow, curEn);
}
}
j++;
}
}
if (((((curArrow._x > g_obsMin_x) && (curArrow._x < g_obsMax_x)) && (curArrow._y > g_obsMin_y)) && (curArrow._y < g_obsMax_y)) && (!curArrow.dead)) {
atATime = 5;
if (g_obstructs.length < 3) {
atATime = g_obstructs.length;
}
j = 0;
while ((j < atATime) && (!curArrow.dead)) {
curObs = getNextObs();
hitObj = curObs.hitTest(curArrow._x, curArrow._y, 1);
if (hitObj && (curObs != ground)) {
obstructCollision(curArrow, curObs);
}
j++;
}
}
if (curArrow._y > g_groundHeight) {
if ((!curArrow.dead) && (ground.hitTest(curArrow._x, curArrow._y, 1))) {
groundCollision(curArrow);
}
}
}
if (curArrow.dead && (curArrow.AoE)) {
forceAoE(curArrow);
}
}
}
function getNextObs() {
g_obsNdx++;
if (g_obsNdx >= g_obstructs.length) {
g_obsNdx = 0;
}
return(g_obstructs[g_obsNdx]);
}
function resetObsMaxes() {
g_obsMax_x = 0;
g_obsMax_y = 0;
g_obsMin_x = g_width;
g_obsMin_y = g_ground;
}
function resetMaxes() {
g_max_height = g_ground;
g_max_width = g_width;
}
function obstructCollision(arr, obs) {
friction = 0.95;
if (!arr.piercing) {
arr.dead = true;
g_arrowDead++;
if (!arr.nonArrow) {
stickArrowInObject(curArrow, obs);
}
if ((obs.oType == "house") && (!obs.dead)) {
g_houses_alive--;
g_noHouseLoss = false;
temp = obs.attachMovie("smoker", "smoker_0", 0);
temp._x = arr._x - obs._x;
temp._y = arr._y - obs._y;
temp = obs.attachMovie("war_flag2", "warflag_0", 1);
temp._x = arr._x - obs._x;
temp._y = arr._y - obs._y;
killPopulationNum(10, arr._x, arr._y);
obs.dead = true;
obs.gotoAndPlay(2);
if (g_frontline > arr._x) {
g_frontline = arr._x;
}
}
} else {
arr.vx = arr.vx * friction;
arr.vy = arr.vy * friction;
}
}
function enemyCollision(arr, ene) {
if (!arr.piercing) {
arr.dead = true;
g_arrowDead++;
if (!arr.nonArrow) {
stickArrowInEnemy(arr, ene);
}
dmg = calculateDamage(arr, ene);
addBloods(arr, dmg);
} else {
dmg = calculateDamage(arr, ene);
addBloods(arr, dmg);
}
}
function groundCollision(arr) {
bounceFactor = 0.3;
friction = 0.3;
if (!arr.bouncy) {
playSound("hit.wav");
arr.dead = true;
g_arrowDead++;
if (!arr.nonArrow) {
stickArrowInObject(arr, ground);
}
} else {
if (arr.blastRange > 100) {
forceAoE(arr);
}
arr.vy = arr.vy * (-bounceFactor);
arr.vx = arr.vx * friction;
midX = arr._x - ((arr._x - arr.prevX) / 2);
midY = arr._y - ((arr._y - arr.prevY) / 2);
arr._x = midX;
arr._y = midY;
arr.blastPower = arr.blastPower * 0.5;
arr.blastRange = arr.blastRange * 0.5;
if (((arr.vx < 1) && (arr.vy < 1)) && (ground.hitTest(arr._x, arr._y, 1) || (arr._y > (g_ground - 5)))) {
arr.dead = true;
g_arrowDead++;
}
}
}
function checkAoE(arr) {
if (arr.dead && (arr.AoE)) {
forceAoE(arr);
}
}
function detonateBomb() {
i = 0;
while ((i < g_arrows.length) && (g_detonateNum > 0)) {
arr = g_arrows[i];
if (arr.aType == "flak_arrow") {
arr.dead = true;
g_arrowDead++;
}
i++;
}
}
function getPopsClip() {
g_popsLevel++;
if (g_popsLevel > 7) {
g_popsLevel = 0;
}
return(g_popsLevel);
}
function getExplosionClip() {
g_explosionsLevel++;
if (g_explosionsLevel > 5) {
g_explosionsLevel = 0;
}
return(g_explosionsLevel);
}
function forceAoE(arr) {
lvl = getExplosionClip();
if (arr.aType == "flak_arrow") {
temp = explosions.attachMovie("flak_animation", "b_anim" + lvl, lvl);
playSound("flak.wav");
} else {
temp = explosions.attachMovie("bomb_animation", "b_anim" + lvl, lvl);
playSound("bomb.wav");
}
temp._x = arr._x;
temp._y = arr._y;
temp._width = arr.blastRange;
temp._height = arr.blastRange;
if (((arr._x + arr.blastRange) > g_max_width) && ((arr._y + arr.blastRange) > g_max_height)) {
for (i in g_enemies) {
cur = g_enemies[i];
if (!cur.dead) {
dx = (cur._x + cur.critical._x) - arr._x;
dy = (cur._y + cur.critical._y) - arr._y;
dis = Math.sqrt((dx * dx) + (dy * dy));
if (dis < (arr.blastRange / 1.5)) {
damage = Math.ceil(((arr.blastRange - dis) / arr.blastRange) * arr.blastPower);
if (((cur.eType == "flying_enemy") && (arr.aType == "flak_arrow")) || ((cur.eType == "enemy_archer") && (arr.aType == "bomb_arrow"))) {
damage = damage * 5;
lvl = getPopsClip();
ch = pops.attachMovie("critical_hit", "critical_hit_" + lvl, lvl);
ch._x = cur._x + cur.critical._x;
ch._y = cur._y + cur.critical._y;
}
displayDamage(cur._x, cur._y, damage);
cur.hp = cur.hp - damage;
}
checkEnemyDeath(cur);
}
}
}
}
function stickArrowInEnemy(arr, ene) {
lvl = random(3);
temp = ene.center.attachMovie(arr.aType, "sarrow_" + lvl, lvl);
if ((arr.aType == "fire_arrow") && (ene.eType != "boss")) {
lvl = random(3);
fire = ene.fire.attachMovie("smoker", "smoker_" + lvl, lvl);
fire._x = arr._x - ene._x;
fire._y = arr._y - ene._y;
ene.vy = ene.vy * 1.2;
ene.sick = true;
if (ene.eType == "enemy_catapult") {
ene.sickDmg = ene.sickDmg + (g_fire_dot * 10);
} else {
ene.sickDmg = ene.sickDmg + g_fire_dot;
}
} else if ((arr.aType == "ice_arrow") && (ene.eType != "boss")) {
lvl = random(3);
ice = ene.ice.attachMovie("ice_crystal", "ice_" + lvl, lvl);
ice._x = arr._x - ene._x;
ice._y = arr._y - ene._y;
ice._rotation = random(360);
}
temp._rotation = arr._rotation;
temp._x = arr._x - ene._x;
temp._y = arr._y - ene._y;
}
function stickArrowInObject(arr, obs) {
temp = null;
lvl = 0;
if (obs.oType == "house") {
lvl = getDebrisClipFG();
temp = fg.attachMovie(arr.aType, "s_arrow_" + lvl, lvl);
g_debris_fg[lvl] = temp;
} else {
lvl = getDebrisClipBG();
temp = bg.attachMovie(arr.aType, "sarrow_" + lvl, lvl);
g_debris_bg[lvl] = temp;
}
temp._rotation = arr._rotation;
temp._x = arr._x;
temp._y = arr._y;
}
function calculateDamage(arr, ene) {
vx = arr.vx;
vy = arr.vy;
damage = (Math.sqrt((vx * vx) + (vy * vy)) / 1000) * arr.dmg;
if (arr.aType == "fire_arrow") {
damage = damage * 0.25;
} else if ((arr.aType == "ice_arrow") && (ene.eType != "dragon_archer")) {
damage = damage * 0.2;
} else if ((arr.aType == "ice_arrow") && (ene.eType == "dragon_archer")) {
damage = damage * 10;
} else if ((arr.aType == "p_arrow") && (ene.eType != "ogre")) {
damage = damage * 0.33;
} else if ((arr.aType == "p_arrow") && (ene.eType == "ogre")) {
damage = damage * 2;
} else if ((arr.aType == "bomb_arrow") && (ene.eType != "enemy_archer")) {
damage = damage * 0.5;
} else if ((arr.aType == "bomb_arrow") && (ene.eType == "enemy_archer")) {
damage = damage * 3;
}
damage = Math.ceil(damage);
dx = (arr._x - ene._x) - ene.critical._x;
dy = (arr._y - ene._y) - ene.critical._y;
dis = Math.sqrt((dx * dx) + (dy * dy));
if (dis < 20) {
damage = damage * 2;
lvl = getPopsClip();
ch = pops.attachMovie("critical_hit", "critical_hit_" + lvl, lvl);
ch._x = arr._x;
ch._y = arr._y;
if ((arr.aType == "arrow") && (ene.eType != "boss")) {
checkXPBonus(arr._x, arr._y);
}
}
playRandomHit();
displayDamage(arr._x, arr._y, damage);
ene.hp = ene.hp - damage;
ene.vx = ene.vx * 0.98;
if ((arr.aType == "ice_arrow") && (ene.eType != "boss")) {
ene.vx = ene.vx * 0.25;
}
checkEnemyDeath(ene);
return(damage / ene.maxhp);
}
function playSound(filename) {
if (g_sound_on) {
mysound = new Sound();
mysound.attachSound(filename);
mysound.start(0, 1);
}
}
function playRandomHit() {
name = "";
num = random(4);
if (num == 0) {
name = "doeh.wav";
} else if (num == 1) {
name = "uh.wav";
} else if (num == 2) {
name = "oof.wav";
} else {
name = "oreh.wav";
}
playSound(name);
}
function resetXPcounts() {
g_longs = 0;
g_mids = 0;
g_shorts = 0;
}
function checkXPBonus(x, y) {
if (x > (g_width * 0.8)) {
g_longs++;
displayXP(x, y, g_long_xp);
} else if (x > (g_width * 0.6)) {
g_mids++;
displayXP(x, y, g_mid_xp);
} else if (x > (g_width * 0.4)) {
g_shorts++;
displayXP(x, y, g_short_xp);
}
}
function addXP(num) {
g_xp = g_xp + num;
g_total_xp = g_total_xp + num;
}
function displayXP(x, y, num) {
lvl = getPopsClip();
xp = pops.attachMovie("xp_bonus", "xp_" + lvl, lvl);
xp._x = x;
xp._y = y;
xp.num = num;
}
function displayDamage(x, y, num) {
lvl = getPopsClip();
dmg = pops.attachMovie("hp_damage", "dmg_" + lvl, lvl);
dmg._x = x;
dmg._y = y;
dmg.num = num;
}
function displayDodge(x, y) {
lvl = getPopsClip();
temp = pops.attachMovie("dodge", "dodge_" + lvl, lvl);
temp._x = x;
temp._y = y;
}
function displayPop(x, y, num) {
lvl = getPopsClip();
dmg = pops.attachMovie("hp_damage", "dmg_" + lvl, lvl);
dmg._x = x;
dmg._y = y;
dmg.num = num;
}
function checkEnemyDeath(ene) {
if ((ene.dead = ene.hp <= 0)) {
ene.hp = 0;
g_enemyDead++;
}
ene.gotoAndStop(Math.floor((1 - (ene.hp / ene.maxhp)) * 100));
}
function cleanUp() {
cleanUpEnemies();
cleanUpArrows();
cleanUpBlood();
}
function cleanUpEnemies() {
if (g_enemyDead > 0) {
temp = new Array();
for (i in g_enemies) {
cur = g_enemies[i];
if (!cur.dead) {
temp.push(cur);
} else {
g_enemyDead--;
g_curOnScreen--;
checkinEneLevel(cur.lvl);
g_bodies.push(cur);
if (cur.killedHouse) {
trace("Killed House");
cur.gotoAndPlay(136);
} else {
cur.gotoAndPlay(100);
playRandomHit();
}
resetMaxes();
}
}
g_enemies = temp;
}
}
function updateMaxes(x, y) {
if (y < g_max_height) {
g_max_height = y - 100;
}
if (x < g_max_width) {
g_max_width = x - 100;
factr = 20;
if (g_frontline < (g_max_width + 300)) {
spot = g_frontline;
trace("Min Flag");
} else {
spot = g_max_width + 300;
trace("Max Flag");
}
if (spot < 800) {
spot = 800;
}
reinforcements._x = spot;
}
}
function cleanUpBlood() {
if (g_bloodDead > 0) {
temp = new Array();
for (i in g_bloods) {
cur = g_bloods[i];
if (!cur.dead) {
temp.push(cur);
} else {
g_bloodDead--;
cur.gotoAndPlay(2);
}
}
g_bloods = temp;
}
}
function cleanUpArrows() {
if (g_arrowDead > 0) {
temp = new Array();
for (i in g_arrows) {
cur = g_arrows[i];
if (!cur.dead) {
temp.push(cur);
} else {
if (cur.aType == "flak_arrow") {
g_detonateNum--;
}
cur.unloadMovie();
g_arrowDead--;
}
}
g_arrows = temp;
}
}
function cleanDebris() {
i = 0;
while (i < g_dmax) {
g_debris_fg[i].unloadMovie();
i++;
}
i = 0;
while (i < g_dmax) {
g_debris_bg[i].unloadMovie();
i++;
}
i = 0;
while (i < g_bloodMax) {
g_debris_bloods[i].unloadMovie();
i++;
}
}
function cleanEnemies() {
while (g_enemies.length > 0) {
g_enemies.pop().unloadMovie();
}
}
function cleanObstructs() {
while (g_obstructs.length > 0) {
temp = g_obstructs.pop();
temp.unloadMovie();
}
ground.unloadMovie();
}
function cleanArrows() {
while (g_arrows.length > 0) {
temp = g_arrows.pop();
temp.unloadMovie();
}
}
function createLevel(lvl) {
factr = 20;
g_frontline = g_width - (factr * g_currentLevel);
gravX = -50 + random(100);
gravX = gravX * (lvl * 0.1);
wind_indicator._xscale = gravX;
g_population = g_currentLevel * 10;
if ((g_currentLevel % 10) == 0) {
g_numBosses = 1;
} else {
g_numBosses = 0;
}
g_numWalkers = lvl * 2;
g_numObs = Math.floor(lvl * 0.3) + 1;
g_numFlying = Math.floor(lvl * 0.7);
g_numOgres = Math.floor(lvl * 0.4);
g_numHomes = Math.floor(lvl * 0.2) + 1;
g_numEnemyCatapults = Math.floor(lvl * 0.2);
g_numEnemyArchers = Math.floor(lvl * 0.6);
g_numDragonArchers = Math.floor(lvl * 0.3);
if (g_numObs > 4) {
g_numObs = 4;
}
if (g_numHomes > 3) {
g_numhomes = 3;
}
factr = 1.05;
g_ogre_hp = Math.ceil(g_base_ogre_hp * Math.pow(factr, g_currentLevel));
g_walker_hp = Math.ceil(g_base_walker_hp * Math.pow(factr, g_currentLevel));
g_flyer_hp = Math.ceil(g_base_flyer_hp * Math.pow(factr, g_currentLevel));
}
function loadNextLevel() {
g_lastLevel = g_currentLevel;
createLevel(++g_currentLevel);
}
function cleanLevel() {
cleanDebris();
cleanBodies();
cleanObstructs();
cleanArrows();
cleanArchers();
cleanCatapults();
cleanEnemies();
}
function startNextLevel() {
g_houses_alive = g_numhomes;
initializeClipLevels();
reinforcements.gotoAndStop(1);
reinforcements._x = g_width;
lvl = 1;
g_enelvl = -1;
g_arrowLevel = -1;
g_terrainLevel = 0;
g_popsLevel = -1;
g_explosionsLevel = -1;
g_key_listener = keylvl.attachMovie("key_listener", "key_listener_" + lvl, lvl);
g_key_listener._alpha = 0;
g_key_listener._x = -100;
resetXPcounts();
resetMaxes();
cleanDebris();
cleanBodies();
cleanObstructs();
cleanArrows();
cleanArchers();
cleanCatapults();
cleanEnemies();
g_debris_ndx_bg = 0;
g_debris_ndx_fg = 0;
g_curOnScreen = 0;
g_obj_ndx = g_obj_start_ndx;
g_startNew = true;
pause = false;
}
function checkEndGame() {
if (((((((((g_numWalkers == 0) && (g_numFlying == 0)) && (g_numOgres == 0)) && (g_numEnemyArchers == 0)) && (g_numEnemyCatapults == 0)) && (g_numDragonArchers == 0)) && (g_numBosses == 0)) && (g_enemies.length == 0)) && (!g_level_over)) {
g_endTime = getTimer() + g_menuDelay;
g_level_over = true;
resetObsMaxes();
if ((g_currentLevel > 0) && (!g_gameJustStarted)) {
temp = levelComplete.attachMovie("level_complete", "complete_0", 0);
temp._x = g_width / 2;
temp._y = g_ground / 2;
}
}
if (((getTimer() > g_endTime) && (g_level_over)) || (g_forceEndGame)) {
g_key_listener.unloadMovie();
if (((!g_gameJustStarted) && (!g_restarted)) && (!g_skipped)) {
calculateXPAward();
}
pause = true;
g_level_over = false;
setPrevGameVars();
loadNextLevel();
if (g_currentLevel > 1) {
upgrades._x = g_width / 2;
upgrades._y = g_ground / 2;
} else {
displayLevelStats();
}
g_playing = false;
g_forceEndGame = false;
g_gameJustStarted = false;
}
}
function displayLevelStats() {
stats_p._x = g_width / 2;
stats_p._y = g_ground / 2;
}
function resetCosts() {
cost_range = 25;
cost_multi = 25;
cost_archer = 100;
cost_catapult = 700;
cost_bomb_arrow = 125;
cost_flak_arrow = 180;
cost_fire_arrow = 175;
cost_ice_arrow = 175;
cost_pierce_arrow = 220;
cost_blast_range = 50;
cost_blast_power = 55;
cost_arrow_dmg = 35;
cost_bow_loading = 120;
cost_archer_cooldown = 150;
cost_catapult_cooldown = 105;
cost_fire_dot = 125;
}
function floorAmounts() {
g_maxbowpwr_amount = Math.floor(g_maxbowpwr_amount);
g_arrow_dmg_amount = Math.floor(g_arrow_dmg_amount);
g_blast_range_amount = Math.floor(g_blast_range_amount);
g_blast_power_amount = Math.floor(g_blast_power_amount);
g_catapult_cooldown_amount = Math.floor(g_catapult_cooldown_amount);
g_archer_cooldown_amount = Math.floor(g_archer_cooldown_amount);
g_bow_loading_amount = Math.floor(g_bow_loading_amount);
g_fire_dot_amount = Math.floor(g_fire_dot_amount);
}
function buyAmount(name, amount) {
i = 0;
while ((i < amount) && (buy(name))) {
i++;
}
}
function buyMaxType(name) {
while (buy(name)) {
}
}
function buy(name) {
if (name == "range_upgrade") {
if ((g_xp >= cost_range) && (g_maxbowpwr < g_maxbowpwr_max)) {
g_maxbowpwr = g_maxbowpwr + g_maxbowpwr_inc;
if (g_maxbowpwr > g_maxbowpwr_max) {
g_maxbowpwr = g_maxbowpwr_max;
}
g_xp = g_xp - cost_range;
cost_range = cost_range * 1.05;
cost_range = Math.floor(cost_range);
return(true);
}
} else if (name == "multi_arrow") {
if ((g_xp >= cost_multi) && (g_multi_num < g_multi_num_max)) {
g_multi_num++;
g_xp = g_xp - cost_multi;
cost_multi = cost_multi * 1.05;
cost_multi = Math.floor(cost_multi);
return(true);
}
} else if (name == "fire_dot") {
if (g_xp >= cost_fire_dot) {
g_fire_dot = g_fire_dot + g_fire_dot_inc;
g_xp = g_xp - cost_fire_dot;
cost_fire_dot = cost_fire_dot * 1.05;
cost_fire_dot = Math.floor(cost_fire_dot);
return(true);
}
} else if (name == "archer") {
if ((g_xp >= cost_archer) && (g_archer_num < g_archer_num_max)) {
g_archer_num++;
g_xp = g_xp - cost_archer;
cost_archer = cost_archer * 1.05;
cost_archer = Math.floor(cost_archer);
return(true);
}
} else if (name == "catapult") {
if ((g_xp >= cost_catapult) && (g_catapult_num < g_catapult_num_max)) {
g_catapult_num++;
g_xp = g_xp - cost_catapult;
cost_catapult = cost_catapult * 1.5;
cost_catapult = Math.floor(cost_catapult);
return(true);
}
} else if (name == "pierce_arrow") {
if ((g_xp >= cost_pierce_arrow) && (g_piercer_num < g_piercer_num_max)) {
g_piercer_num++;
g_xp = g_xp - cost_pierce_arrow;
cost_pierce_arrow = cost_pierce_arrow * 1.05;
cost_pierce_arrow = Math.floor(cost_pierce_arrow);
return(true);
}
} else if (name == "bomb_arrow") {
if ((g_xp >= cost_bomb_arrow) && (g_bomb_num < g_bomb_num_max)) {
g_bomb_num++;
g_xp = g_xp - cost_bomb_arrow;
cost_bomb_arrow = cost_bomb_arrow * 1.05;
cost_bomb_arrow = Math.floor(cost_bomb_arrow);
return(true);
}
} else if (name == "flak_arrow") {
if ((g_xp >= cost_flak_arrow) && (g_flak_num < g_flak_num_max)) {
g_flak_num++;
g_xp = g_xp - cost_flak_arrow;
cost_flak_arrow = cost_flak_arrow * 1.05;
cost_flak_arrow = Math.floor(cost_flak_arrow);
return(true);
}
} else if (name == "fire_arrow") {
if ((g_xp >= cost_fire_arrow) && (g_fire_num < g_fire_num_max)) {
g_fire_num++;
g_xp = g_xp - cost_fire_arrow;
cost_fire_arrow = cost_fire_arrow * 1.05;
cost_fire_arrow = Math.floor(cost_fire_arrow);
return(true);
}
} else if (name == "ice_arrow") {
if ((g_xp >= cost_ice_arrow) && (g_ice_num < g_ice_num_max)) {
g_ice_num++;
g_xp = g_xp - cost_ice_arrow;
cost_ice_arrow = cost_ice_arrow * 1.05;
cost_ice_arrow = Math.floor(cost_ice_arrow);
return(true);
}
} else if (name == "blast_power") {
if (g_xp >= cost_blast_power) {
g_blast_power = g_blast_power + g_blast_power_inc;
g_xp = g_xp - cost_blast_power;
cost_blast_power = cost_blast_power * 1.05;
cost_blast_power = Math.floor(cost_blast_power);
return(true);
}
} else if (name == "blast_range") {
if ((g_xp >= cost_blast_range) && (g_blast_range < g_blast_range_max)) {
g_blast_range = g_blast_range + g_blast_range_inc;
if (g_blast_range > g_blast_range_max) {
g_blast_range = g_blast_range_max;
}
g_xp = g_xp - cost_blast_range;
cost_blast_range = cost_blast_range * 1.05;
cost_blast_range = Math.floor(cost_blast_range);
return(true);
}
} else if (name == "bow_loading") {
if ((g_xp >= cost_bow_loading) && (g_bow_loading > g_bow_loading_max)) {
g_bow_loading = g_bow_loading - g_bow_loading_inc;
if (g_bow_loading < g_bow_loading_max) {
g_bow_loading = g_bow_loading_max;
}
g_xp = g_xp - cost_bow_loading;
cost_bow_loading = cost_bow_loading * 1.05;
cost_bow_loading = Math.floor(cost_bow_loading);
return(true);
}
} else if (name == "archer_loading") {
if ((g_xp >= cost_archer_cooldown) && (g_archer_cooldown > g_archer_cooldown_max)) {
g_archer_cooldown = g_archer_cooldown - g_archer_cooldown_inc;
if (g_archer_cooldown < g_archer_cooldown_max) {
g_archer_cooldown = g_archer_cooldown_max;
}
g_xp = g_xp - cost_archer_cooldown;
cost_archer_cooldown = cost_archer_cooldown * 1.05;
cost_archer_cooldown = Math.floor(cost_archer_cooldown);
return(true);
}
} else if (name == "catapult_loading") {
if ((g_xp >= cost_catapult_cooldown) && (g_catapult_cooldown > g_catapult_cooldown_max)) {
g_catapult_cooldown = g_catapult_cooldown - g_catapult_cooldown_inc;
if (g_catapult_cooldown < g_catapult_cooldown_max) {
g_catapult_cooldown = g_catapult_cooldown_max;
}
g_xp = g_xp - cost_catapult_cooldown;
cost_catapult_cooldown = cost_catapult_cooldown * 1.05;
cost_catapult_cooldown = Math.floor(cost_catapult_cooldown);
return(true);
}
} else if (name == "arrow_dmg") {
if (g_xp >= cost_arrow_dmg) {
g_arrow_dmg = g_arrow_dmg + g_arrow_dmg_inc;
g_xp = g_xp - cost_arrow_dmg;
cost_arrow_dmg = cost_arrow_dmg * 1.05;
cost_arrow_dmg = Math.floor(cost_arrow_dmg);
return(true);
}
}
return(false);
}
function cleanArchers() {
while (g_archers.length > 0) {
temp = g_archers.pop();
temp.unloadMovie();
}
}
function loadArchers() {
if (g_archer_num > 0) {
aimer._x = 650;
aimer._y = g_ground / 2;
} else {
aimer._x = -100;
}
i = 0;
while (i < g_archer_num) {
temp = archerZone.attachMovie("archer", "archer_" + i, i);
temp._x = archer_spot._x - (i * 10);
temp._y = tower._y + 60;
g_archers.push(temp);
i++;
}
}
function cleanCatapults() {
while (g_catapults.length > 0) {
temp = g_catapults.pop();
temp.unloadMovie();
}
}
function cleanBodies() {
while (g_bodies.length > 0) {
g_bodies.pop().unloadMovie();
}
}
function loadCatapults() {
if (g_catapult_num > 0) {
c_aimer._x = 550;
c_aimer._y = g_ground / 2;
} else {
c_aimer._x = -100;
}
i = 0;
while (i < g_catapult_num) {
temp = catapultZone.attachMovie("catapult", "catapult_" + i, i);
temp._x = catapult_spot._x - (i * 50);
temp._y = tower._y + 60;
g_catapults.push(temp);
i++;
}
}
function getClip() {
}
function getDebrisClipFG() {
g_debris_ndx_fg++;
if (g_debris_ndx_fg == g_dmax) {
g_debris_ndx_fg = 0;
}
return(g_debris_ndx_fg);
}
function getDebrisClipBG() {
g_debris_ndx_bg++;
if (g_debris_ndx_bg == g_dmax) {
g_debris_ndx_bg = 0;
}
return(g_debris_ndx_bg);
}
function getObjClip() {
g_obj_ndx++;
if (g_obj_ndx > 50) {
g_obj_ndx = 0;
}
return(g_obj_ndx);
}
function followTerrain(ene) {
if (ground.hitTest(ene._x, ene._y, 1) || (ene._y > g_ground)) {
if (ene.delta > 0) {
ene.delta = 0;
}
ene.delta = ene.delta - 0.5;
ene._y = ene._y + ene.delta;
} else {
if (ene.delta < 0) {
ene.delta = 0;
}
ene.delta = ene.delta + 0.5;
ene._y = ene._y + ene.delta;
}
}
function placeTower() {
tower._x = 500;
tower._y = -500;
while (!ground.hitTest(tower._x - (tower._width / 2), tower._y + (tower._height / 2), 1)) {
tower._y++;
}
}
function getNextTerrain() {
g_terrainNdx = random(g_terrains.length);
trace("g_terrainNdx: " + g_terrainNdx);
return(g_terrains[g_terrainNdx]);
}
function getNextBackground() {
ndx = random(g_backgrounds.length);
trace("g_terrainNdx: " + ndx);
return(g_backgrounds[ndx]);
}
function getTerrainClip() {
return(g_terrainLevel++);
}
function loadTerrain() {
lvl = getTerrainClip();
ground = hill.attachMovie(getNextTerrain(), "ground_" + lvl, lvl);
back.attachMovie(getNextBackground(), "background_0", 0, back_prop);
back._x = g_width / 2;
back._y = g_ground;
back._width = g_width + 100;
back._height = g_ground;
ground._x = g_width / 2;
ground._width = g_width + 100;
ground._y = g_ground;
g_groundHeight = g_ground - ground._height;
}
function restartLevel() {
trace("entering restart");
g_currentLevel--;
g_restarted = true;
g_game_over = false;
g_forceEndGame = true;
checkEndGame();
g_restarted = false;
trace("exiting restart");
}
function skipToLevel() {
g_skipTo = Math.floor(g_skipTo);
num = new Number(g_skipTo);
if (num.toString() == "NaN") {
g_skipTo = 666;
}
if ((g_skipTo <= g_maxLevel) || (g_skipTo == 666)) {
g_skipped = true;
g_game_over = false;
g_currentLevel = g_skipTo - 1;
g_forceEndGame = true;
checkEndGame();
g_skipped = false;
}
}
function restartGame() {
g_restarted = true;
g_game_over = false;
g_mode = "normal";
resetGameVars();
g_currentLevel = 0;
g_forceEndGame = true;
checkEndGame();
g_restarted = false;
}
function resetToPrev() {
g_maxbowpwr = g_Pmaxbowpwr;
g_currentLevel = g_PcurrentLevel;
g_xp = g_Pxp;
g_population = g_Ppopulation;
g_multi_num = g_Pmulti_num;
g_bomb_num = g_Pbomb_num;
g_catapult_num = g_Pcatapult_num;
g_archer_num = g_Parcher_num;
g_piercer_num = g_Ppiercer_num;
g_arrow_dmg = g_Parrow_dmg;
g_blast_range = g_Pblast_range;
g_blast_power = g_Pblast_power;
g_catapult_cooldown = g_Pcatapult_cooldown;
g_archer_cooldown = g_Parcher_cooldown;
}
function setKey(mode, mode_icon) {
for (i in g_keys) {
curKey = g_keys[i];
if (curKey.hitTest(_xmouse, _ymouse, 1)) {
curKey.attachMovie(mode_icon, "mode_1", 1);
curKey.mode = mode;
}
}
}
function setMode(keyNum) {
g_mode = g_keys[keyNum].mode;
}
function buymax() {
prev_xp = 0;
do {
prev_xp = g_xp;
buy("bow_loading");
buy("range_upgrade");
buy("multi_arrow");
buy("fire_arrow");
buy("ice_arrow");
buy("pierce_arrow");
buy("bomb_arrow");
buy("catapult");
buy("archer");
buy("blast_range");
buy("catapult_loading");
buy("archer_loading");
buy("blast_power");
buy("arrow_dmg");
buy("fire_dot");
buy("flak_arrow");
} while (g_xp < prev_xp);
}
stop();
g_sound_on = true;
g_playing = false;
g_ground = 1400;
g_width = 2500;
g_currentLevel = 0;
g_lastLevel = 0;
g_total_xp = 0;
g_xp = 0;
g_maxLevel = 0;
g_gameJustStarted = true;
g_skipTo = 1;
g_restarted = false;
g_skipped = false;
g_base_ogre_hp = 50;
g_base_flyer_hp = 8;
g_base_walker_hp = 10;
g_ogre_hp = g_base_ogre_hp;
g_walker_hp = g_base_flyer_hp;
g_flyer_hp = g_base_walker_hp;
myLocalSO = sharedobject.getLocal("testbm0");
if (myLocalSO.data.g_currentLevel != null) {
trace("Shared Object Data Found... loading data");
g_total_xp = myLocalSO.data.g_total_xp;
g_currentLevel = myLocalSo.data.g_currentLevel;
g_xp = _root.g_total_xp;
g_maxLevel = myLocalSo.data.g_currentLevel + 1;
g_lastLevel = g_currentLevel - 1;
} else {
trace("Shared Object Data Not Found... using default data");
g_total_xp = (g_xp = 0);
g_currentLevel = 0;
g_maxLevel = 1;
displayHelp();
}
g_longs = 0;
g_shorts = 0;
g_mids = 0;
g_long_award_xp = 0;
g_mid_award_xp = 0;
g_short_award_xp = 0;
g_house_award_xp = 0;
g_long_xp = 15;
g_mid_xp = 11;
g_short_xp = 5;
g_level_xp = 5;
g_awarded_xp = 0;
g_level_award_xp = 0;
g_house_xp = 100;
g_zero_loss_award = 0;
g_allhouse_award = 0;
g_xp_msg = "nothing of interest";
g_noPopLoss = true;
g_noHouseLoss = true;
g_arrows = new Array();
g_enemies = new Array();
g_obstructs = new Array();
g_bloods = new Array();
g_archers = new Array();
g_catapults = new Array();
g_bodies = new Array();
g_terrains = new Array("ground1", "ground2", "ground3", "ground4", "ground5", "ground6", "ground7", "ground8", "ground9", "ground10", "ground11", "ground12", "ground13", "ground14", "ground15", "ground16", "ground17", "ground18");
g_keys = new Array();
g_trees = new Array("tree", "tree2", "tree3");
g_homes = new Array();
g_homeNdx = -1;
g_ogres_entered = 0;
g_fliers_entered = 0;
g_walkers_entered = 0;
ground = ground1;
g_clipnum = 0;
g_andx = 0;
g_endx = 0;
gravX = 0;
gravY = 1000;
elapsed = 0;
g_arcount = 0;
g_bcount = 0;
g_boost = 4.5;
g_unloadndx = 0;
pause = false;
bloodOn = true;
g_forceEndGame = false;
g_startNew = false;
g_bow_pwr = 5;
g_mode_single = 0;
g_mode_multi = 1;
g_mode_bomb = 2;
g_mode = "normal";
g_arrowMode = g_mode_bomb;
g_bow_cooldown = 0;
g_key_listener = null;
resetGameVars();
setPrevGameVars();
g_numWalkers = 0;
g_numBosses = 0;
g_numObs = 0;
g_numFlying = 0;
g_numOgres = 0;
g_numEnemyCatapults = 0;
g_numEnemyArchers = 0;
g_numDragonArchers = 0;
g_numHomes = 0;
g_game_over = false;
g_level_over = false;
g_endTime = 0;
g_menuDelay = 3000;
g_icon_spacing = 55;
g_icon_offset = 75;
g_icon_spacing_y = 140;
g_dmax = 10;
g_debris_ndx_fg = 0;
g_debris_ndx_bg = 0;
g_obj_start_ndx = 0;
g_obj_ndx = g_obj_start_ndx;
g_freed = new Array();
g_debris_fg = new Array(g_dmax);
g_debris_bg = new Array(g_dmax);
g_enemyDead = 0;
g_arrowDead = 0;
g_bloodDead = 0;
g_maxOnScreen = 3;
g_curOnScreen = 0;
g_eneNdx = -1;
g_eneLvlMax = 12;
g_arrowLevels = new Array(100);
g_enemyLevels = new Array(g_eneLvlMax);
initializeClipLevels();
g_test_lastOut = 0;
g_enelvl = -1;
g_fps = 0;
g_max_height = g_ground;
g_max_width = g_width;
g_arrowLevel = -1;
g_bloodNdx = 0;
g_bloodMax = 80;
g_debris_bloods = new Array(g_bloodMax);
g_obsMax_x = 0;
g_obsMax_y = 0;
g_obsMin_x = g_width;
g_obsMin_y = g_ground;
g_homepositions = new Array();
g_treepositions = new Array();
g_obsNdx = 0;
g_detonateNum = 0;
g_popsLevel = -1;
g_explosionsLevel = -1;
cost_range = 25;
cost_multi = 25;
cost_archer = 100;
cost_catapult = 700;
cost_bomb_arrow = 125;
cost_flak_arrow = 180;
cost_fire_arrow = 175;
cost_ice_arrow = 175;
cost_pierce_arrow = 220;
cost_blast_range = 50;
cost_blast_power = 55;
cost_arrow_dmg = 35;
cost_bow_loading = 120;
cost_archer_cooldown = 150;
cost_catapult_cooldown = 105;
cost_fire_dot = 125;
g_maxbowpwr_max = 1400;
g_multi_num_max = 3;
g_fire_num_max = 4;
g_ice_num_max = 4;
g_bomb_num_max = 4;
g_flak_num_max = 1;
g_catapult_num_max = 2;
g_archer_num_max = 10;
g_piercer_num_max = 3;
g_arrow_dmg_max = "no limit";
g_blast_range_max = 300;
g_blast_power_max = "no limit";
g_catapult_cooldown_max = 5;
g_archer_cooldown_max = 3;
g_bow_loading_max = 0.4;
g_fire_dot_max = "no limit";
g_maxbowpwr_inc = 50;
g_arrow_dmg_inc = 1;
g_blast_range_inc = 20;
g_blast_power_inc = 0.5;
g_catapult_cooldown_inc = 1;
g_archer_cooldown_inc = 0.5;
g_bow_loading_inc = 0.05;
g_fire_dot_inc = 1.5;
g_maxbowpwr_amount = 1;
g_arrow_dmg_amount = 1;
g_blast_range_amount = 1;
g_blast_power_amount = 1;
g_catapult_cooldown_amount = 1;
g_archer_cooldown_amount = 1;
g_bow_loading_amount = 1;
g_fire_dot_amount = 1;
g_groundHeight = 0;
g_terrainNdx = 5;
g_backgrounds = new Array("bg_1", "bg_2", "bg_3", "bg_4");
g_terrainLevel = 0;
Instance of Symbol 281 MovieClip [war_flag] "reinforcements" in Frame 1
/* no clip actions */
Instance of Symbol 301 MovieClip "string" in Frame 1
onClipEvent (load) {
time = 0;
}
onClipEvent (enterFrame) {
if (!_root.pause) {
if (!_root.holding) {
time = time + _root.elapsed;
}
if ((time > _root.g_bow_cooldown) && (!_root.holding)) {
_x = _root.bow.spotX;
_y = _root.bow.spotY;
_root.holding = true;
time = 0;
}
}
}
Instance of Symbol 305 MovieClip "bow" in Frame 1
onClipEvent (load) {
radians = 0;
spotX = 0;
spotY = 0;
width = 45;
}
onClipEvent (enterFrame) {
_x = _root.tower._x;
_y = _root.tower._y;
dx = _root.string._x - _root.bow._x;
dy = _root.string._y - _root.bow._y;
radians = Math.atan(dy / dx);
if (dx > 0) {
_rotation = (((radians * 180) / Math.PI) + 180);
spotX = _x - (Math.cos(radians + Math.PI) * width);
spotY = _y - (Math.sin(radians + Math.PI) * width);
} else {
_rotation = ((radians * 180) / Math.PI);
spotX = _x - (Math.cos(radians) * width);
spotY = _y - (Math.sin(radians) * width);
}
}
Instance of Symbol 308 MovieClip "fps" in Frame 1
onClipEvent (load) {
current = (prev = getTimer());
_root.elapsed = 0;
}
onClipEvent (enterFrame) {
current = getTimer();
_root.elapsed = (current - prev) / 1000;
prev = current;
}
Instance of Symbol 310 MovieClip in Frame 1
onClipEvent (load) {
walkerT = 0;
ogreT = 0;
flyerT = 0;
catapultT = 0;
archerT = 0;
dragonArcherT = 0;
bossT = 0;
walkerF = 2;
ogreF = 10;
flyerF = 6;
bossF = 40;
catapultF = 11;
archerF = 11;
dragonArcherF = 7;
fps_time = 1;
frames = 0;
_root.pause = true;
_root.checkEndGame();
}
onClipEvent (enterFrame) {
if (fps_time < 0.5) {
fps_time = fps_time + _root.elapsed;
frames++;
} else {
_root.g_fps = frames * 2;
fps_time = 0;
frames = 0;
}
_root.checkEndGame();
if (!_root.pause) {
if (_root.g_curOnScreen <= _root.g_maxOnScreen) {
area = _root.g_width - _root.reinforcements._x;
lvl = _root.g_currentLevel;
spot = _root.reinforcements._x + random(area);
if (spot < 600) {
spot = 600;
}
if (spot > (_root.g_width - 100)) {
spot = _root.g_width - 100;
}
flyerT = flyerT + _root.elapsed;
walkerT = walkerT + _root.elapsed;
ogreT = ogreT + _root.elapsed;
catapultT = catapultT + _root.elapsed;
archerT = archerT + _root.elapsed;
dragonArcherT = dragonArcherT + _root.elapsed;
if (((flyerT > (flyerF / lvl)) || (_root.g_curOnScreen == 0)) && (_root.g_numFlying > 0)) {
alt = (_root.g_groundHeight - random(300)) - 300;
if (alt < 600) {
alt = 600;
}
_root.addEnemy(_root.g_width + 20, alt, ((-random(100)) - 20) - (_root.g_currentLevel * 1.1), 0, _root.g_flyer_hp, "flying_enemy");
_root.g_numFlying--;
flyerT = 0;
_root.g_curOnScreen++;
}
if (((ogreT > (ogreF / lvl)) || (_root.g_curOnScreen == 0)) && (_root.g_numOgres > 0)) {
_root.addEnemy(spot, _root.g_ground, -10 - random(_root.g_currentLevel / 2), 0, _root.g_ogre_hp, "ogre");
_root.g_numOgres--;
ogreT = 0;
_root.g_curOnScreen++;
}
if (((walkerT > (walkerF / lvl)) || (_root.g_curOnScreen == 0)) && (_root.g_numWalkers > 0)) {
_root.addEnemy(spot, _root.g_ground, -20 - random(_root.g_currentLevel / 2), 0, _root.g_walker_hp, "enemy");
_root.g_numWalkers--;
walkerT = 0;
_root.g_curOnScreen++;
}
if (((catapultT > (catapultF / lvl)) || (_root.g_curOnScreen == 0)) && (_root.g_numEnemyCatapults > 0)) {
_root.addEnemy(spot, _root.g_ground, -5, 0, _root.g_ogre_hp * 2, "enemy_catapult");
_root.g_numEnemyCatapults--;
catapultT = 0;
_root.g_curOnScreen++;
}
if (((archerT > (archerF / lvl)) || (_root.g_curOnScreen == 0)) && (_root.g_numEnemyArchers > 0)) {
_root.addEnemy(spot, _root.g_ground, -30 - random(_root.g_currentLevel / 2), 0, _root.g_walker_hp, "enemy_archer");
_root.g_numEnemyArchers--;
archerT = 0;
_root.g_curOnScreen++;
}
if (((dragonArcherT > (dragonArcherF / lvl)) || (_root.g_curOnScreen == 0)) && (_root.g_numDragonArchers > 0)) {
alt = (_root.g_groundHeight - random(300)) - 300;
if (alt < 600) {
alt = 600;
}
_root.addEnemy(_root.g_width + 20, alt, ((-random(100)) - 20) - (_root.g_currentLevel * 1.1), 0, _root.g_flyer_hp * 2, "dragon_archer");
_root.g_numDragonArchers--;
dragonArcherT = 0;
_root.g_curOnScreen++;
}
if (_root.g_numBosses > 0) {
_root.addEnemy(_root.g_width, _root.g_ground, -8, 0, _root.g_ogre_hp * 60, "boss");
_root.g_numBosses--;
bossT = 0;
_root.g_curOnScreen++;
}
}
_root.stepArrows();
_root.stepEnemies();
_root.stepBloods();
_root.testHit();
_root.cleanUp();
}
if (_root.g_startNew) {
_root.initObstructs();
_root.loadArchers();
_root.loadCatapults();
_root.holding = false;
_root.g_startNew = false;
}
updateAfterEvent();
}
Instance of Symbol 320 MovieClip "pause_sign" in Frame 1
onClipEvent (enterFrame) {
if (_root.pause) {
_x = (_root.g_width / 2);
_y = (_root.g_ground / 2);
} else {
_y = -100;
}
}
Instance of Symbol 339 MovieClip "key6" in Frame 1
onClipEvent (load) {
mode = "all";
_root.g_keys[5] = this;
this.attachMovie("all_moder", "mode_1", 1);
}
on (press) {
_root.g_mode = mode;
}
Instance of Symbol 341 MovieClip "key1" in Frame 1
onClipEvent (load) {
mode = "normal";
_root.g_keys[0] = this;
this.attachMovie("normal_moder", "mode_1", 1);
}
on (press) {
_root.g_mode = mode;
}
Instance of Symbol 343 MovieClip "key2" in Frame 1
onClipEvent (load) {
mode = "normal";
_root.g_keys[1] = this;
this.attachMovie("normal_moder", "mode_1", 1);
}
on (press) {
_root.g_mode = mode;
}
Instance of Symbol 345 MovieClip "key3" in Frame 1
onClipEvent (load) {
mode = "normal";
_root.g_keys[2] = this;
this.attachMovie("normal_moder", "mode_1", 1);
}
on (press) {
_root.g_mode = mode;
}
Instance of Symbol 347 MovieClip "key4" in Frame 1
onClipEvent (load) {
mode = "normal";
_root.g_keys[3] = this;
this.attachMovie("normal_moder", "mode_1", 1);
}
on (press) {
_root.g_mode = mode;
}
Instance of Symbol 349 MovieClip "key5" in Frame 1
onClipEvent (load) {
mode = "normal";
_root.g_keys[4] = this;
this.attachMovie("normal_moder", "mode_1", 1);
}
on (press) {
_root.g_mode = mode;
}
Instance of Symbol 350 MovieClip "fire_b" in Frame 1
onClipEvent (enterFrame) {
if (!dragging) {
if (_root.g_fire_num > 0) {
_x = ((5 * _root.g_icon_spacing) + _root.g_icon_offset);
_y = (_root.tower._y + _root.g_icon_spacing_y);
} else {
_x = -100;
}
}
}
on (press) {
startDrag (this);
dragging = true;
_root.g_mode = "fire";
}
on (release) {
stopDrag();
_root.setKey("fire", "fire_icon");
dragging = false;
}
Instance of Symbol 351 MovieClip "ice_b" in Frame 1
onClipEvent (enterFrame) {
if (!dragging) {
if (_root.g_ice_num > 0) {
_x = ((4 * _root.g_icon_spacing) + _root.g_icon_offset);
_y = (_root.tower._y + _root.g_icon_spacing_y);
} else {
_x = -100;
}
}
}
on (press) {
startDrag (this);
dragging = true;
_root.g_mode = "ice";
}
on (release) {
stopDrag();
_root.setKey("ice", "ice_icon");
dragging = false;
}
Instance of Symbol 278 MovieClip [bomb_moder] "bomb_b" in Frame 1
onClipEvent (enterFrame) {
if (!dragging) {
if (_root.g_bomb_num > 0) {
_x = ((3 * _root.g_icon_spacing) + _root.g_icon_offset);
_y = (_root.tower._y + _root.g_icon_spacing_y);
} else {
_x = -100;
}
}
}
on (press) {
startDrag (this);
dragging = true;
_root.g_mode = "bomb";
}
on (release) {
stopDrag();
_root.setKey("bomb", "bomb_moder");
dragging = false;
}
Instance of Symbol 277 MovieClip [pierce_moder] "pierce_b" in Frame 1
onClipEvent (enterFrame) {
if (!dragging) {
if (_root.g_piercer_num > 0) {
_x = ((2 * _root.g_icon_spacing) + _root.g_icon_offset);
_y = (_root.tower._y + _root.g_icon_spacing_y);
} else {
_x = -100;
}
}
}
on (press) {
startDrag (this);
dragging = true;
_root.g_mode = "pierce";
}
on (release) {
stopDrag();
_root.setKey("pierce", "pierce_moder");
dragging = false;
}
Instance of Symbol 276 MovieClip [normal_moder] "normal_b" in Frame 1
onClipEvent (enterFrame) {
if (!dragging) {
if (_root.g_multi_num > 0) {
_x = ((1 * _root.g_icon_spacing) + _root.g_icon_offset);
_y = (_root.tower._y + _root.g_icon_spacing_y);
} else {
_x = -100;
}
}
}
on (press) {
startDrag (this);
dragging = true;
_root.g_mode = "normal";
}
on (release) {
stopDrag();
_root.setKey("normal", "normal_moder");
dragging = false;
}
Instance of Symbol 275 MovieClip [all_moder] "all_b" in Frame 1
onClipEvent (enterFrame) {
if (!dragging) {
_x = ((6 * _root.g_icon_spacing) + _root.g_icon_offset);
_y = (_root.tower._y + _root.g_icon_spacing_y);
}
}
on (press) {
startDrag (this);
dragging = true;
_root.g_mode = "all";
}
on (release) {
stopDrag();
_root.setKey("all", "all_moder");
dragging = false;
}
Instance of Symbol 274 MovieClip [flak_moder] "flak_b" in Frame 1
onClipEvent (enterFrame) {
if (!dragging) {
if (_root.g_flak_num > 0) {
_x = ((1 * _root.g_icon_spacing) + _root.g_icon_offset);
_y = ((_root.tower._y + _root.g_icon_spacing_y) + 50);
} else {
_x = -100;
}
}
}
on (press) {
startDrag (this);
dragging = true;
_root.g_mode = "flak";
}
on (release) {
stopDrag();
_root.setKey("flak", "flak_moder");
dragging = false;
}
Instance of Symbol 353 MovieClip in Frame 1
onClipEvent (enterFrame) {
if (_root.g_mode == "all") {
_x = _root.all_b._x;
_y = _root.all_b._y;
} else if (_root.g_mode == "normal") {
_x = _root.normal_b._x;
_y = _root.normal_b._y;
} else if (_root.g_mode == "fire") {
_x = _root.fire_b._x;
_y = _root.fire_b._y;
} else if (_root.g_mode == "ice") {
_x = _root.ice_b._x;
_y = _root.ice_b._y;
} else if (_root.g_mode == "pierce") {
_x = _root.pierce_b._x;
_y = _root.pierce_b._y;
} else if (_root.g_mode == "bomb") {
_x = _root.bomb_b._x;
_y = _root.bomb_b._y;
} else if (_root.g_mode == "flak") {
_x = _root.flak_b._x;
_y = _root.flak_b._y;
}
}
Instance of Symbol 284 MovieClip "archer_spot" in Frame 1
onClipEvent (load) {
_alpha = 0;
}
Instance of Symbol 284 MovieClip "catapult_spot" in Frame 1
onClipEvent (load) {
_alpha = 0;
}
Instance of Symbol 401 MovieClip "game_over" in Frame 1
onClipEvent (enterFrame) {
if (_root.g_game_over) {
_x = (_root.g_width / 2);
_y = (_root.g_ground / 2);
} else {
_y = (_root.g_ground + _height);
}
}
Instance of Symbol 589 MovieClip in Frame 1
onClipEvent (load) {
_y = (_root.g_ground / 2);
_x = (_root.g_width / 2);
}
onClipEvent (enterFrame) {
if (getTimer() > _root.g_menuDelay) {
this.unloadMovie();
}
}
Symbol 11 MovieClip [flak_animation2] Frame 44
stop();
this.unloadMovie();
Symbol 23 MovieClip [dragon_archer] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = ((Math.sin(_x / 100) * 50) + fhight);
if (getTimer() > timeToShoot) {
timeToShoot = getTimer() + 8000;
en_arrow_vx = (-1000 - random(200)) * 0.5;
en_arrow_vy = (200 - random(100)) * 0.5;
_root.addGeneric(_x - (_width / 2), _y, en_arrow_vx, en_arrow_vy, 1, false, 0, 0, false, false, false, "fire_arrow");
}
}
function setInXY(x, y) {
inx = x;
iny = y;
}
stop();
Symbol 23 MovieClip [dragon_archer] Frame 135
stop();
this.unloadMovie();
Symbol 23 MovieClip [dragon_archer] Frame 171
stop();
this.unloadMovie();
Symbol 26 MovieClip [flying_enemy] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = ((Math.sin(_x / 100) * 50) + fhight);
}
function setInXY(x, y) {
inx = x;
iny = y;
}
stop();
Symbol 26 MovieClip [flying_enemy] Frame 135
stop();
this.unloadMovie();
Symbol 26 MovieClip [flying_enemy] Frame 171
stop();
this.unloadMovie();
Symbol 33 MovieClip [flying_enemy2] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = ((Math.sin(_x / 100) * 50) + fhight);
}
function setInXY(x, y) {
inx = x;
iny = y;
}
stop();
stop();
Symbol 33 MovieClip [flying_enemy2] Frame 100
play();
Symbol 33 MovieClip [flying_enemy2] Frame 135
stop();
this.unloadMovie();
Symbol 49 MovieClip Frame 1
stop();
Symbol 52 MovieClip [ogre3] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = (_y + (vy * _root.elapsed));
}
stop();
Symbol 52 MovieClip [ogre3] Frame 100
play();
Symbol 52 MovieClip [ogre3] Frame 135
stop();
this.unloadMovie();
Symbol 55 MovieClip [boss] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = (_y + (vy * _root.elapsed));
}
stop();
Symbol 55 MovieClip [boss] Frame 135
stop();
this.unloadMovie();
Symbol 55 MovieClip [boss] Frame 175
stop();
this.unloadMovie();
Symbol 58 MovieClip [ogre] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = (_y + (vy * _root.elapsed));
}
stop();
Symbol 58 MovieClip [ogre] Frame 135
stop();
this.unloadMovie();
Symbol 58 MovieClip [ogre] Frame 175
stop();
this.unloadMovie();
Symbol 63 MovieClip [enemy_archer] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = (_y + (vy * _root.elapsed));
if (getTimer() > timeToShoot) {
timeToShoot = getTimer() + 7000;
en_arrow_vx = ((-800 - random(200)) - envx) * 0.5;
en_arrow_vy = ((-1200 - random(200)) - envy) * 0.5;
_root.addGeneric(_x - (_width / 2), _y - _height, en_arrow_vx, en_arrow_vy, 1, false, 0, 0, false, false, false, "arrow_bad");
envx = envx + 80;
envy = envy + 120;
if (vx < 0) {
speed = vx;
vx = 0;
} else {
vx = speed;
}
}
}
stop();
Symbol 63 MovieClip [enemy_archer] Frame 135
stop();
this.unloadMovie();
Symbol 63 MovieClip [enemy_archer] Frame 170
stop();
this.unloadMovie();
Symbol 74 MovieClip Frame 1
stop();
Symbol 74 MovieClip Frame 25
stop();
Instance of Symbol 78 MovieClip in Symbol 79 MovieClip [smoker] Frame 1
onClipEvent (load) {
lvl = 0;
time = 3;
}
onClipEvent (enterFrame) {
}
Symbol 80 MovieClip [enemy_catapult] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = (_y + (vy * _root.elapsed));
if (getTimer() > timeToShoot) {
timeToShoot = getTimer() + 15000;
en_arrow_vx = ((-800 - random(200)) - envx) * 0.5;
en_arrow_vy = ((-1200 - random(200)) - envy) * 0.5;
_root.addGeneric(_x - (_width / 2), _y - _height, en_arrow_vx, en_arrow_vy, 1, true, 100, 1, false, false, true, "cat_ammo1");
envx = envx + 80;
envy = envy + 120;
if (vx < 0) {
speed = vx;
vx = 0;
} else {
vx = speed;
}
}
}
stop();
Symbol 80 MovieClip [enemy_catapult] Frame 135
stop();
this.unloadMovie();
Symbol 80 MovieClip [enemy_catapult] Frame 170
stop();
this.unloadMovie();
Symbol 81 MovieClip [enemy] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = (_y + (vy * _root.elapsed));
}
stop();
Symbol 81 MovieClip [enemy] Frame 135
stop();
this.unloadMovie();
Symbol 81 MovieClip [enemy] Frame 170
stop();
this.unloadMovie();
Symbol 84 MovieClip [enemy2] Frame 1
function step() {
_x = (_x + (vx * _root.elapsed));
_y = (_y + (vy * _root.elapsed));
}
stop();
Symbol 84 MovieClip [enemy2] Frame 100
play();
Symbol 84 MovieClip [enemy2] Frame 135
stop();
this.unloadMovie();
Symbol 92 MovieClip [blood] Frame 1
stop();
Symbol 92 MovieClip [blood] Frame 45
stop();
Symbol 97 MovieClip [critical_hit] Frame 40
this.unloadMovie();
Instance of Symbol 74 MovieClip in Symbol 98 MovieClip [catapult] Frame 1
onClipEvent (load) {
time = 0;
}
onClipEvent (enterFrame) {
if (!_root.pause) {
time = time + _root.elapsed;
}
if (time > _root.g_catapult_cooldown) {
dx = _root.c_aimer._x - _parent._x;
dy = _root.c_aimer._y - _parent._y;
_root.shootGeneric(_parent._x, _parent._y, dx, dy, 50, true, 300, 300, true, true, true, 50, 50, "cat_ammo1");
time = 0;
}
}
Instance of Symbol 103 MovieClip in Symbol 104 MovieClip [archer] Frame 1
onClipEvent (load) {
time = 0;
}
onClipEvent (enterFrame) {
if (!_root.pause) {
time = time + _root.elapsed;
}
if (time > _root.g_archer_cooldown) {
dx = _root.aimer._x - _parent._x;
dy = _root.aimer._y - _parent._y;
_root.shootGeneric(_parent._x, _parent._y, dx, dy, _root.g_arrow_dmg, false, 0, 0, false, false, false, 100, 100, "arrow");
time = 0;
}
}
Symbol 111 MovieClip [hp_damage] Frame 65
this.unloadMovie();
Symbol 117 MovieClip [pop_killed] Frame 65
this.unloadMovie();
Symbol 123 MovieClip [xp_bonus] Frame 65
this.unloadMovie();
Symbol 129 MovieClip [flak_animation] Frame 43
this.unloadMovie();
Symbol 131 MovieClip [bomb_animation] Frame 11
this.unloadMovie();
Symbol 166 MovieClip [house] Frame 1
stop();
Symbol 166 MovieClip [house] Frame 25
stop();
Instance of Symbol 168 MovieClip in Symbol 169 MovieClip [smoke_animation] Frame 1
onClipEvent (load) {
time = 0;
smokeT = 0;
smokeF = 0.1;
}
onClipEvent (enterFrame) {
if (time > 15) {
this.unloadMovie();
}
if (smokeT > smokeF) {
smokeT = 0;
_alpha = (_alpha - 1);
}
_x = (_x + 0.05);
_y = (_y - 0.2);
_xscale = (_xscale * 1.003);
_yscale = (_yscale * 1.01);
time = time + _root.elapsed;
smokeT = smokeT + _root.elapsed;
}
Symbol 193 MovieClip [level_complete] Frame 158
this.unloadMovie();
Symbol 197 Button
on (keyPress "1") {
_root.setMode(0);
}
on (keyPress "2") {
_root.setMode(1);
}
on (keyPress "3") {
_root.setMode(2);
}
on (keyPress "4") {
_root.setMode(3);
}
on (keyPress "5") {
_root.setMode(4);
}
on (keyPress "6") {
_root.setMode(5);
}
on (keyPress "<Space>") {
_root.detonateBomb();
}
Symbol 203 MovieClip [war_flag2] Frame 1
stop();
Symbol 208 MovieClip [dodge] Frame 55
this.unloadMovie();
Symbol 230 Button
on (release) {
_y = -800;
}
Symbol 235 Button [flak_moder]
on (release) {
_root.buy("flak_arrow");
}
on (rollOver) {
text = "Great against dragon scouts. Weak against all other units. Hit spacebar to detonate in air.";
}
Symbol 237 Button [all_moder]
on (release) {
_root.floorAmounts();
_root.buyAmount("bow_loading", _root.g_bow_loading_amount);
}
on (rollOver) {
text = "Allows you to fire more frequently (decreases your shooting cool down time)";
}
Symbol 239 Button [normal_moder]
on (release) {
_root.buy("multi_arrow");
}
on (rollOver) {
text = "Standard issue arrow - skill points are only awarded for basic arrow critical hits.";
}
Symbol 241 Button [pierce_moder]
on (release) {
_root.buy("pierce_arrow");
}
on (rollOver) {
text = "Passes through objects and enemies doing reduced damage. Extra damage to ogres.";
}
Symbol 243 Button [bomb_moder]
on (release) {
_root.buy("bomb_arrow");
}
on (rollOver) {
text = "Explodes on contact doing splash damage to nearby enemies. Extra damage to enemy archers.";
}
Symbol 272 Button
on (release) {
_root.startNextLevel();
_x = 9999;
_y = 9999;
_root.g_playing = true;
}
Symbol 281 MovieClip [war_flag] Frame 1
stop();
Symbol 281 MovieClip [war_flag] Frame 35
stop();
Instance of Symbol 283 MovieClip in Symbol 284 MovieClip Frame 1
onClipEvent (load) {
_alpha = 0;
}
Instance of Symbol 298 MovieClip in Symbol 299 MovieClip Frame 1
onClipEvent (enterFrame) {
_rotation = _root.bow._rotation;
}
Symbol 300 Button
on (press) {
startDrag (this);
_x = _root._xmouse;
_y = _root._ymouse;
_root.holding = true;
}
on (releaseOutside) {
stopDrag();
if (!_root.pause) {
_root.shoot();
_x = (((_root.bow.spotX - _root.bow._x) * 100) + _root.bow._x);
_y = (((_root.bow.spotY - _root.bow._y) * 100) + _root.bow._y);
_root.holding = false;
_root.last_spot._x = _root._xmouse;
_root.last_spot._y = _root._ymouse;
_root.last_spot._rotation = _root.bow._rotation;
_root.last_angle._rotation = _root.bow._rotation;
_root.last_angle._x = _root.bow._x;
_root.last_angle._y = _root.bow._y;
}
}
on (release) {
stopDrag();
if (!_root.pause) {
_root.shoot();
_x = (((_root.bow.spotX - _root.bow._x) * 100) + _root.bow._x);
_y = (((_root.bow.spotY - _root.bow._y) * 100) + _root.bow._y);
_root.holding = false;
_root.last_spot._x = _root._xmouse;
_root.last_spot._y = _root._ymouse;
_root.last_spot._rotation = _root.bow._rotation;
_root.last_angle._rotation = _root.bow._rotation;
_root.last_angle._x = _root.bow._x;
_root.last_angle._y = _root.bow._y;
}
}
Symbol 313 Button
on (release) {
if ((!g_game_over) && (g_playing)) {
pause = !pause;
}
}
Symbol 318 Button
on (release) {
_root.displayHelp();
pause = true;
pause_sign._x = g_width / 2;
pause_sign._y = g_ground / 2;
}
Symbol 322 Button
on (release) {
getURL ("http://www.csc.calpoly.edu/~jreinsvo", "_blank");
}
Symbol 324 Button
on (release) {
getURL ("http://www.csc.calpoly.edu/~jreinsvo/bowmaster/alpha_q.html", "_blank");
}
on (keyPress "|") {
_root.g_xp = _root.g_xp + 1000;
}
Symbol 328 Button
on (release) {
g_sound_on = !g_sound_on;
}
Symbol 339 MovieClip Frame 1
stop();
Symbol 341 MovieClip Frame 1
function setModeAs(mode) {
lvl = 1;
this.attachMovie(mode, "mode_" + lvl, lvl);
}
stop();
Symbol 343 MovieClip Frame 1
function setModeAs(mode) {
lvl = 1;
this.attachMovie(mode, "mode_" + lvl, lvl);
}
stop();
Symbol 345 MovieClip Frame 1
function setModeAs(mode) {
lvl = 1;
this.attachMovie(mode, "mode_" + lvl, lvl);
}
stop();
Symbol 347 MovieClip Frame 1
function setModeAs(mode) {
lvl = 1;
this.attachMovie(mode, "mode_" + lvl, lvl);
}
stop();
Symbol 349 MovieClip Frame 1
function setModeAs(mode) {
lvl = 1;
this.attachMovie(mode, "mode_" + lvl, lvl);
}
stop();
Symbol 359 Button
on (press) {
startDrag (this);
}
on (release) {
stopDrag();
}
Symbol 364 Button
on (press) {
startDrag (this);
}
on (release) {
stopDrag();
}
Symbol 398 Button
on (release) {
_root.restartGame();
}
Symbol 399 Button
on (release) {
_root.restartLevel();
}
Symbol 400 Button
on (release) {
_root.skipToLevel();
}
Symbol 406 Button
on (release) {
_root.floorAmounts();
_root.buyAmount("blast_range", _root.g_blast_range_amount);
}
on (rollOver) {
text = "Increases the blast radius of bomb arrows, but not flak bombs";
}
Symbol 407 Button
on (release) {
_root.floorAmounts();
_root.buyAmount("blast_power", _root.g_blast_power_amount);
}
on (rollOver) {
text = "Increases the amount of damage a bomb or flak bomb does within the blast radius";
}
Symbol 408 Button
on (release) {
_root.floorAmounts();
_root.buyAmount("arrow_dmg", _root.g_arrow_dmg_amount);
}
on (rollOver) {
text = "Increases the amount of impact damage done by all arrows";
}
Symbol 409 Button
on (release) {
_root.floorAmounts();
_root.buyAmount("catapult_loading", _root.g_catapult_cooldown_amount);
}
on (rollOver) {
text = "Makes your catapults shoot more frequently. (decreases the loading time)";
}
Symbol 410 Button
on (release) {
_root.floorAmounts();
_root.buyAmount("archer_loading", _root.g_archer_cooldown_amount);
}
on (rollOver) {
text = "Makes your archers shoot more frequently. (decreases the loading time)";
}
Symbol 417 Button
on (release) {
_root.floorAmounts();
_root.buyAmount("range_upgrade", _root.g_maxbowpwr_amount);
}
on (rollOver) {
text = "Increases the maximum range of your bow";
}
Symbol 425 Button
on (release) {
_x = 9999;
_y = 9999;
_root.displayLevelStats();
}
Symbol 444 Button
on (release) {
_root.buy("fire_arrow");
}
on (rollOver) {
text = "Sets enemies on fire. Impact damage is slightly reduced. Slightly increases enemy speed but causes damage over time. Extra damage to catapults. Bosses are immune to fire.";
}
Symbol 446 Button
on (release) {
_root.buy("archer");
}
on (rollOver) {
text = "Archer that fires every so often - it aims for the archer icon which you can move around. Archers fire basic arrows which award skill points.";
}
Symbol 447 Button
on (release) {
_root.buy("catapult");
}
on (rollOver) {
text = "Catapult that fires every so often. The rocks explode on contact and can pass through enemies and objects. It aims for the catapult icon which you can move around";
}
Symbol 448 Button
on (release) {
_root.buy("ice_arrow");
}
on (rollOver) {
text = "Slows enemies but does little impact damage except agains dragon archers. Massive damage to dragon archers. Bosses are immune to ice slowdown";
}
Symbol 466 Button
on (release) {
_root.floorAmounts();
_root.buyAmount("fire_dot", _root.g_fire_dot_amount);
}
on (rollOver) {
text = "Increases how much fire damage enemies take per second when on fire";
}
Symbol 489 Button
on (release) {
_root.buymax();
}
on (rollOver) {
text = "Buys one of everything until maxed or you run out of points to spend";
}
Symbol 522 Button
on (release) {
_root.resetCosts();
_root.resetGameVars();
}
on (rollOver) {
text = "Allows you to respend all of your xp";
}
Symbol 527 MovieClip Frame 1
text = "";
Instance of Symbol 501 MovieClip in Symbol 527 MovieClip Frame 1
on (release) {
_root.buyMaxType("range_upgrade");
}
Instance of Symbol 501 MovieClip in Symbol 527 MovieClip Frame 1
on (release) {
_root.buyMaxType("blast_range");
}
Instance of Symbol 501 MovieClip in Symbol 527 MovieClip Frame 1
on (release) {
_root.buyMaxType("blast_power");
}
Instance of Symbol 501 MovieClip in Symbol 527 MovieClip Frame 1
on (release) {
_root.buyMaxType("arrow_dmg");
}
Instance of Symbol 501 MovieClip in Symbol 527 MovieClip Frame 1
on (release) {
_root.buyMaxType("archer_loading");
}
Instance of Symbol 501 MovieClip in Symbol 527 MovieClip Frame 1
on (release) {
_root.buyMaxType("catapult_loading");
}
Instance of Symbol 501 MovieClip in Symbol 527 MovieClip Frame 1
on (release) {
_root.buyMaxType("fire_dot");
}
Instance of Symbol 501 MovieClip in Symbol 527 MovieClip Frame 1
on (release) {
_root.buyMaxType("bow_loading");
}
Symbol 554 Button
on (release) {
_x = 9999;
_y = 9999;
}
Symbol 590 Button
on (release) {
_root.g_xp = 0;
}