Frame 1
stop();
Frame 8
stop();
Frame 15
stop();
Frame 28
gotoAndPlay ("win");
Frame 29
stop();
Frame 45
function updateEnemy() {
prone_count = 0;
wave_over = 1;
var _local1 = 0;
while (_local1 < MAX_ENEMY) {
think(_local1);
if ((e_action[_local1] != EACT_PRONE) && (e_action[_local1] != EACT_DEAD)) {
wave_over = 0;
}
if (e_action[_local1] == EACT_PRONE) {
prone_count = prone_count + 1;
}
_local1++;
}
}
function think(num) {
if (e_actionTime[num] >= runTime) {
return(undefined);
}
if (e_action[num] != e_nextaction[num]) {
setAction(num);
}
with (_root["enemy" + num]) {
switch (e_action[num]) {
case EACT_NONE :
default :
spawnEnemy(num);
return;
case EACT_RUN :
var origin = new v3d(_x, _y, 0);
var dest = new v3d(e_destx[num], e_desty[num], 0);
dest.minVec(origin);
dest.normalize();
_x = _x + ((deltaTime * dest.x) * e_speed);
_y = _y + ((deltaTime * dest.y) * e_speed);
r = random(500);
if (r == 1) {
nextAction(num, EACT_SHOOT, 0);
}
if (hitTest(defense)) {
nextAction(num, EACT_PRONE, 0);
}
return;
case EACT_SHOOT :
fireBullet(_x, _y, -90, random(100), random(400), 1);
nextAction(num, EACT_RUN, 3000);
return;
case EACT_COVER :
nextAction(num, EACT_RUN, random(3000) + 1000);
return;
case EACT_PRONE :
return;
case EACT_GRANADE :
return;
case EACT_KILLED :
}
_root["deadenemy" + d_curDeadEnemy]._x = _root["enemy" + num]._x;
_root["deadenemy" + d_curDeadEnemy]._y = _root["enemy" + num]._y;
_root["deadenemy" + d_curDeadEnemy]._rotation = random(90) - 45;
if (random(2) == 1) {
_root["deadenemy" + d_curDeadEnemy]._yscale = -70;
} else {
_root["deadenemy" + d_curDeadEnemy]._yscale = 70;
}
if (random(2) == 1) {
_root["deadenemy" + d_curDeadEnemy]._xscale = -70;
} else {
_root["deadenemy" + d_curDeadEnemy]._xscale = 70;
}
_root["deadenemy" + d_curDeadEnemy].gotoAndPlay(1);
d_curDeadEnemy = d_curDeadEnemy + 1;
if (d_curDeadEnemy >= MAX_DEADENEMY) {
d_curDeadEnemy = 0;
}
_root["enemy" + num]._x = 700;
nextAction(num, EACT_DEAD, 0);
}
}
function nextAction(num, act, time) {
e_actionTime[num] = runTime + time;
e_nextaction[num] = act;
}
function setAction(num) {
with (_root["enemy" + num]) {
switch (e_nextaction[num]) {
case EACT_NONE :
default :
break;
case EACT_RUN :
gotoAndPlay("run");
break;
case EACT_SHOOT :
gotoAndPlay("shoot");
break;
case EACT_COVER :
gotoAndPlay("prone");
break;
case EACT_PRONE :
gotoAndPlay("prone");
break;
case EACT_GRANADE :
}
}
e_action[num] = e_nextaction[num];
}
function killEnemy(num) {
nextAction(num, EACT_KILLED, 0);
shots_hit = shots_hit + 1;
}
function spawnEnemy(num) {
if (wave_count <= 0) {
return(undefined);
}
lc = chooseLC();
_root["enemy" + num]._x = _root["lc" + lc]._x;
_root["enemy" + num]._y = _root["lc" + lc]._y;
e_destx[num] = random(50) + 100;
e_desty[num] = random(380) + 10;
nextAction(num, EACT_RUN, 0);
wave_count = wave_count - 1;
}
function killEnemyInRadius(x, y, rad) {
var i = 0;
while (i < MAX_ENEMY) {
if (e_action[i] != EACT_DEAD) {
with (_root["enemy" + i]) {
var origin = new v3d(_x, _y, 0);
var dest = new v3d(x, y, 0);
var dist = dest.distance(origin);
if (dist <= rad) {
killEnemy(i);
} else if (dist <= (rad * 2)) {
nextAction(i, EACT_COVER, 0);
}
}
}
i++;
}
}
function chooseLC() {
return(random(MAX_LC));
}
EACT_NONE = 0;
EACT_RUN = 1;
EACT_SHOOT = 2;
EACT_COVER = 3;
EACT_PRONE = 4;
EACT_GRENADE = 5;
EACT_DEAD = 6;
EACT_KILLED = 7;
MAX_ENEMY = 20;
e_speed = 10;
e_destx = new Array();
e_desty = new Array();
e_action = new Array();
e_nextaction = new Array();
e_actionTime = new Array();
MAX_DEADENEMY = 20;
d_curDeadEnemy = 0;
var prone_count = 0;
startDrag ("/drag", true);
function togglePause() {
paused = !paused;
if (paused) {
var _local3 = 0;
while (_local3 < MAX_EXPLODES) {
_root["explosion" + _local3].gotoAndStop("suspendexplosion");
_local3++;
}
var _local2 = 0;
while (_local2 < MAX_ENEMY) {
_root["enemy" + _local2].stop();
_local2++;
}
} else {
var _local2 = 0;
while (_local2 < MAX_ENEMY) {
_root["enemy" + _local2].play();
_local2++;
}
}
}
function fireRifleman() {
r = random(MAX_RIFLEMEN);
if (r_dead[r] == 1) {
r_fireTime = runTime + 1000;
return(undefined);
}
targx = random(200) + 350;
targy = random(300) + 50;
with (_root["rifleman" + r]) {
riflefire.gotoAndPlay("riflefire");
fireBullet(_x, _y, 90, targx, targy, 0);
}
r_fireTime = runTime + (random(3000) + 1000);
}
function nextWave() {
wave_over = 0;
wave_state = 0;
wave = wave + 1;
e_speed = e_speed + 1;
x_nextExplode = (runTime + random(5000)) + 5000;
wave_count = 25 * wave;
var _local2 = 0;
while (_local2 < MAX_ENEMY) {
if (e_action[_local2] != EACT_PRONE) {
e_action[_local2] = EACT_NONE;
e_nextaction[_local2] = EACT_NONE;
}
_local2++;
}
var _local3 = 0;
while (_local3 < MAX_RIFLEMEN) {
r_dead[_local3] = 0;
_root["rifleman" + _local3]._alpha = 100;
_local3++;
}
}
function addExplosion(x, y, type) {
with (_root["explosion" + x_currentExplode]) {
_x = x;
_y = y;
if (type == 0) {
gotoAndPlay("explode");
} else if (type == 1) {
gotoAndPlay("incoming");
}
}
x_currentExplode = x_currentExplode + 1;
if (x_currentExplode >= MAX_EXPLODES) {
x_currentExplode = 0;
}
if (x_inBarrage <= 0) {
x_nextExplode = (runTime + random(5000)) + 5000;
} else {
x_nextExplode = runTime + 2000;
}
x_inBarrage = x_inBarrage - 1;
}
function initiateBarrage() {
if (x_barrageCount <= 0) {
return(undefined);
}
x_nextExplode = runTime + 2000;
x_inBarrage = 10;
x_barrageCount = x_barrageCount - 1;
radio._alpha = 0;
}
function updateMg42() {
if (drag._x < mg42._x) {
drag._x = mg42._x;
}
var _local2 = new v3d(mg42._x, mg42._y, 0);
var _local1 = new v3d(drag._x, drag._y, 0);
_local1.minVec(_local2);
_local1.normalize();
degrees = Math.acos(_local1.x) * 57.2958;
if (_local1.y < 0) {
degrees = 360 - degrees;
}
mg42._rotation = degrees + 90;
if (firing == 1) {
if (firetime < runTime) {
firetime = runTime + 175;
fireBullet(mg42._x, mg42._y, mg42._rotation, drag._x, drag._y, 0);
numfired = numfired + 1;
if (numfired >= 6) {
firing = 0;
numfired = 0;
clicker.enabled = true;
}
}
}
}
function setMessage(msg) {
messageText = msg;
messagetime = runTime + 3000;
}
function updateBullets() {
var i = 0;
while (i < MAX_BULLETS) {
with (_root["bullet" + i]) {
if (bullet_active[i] == false) {
_x = -100;
} else {
_x = _x + (deltaTime * bullet_velx[i]);
_y = _y + (deltaTime * bullet_vely[i]);
var origin = new v3d(_x, _y, 0);
var dest = new v3d(bullet_destx[i], bullet_desty[i], 0);
var dist = dest.distance(origin);
if (bullet_owner[i] == 0) {
if (!bulletHitObstacle(i)) {
var e = 0;
while (e < MAX_ENEMY) {
if (e_action[e] != EACT_PRONE) {
if (hitTest(_root["enemy" + e])) {
killEnemy(e);
_x = 1000;
bullet_active[i] = false;
}
}
e++;
}
}
} else if (bullet_owner[i] == 1) {
var r = 0;
while (r < MAX_RIFLEMEN) {
if (hitTest(_root["rifleman" + r]) && (r_dead[r] == 0)) {
r_dead[r] = 1;
_root["rifleman" + r]._alpha = 0;
break;
}
r++;
}
}
if (dist < 15) {
if (bullet_destx[i] > 460) {
with (splash) {
splash._x = bullet_destx[i];
splash._y = bullet_desty[i];
gotoAndPlay("splash");
bullet_active[i] = false;
}
} else {
with (sand_poof) {
sand_poof._x = bullet_destx[i];
sand_poof._y = bullet_desty[i];
gotoAndPlay("sand_poof");
bullet_active[i] = false;
}
}
_x = 1000;
}
}
}
i++;
}
}
function bulletHitObstacle(num) {
var i = 0;
while (i < MAX_OBSTACLES) {
with (_root["obstacle" + i]) {
if (hitTest(_root["bullet" + num])) {
sparks._x = _root["bullet" + num]._x;
sparks._y = _root["bullet" + num]._y;
sparks.gotoAndPlay("sparks");
bullet_active[num] = false;
return(true);
}
}
i++;
}
return(false);
}
function fireBullet(x, y, rot, destx, desty, owner) {
_root["bullet" + cur_bullet]._x = x;
_root["bullet" + cur_bullet]._y = y;
_root["bullet" + cur_bullet]._rotation = rot;
var _local3 = new v3d(x, y, 0);
var _local2 = new v3d(destx, desty, 0);
_local2.minVec(_local3);
_local2.normalize();
bullet_velx[cur_bullet] = _local2.x * bullet_speed;
bullet_vely[cur_bullet] = _local2.y * bullet_speed;
bullet_destx[cur_bullet] = destx;
bullet_desty[cur_bullet] = desty;
bullet_owner[cur_bullet] = owner;
bullet_active[cur_bullet] = true;
cur_bullet = cur_bullet + 1;
if (cur_bullet >= MAX_BULLETS) {
cur_bullet = 0;
}
if (owner == 0) {
shots_fired = shots_fired + 1;
}
}
function initGame() {
var _local6 = 0;
while (_local6 < MAX_DEADENEMY) {
_root.attachMovie("deadenemy", "deadenemy" + _local6, this.getNextHighestDepth());
_root["deadenemy" + _local6]._y = 0;
_root["deadenemy" + _local6]._x = -50;
_root["deadenemy" + _local6]._xscale = 70;
_root["deadenemy" + _local6]._yscale = 70;
_local6++;
}
var _local8 = 0;
while (_local8 < MAX_EXPLODES) {
_root.attachMovie("explosion", "explosion" + _local8, this.getNextHighestDepth());
_root["explosion" + _local8]._y = 0;
_root["explosion" + _local8]._x = -50;
_root["explosion" + _local8]._xscale = 70;
_root["explosion" + _local8]._yscale = 70;
_local8++;
}
var _local4 = 0;
while (_local4 < MAX_BULLETS) {
_root.attachMovie("bullet", "bullet" + _local4, this.getNextHighestDepth());
_root["bullet" + _local4].gotoAndStop(1);
_root["bullet" + _local4]._xscale = 50;
_root["bullet" + _local4]._yscale = 50;
_root["bullet" + _local4]._alpha = 60;
bullet_active[_local4] = false;
_local4++;
}
ox = 325;
oy = 60;
oi = 0;
var _local7 = 0;
while (_local7 < MAX_OBSTACLES) {
_root.attachMovie("obstacle", "obstacle" + _local7, this.getNextHighestDepth());
_root["obstacle" + _local7].gotoAndStop(1);
if (_local7 == 5) {
ox = 400;
oy = 100;
oi = 0;
}
_root["obstacle" + _local7]._x = ox;
_root["obstacle" + _local7]._y = (oi * 70) + oy;
oi = oi + 1;
_local7++;
}
onstacle1._x = -100;
var _local5 = 0;
while (_local5 < MAX_LC) {
_root.attachMovie("lc", "lc" + _local5, this.getNextHighestDepth());
_root["lc" + _local5].gotoAndStop(1);
_root["lc" + _local5]._x = 450 + random(20);
_root["lc" + _local5]._y = 100 * (_local5 + 1);
_local5++;
}
var _local3 = 0;
while (_local3 < MAX_ENEMY) {
_root.attachMovie("enemy", "enemy" + _local3, this.getNextHighestDepth());
_root["enemy" + _local3]._xscale = 50;
_root["enemy" + _local3]._yscale = 40;
_root["enemy" + _local3]._x = 1000;
_root["enemy" + _local3]._y = 1000;
e_destx[_local3] = random(50) + 100;
e_desty[_local3] = random(300) + 50;
e_action[_local3] = EACT_DEAD;
e_nextaction[_local3] = EACT_DEAD;
e_actionTime[_local3] = random(3000) + 1000;
_local3++;
}
var _local9 = 0;
while (_local9 < MAX_RIFLEMEN) {
_root.attachMovie("rifleman", "rifleman" + _local9, this.getNextHighestDepth());
_root["rifleman" + _local9]._y = (_local9 * 40) + 80;
_root["rifleman" + _local9]._x = 50;
_local9++;
}
sparks.swapDepths(this.getNextHighestDepth());
messagetext.swapDepths(this.getNextHighestDepth());
drag.swapDepths(this.getNextHighestDepth());
frame.swapDepths(this.getNextHighestDepth());
radio._alpha = 100;
init = 1;
}
function endGame(wl) {
var _local4 = 0;
while (_local4 < MAX_DEADENEMY) {
_root["deadenemy" + _local4].removeMovieClip();
_local4++;
}
var _local7 = 0;
while (_local7 < MAX_BULLETS) {
_root["bullet" + _local7].removeMovieClip();
_local7++;
}
var _local8 = 0;
while (_local8 < MAX_EXPLODES) {
_root["explosion" + _local8].removeMovieClip();
_local8++;
}
var _local6 = 0;
while (_local6 < MAX_OBSTACLES) {
_root["obstacle" + _local6].removeMovieClip();
_local6++;
}
var _local2 = 0;
while (_local2 < MAX_LC) {
_root["lc" + _local2].removeMovieClip();
_local2++;
}
var _local3 = 0;
while (_local3 < MAX_ENEMY) {
_root["enemy" + _local3].removeMovieClip();
_local3++;
}
var _local5 = 0;
while (_local5 < MAX_RIFLEMEN) {
_root["rifleman" + _local5].removeMovieClip();
_local5++;
}
init = 0;
if (wl == 0) {
_root.gotoAndPlay("Win");
} else if (wl == 1) {
_root.gotoAndPlay("Loose");
}
game_over = 1;
drag.stopDrag();
drag.removeMovieClip();
}
stop();
wave = 0;
wave_count = 25;
wave_over = 1;
wave_time = 0;
wave_state = 0;
shots_fired = 0;
shots_hit = 0;
hit_ratio = 0;
MAX_BULLETS = 10;
bullet_speed = 300;
bullet_velx = new Array();
bullet_vely = new Array();
bullet_destx = new Array();
bullet_desty = new Array();
bullet_owner = new Array();
bullet_active = new Array();
cur_bullet = 0;
firing = 0;
numfired = 0;
firetime = 0;
MAX_LC = 3;
MAX_OBSTACLES = 9;
MAX_RIFLEMEN = 3;
r_fireTime = 0;
r_dead = new Array();
MAX_EXPLODES = 10;
x_currentExplode = 0;
x_nextExplode = 0;
x_barrageCount = 1;
x_inBarrage = 0;
init = 0;
runTime = getTimer();
lastTime = runTime;
deltaTime = 0;
messagetime = 0;
messageText = "";
var game_over = 0;
paused = 0;
onEnterFrame = function () {
if (game_over == 1) {
return(undefined);
}
if (init == 0) {
initGame();
}
runTime = getTimer();
if (wave_over == 1) {
if (wave == 10) {
endGame(0);
return(undefined);
}
if (wave_time < runTime) {
if (wave_state == 0) {
if (wave == 0) {
setMessage("The enemy is coming!");
wave_state = 2;
} else {
setMessage("Wave Completed!");
wave_state = 1;
}
wave_time = runTime + 3000;
} else if (wave_state == 1) {
setMessage("Prepare for next wave!!");
wave_time = runTime + 3000;
wave_state = 2;
} else if (wave_state == 2) {
setMessage("Get ready!");
wave_time = runTime + 3000;
wave_state = 3;
} else if (wave_state == 3) {
setMessage("GO!!");
wave_time = runTime + 3000;
nextWave();
}
}
} else if (paused == 0) {
updateMg42();
updateEnemy();
updateBullets();
if (r_fireTime < runTime) {
fireRifleman();
}
if (x_nextExplode < runTime) {
if (x_inBarrage <= 0) {
mortarman.gotoAndPlay("firemortar");
x_nextExplode = runTime + 5000;
shots_fired = shots_fired + 1;
} else {
addExplosion(random(150) + 250, random(300) + 50, 1);
}
}
if (prone_count >= 10) {
endGame(1);
return(undefined);
}
}
hit_ratio = (shots_hit / shots_fired) * 100;
hit_ratio = Math.round(hit_ratio) + "%";
if (messagetime < runTime) {
setMessage("");
}
if (paused) {
setMessage("GAME PAUSED");
}
deltaTime = runTime - lastTime;
deltaTime = deltaTime * 0.001;
lastTime = runTime;
};
Frame 46
stop();
Frame 47
stop();
Symbol 12 MovieClip [explosion] Frame 1
stop();
Symbol 12 MovieClip [explosion] Frame 2
_root.killEnemyInRadius(this._x, this._y, 35);
Symbol 12 MovieClip [explosion] Frame 19
stop();
stop();
Symbol 12 MovieClip [explosion] Frame 40
gotoAndPlay ("explode");
Symbol 19 MovieClip [deadenemy] Frame 101
stop();
Symbol 43 MovieClip [enemy] Frame 9
gotoAndPlay ("run");
Symbol 43 MovieClip [enemy] Frame 19
stop();
Symbol 43 MovieClip [enemy] Frame 26
stop();
Symbol 49 Button
on (release) {
gotoAndPlay ("rungame");
}
Symbol 65 Button
on (release) {
gotoAndPlay ("help");
}
Symbol 153 MovieClip [__Packages.v3d] Frame 0
class v3d
{
var x, y, z;
function v3d (px, py, pz) {
x = px;
y = py;
z = pz;
}
function toString() {
trace(((((("[" + x) + ",") + y) + ",") + z) + "]");
}
function reset(px, py, pz) {
x = px;
y = py;
z = pz;
}
function resetNew(px, py, pz) {
return(new v3d((x = px), (y = py), (z = pz)));
}
function cloneVec(vec) {
x = vec.x;
y = vec.y;
z = vec.z;
}
function cloneVecNew(vec) {
return(new v3d((x = vec.x), (y = vec.y), (z = vec.z)));
}
function incrX(xScalar) {
x = x + xScalar;
}
function incrY(yScalar) {
y = y + yScalar;
}
function incrZ(zScalar) {
z = z + zScalar;
}
function incrXY(xScalar, yScalar) {
x = x + xScalar;
y = y + yScalar;
}
function incrXZ(xScalar, zScalar) {
x = x + xScalar;
z = z + zScalar;
}
function incrYZ(yScalar, zScalar) {
y = y + yScalar;
z = z + zScalar;
}
function incrXYZ(xScalar, yScalar, zScalar) {
x = x + xScalar;
y = y + yScalar;
z = z + zScalar;
}
function addVec(vec) {
x = x + vec.x;
y = y + vec.y;
z = z + vec.z;
}
function addVecNew(vec) {
return(new v3d(x + vec.x, y + vec.y, z + vec.z));
}
function minVec(vec) {
x = x - vec.x;
y = y - vec.y;
z = z - vec.z;
}
function minVecNew(vec) {
return(new v3d(x - vec.x, y - vec.y, z - vec.z));
}
function getNegativeVec(vec) {
x = -x;
y = -y;
z = -z;
}
function getNegativeVecNew(vec) {
return(new v3d((x = -x), (y = -y), (z = -z)));
}
function scaleVec(scalar) {
x = x * scalar;
y = y * scalar;
z = z * scalar;
}
function scaleVecNew(scalar) {
return(new v3d((x = x * scalar), (y = y * scalar), (z = z * scalar)));
}
function dot(vec) {
return(((x * vec.x) + (y * vec.y)) + (z * vec.z));
}
function cross(vec) {
var _local3 = new v3d(0, 0, 0);
_local3.x = (y * vec.z) - (z * vec.y);
_local3.y = (z * vec.x) - (x * vec.z);
_local3.z = (x * vec.y) - (y * vec.x);
return(_local3);
}
function getNormal() {
return(Math.sqrt(((x * x) + (y * y)) + (z * z)));
}
function normalize() {
var _local2 = getNormal();
x = x / _local2;
y = y / _local2;
z = z / _local2;
}
function getUnitVec() {
var _local2 = new v3d(x, y, z);
var _local3 = getNormal();
_local2.x = _local2.x / _local3;
_local2.y = _local2.y / _local3;
_local2.z = _local2.z / _local3;
return(_local2);
}
function distance(other) {
var _local4 = other.x - x;
var _local3 = other.y - y;
var _local2 = other.z - z;
return(Math.sqrt(((_local4 * _local4) + (_local3 * _local3)) + (_local2 * _local2)));
}
}
Symbol 69 Button
on (release) {
gotoAndPlay ("tips");
}
Symbol 118 MovieClip Frame 1
stop();
Symbol 118 MovieClip Frame 20
_root.addExplosion(random(150) + 250, random(300) + 50, 1);
stop();
Symbol 141 MovieClip Frame 1
stop();
Symbol 142 MovieClip Frame 10
stop();
Symbol 144 Button
on (press) {
if (firing) {
return(undefined);
}
with (fire) {
gotoAndPlay("fire");
}
firing = 1;
clicker.enabled = false;
}
on (keyPress "<Space>") {
initiateBarrage();
}
on (keyPress "p") {
togglePause();
}
Symbol 147 MovieClip Frame 1
stop();
Symbol 147 MovieClip Frame 12
stop();
Symbol 149 MovieClip Frame 1
stop();
Symbol 149 MovieClip Frame 9
stop();
Symbol 151 MovieClip Frame 9
gotoAndStop (1);