Frame 1
function remove_from_array(obj, array) {
trace(array.length);
var _local2 = new Array();
for (ndx in array) {
if (!(array[ndx] === obj)) {
_local2.push(array[ndx]);
}
}
trace(_local2.length);
return(_local2);
}
function game_init() {
cur_cutscene_obj = cutscene_1;
next_level_obj = level_1;
layer = 0;
viewport_scroll_speed = 12;
screen_width = 600;
lives = 5;
enemy_delay = 0.08;
Stage.showMenu = false;
_global.gs_loading = 0;
_global.gs_init = 1;
_global.gs_intro = 2;
_global.gs_menu = 3;
_global.gs_init_level = 4;
_global.gs_instructions = 5;
_global.gs_level_init = 6;
_global.gs_level_play = 6.5;
_global.gs_level_out = 6.75;
_global.gs_cutscene = 7;
_global.gs_game_over = 8;
game_state = gs_loading;
_global.gp_shoot_time = 0;
_global.gp_reshoot_time = 1;
_global.gp_shoot_frame = 2;
_global.gp_power = 3;
_global.gp_frame_num = 4;
_global.gp_speed_scale = 5;
_global.gp_max_ammo = 6;
_global.gp_clip_size = 7;
_global.gp_clip_left = 8;
_global.gp_reload_time = 9;
_global.gp_owned = 10;
_global.gp_shot_type = 11;
moonshine = new Array(16, 16, 5, 35, 3, 1, -99, -99, -99, 0, true, "moonshine_bullet");
pistol = new Array(8, 4, 6, 15, 1, 1, 50, 7, 0, 30, false, "pistol_bullet");
shotgun = new Array(22, 22, 6, 60, 2, 1, 50, 6, 6, 50, true, "capfield1_shot");
taser = new Array(4, -1, 2, 0.15, 4, 1, -99, -99, -99, 0, false, "stunBullet");
smg = new Array(8, -4, 5, 15, 5, 1, 100, 32, 0, 30, false, "pistol_bullet");
nader = new Array(15, 15, 5, 35, 6, 1, 24, 6, 0, 45, false, "nader_bullet");
zader = new Array(6, 6, 3, 45, 7, 1, -99, -99, -99, 0, false, "zader_bullet");
laser = new Array(8, 4, 6, 45, 8, 1, 100, 69, 0, 30, false, "laser_shot");
flamer = new Array(8, -7, 2, 30, 9, 1, -99, 50, 0, 0, false, "flamer_shot");
ammo_array = new Array(-99, 0, 24, -99, 0, 0, -99, 0, 0);
_global.rp_grab_time = 0;
_global.rp_rastle_time = 1;
_global.rp_grab_frame = 2;
_global.rp_power = 3;
_global.rp_frame_num = 4;
rastle_1 = new Array(12, 0, 6, 10, 1);
_global.timer = 0;
_global.max_x_ref = 560;
_global.min_x_ref = 40;
_global.max_x = max_x_ref;
_global.min_x = min_x_ref;
_global.max_y = 360;
_global.min_y = 200;
_global.upKey = 38;
_global.downKey = 40;
_global.leftKey = 37;
_global.rightKey = 39;
_global.shootKey = 68;
_global.rastleKey = 65;
_global.jumpKey = 83;
_global.reloadKey = 82;
_global.changeKey = 32;
_global.E_AI_WAIT = 0;
_global.E_AI_ATTACK = 1;
_global.E_AI_DODGE = 2;
_global.E_AI_TARGET = 3;
_global.E_AI_OFF = 4;
_global.E_IDLE = 0;
_global.E_WALK = 1;
_global.E_SHOOT = 2;
_global.E_RASTLE_START = 3;
_global.E_HIT = 4;
_global.E_FIRE = 5;
_global.E_DIE = 6;
_global.E_BURN = 7;
_global.E_STUN = 8;
_global.E_GIB = 9;
}
function cutscene() {
gotoAndStop ("level");
cur_level_obj = next_level_obj;
if (!cutscene_clip) {
cutscene_counter = 0;
_root.attachMovie(cur_cutscene_obj.clip, "cutscene_clip", layer++);
stopAllSounds();
ode.start();
} else {
cutscene_counter++;
}
}
function end_cutscene() {
cutscene_counter = 0;
cutscene_clip.removeMovieClip();
game_state = gs_level_init;
}
function next_level(run_out) {
if (run_out) {
game_state = gs_level_out;
} else {
next_scene();
}
}
function game_over() {
for (i in viewport) {
viewport[i].removeMovieClip();
}
viewport.removeMovieClip();
stats.removeMovieClip();
gotoAndStop ("gameOver");
game_state = gs_game_over;
}
function level_out() {
viewport.cooter.my_state = viewport.cooter.cs_remote_walk;
viewport.cooter._x = viewport.cooter._x + viewport.cooter.speed;
viewport.cooter._xscale = 100;
if (viewport.cooter._x > (((-viewport._x) + screen_width) + 50)) {
next_scene();
}
}
function next_scene() {
for (i in viewport) {
viewport[i].removeMovieClip();
}
viewport.removeMovieClip();
stats.removeMovieClip();
game_state = gs_cutscene;
}
function cleanUpStage() {
for (i in _root) {
_root[i].removeMovieClip();
delete _root[i];
}
}
function spawnItem(item, obj) {
viewport.attachMovie(item, "item" + viewport.layer, viewport.layer++, {_x:obj._x, _y:obj._y});
}
function level_init() {
gotoAndStop ("level");
enemy_array = new Array();
object_array = new Array();
friendly_array = new Array();
vehicle_array = new Array();
this.createEmptyMovieClip("viewport", layer++);
viewport.layer = 0;
cur_enemy_stack = 0;
cur_enemy_ndx = 0;
build_bg(cur_level_obj, viewport);
viewport.attachMovie("cooter", "cooter", viewport.layer++, {_x:50, _y:200});
this.attachMovie("stats", "stats", layer++, {_x:0, _y:375});
rastle_meter = stats.rastle_meter;
bg_fixed = false;
bg_midpoint = screen_width / 2;
next_stop_point = 0;
num_enemies = 0;
game_state = gs_level_play;
cur_level_obj.init();
bg_midpoint = (-viewport._x) + (screen_width / 2);
_global.max_x = (-viewport._x) + max_x_ref;
_global.min_x = (-viewport._x) + min_x_ref;
}
function level_play() {
if (!bg_fixed) {
cur_level_obj.max_enemies = 3;
if (viewport.cooter._x > bg_midpoint) {
if ((viewport.cooter._x - bg_midpoint) > viewport_scroll_speed) {
viewport._x = viewport._x - viewport_scroll_speed;
} else {
viewport._x = viewport._x - (viewport.cooter._x - bg_midpoint);
}
bg_midpoint = (-viewport._x) + (screen_width / 2);
_global.max_x = (-viewport._x) + max_x_ref;
_global.min_x = (-viewport._x) + min_x_ref;
}
if ((-viewport._x) > cur_level_obj.stop_points[next_stop_point]) {
bg_fixed = true;
next_stop_point++;
}
} else {
if ((num_enemies < cur_level_obj.max_enemies) && (cur_enemy_ndx < cur_level_obj.enemy_stacks[cur_enemy_stack].length)) {
if ((cur_level_obj.enemy_stacks[cur_enemy_stack] == cur_level_obj.boss_stack) && (cur_enemy_ndx == 0)) {
cur_level_obj.max_enemies = 2;
x_place = (-viewport._x) + cur_level_obj.boss_place_x;
y_place = cur_level_obj.boss_place_y;
} else {
if (Math.random() > 0.5) {
x_place = (-viewport._x) + screen_width;
} else {
x_place = -viewport._x;
}
y_place = (Math.random() * 160) + 200;
}
spawn_enemy(cur_level_obj.enemy_stacks[cur_enemy_stack][cur_enemy_ndx++], viewport, x_place, y_place);
num_enemies++;
}
if ((num_enemies == 0) && (cur_enemy_ndx >= cur_level_obj.enemy_stacks[cur_enemy_stack].length)) {
cur_enemy_stack++;
cur_enemy_ndx = 0;
bg_fixed = false;
cleanup_arrays();
stats.go_arrow_start();
}
}
var _local2 = 0;
for (i in object_array) {
if (object_array[i]) {
for (j in object_array) {
if (object_array[j]) {
check_depth_ext(object_array[i], object_array[j]);
check_depth_ext(object_array[j], object_array[i]);
}
}
}
}
}
function cleanup_objects() {
temp_ar = new Array();
i = 0;
while (i < object_array.length) {
if (object_array[i]._y != undefined) {
temp_ar[temp_ar.length] = object_array[i];
}
i++;
}
object_array = new Array();
i = 0;
while (i < temp_ar.length) {
object_array[i] = temp_ar[i];
i++;
}
}
function cleanup_arrays() {
temp_ar = new Array();
i = 0;
while (i < object_array.length) {
if (object_array[i]._y != undefined) {
temp_ar[temp_ar.length] = object_array[i];
}
i++;
}
object_array = new Array();
i = 0;
while (i < temp_ar.length) {
object_array[i] = temp_ar[i];
i++;
}
temp_ar = new Array();
i = 0;
while (i < enemy_array.length) {
if (enemy_array[i]._y != undefined) {
temp_ar[temp_ar.length] = enemy_array[i];
}
i++;
}
enemy_array = new Array();
i = 0;
while (i < temp_ar.length) {
enemy_array[i] = temp_ar[i];
i++;
}
temp_ar = new Array();
i = 0;
while (i < friendly_array.length) {
if (friendly_array[i]._y != undefined) {
temp_ar[temp_ar.length] = friendly_array[i];
}
i++;
}
friendly_array = new Array();
i = 0;
while (i < temp_ar.length) {
friendly_array[i] = temp_ar[i];
i++;
}
}
function spawn_enemy(nme, vp, x, y) {
viewport.attachMovie(nme, nme + vp.layer, vp.layer++, {_x:x, _y:y, item:cur_level_obj.item_funct(nme)});
}
function build_bg(lev_obj, vp) {
vp.createEmptyMovieClip("bg", vp.layer++);
vp.bg.layer = 0;
bg_pos_x = 0;
bg_tile_width = 650;
i = 0;
while (i < lev_obj.scene_array.length) {
vp.bg.attachMovie(lev_obj.scene_array[i], "scene" + i, vp.bg.layer++, {_x:bg_pos_x, _y:0});
bg_pos_x = bg_pos_x + bg_tile_width;
i++;
}
bg_pos_x = 0;
i = 0;
while (i < lev_obj.detail_array.length) {
vp.bg.attachMovie(lev_obj.detail_array[i], "detail" + i, vp.bg.layer++, {_x:bg_pos_x, _y:0});
bg_pos_x = bg_pos_x + bg_tile_width;
i++;
}
i = 0;
while (i < lev_obj.vehicle_array.length) {
veh = lev_obj.vehicle_array[i];
vp.attachMovie(veh.vehicle, "vehic" + i, vp.layer++, {_x:veh.x, _y:veh.y});
i++;
}
}
function game_main() {
_global.timer++;
quality_demon();
switch (game_state) {
case gs_loading :
loading();
break;
case gs_intro :
intro();
break;
case gs_menu :
menu();
break;
case gs_instructions :
instructions();
break;
case gs_level_init :
level_init();
break;
case gs_level_play :
level_play();
break;
case gs_level_out :
level_out();
break;
case gs_cutscene :
cutscene();
break;
case gs_game_over :
break;
}
}
function quality_demon() {
if (Key.isDown(81)) {
if (q_key_up) {
q_key_up = false;
if (_root._quality == "BEST") {
_root._quality = "LOW";
} else if (_root._quality == "HIGH") {
_root._quality = "BEST";
} else if (_root._quality == "MEDIUM") {
_root._quality = "HIGH";
} else if (_root._quality == "LOW") {
_root._quality = "MEDIUM";
}
}
} else {
q_key_up = true;
}
}
function check_depth(obj1, obj2) {
if ((obj1._y > obj2._y) && (obj1.getDepth() < obj2.getDepth())) {
obj1.swapDepths(obj2);
}
}
function check_depth_ext(obj1, obj2) {
if (obj1.is_jumping()) {
if ((obj1.ground < obj2._y) && (obj1.getDepth() > obj2.getDepth())) {
obj1.swapDepths(obj2);
}
} else if ((obj1._y < obj2._y) && (obj1.getDepth() > obj2.getDepth())) {
obj1.swapDepths(obj2);
}
}
function loading() {
gotoAndStop ("loading");
stopAllSounds();
bl = _root.getBytesLoaded();
bt = _root.getBytesTotal();
pl = Math.floor((bl / bt) * 100);
loader_clip.p_loaded.text = pl;
loader_clip.cup.gotoAndStop(pl);
if ((bl >= bt) && (bt > 0)) {
game_state = gs_intro;
stopAllSounds();
_root.louis.start();
}
}
function intro() {
if (!intro_played) {
intro_played = true;
gotoAndPlay ("intro");
}
}
function menu() {
gotoAndStop ("menu");
}
function instructions() {
gotoAndStop ("instructions");
}
function restart() {
game_init();
game_state = gs_intro;
}
stop();
ccl = new Sound();
ccl2 = new Sound();
louis = new Sound();
louis2 = new Sound();
ode = new Sound();
beet = new Sound();
beet2 = new Sound();
hit1 = new Sound();
hit2 = new Sound();
hit3 = new Sound();
hit4 = new Sound();
shakeup = new Sound();
sgcock = new Sound();
ccl.setVolume(80);
ccl.attachSound("ccl.mp3");
ccl2.attachSound("ccl.mp3");
louis.attachSound("louis_l.mp3");
louis2.attachSound("louis_1.mp3");
ode.attachSound("ode.mp3");
beet.attachSound("beet.mp3");
beet2.attachSound("beet.mp3");
hit1.attachSound("slap2.wav");
hit2.attachSound("Bowhit.wav");
hit3.attachSound("hit3");
hit4.attachSound("hit4");
shakeup.attachSound("shakeup.wav");
sgcock.attachSound("sg");
ode.onSoundComplete = function () {
_root.ccl.start();
};
ccl.onSoundComplete = function () {
_root.ccl2.start();
};
ccl2.onSoundComplete = function () {
_root.ode.start();
};
louis.onSoundComplete = function () {
_root.beet.start();
};
beet.onSoundComplete = function () {
_root.louis.start();
};
beet2.onSoundComplete = function () {
_root.beet2.start();
};
louis2.onSoundComplete = function () {
_root.louis2.start();
};
completed = false;
cutscene_1 = new Object();
cutscene_1.clip = "cutscene_1_clip";
cutscene_2 = new Object();
cutscene_2.clip = "cutscene_2_clip";
cutscene_3 = new Object();
cutscene_3.clip = "cutscene_3_clip";
cutscene_4 = new Object();
cutscene_4.clip = "cutscene_4_clip";
cutscene_5 = new Object();
cutscene_5.clip = "cutscene_5_clip";
game_init();
level_4.item_funct = function (nme) {
switch (nme) {
case "alienVarmint" :
if (Math.random() > 0.8) {
return("hp_up_small");
}
if (Math.random() > 0.8) {
return("hp_up_large");
}
break;
case "alien" :
if (!_root.nader[gp_owned]) {
return("laser_pickup");
}
if (Math.random() > 0.5) {
return("laser_ammo");
}
if (Math.random() > 0.8) {
return("hp_up_large");
}
if (Math.random() > 0.8) {
return("life_up");
}
break;
case "alienCap" :
if (!_root.pistol[gp_owned]) {
return("laser_pickup");
}
if (Math.random() > 0.5) {
return("laser_ammo");
}
if (Math.random() > 0.9) {
return("hp_up_small");
}
break;
case "alienSol" :
if (!_root.flamer[gp_owned]) {
return("laser_pickup");
}
if (Math.random() > 0.5) {
return("laser_ammo");
}
if (Math.random() > 0.9) {
return("hp_up_large");
}
if (Math.random() <= 0.3) {
break;
}
return("life_up");
}
};
level_4 = new Object();
level_4.init = function () {
zader[gp_owned] = true;
next_level_obj = level_5;
cur_cutscene_obj = cutscene_5;
};
level_4.max_enemies = 3;
level_4.scene_array = new Array("spaceship_bg", "spaceship_bg", "spaceship_bg", "spaceship_bg");
level_4.detail_array = new Array("detail_3_1", "detail_3_2", "detail_3_3", "detail_3_1");
level_4.item_funct = function (nme) {
switch (nme) {
case "alienVarmint" :
if (Math.random() > 0.8) {
return("hp_up_small");
}
if (Math.random() > 0.8) {
return("hp_up_large");
}
break;
case "alien" :
if (!_root.laser[gp_owned]) {
return("laser_pickup");
}
if (Math.random() > 0.3) {
return("laser_ammo");
}
if (Math.random() > 0.8) {
return("hp_up_large");
}
if (Math.random() > 0.8) {
return("life_up");
}
break;
case "alienCap" :
if (!_root.laser[gp_owned]) {
return("laser_pickup");
}
if (Math.random() > 0.3) {
return("laser_ammo");
}
if (Math.random() > 0.9) {
return("hp_up_small");
}
break;
case "alienSol" :
if (!_root.flamer[gp_owned]) {
return("laser_pickup");
}
if (Math.random() > 0.5) {
return("laser_ammo");
}
if (Math.random() > 0.9) {
return("hp_up_large");
}
if (Math.random() <= 0.3) {
break;
}
return("life_up");
}
};
level_4.enemy_stack_1 = new Array("alien", "alienVarmint", "alien", "alienVarmint", "alien", "alienVarmint", "alien");
level_4.enemy_stack_2 = new Array("alienCap", "alien", "alienCap", "alienVarmint", "alienSol", "alienCap", "alienVarmint");
level_4.enemy_stack_3 = new Array("alien", "alienSol", "alienVarmint", "alien", "alienSol", "alienVarmint", "alien", "alienCap");
level_4.enemy_stack_4 = new Array("alienVarmint", "alienVarmint", "alien", "alienVarmint", "alienVarmint", "alienVarmint", "alienBeast");
level_4.enemy_stack_5 = new Array("boss_brain", "alienVarmint", "alienSol", "alienVarmint", "alienCap", "alienSol", "alienVarmint", "alienVarmint", "alienVarmint", "alienSol");
level_4.enemy_stacks = new Array(level_4.enemy_stack_1, level_4.enemy_stack_2, level_4.enemy_stack_3, level_4.enemy_stack_4, level_4.enemy_stack_5);
level_4.boss_stack = level_4.enemy_stack_5;
level_4.boss_place_x = 325;
level_4.boss_place_y = 395;
level_4.stop_points = new Array(400, 800, 1200, 1400, 1500);
level_3 = new Object();
level_3.init = function () {
taser[gp_owned] = true;
next_level_obj = level_4;
cur_cutscene_obj = cutscene_4;
};
level_3.max_enemies = 3;
level_3.scene_array = new Array("country_bg2", "country_bg2", "country_bg2", "country_bg2");
level_3.detail_array = new Array("detail_1_3", "detail_1_4", "detail_2_2", "detail_2_1");
level_3.item_funct = function (nme) {
switch (nme) {
case "chippy" :
if (Math.random() > 0.7) {
return("hp_up_small");
}
if (Math.random() > 0.7) {
return("shotgun_ammo");
}
break;
case "possy" :
if (Math.random() > 0.7) {
return("hp_up_small");
}
if (Math.random() > 0.7) {
return("shotgun_ammo");
}
break;
case "fed1" :
if (!_root.smg[gp_owned]) {
return("smg_pickup");
}
if (Math.random() > 0.2) {
return("smg_ammo");
}
if (Math.random() > 0.8) {
return("hp_up_small");
}
if (Math.random() > 0.8) {
return("hp_up_large");
}
break;
case "fed2" :
if (!_root.nader[gp_owned]) {
return("nader_pickup");
}
if (Math.random() > 0.2) {
return("nader_ammo");
}
if (Math.random() > 0.8) {
return("hp_up_large");
}
if (Math.random() > 0.8) {
return("life_up");
}
break;
case "police" :
if (!_root.pistol[gp_owned]) {
return("pistol_pickup");
}
if (Math.random() > 0.2) {
return("pistol_ammo");
}
if (Math.random() > 0.9) {
return("hp_up_small");
}
break;
case "soldier1" :
if (!_root.flamer[gp_owned]) {
return("flamer_pickup");
}
if (Math.random() > 0.5) {
return("flamer_ammo");
}
if (Math.random() > 0.9) {
return("hp_up_large");
}
if (Math.random() <= 0.3) {
break;
}
return("life_up");
}
};
level_3.enemy_stack_1 = new Array("police", "possy", "police", "chippy", "fed1", "police", "fed1");
level_3.enemy_stack_2 = new Array("chippy", "possy", "fed1", "fed2", "police", "fed1", "soldier1");
level_3.enemy_stack_3 = new Array("possy", "fed2", "fed1", "soldier1", "police", "soldier1", "fed2", "chippy");
level_3.enemy_stack_4 = new Array("boss_robot", "soldier1", "chippy", "possy", "soldier1", "possy", "soldier1");
level_3.enemy_stacks = new Array(level_3.enemy_stack_1, level_3.enemy_stack_2, level_3.enemy_stack_3, level_3.enemy_stack_4);
level_3.vehicle_array = new Array({vehicle:"tractor", x:1250, y:250});
level_3.boss_stack = level_3.enemy_stack_1;
level_3.boss_place_x = 600;
level_3.boss_place_y = 395;
level_3.stop_points = new Array(600, 1200, 1800, 1900);
level_2 = new Object();
level_2.init = function () {
next_level_obj = level_3;
cur_cutscene_obj = cutscene_3;
};
level_2.max_enemies = 3;
level_2.scene_array = new Array("bubba_house_bg", "bubba_house_bg");
level_2.enemy_stack_1 = new Array("bubba", "chippy", "possy", "chippy", "possy", "chippy", "possy", "chippy", "possy", "chippy", "possy");
level_2.enemy_stacks = new Array(level_2.enemy_stack_1);
level_2.boss_stack = level_2.enemy_stack_1;
level_2.boss_place_x = 600;
level_2.boss_place_y = 300;
level_2.stop_points = new Array(120, 40);
level_2.item_funct = function (nme) {
switch (nme) {
case "chippy" :
if (Math.random() > 0.7) {
return("hp_up_small");
}
if (Math.random() > 0.7) {
return("shotgun_ammo");
}
break;
case "possy" :
if (Math.random() > 0.7) {
return("hp_up_small");
}
if (Math.random() <= 0.7) {
break;
}
return("pistol_ammo");
}
};
level_1 = new Object();
level_1.init = function () {
next_level_obj = level_2;
cur_cutscene_obj = cutscene_2;
};
level_1.max_enemies = 3;
level_1.scene_array = new Array("country_bg", "country_bg", "country_bg", "country_bg");
level_1.detail_array = new Array("detail_1_1", "detail_1_2", "detail_1_3", "detail_1_4");
level_1.vehicle_array = new Array({vehicle:"tractor", x:850, y:250});
level_1.item_funct = function (nme) {
switch (nme) {
case "chippy" :
if (Math.random() > 0.7) {
return("hp_up_small");
}
if (Math.random() > 0.7) {
return("shotgun_ammo");
}
break;
case "possy" :
if (Math.random() > 0.7) {
return("hp_up_small");
}
if (Math.random() > 0.7) {
return("pistol_ammo");
}
break;
case "capfield1" :
if (Math.random() > 0.2) {
return("shotgun_ammo");
}
if (Math.random() > 0.7) {
return("hp_up_small");
}
break;
case "capfield2" :
if (!_root.pistol[gp_owned]) {
return("pistol_pickup");
}
if (Math.random() > 0.2) {
return("pistol_ammo");
}
if (Math.random() <= 0.7) {
break;
}
return("hp_up_small");
}
};
level_1.enemy_stack_1 = new Array("chippy", "possy", "chippy", "chippy", "possy", "capfield1");
level_1.enemy_stack_2 = new Array("chippy", "possy", "capfield1", "chippy", "capfield1", "possy", "capfield2");
level_1.enemy_stack_3 = new Array("capfield1", "capfield2", "possy", "capfield2", "possy", "capfield1", "chippy", "capfield2");
level_1.enemy_stack_4 = new Array("boss_combine", "chippy", "chippy", "chippy", "chippy", "chippy");
level_1.enemy_stacks = new Array(level_1.enemy_stack_1, level_1.enemy_stack_2, level_1.enemy_stack_3, level_1.enemy_stack_4);
level_1.boss_stack = level_1.enemy_stack_4;
level_1.boss_place_x = 600;
level_1.boss_place_y = 395;
level_1.stop_points = new Array(600, 1200, 1800, 1900);
next_level_obj = level_1;
this.onEnterFrame = game_main;
Frame 14
stop();
Frame 21
stop();
Frame 27
Instance of Symbol 1729 MovieClip in Frame 27
on (release) {
_root.game_init();
game_state = gs_intro;
}
Frame 38
stop();
Frame 48
stop();
Frame 125
stop();
intro_played = false;
game_state = gs_menu;
Symbol 16 MovieClip Frame 1
stop();
Symbol 277 MovieClip Frame 6
stop();
Symbol 281 MovieClip Frame 6
stop();
Symbol 285 MovieClip Frame 6
stop();
Symbol 289 MovieClip Frame 6
stop();
Symbol 293 MovieClip Frame 6
stop();
Symbol 297 MovieClip Frame 6
stop();
Symbol 301 MovieClip Frame 6
stop();
Symbol 305 MovieClip Frame 6
stop();
Symbol 309 MovieClip Frame 6
stop();
Symbol 330 MovieClip Frame 2
stop();
Symbol 333 MovieClip Frame 2
stop();
Symbol 336 MovieClip Frame 2
stop();
Symbol 339 MovieClip Frame 2
stop();
Symbol 342 MovieClip Frame 2
stop();
Symbol 345 MovieClip Frame 2
stop();
Symbol 348 MovieClip Frame 2
stop();
Symbol 351 MovieClip Frame 2
stop();
Symbol 354 MovieClip Frame 2
stop();
Symbol 357 MovieClip Frame 4
stop();
Symbol 360 MovieClip Frame 4
stop();
Symbol 363 MovieClip Frame 4
stop();
Symbol 366 MovieClip Frame 4
stop();
Symbol 369 MovieClip Frame 4
stop();
Symbol 372 MovieClip Frame 4
stop();
Symbol 375 MovieClip Frame 4
stop();
Symbol 378 MovieClip Frame 4
stop();
Symbol 381 MovieClip Frame 4
stop();
Symbol 405 MovieClip Frame 17
gotoAndPlay ("loop");
Symbol 426 MovieClip Frame 16
stop();
Symbol 434 MovieClip Frame 8
gotoAndPlay (5);
Symbol 437 MovieClip Frame 6
stop();
Symbol 443 MovieClip Frame 22
stop();
Symbol 471 MovieClip Frame 50
stop();
Symbol 483 MovieClip Frame 30
stop();
Symbol 508 MovieClip Frame 42
stop();
Symbol 545 MovieClip Frame 8
stop();
Symbol 573 MovieClip Frame 1
this._rotation = Math.random() * 360;
Symbol 580 MovieClip Frame 4
stop();
Symbol 585 MovieClip Frame 5
stop();
Symbol 592 MovieClip Frame 5
stop();
Symbol 599 MovieClip Frame 7
stop();
Symbol 600 MovieClip [cooter] Frame 1
function reset_counters() {
jump_counter = 0;
idle_counter = 0;
shoot_counter = 0;
rastle_counter = 0;
}
function change_gun(newGun) {
if (newGun == -1) {
gun_ndx++;
if (gun_ndx >= my_guns.length) {
gun_ndx = 0;
}
if (my_guns[gun_ndx][gp_owned] && ((my_guns[gun_ndx][gp_clip_left] + ammo_array[gun_ndx]) != 0)) {
gun = my_guns[gun_ndx];
} else {
change_gun(-1);
}
} else if (newGun != 0) {
tempGun = newGun - 1;
if (my_guns[tempGun][gp_owned]) {
gun_ndx = tempGun;
gun = my_guns[gun_ndx];
}
}
cur_gun_clip.gotoAndStop("gun_" + gun_ndx);
}
function is_jumping() {
return(my_state == cs_jump_middle_1);
}
function disable_keys() {
tempUp = _global.upKey;
tempDown = _global.downKey;
tempLeft = _global.leftKey;
tempRight = _global.rightKey;
tempShoot = _global.shootKey;
tempRastle = _global.rastleKey;
tempJump = _global.jumpKey;
tempChange = _global.changeKey;
tempReload = _global.reloadKey;
_global.upKey = null;
_global.downKey = null;
_global.leftKey = null;
_global.rightKey = null;
_global.shootKey = null;
_global.rastleKey = null;
_global.jumpKey = null;
_global.changeKey = null;
_global.reloadKey = null;
}
function enable_keys() {
_global.upKey = tempUp;
_global.downKey = tempDown;
_global.leftKey = tempLeft;
_global.rightKey = tempRight;
_global.shootKey = tempShoot;
_global.rastleKey = tempRastle;
_global.jumpKey = tempJump;
_global.changeKey = tempChange;
_global.reloadKey = tempReload;
}
function idle_1() {
gotoAndStop("idle_" + gun[gp_frame_num]);
if (((Key.isDown(upKey) || (Key.isDown(downKey))) || (Key.isDown(leftKey))) || (Key.isDown(rightKey))) {
my_state = cs_run_1;
}
if (check_shoot_key()) {
my_state = cs_shoot_1;
} else if (check_jump_key()) {
my_state = cs_jump_start_1;
} else if (check_rastle_key()) {
my_state = cs_rastle_start_1;
} else if ((newGun = check_change_key())) {
change_gun(newGun);
} else if (check_reload_key()) {
reload_start();
}
}
function rastle_win_1() {
state_counter++;
if (state_counter > 6) {
state_counter = 0;
my_state = cs_idle_1;
}
gotoAndStop ("rastle_win_1");
}
function add_ammo(gun, amt) {
if (my_guns[gun][gp_max_ammo] < 0) {
my_guns[gun][gp_clip_left] = my_guns[gun][gp_clip_left] + amt;
if (my_guns[gun][gp_clip_left] > my_guns[gun][gp_clip_size]) {
my_guns[gun][gp_clip_left] = my_guns[gun][gp_clip_size];
}
} else {
ammo_array[gun] = ammo_array[gun] + amt;
if (ammo_array[gun] > my_guns[gun][gp_max_ammo]) {
ammo_array[gun] = my_guns[gun][gp_max_ammo];
}
}
}
function check_rastle_key() {
if (Key.isDown(rastleKey)) {
if (rastle_key_up) {
rastle_key_up = false;
return(true);
}
return(false);
}
rastle_key_up = true;
return(false);
}
function check_change_key() {
if (Key.isDown(changeKey)) {
if (change_key_up) {
change_key_up = false;
return(-1);
}
return(false);
}
i = 1;
while (i <= 9) {
if (Key.isDown(48 + i)) {
return(i);
}
i++;
}
change_key_up = true;
return(0);
}
function check_jump_key() {
if (Key.isDown(jumpKey)) {
if (jump_key_up) {
jump_key_up = false;
return(true);
}
return(false);
}
jump_key_up = true;
return(false);
}
function check_reload_key() {
if (Key.isDown(reloadKey)) {
if (reload_key_up) {
reload_key_up = false;
return(true);
}
return(false);
}
reload_key_up = true;
return(false);
}
function check_shoot_key() {
if (Key.isDown(shootKey)) {
if (shoot_key_up) {
shoot_key_up = false;
return(true);
}
return(false);
}
shoot_key_up = true;
return(false);
}
function run_1() {
ground = _y;
gotoAndStop("run_" + gun[gp_frame_num]);
if (check_shoot_key()) {
my_state = cs_shoot_1;
} else if (check_jump_key()) {
my_state = cs_jump_start_1;
} else if (check_rastle_key()) {
my_state = cs_rastle_start_1;
} else if ((newGun = check_change_key())) {
change_gun(newGun);
} else if (check_reload_key()) {
reload_start();
} else {
if (!move_char_arrow_keys()) {
my_state = cs_idle_1;
}
face_char_left_right();
}
check_bounds_walking();
}
function check_vehicles() {
for (v in _root.vehicle_array) {
if (((_root.vehicle_array[v]._alpha == 100) && (Math.abs(_y - _root.vehicle_array[v]._y) < 20)) && (Math.abs(_x - _root.vehicle_array[v]._x) < 40)) {
vehicle = _root.vehicle_array[v];
my_state = cs_mount_vehicle;
return(true);
}
}
return(false);
}
function jump_start_1() {
if (check_vehicles()) {
} else {
gotoAndStop("jump_start_" + gun[gp_frame_num]);
ground = _y;
jump_counter = 0;
lift = jump_height;
jump_counter++;
my_state = cs_jump_middle_1;
}
}
function jump_middle_1() {
last_y = _y;
jump_counter++;
if (jump_counter > 3) {
check_bounds_jumping();
if (move_char_arrow_keys()) {
ground = ground + (_y - last_y);
}
face_char_left_right();
_y = (_y - lift);
lift = lift - gravity;
if (check_shoot_key() || (check_rastle_key())) {
gotoAndStop("jump_shoot_" + gun[gp_frame_num]);
kicking = true;
if (lift > 0) {
lift = 0;
}
}
if (kicking) {
i = 0;
while (i < _root.enemy_array.length) {
if (this.hitArea.hitTest(_root.enemy_array[i].tgtArea) && (Math.abs(_root.enemy_array[i]._y - ground) < 15)) {
_root.enemy_array[i].doHit(4, 17, 1);
}
i++;
}
}
if ((lift < 0) && (!kicking)) {
gotoAndStop("jump_mid_" + gun[gp_frame_num]);
}
if (_y > ground) {
kicking = false;
jump_counter = 0;
_y = ground;
my_state = cs_jump_end_1;
}
}
}
function jump_end_1() {
jump_counter++;
gotoAndStop("jump_end_" + gun[gp_frame_num]);
if (jump_counter > 3) {
jump_counter = 0;
my_state = cs_idle_1;
}
}
function shoot_1() {
if ((gun[gp_clip_left] == 0) && (shoot_counter <= gun[gp_shoot_frame])) {
reload_counter = 80;
my_state = cs_idle_1;
return(undefined);
}
if (shoot_counter == gun[gp_shoot_frame]) {
spawnShot(gun);
}
if (re_shooting) {
gotoAndStop("re_shoot_" + gun[gp_frame_num]);
} else {
gotoAndStop("shoot_" + gun[gp_frame_num]);
}
if (!Key.isDown(shootKey)) {
shoot_key_up = true;
} else if (shoot_key_up && (shoot_counter > ((2 * gun[gp_shoot_time]) / 3))) {
shoot_again = true;
}
if ((Key.isDown(shootKey) && (gun[gp_reshoot_time] < 0)) && (shoot_counter >= gun[gp_shoot_time])) {
shoot_counter = shoot_counter + gun[gp_reshoot_time];
}
shoot_counter++;
if (shoot_counter > gun[gp_shoot_time]) {
if (shoot_again && (gun[gp_clip_left] != 0)) {
shoot_again = false;
re_shooting = true;
shoot_key_up = false;
gotoAndStop("re_shoot_" + gun[gp_frame_num]);
shoot_counter = gun[gp_shoot_time] - gun[gp_reshoot_time];
} else {
re_shooting = false;
shoot_again = false;
my_state = cs_idle_1;
shoot_counter = 0;
}
}
}
function spawnShot(gunType) {
if (gunType[gp_clip_left] > 0) {
gunType[gp_clip_left] = gunType[gp_clip_left] - 1;
}
if (gunType[gp_clip_left] == 0) {
reload_counter = 80;
}
shotType = gunType[gp_shot_type];
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.targetArray = _root.enemy_array;
shotPlace.power = gun[gp_power];
_parent.attachMovie(shotType, "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function face_char_left_right() {
if (Key.isDown(leftKey)) {
dir = -1;
} else if (Key.isDown(rightKey)) {
dir = 1;
}
_xscale = (100 * dir);
}
function move_char_arrow_keys() {
if (Key.isDown(upKey)) {
if (Key.isDown(leftKey)) {
_x = (_x - ((speed * gun[gp_speed_scale]) * diagonal));
_y = (_y - ((speed * gun[gp_speed_scale]) * diagonal));
} else if (Key.isDown(rightKey)) {
_x = (_x + ((speed * gun[gp_speed_scale]) * diagonal));
_y = (_y - ((speed * gun[gp_speed_scale]) * diagonal));
} else {
_y = (_y - (speed * gun[gp_speed_scale]));
}
} else if (Key.isDown(downKey)) {
if (Key.isDown(leftKey)) {
_x = (_x - ((speed * gun[gp_speed_scale]) * diagonal));
_y = (_y + ((speed * gun[gp_speed_scale]) * diagonal));
} else if (Key.isDown(rightKey)) {
_x = (_x + ((speed * gun[gp_speed_scale]) * diagonal));
_y = (_y + ((speed * gun[gp_speed_scale]) * diagonal));
} else {
_y = (_y + (speed * gun[gp_speed_scale]));
}
} else if (Key.isDown(rightKey)) {
_x = (_x + (speed * gun[gp_speed_scale]));
} else if (Key.isDown(leftKey)) {
_x = (_x - (speed * gun[gp_speed_scale]));
} else {
return(false);
}
return(true);
}
function rastle_start_1() {
rastle_counter++;
gotoAndStop ("rastle_start_1");
if (rastle_counter > rastle[rp_grab_time]) {
rastle_counter = 0;
my_state = check_grab();
}
}
function check_grab() {
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].rastler != 0) && (hitArea.hitTest(_root.enemy_array[i].tgtArea))) {
_root.enemy_array[i].doRastle();
rastle_partner = _root.enemy_array[i];
rastle_meter.startRastle(this, rastle_partner);
return(cs_rastle_mid_1);
}
i++;
}
return(cs_idle_1);
}
function stopRastle(score) {
rastlin = false;
if (score > 85) {
my_state = cs_rastle_win_1;
rastle_partner.doGib();
} else if (score > 50) {
my_state = cs_rastle_win_1;
rastle_partner.doHit(score - 10, 20, 1.5);
} else {
doHit(50 - score, 20, 1.5);
rastle_partner.my_ai_state = E_AI_WAIT;
}
}
function rastle_mid_1() {
if (Math.random() < 0.07) {
spawnGib();
}
_x = (_x + ((Math.random() * 4) - 2));
_y = (_y + ((Math.random() * 4) - 2));
check_bounds_walking();
rastle_partner._x = _x;
rastle_partner._y = _y;
gotoAndStop ("rastle_mid_1");
}
function spawnGib() {
gibNum = Math.floor(Math.random() * 8);
gibPlace = new Object();
gibPlace._x = _x;
gibPlace._y = _y - 50;
gibPlace.firstY = _y;
gibPlace.xSpeed = (Math.random() * 30) - 15;
gibPlace.ySpeed = Math.random() * 15;
gibPlace._xscale = (gibPlace._yscale = 35);
gibPlace.counter = 0;
gibName = "gib" + _parent.layer;
_parent.attachMovie("gib" + gibNum, gibName, _parent.layer++, gibPlace);
_parent[gibName].onEnterFrame = function () {
this.counter++;
this._x = this._x + this.xSpeed;
this._y = this._y - this.ySpeed;
this.ySpeed = this.ySpeed - 1;
this.xSpeed = this.xSpeed * 0.95;
this._rotation = this._rotation + this.xSpeed;
if (this._y > this.firstY) {
this.ySpeed = this.ySpeed * -0.5;
this._y = this.firstY;
}
if (this.counter > 60) {
this.removeMovieClip();
}
};
}
function rastle_draw_1() {
}
function rastle_lose_1() {
}
function reload_start() {
if (ammo_array[gun_ndx] > 0) {
state_counter = 0;
my_state = cs_reload_1;
}
}
function reload_1() {
gotoAndStop("reload_" + gun[gp_frame_num]);
state_counter++;
if (state_counter > gun[gp_reload_time]) {
my_state = cs_idle_1;
state_counter = 0;
ammo_temp = gun[gp_clip_size] - gun[gp_clip_left];
gun[gp_clip_left] = gun[gp_clip_size];
ammo_array[gun_ndx] = ammo_array[gun_ndx] - ammo_temp;
if (ammo_array[gun_ndx] < 0) {
gun[gp_clip_left] = gun[gp_clip_left] + ammo_array[gun_ndx];
ammo_array[gun_ndx] = 0;
}
}
}
function mount_vehicle() {
gotoAndStop("jump_mid_" + gun[gp_fram_num]);
_x = vehicle._x;
_y = vehicle._y;
my_state = cs_driving_1;
vehicle.gotoAndStop("mounting");
vehicle_counter = 0;
}
function driving_1() {
vehicle_counter++;
gotoAndStop ("driving_1");
if (!vehicle) {
my_state = cs_dismount_vehicle;
}
if (vehicle_counter > vehicle.mount_time) {
vehicle.get_input();
_x = vehicle._x;
_y = (vehicle._y + 20);
}
if ((vehicle.life_span != -1) && (vehicle_counter > vehicle.life_span)) {
vehicle.expire();
my_state = cs_dismount_vehicle;
}
}
function dismount_vehicle() {
gotoAndStop("jump_mid_" + gun[gp_frame_num]);
if (vehicle.life_span != -1) {
vehicle.life_span = vehicle.life_span - vehicle_counter;
}
vehicle_counter = 0;
vehicle = null;
my_state = cs_idle_1;
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
}
if (_x < min_x) {
_x = min_x;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function check_bounds_jumping() {
if (_x > max_x) {
_x = max_x;
}
if (_x < min_x) {
_x = min_x;
}
if (ground > max_y) {
_y = (_y - (ground - max_y));
}
if (ground < min_y) {
_y = (_y + (min_y - ground));
}
}
function z_sort() {
for (enemy in _root.enemy_array) {
check_depth(_root.enemy_array[enemy]);
}
for (friendly in _root.friendly_array) {
check_depth(_root.friendly_array[friendly]);
}
for (vehicle in _root.vehicle_array) {
check_depth(_root.vehicle_array[vehicle]);
}
for (object in _root.object_array) {
check_depth(_root.object_array[object]);
}
}
function check_depth(obj) {
if ((this._y > obj._y) && (this.getDepth() < obj.getDepth())) {
this.swapDepths(obj);
}
}
function check_depth_ext(obj) {
if (my_state == cs_jump_middle_1) {
if ((this.ground < obj._y) && (this.getDepth() > obj.getDepth())) {
this.swapDepths(obj);
}
} else if ((this._y < obj._y) && (this.getDepth() > obj.getDepth())) {
this.swapDepths(obj);
}
}
function doHitFire(hitP, hitD) {
doHit(hitP, 15, 1);
}
function doStun(hitP, hitD) {
doHit(hitP, 15, 1);
}
function doHit(hitP, hitD, hitS) {
if (!spawning) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
reset_counters();
face_char_left_right();
my_state = cs_hit;
hp = hp - hitP;
updateHP();
if (hp <= 0) {
doDie();
}
}
}
function updateHP() {
hpBar.hpMask._xscale = (hp / maxHp) * 100;
}
function doDie() {
my_state = cs_die;
}
function die() {
state_counter++;
if (state_counter > die_duration) {
state_counter = 0;
if (_root.lives > 0) {
respawn();
} else {
_root.game_over();
}
}
gotoAndStop ("die");
}
function respawn() {
if (_root.lives > 0) {
hp = maxHp;
updateHP();
_root.lives = _root.lives - 1;
_x = (min_x + 50);
_y = (min_y + 50);
spawning = true;
my_state = cs_idle_1;
} else {
_root.gameOver();
}
}
function hit() {
state_counter++;
if (state_counter > hit_duration) {
state_counter = 0;
my_state = cs_idle_1;
}
gotoAndStop ("hit");
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
}
function main() {
if (spawning) {
spawn_counter++;
if ((Math.floor(spawn_counter / 8) % 2) == 0) {
_alpha = 50;
} else {
_alpha = 100;
}
if (spawn_counter > spawnTime) {
spawn_counter = 0;
spawning = false;
_alpha = 100;
}
}
switch (my_state) {
case cs_hit :
hit();
break;
case cs_idle_1 :
idle_1();
break;
case cs_run_1 :
run_1();
break;
case cs_jump_start_1 :
jump_start_1();
break;
case cs_jump_middle_1 :
jump_middle_1();
break;
case cs_jump_end_1 :
jump_end_1();
break;
case cs_shoot_1 :
shoot_1();
break;
case cs_rastle_start_1 :
rastle_start_1();
break;
case cs_rastle_mid_1 :
rastle_mid_1();
break;
case cs_rastle_win_1 :
rastle_win_1();
break;
case cs_rastle_lose_1 :
rastle_lose_1();
break;
case cs_rastle_draw_1 :
rastle_draw_1();
break;
case cs_reload_1 :
reload_1();
break;
case cs_mount_vehicle :
mount_vehicle();
break;
case cs_dismount_vehicle :
dismount_vehicle();
break;
case cs_driving_1 :
driving_1();
break;
case cs_die :
die();
break;
case cs_off :
break;
case cs_remote_walk :
gotoAndStop("run_" + gun[gp_frame_num]);
break;
case cs_remote_idle :
gotoAndStop("idle_" + gun[gp_frame_num]);
break;
}
if (ammo_array[gun_ndx] < 0) {
_root.curAmmo = "INF";
} else {
_root.curAmmo = ammo_array[gun_ndx];
}
if (gun[gp_clip_left] < 0) {
_root.curClip = "INF";
} else {
_root.curClip = gun[gp_clip_left];
}
reload_demon();
}
function reload_demon() {
if (reload_counter <= 0) {
reload_counter = 0;
reload_clip._alpha = 0;
reload_clip._xscale = _xscale;
} else {
reload_counter--;
reload_clip._xscale = _xscale;
if ((reload_counter % 20) > 10) {
reload_clip._alpha = 100;
} else {
reload_clip._alpha = 0;
}
}
}
stop();
reload_counter = 0;
farl = _root.friendly_array.length;
oarl = _root.object_array.length;
i = 0;
while (i <= farl) {
if (!_root.friendly_array[i]) {
_root.friendly_array[i] = this;
}
i++;
}
i = 0;
while (i <= oarl) {
if (!_root.object_array[i]) {
_root.object_array[i] = this;
}
i++;
}
rastlin = false;
viewport = _parent;
stats = _root.stats;
rastle_meter = stats.rastle_meter;
hpBar = stats.hpBar;
cur_gun_clip = stats.cur_gun_clip;
spawning = true;
spawnTime = 75;
spawn_counter = 0;
cs_idle_1 = 0;
cs_run_1 = 1;
cs_jump_start_1 = 2;
cs_jump_middle_1 = 3;
cs_jump_end_1 = 4;
cs_shoot_1 = 5;
cs_rastle_start_1 = 6;
cs_rastle_mid_1 = 7;
cs_rastle_win_1 = 8;
cs_rastle_lose_1 = 9;
cs_rastle_draw_1 = 10;
cs_mount_vehicle = 11;
cs_dismount_vehicle = 12;
cs_driving_1 = 13;
cs_reload_1 = 14;
cs_die = 15;
cs_hit = 16;
cs_off = 17;
cs_remote_walk = 18;
cs_remote_idle = 19;
my_state = cs_idle_1;
shoot_key_up = false;
jump_key_up = false;
rastle_key_up = false;
base_speed = 10;
speed = base_speed;
diagonal = Math.SQRT1_2;
dir = 1;
lift = 0;
gravity = 3;
jump_height = 25;
jump_counter = 0;
idle_counter = 0;
shoot_counter = 0;
rastle_counter = 0;
shoot_again = false;
re_shooting = false;
ground = _y;
rastle = _root.rastle_1;
maxHp = 750;
hp = maxHp;
die_duration = 75;
my_guns = new Array();
my_guns[0] = _root.moonshine;
my_guns[1] = _root.pistol;
my_guns[2] = _root.shotgun;
my_guns[3] = _root.taser;
my_guns[4] = _root.smg;
my_guns[5] = _root.nader;
my_guns[6] = _root.zader;
my_guns[7] = _root.laser;
my_guns[8] = _root.flamer;
ammo_array = _root.ammo_array;
gun_ndx = 0;
gun = my_guns[gun_ndx];
vehicle = null;
vehicle_counter = 0;
state_counter = 0;
hit_duration = 10;
hit_slider = 1;
this.onEnterFrame = main;
Symbol 606 MovieClip [capfield1_shot] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
if (!power) {
power = 4;
}
this.onEnterFrame = function () {
_x = (_x + (20 * dir));
i = 0;
while (i < targetArray.length) {
if (this.hitArea.hitTest(targetArray[i].tgtArea)) {
targetArray[i].dir = -dir;
targetArray[i].doHit(power, 18, 1);
cleanUp();
break;
}
i++;
}
};
ndx = _root.object_array.push(this) - 1;
Symbol 606 MovieClip [capfield1_shot] Frame 8
this.onEnterFrame = null;
cleanUp();
Symbol 607 MovieClip [flamer_shot] Frame 1
function is_jumping() {
return(true);
}
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
if (!power) {
power = 2;
}
ground = _y;
_x = (_x + (45 * dir));
_y = (_y - 43);
this.onEnterFrame = function () {
i = 0;
while (i < targetArray.length) {
if ((targetArray[i].any_y || (Math.abs(ground - targetArray[i]._y) < 16)) && (this.hitArea.hitTest(targetArray[i].tgtArea))) {
targetArray[i].doHitFire(power, 50);
cleanUp();
}
i++;
}
};
ndx = _root.object_array.push(this) - 1;
Symbol 607 MovieClip [flamer_shot] Frame 17
cleanUp();
Symbol 614 MovieClip [laser_shot] Frame 1
function is_jumping() {
return(true);
}
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
ground = _y;
_y = (_y - 45);
_x = (_x + (55 * dir));
if (!power) {
power = 3;
}
object_ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (_currentframe > 4) {
_x = (_x + (40 * dir));
}
i = 0;
while (i < targetArray.length) {
if ((targetArray[i].any_y || (Math.abs(targetArray[i]._y - ground) < 16)) && (this.hitArea.hitTest(targetArray[i].tgtArea))) {
targetArray[i].dir = -dir;
targetArray[i].doStun(power, 25);
cleanUp();
break;
}
i++;
}
if ((_x > max_x) || (_x < min_x)) {
cleanUp();
}
};
Symbol 614 MovieClip [laser_shot] Frame 5
stop();
Symbol 625 MovieClip [moonshine_bullet] Frame 1
function is_jumping() {
return(true);
}
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
stop();
_x = (_x + (40 * dir));
ground = _y;
_y = (_y - 25);
rot = 35;
lift = 12;
grav = 1.6;
speed = 8;
if (!power) {
power = 2;
}
fire_prob = 0.15;
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
clip._rotation = clip._rotation + rot;
_y = (_y - lift);
_x = (_x + (speed * dir));
lift = lift - grav;
if (_y > ground) {
_y = ground;
gotoAndPlay ("break_fire");
this.onEnterFrame = null;
}
i = 0;
while (i < _root.enemy_array.length) {
if ((enemy_array[i].any_y || (this.hitArea.hitTest(_root.enemy_array[i].tgtArea))) && (Math.abs(ground - _root.enemy_array[i]._y) < 17)) {
this.onEnterFrame = null;
_root.enemy_array[i].doHitFire(power, 60);
gotoAndPlay ("break_fire");
return(undefined);
}
i++;
}
};
Symbol 625 MovieClip [moonshine_bullet] Frame 10
cleanUp();
Symbol 625 MovieClip [moonshine_bullet] Frame 19
cleanUp();
Symbol 633 MovieClip [nader_bullet] Frame 1
function is_jumping() {
return(true);
}
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
stop();
_x = (_x + (65 * dir));
ground = _y;
_y = (_y - 40);
lift = 5;
grav = 1;
rot = Math.random() * 15;
speed = 12;
blowTimer = 0;
blowTime = 30;
if (!power) {
power = 2;
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
clip._rotation = clip._rotation + rot;
blowTimer++;
if (blowTimer > blowTime) {
gotoAndPlay ("blow");
}
_x = (_x + (speed * dir));
speed = speed * 0.9;
lift = lift - grav;
_y = (_y - lift);
if (_y > ground) {
rot = Math.random() * 15;
lift = lift * -0.5;
_y = ground;
}
};
Symbol 633 MovieClip [nader_bullet] Frame 2
this.onEnterFrame = null;
i = 0;
while (i < targetArray.length) {
if (this.hitArea.hitTest(targetArray[i].tgtArea)) {
targetArray[i].doHitFire(power, 60);
}
i++;
}
Symbol 633 MovieClip [nader_bullet] Frame 7
cleanUp();
_root.object_array[ndx] = null;
Symbol 635 MovieClip [pistol_bullet] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
stop();
if (!power) {
power = 1;
}
object_ndx = _root.push_to_array(this, object_array);
oarl = _root.object_array.length;
i = 0;
while (i <= oarl) {
if (!_root.object_array[i]) {
_root.object_array[i] = this;
object_ndx = i;
break;
}
i++;
}
this.onEnterFrame = function () {
_x = (_x + (25 * dir));
i = 0;
while (i < targetArray.length) {
if (this.hitArea.hitTest(targetArray[i].tgtArea)) {
targetArray[i].dir = -dir;
targetArray[i].doHit(power, 12, 1);
cleanUp();
break;
}
i++;
}
if ((_x > max_x) || (_x < min_x)) {
cleanUp();
}
};
Symbol 640 MovieClip [stunBullet] Frame 1
function is_jumping() {
return(true);
}
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
_x = (_x + (50 * dir));
ground = _y;
_y = (_y - 35);
if (!power) {
power = 0.01;
}
oarl = _root.object_array.length;
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
i = 0;
while (i < targetArray.length) {
if (this.hitArea.hitTest(targetArray[i].tgtArea)) {
targetArray[i].doStun(power, 100);
break;
}
i++;
}
if (!Key.isDown(shootKey)) {
cleanUp();
}
};
Symbol 650 MovieClip [trash1] Frame 1
function is_jumping() {
return(true);
}
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
stop();
_x = (_x + (40 * dir));
ground = _y;
_y = (_y - 45);
rot = 35;
lift = 12;
grav = 1.6;
speed = 16;
if (!power) {
power = 3;
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
clip._rotation = clip._rotation + rot;
_y = (_y - lift);
_x = (_x + (speed * dir));
lift = lift - grav;
if (_y > ground) {
_y = ground;
gotoAndPlay ("break");
this.onEnterFrame = null;
}
i = 0;
while (i < targetArray.length) {
if (this.hitArea.hitTest(targetArray[i].tgtArea) && (Math.abs(ground - targetArray[i]._y) < 15)) {
this.onEnterFrame = null;
targetArray[i].doHit(power, 15, 1);
gotoAndPlay ("break");
return(undefined);
}
i++;
}
};
Symbol 650 MovieClip [trash1] Frame 10
cleanUp();
Symbol 650 MovieClip [trash1] Frame 19
cleanUp();
Symbol 652 MovieClip [zader_bullet] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
if (!power) {
power = 3;
}
i = 0;
while (i < targetArray.length) {
if ((targetArray[i].any_y || (Math.abs(_y - targetArray[i]._y) < 16)) && (this.hitTest(targetArray[i].tgtArea))) {
targetArray[i].doHit(power, 15, 0.5);
}
i++;
}
ndx = _root.object_array.push(this) - 1;
Symbol 652 MovieClip [zader_bullet] Frame 3
cleanUp();
Symbol 704 MovieClip [tractor] Frame 1
function expire() {
gotoAndPlay ("expire");
}
function face_dir() {
if (Key.isDown(rightKey)) {
dir = 1;
}
if (Key.isDown(leftKey)) {
dir = -1;
}
_xscale = (100 * dir);
}
function get_input() {
if (Key.isDown(upKey)) {
gotoAndStop ("moving");
if (Key.isDown(rightKey)) {
_x = (_x + (speed * diagonal));
_y = (_y - (speed * diagonal));
} else if (Key.isDown(leftKey)) {
_x = (_x - (speed * diagonal));
_y = (_y - (speed * diagonal));
} else {
_y = (_y - speed);
}
} else if (Key.isDown(downKey)) {
gotoAndStop ("moving");
if (Key.isDown(rightKey)) {
_x = (_x + (speed * diagonal));
_y = (_y + (speed * diagonal));
} else if (Key.isDown(leftKey)) {
_x = (_x - (speed * diagonal));
_y = (_y + (speed * diagonal));
} else {
_y = (_y + speed);
}
} else if (Key.isDown(rightKey)) {
gotoAndStop ("moving");
_x = (_x + speed);
} else if (Key.isDown(leftKey)) {
_x = (_x - speed);
gotoAndStop ("moving");
} else {
gotoAndStop ("driving");
}
check_bounds();
if (Key.isDown(jumpKey)) {
if (jump_key_up) {
_parent.cooter.my_state = _parent.cooter.cs_dismount_vehicle;
gotoAndStop ("idle");
}
jump_key_up = false;
} else {
jump_key_up = true;
}
face_dir();
}
function check_bounds() {
if (_x > max_x) {
_x = max_x;
}
if (_x < min_x) {
_x = min_x;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function vehicleDemon() {
demonCounter++;
if (hit) {
vehicleColor.setTransform(hitColor);
if (demonCounter > (hitStart + hitDuration)) {
vehicleColor.setTransform(normalColor);
hit = false;
}
}
}
function doHit() {
if (!hit) {
life_span = life_span - 200;
hitStart = demonCounter;
hit = true;
}
if (life_span < 0) {
gotoAndStop ("expire");
}
}
mount_time = 7;
life_span = 1500;
speed = 3;
jump_key_up = false;
diagonal = Math.SQRT1_2;
dir = 1;
demonCounter = 0;
hitDuration = 3;
vehicleColor = new Color(this);
hitColor = {ga:0, ba:0};
normalColor = {ra:100, ga:100, ba:100, rb:0, gb:0, bb:0};
farl = _root.friendly_array.length;
oarl = _root.object_array.length;
varl = _root.vehicle_array.length;
i = 0;
while (i <= farl) {
if (!_root.friendly_array[i]) {
_root.friendly_array[i] = this;
}
i++;
}
i = 0;
while (i <= oarl) {
if (!_root.object_array[i]) {
_root.object_array[i] = this;
}
i++;
}
i = 0;
while (i <= varl) {
if (!_root.vehicle_array[i]) {
_root.vehicle_array[i] = this;
}
i++;
}
i = 0;
while (i <= _root.vehicle_array.length) {
if (!_root.vehicle_array[i].alive) {
_root.vehicle_array[i] = this;
break;
}
i++;
}
this.onEnterFrame = vehicleDemon;
alive = true;
gotoAndStop ("idle");
Instance of Symbol 41 MovieClip "hitArea" in Symbol 704 MovieClip [tractor] Frame 26
onClipEvent (enterFrame) {
i = 0;
while (i < _root.enemy_array.length) {
if (this.hitTest(_root.enemy_array[i].tgtArea)) {
_root.enemy_array[i].doGib();
}
i++;
}
}
Symbol 704 MovieClip [tractor] Frame 33
stop();
this.onEnterFrame = function () {
alive = false;
_alpha = (_alpha - 2);
if (_alpha < 0) {
this.removeMovieClip();
}
};
Symbol 710 MovieClip Frame 1
this._visible = false;
stop();
this.onEnterFrame = function () {
if (showTime > 0) {
this._visible = true;
showTime--;
} else {
_visible = false;
}
};
Symbol 744 MovieClip Frame 19
stop();
Symbol 754 MovieClip Frame 4
stop();
Symbol 775 MovieClip Frame 7
stop();
Symbol 790 MovieClip Frame 30
stop();
Symbol 821 MovieClip Frame 1
grav = 0.5;
air = 0.95;
dirAr = new Array();
rotAr = new Array();
i = 0;
while (i <= 8) {
dirAr[i] = (Math.random() * 2) * Math.PI;
rotAr[i] = (Math.random() * 20) + 5;
gibSpeed = (Math.random() * 20) - 10;
this["gib" + i].xSpeed = Math.cos(dirAr[i]) * gibSpeed;
this["gib" + i].ySpeed = Math.sin(dirAr[i]) * gibSpeed;
i++;
}
this.onEnterFrame = function () {
i = 0;
while (i <= 8) {
this["gib" + i].ySpeed = this["gib" + i].ySpeed - grav;
this["gib" + i].ySpeed = this["gib" + i].ySpeed * air;
this["gib" + i].xSpeed = this["gib" + i].xSpeed * air;
this["gib" + i]._rotation = this["gib" + i]._rotation + rotAr[i];
this["gib" + i]._x = this["gib" + i]._x + this["gib" + i].xSpeed;
this["gib" + i]._y = this["gib" + i]._y - this["gib" + i].ySpeed;
if (this["gib" + i]._y > 0) {
this["gib" + i].ySpeed = this["gib" + i].ySpeed * -1;
this["gib" + i]._y = 0;
rotAr[i] = rotAr[i] * 0.5;
}
i++;
}
};
Symbol 821 MovieClip Frame 15
stop();
Symbol 822 MovieClip [capfield1] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("capfield1_shot", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 1;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 150;
c_hp = c_maxHp;
c_pow = 45;
c_speed = 4;
c_longRange = 200;
c_shortRange = 40;
c_yRange = 16;
gun_reload = 35;
fire_hit_duration = 0;
rastler = 3;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 19;
spawnShotTime = 8;
reloadTime = 30;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 853 MovieClip Frame 12
stop();
Symbol 861 MovieClip Frame 4
stop();
Symbol 875 MovieClip Frame 7
stop();
Symbol 887 MovieClip Frame 30
stop();
Symbol 893 MovieClip [capfield2] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("pistol_bullet", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 1;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 150;
c_hp = c_maxHp;
c_pow = 30;
c_speed = 5;
c_longRange = 400;
c_shortRange = 40;
c_yRange = 16;
gun_reload = 25;
fire_hit_duration = 0;
rastler = 3;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 12;
spawnShotTime = 6;
reloadTime = 15;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 923 MovieClip Frame 4
stop();
Symbol 945 MovieClip Frame 12
stop();
Symbol 951 MovieClip [possy] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
if (c_hp < 0) {
my_ai_state = E_AI_OFF;
my_state = E_BURN;
}
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if (((timer >= reload) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
if (Math.abs(_y - target._y) < (c_yRange * 3)) {
if (((_y > target._y) && (_y < (max_y - c_yRange))) || (_y < (min_y + c_yRange))) {
_y = (_y + c_speed);
} else {
_y = (_y - c_speed);
}
}
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
targetArray = _root.friendly_array;
i = 0;
while (i < targetArray.length) {
if (this.hitArea.hitTest(targetArray[i].tgtArea) && (Math.abs(_y - targetArray[i]._y) < 16)) {
targetArray[i].doHit(c_pow, 15, 1);
return(true);
}
i++;
}
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
_x = (_x + (11 * dir));
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 1.2;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 85;
c_hp = c_maxHp;
c_pow = 30;
c_speed = 5;
c_longRange = 100;
c_shortRange = 40;
c_yRange = 16;
gun_reload = 12;
fire_hit_duration = 0;
rastler = 3;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 6;
spawnShotTime = 3;
reloadTime = 15;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 982 MovieClip Frame 4
gotoAndPlay (1);
Symbol 1003 MovieClip Frame 7
stop();
Symbol 1014 MovieClip Frame 12
stop();
Symbol 1020 MovieClip [chippy] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
if (c_hp < 0) {
my_ai_state = E_AI_OFF;
my_state = E_BURN;
}
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if (((timer >= reload) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
if (Math.abs(_y - target._y) < (c_yRange * 3)) {
if (((_y > target._y) && (_y < (max_y - c_yRange))) || (_y < (min_y + c_yRange))) {
_y = (_y + c_speed);
} else {
_y = (_y - c_speed);
}
}
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
targetArray = _root.friendly_array;
i = 0;
while (i < targetArray.length) {
if (this.hitArea.hitTest(targetArray[i].tgtArea) && (Math.abs(_y - targetArray[i]._y) < 16)) {
targetArray[i].doHit(c_pow, 15, 1);
return(true);
}
i++;
}
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
_x = (_x + (11 * dir));
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
rastlerScale = 0.8;
c_maxHp = 75;
c_hp = c_maxHp;
c_pow = 15;
c_speed = 6;
c_longRange = 100;
c_shortRange = 40;
c_yRange = 16;
gun_reload = 12;
fire_hit_duration = 0;
rastler = 3;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 6;
spawnShotTime = 3;
reloadTime = 15;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1054 MovieClip Frame 10
stop();
Symbol 1059 MovieClip Frame 4
stop();
Symbol 1071 MovieClip [bubba] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
doDie();
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("trash1", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
_root.next_level(false);
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 2;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 500;
c_hp = c_maxHp;
c_pow = 75;
c_speed = 5;
c_longRange = 350;
c_shortRange = 40;
c_yRange = 16;
gun_reload = 12;
fire_hit_duration = 0;
rastler = 5;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = true;
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 12;
spawnShotTime = 6;
reloadTime = 15;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1099 MovieClip Frame 24
stop();
Symbol 1109 MovieClip Frame 4
stop();
Symbol 1124 MovieClip Frame 6
stop();
Symbol 1138 MovieClip Frame 30
stop();
Symbol 1144 MovieClip [fed1] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("pistol_bullet", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (((state_counter == spawnShotTime1) || (state_counter == spawnShotTime2)) || (state_counter == spawnShotTime3)) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 1;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 250;
c_hp = c_maxHp;
c_pow = 20;
c_speed = 5;
c_longRange = 400;
c_shortRange = 40;
c_yRange = 16;
gun_reload = 45;
fire_hit_duration = 0;
rastler = 4;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 25;
spawnShotTime1 = 7;
spawnShotTime2 = 13;
spawnShotTime3 = 19;
reloadTime = 30;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1172 MovieClip Frame 13
stop();
Symbol 1177 MovieClip Frame 4
stop();
Symbol 1191 MovieClip Frame 6
stop();
Symbol 1205 MovieClip Frame 30
stop();
Symbol 1211 MovieClip [fed2] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP * 100;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP * 2;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
if (Math.abs(_y - target._y) < (c_yRange * 3)) {
if (((_y > target._y) && (_y < (max_y - c_yRange))) || (_y < (min_y + c_yRange))) {
_y = (_y + c_speed);
} else {
_y = (_y - c_speed);
}
}
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("nader_bullet", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 0.5;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 500;
c_hp = c_maxHp;
c_pow = 100;
c_speed = 5;
c_longRange = 520;
c_shortRange = 40;
c_yRange = 20;
gun_reload = 45;
fire_hit_duration = 0;
rastler = 4;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 25;
spawnShotTime = 8;
reloadTime = 30;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1234 MovieClip Frame 16
stop();
Symbol 1242 MovieClip Frame 4
stop();
Symbol 1256 MovieClip Frame 7
stop();
Symbol 1270 MovieClip Frame 30
stop();
Symbol 1276 MovieClip [police] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("pistol_bullet", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 0.5;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 250;
c_hp = c_maxHp;
c_pow = 30;
c_speed = 5;
c_longRange = 520;
c_shortRange = 40;
c_yRange = 20;
gun_reload = 45;
fire_hit_duration = 0;
rastler = 4;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 25;
spawnShotTime = 5;
reloadTime = 30;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1295 MovieClip Frame 9
stop();
Symbol 1303 MovieClip Frame 4
stop();
Symbol 1313 MovieClip Frame 7
stop();
Symbol 1322 MovieClip Frame 1
grav = 0.5;
air = 0.95;
dirAr = new Array();
rotAr = new Array();
i = 0;
while (i <= 8) {
dirAr[i] = (Math.random() * 2) * Math.PI;
rotAr[i] = (Math.random() * 20) + 5;
gibSpeed = (Math.random() * 20) - 10;
this["gib" + i].xSpeed = Math.cos(dirAr[i]) * gibSpeed;
this["gib" + i].ySpeed = Math.sin(dirAr[i]) * gibSpeed;
i++;
}
this.onEnterFrame = function () {
i = 0;
while (i <= 8) {
this["gib" + i].ySpeed = this["gib" + i].ySpeed - grav;
this["gib" + i].ySpeed = this["gib" + i].ySpeed * air;
this["gib" + i].xSpeed = this["gib" + i].xSpeed * air;
this["gib" + i]._rotation = this["gib" + i]._rotation + rotAr[i];
this["gib" + i]._x = this["gib" + i]._x + this["gib" + i].xSpeed;
this["gib" + i]._y = this["gib" + i]._y - this["gib" + i].ySpeed;
if (this["gib" + i]._y > 0) {
this["gib" + i].ySpeed = this["gib" + i].ySpeed * -1;
this["gib" + i]._y = 0;
rotAr[i] = rotAr[i] * 0.5;
}
i++;
}
};
Symbol 1322 MovieClip Frame 15
stop();
Symbol 1328 MovieClip [soldier1] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
if (Math.abs(_y - target._y) < (c_yRange * 3)) {
if (((_y > target._y) && (_y < (max_y - c_yRange))) || (_y < (min_y + c_yRange))) {
_y = (_y + c_speed);
} else {
_y = (_y - c_speed);
}
}
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("flamer_shot", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if ((state_counter > spawnShotTime) && ((state_counter % respawnShotTime) == 0)) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 0.5;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 550;
c_hp = c_maxHp;
c_pow = 50;
c_speed = 3;
c_longRange = 200;
c_shortRange = 40;
c_yRange = 20;
gun_reload = 45;
fire_hit_duration = 0;
rastler = 4;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 70;
spawnShotTime = 10;
respawnShotTime = 20;
reloadTime = 30;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1330 MovieClip [flamer_ammo] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.flamer[gp_clip_left] = _root.flamer[gp_clip_size];
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1332 MovieClip [flamer_pickup] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.flamer[gp_clip_left] = _root.flamer[gp_clip_size];
_root.flamer[gp_owned] = true;
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1334 MovieClip [hp_up_large] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_parent.cooter.hp = _parent.cooter.maxHp;
_parent.cooter.updateHP();
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1336 MovieClip [hp_up_small] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_parent.cooter.hp = _parent.cooter.hp + (_parent.cooter.maxHp / 4);
if (_parent.cooter.hp > _parent.cooter.maxHp) {
_parent.cooter.hp = _parent.cooter.maxHp;
}
_parent.cooter.updateHP();
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1338 MovieClip [laser_ammo] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[7] = _root.ammo_array[7] + 15;
if (_root.ammo_array[7] > _root.laser[gp_max_ammo]) {
_root.ammo_array[7] = _root.laser[gp_max_ammo];
}
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1339 MovieClip [laser_pickup] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[7] = _root.ammo_array[7] + 15;
if (_root.ammo_array[7] > _root.laser[gp_max_ammo]) {
_root.ammo_array[7] = _root.laser[gp_max_ammo];
}
_root.laser[gp_clip_left] = _root.laser[gp_clip_size];
_root.laser[gp_owned] = true;
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1341 MovieClip [life_up] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.lives++;
_parent.cooter.hp = _parent.cooter.maxHp;
_parent.cooter.updateHP();
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1343 MovieClip [nade_ammo] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[5] = _root.ammo_array[5] + 6;
if (_root.ammo_array[5] > _root.nader[gp_max_ammo]) {
_root.ammo_array[5] = _root.nader[gp_max_ammo];
}
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1344 MovieClip [nader_pickup] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[5] = _root.ammo_array[5] + 6;
if (_root.ammo_array[5] > _root.nader[gp_max_ammo]) {
_root.ammo_array[5] = _root.nader[gp_max_ammo];
}
_root.nader[gp_clip_left] = _root.nader[gp_clip_size];
_root.nader[gp_owned] = true;
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1346 MovieClip [pistol_ammo] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[1] = _root.ammo_array[1] + 14;
if (_root.ammo_array[1] > _root.pistol[gp_max_ammo]) {
_root.ammo_array[2] = _root.pistol[gp_max_ammo];
}
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1348 MovieClip [pistol_pickup] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[1] = _root.ammo_array[1] + 12;
if (_root.ammo_array[1] > _root.pistol[gp_max_ammo]) {
_root.ammo_array[1] = _root.pistol[gp_max_ammo];
}
_root.pistol[gp_clip_left] = _root.pistol[gp_clip_size];
_root.pistol[gp_owned] = true;
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1350 MovieClip [shotgun_ammo] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[2] = _root.ammo_array[2] + 6;
if (_root.ammo_array[2] > _root.shotgun[gp_max_ammo]) {
_root.ammo_array[2] = _root.shotgun[gp_max_ammo];
}
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1352 MovieClip [smg_ammo] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[4] = _root.ammo_array[4] + 32;
if (_root.ammo_array[4] > _root.smg[gp_max_ammo]) {
_root.ammo_array[4] = _root.smg[gp_max_ammo];
}
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1353 MovieClip [smg_pickup] Frame 1
function cleanUp() {
_root.object_array = _root.remove_from_array(this, _root.object_array);
this.removeMovieClip();
}
function pickup() {
_root.sgcock.start();
_root.ammo_array[4] = _root.ammo_array[4] + 32;
if (_root.ammo_array[4] > _root.smg[gp_max_ammo]) {
_root.ammo_array[4] = _root.smg[gp_max_ammo];
}
_root.smg[gp_clip_left] = _root.smg[gp_clip_size];
_root.smg[gp_owned] = true;
cleanUp();
}
ndx = _root.object_array.push(this) - 1;
this.onEnterFrame = function () {
if (this.hitTest(_parent.cooter.tgtArea)) {
pickup();
}
};
Symbol 1407 Button
on (release) {
getURL ("http://www.mofunzone.com/", "_blank");
}
Symbol 1423 MovieClip Frame 1
stop();
Symbol 1428 MovieClip Frame 1
stop();
Symbol 1433 MovieClip Frame 1
stop();
Symbol 1438 MovieClip Frame 1
stop();
Symbol 1455 MovieClip Frame 1
function timer(timeLeft) {
gotoAndStop(10 - timeLeft);
}
stop();
Symbol 1460 MovieClip Frame 1
function startRastle(r1, r2) {
if (!rastler1.rastlin) {
rastler1.rastlin = true;
rastler1 = r1;
rastler2 = r2;
patArray = makePattern(rastler2.rastler);
scoreScale = rastler2.rastlerScale;
gotoAndStop ("start");
score = 50;
this.onEnterFrame = meterMain;
}
}
function stopRastle() {
reInit();
rastler1.stopRastle(score);
rastler2.stopRastle(score);
timer.gotoAndStop(1);
}
function reInit() {
gotoAndStop ("stop");
this.onEnterFrame = null;
sound_interval = 0;
sound_counter = 0;
OFF = 1;
ON = 2;
ON_TEST = 3;
ON_START = 4;
scoreScale = 1;
btnArray = new Array(upBtn, downBtn, leftBtn, rightBtn);
keyArray = new Array(upKey, downKey, leftKey, rightKey);
patLength = Math.floor((Math.random() * 3) + 3);
patArray = makePattern(patLength);
i = 0;
while (i < btnArray.length) {
btnArray[i].gotoAndStop(OFF);
i++;
}
nextSwap = (Math.random() * 10) + 5;
counter = 0;
time_counter = 0;
ndx = -1;
switches = 0;
r_time = 150;
}
function makePattern(len) {
retAr = new Array();
i = 0;
while (i < len) {
retAr[i] = Math.floor(Math.random() * 4);
while (retAr[i] == retAr[i - 1]) {
retAr[i] = Math.floor(Math.random() * 4);
}
i++;
}
return(retAr);
}
function meterMain() {
counter++;
sound_counter++;
if (sound_counter > sound_interval) {
sound_counter = 0;
hit_num = Math.floor(Math.random() * sound_array.length);
sound_array[hit_num].start();
sound_interval = Math.floor(Math.random() * max_sound_interval);
}
if (switches > patArray.length) {
time_counter++;
timeLeft = Math.floor((9 * (r_time - time_counter)) / r_time);
timer.timer(timeLeft);
if (timeLeft <= 0) {
stopRastle();
}
}
if (((counter > (20 - (score / 6))) && (counter > 3)) || (counter > 15)) {
switches++;
counter = 0;
i = 0;
while (i < btnArray.length) {
btnArray[i].gotoAndStop(OFF);
i++;
}
if ((++ndx) >= patArray.length) {
ndx = 0;
}
onButton = patArray[ndx];
if (switches < patArray.length) {
btnArray[onButton].gotoAndStop(ON_TEST);
} else if (switches == patArray.length) {
btnArray[onButton].gotoAndStop(ON_START);
} else {
btnArray[onButton].gotoAndStop(ON);
}
}
if (switches > patArray.length) {
addScore(onButton);
}
}
function addScore(btn) {
scoreKey = keyArray[btn];
keysPressed = ((Key.isDown(keyArray[0]) + Key.isDown(keyArray[1])) + Key.isDown(keyArray[2])) + Key.isDown(keyArray[3]);
if (Key.isDown(scoreKey) && (keysPressed == 1)) {
score = score + 1;
} else if (score > 40) {
score = score - (3 * scoreScale);
} else if (score > 20) {
score = score - (1.5 * scoreScale);
} else {
score = score - (1 * scoreScale);
}
scoreBar._yscale = score;
if ((score >= 90) || (score < 0)) {
stopRastle();
}
}
reInit();
max_sound_interval = 12;
sound_interval = 0;
sound_array = new Array(_root.hit1, _root.hit2, _root.hit3, _root.hit4);
sound_counter = 0;
Symbol 1482 MovieClip Frame 1
stop();
Symbol 1484 MovieClip Frame 1
function go() {
go_count = 100;
this.onEnterFrame = function () {
go_count--;
if ((Math.floor(go_count / 20) % 2) == 1) {
_visible = false;
} else {
_visible = true;
}
if (go_count < 0) {
this.onEnterFrame = null;
_visible = false;
}
};
}
Symbol 1485 MovieClip [stats] Frame 1
function go_arrow_start() {
go_arrow.go();
}
go_arrow._visible = false;
Symbol 1516 MovieClip Frame 12
stop();
Symbol 1524 MovieClip Frame 4
stop();
Symbol 1544 MovieClip Frame 25
stop();
Symbol 1558 MovieClip Frame 12
stop();
Symbol 1584 MovieClip Frame 1
grav = 0.5;
air = 0.95;
dirAr = new Array();
rotAr = new Array();
i = 0;
while (i <= 8) {
dirAr[i] = (Math.random() * 2) * Math.PI;
rotAr[i] = (Math.random() * 20) + 5;
gibSpeed = (Math.random() * 20) - 10;
this["gib" + i].xSpeed = Math.cos(dirAr[i]) * gibSpeed;
this["gib" + i].ySpeed = Math.sin(dirAr[i]) * gibSpeed;
i++;
}
this.onEnterFrame = function () {
i = 0;
while (i <= 8) {
this["gib" + i].ySpeed = this["gib" + i].ySpeed - grav;
this["gib" + i].ySpeed = this["gib" + i].ySpeed * air;
this["gib" + i].xSpeed = this["gib" + i].xSpeed * air;
this["gib" + i]._rotation = this["gib" + i]._rotation + rotAr[i];
this["gib" + i]._x = this["gib" + i]._x + this["gib" + i].xSpeed;
this["gib" + i]._y = this["gib" + i]._y - this["gib" + i].ySpeed;
if (this["gib" + i]._y > 0) {
this["gib" + i].ySpeed = this["gib" + i].ySpeed * -1;
this["gib" + i]._y = 0;
rotAr[i] = rotAr[i] * 0.5;
}
i++;
}
};
Symbol 1584 MovieClip Frame 15
stop();
Symbol 1585 MovieClip [alien] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
stun_power = stunP / 3;
stun_duration = stunD;
c_hp = c_hp - stun_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_state = E_STUN;
my_ai_state = E_AI_OFF;
if (c_hp < 0) {
doDie();
}
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("laser_shot", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 1.5;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 350;
c_hp = c_maxHp;
c_pow = 60;
c_speed = 6;
c_longRange = 500;
c_shortRange = 40;
c_yRange = 16;
gun_reload = 15;
fire_hit_duration = 0;
rastler = 5;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 12;
spawnShotTime = 6;
reloadTime = 15;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1604 MovieClip Frame 9
stop();
Symbol 1609 MovieClip Frame 4
stop();
Symbol 1619 MovieClip Frame 7
stop();
Symbol 1620 MovieClip [alienSol] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
doHit(stunP / 3, 15, 1);
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
if (Math.abs(_y - target._y) < (c_yRange * 3)) {
if (((_y > target._y) && (_y < (max_y - c_yRange))) || (_y < (min_y + c_yRange))) {
_y = (_y + c_speed);
} else {
_y = (_y - c_speed);
}
}
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("flamer_shot", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if ((state_counter > spawnShotTime) && ((state_counter % respawnShotTime) == 0)) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 0.5;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 550;
c_hp = c_maxHp;
c_pow = 50;
c_speed = 3;
c_longRange = 200;
c_shortRange = 40;
c_yRange = 20;
gun_reload = 45;
fire_hit_duration = 0;
rastler = 4;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 70;
spawnShotTime = 10;
respawnShotTime = 20;
reloadTime = 30;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1645 MovieClip Frame 9
stop();
Symbol 1653 MovieClip Frame 4
stop();
Symbol 1667 MovieClip Frame 7
stop();
Symbol 1679 MovieClip Frame 30
stop();
Symbol 1680 MovieClip [alienCap] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
doHit(stunP / 3, 15, 1);
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
fire_hit_power = hitP;
fire_hit_duration = fire_hit_duration + hitD;
hpBar._visible = true;
hpBar.showTime = fire_hit_duration + 30;
my_ai_state = E_AI_OFF;
my_state = E_FIRE;
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
if (target.rastle_partner != this) {
my_ai_state = E_AI_ATTACK;
}
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_delay) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
shotPlace = new Object();
shotPlace._y = _y;
shotPlace._x = _x;
shotPlace._xscale = _xscale;
shotPlace.dir = dir;
shotPlace.power = c_pow;
shotPlace.targetArray = _root.friendly_array;
_parent.attachMovie("laser_shot", "shot" + _parent.layer, _parent.layer++, shotPlace);
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 1;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 300;
c_hp = c_maxHp;
c_pow = 60;
c_speed = 4;
c_longRange = 400;
c_shortRange = 40;
c_yRange = 16;
gun_reload = 35;
fire_hit_duration = 0;
rastler = 3;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
wannaRastle = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 19;
spawnShotTime = 8;
reloadTime = 30;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1707 MovieClip Frame 5
stop();
Symbol 1717 MovieClip Frame 14
stop();
Symbol 1718 MovieClip [alienVarmint] Frame 1
function cleanUp() {
_root.enemy_array = _root.remove_from_array(this, _root.enemy_array);
_root.object_array = _root.remove_from_array(this, _root.object_array);
if (item) {
_root.spawnItem(item, {_x:_x, _y:_y});
}
}
function main() {
traceOut = (("reload: " + reload) + "\ntimer: ") + timer;
switch (my_ai_state) {
case E_AI_WAIT :
eaiWait();
break;
case E_AI_ATTACK :
eaiAttack();
break;
case E_AI_TARGET :
eaiTarget();
break;
case E_AI_DODGE :
eaiDodge();
break;
case E_AI_WANDER :
eaiWander();
break;
case E_AI_OFF :
break;
default :
eaiWait();
}
switch (my_state) {
case E_IDLE :
idle();
return;
case E_WALK :
walk();
return;
case E_SHOOT :
shoot();
return;
case E_RASTLE_START :
rastleStart();
return;
case E_RASTLE :
rastle();
return;
case E_HIT :
hit();
return;
case E_FIRE :
hitFire();
return;
case E_DIE :
die();
return;
case E_BURN :
dieFire();
return;
case E_STUN :
stun();
return;
case E_GIB :
gib();
return;
default :
idle();
}
}
function stopRastle(score) {
if (score < 50) {
reload = timer + (reloadTime * 3);
}
}
function doStun(stunP, stunD) {
doHit(stunP, 15, 1);
}
function stun() {
state_counter++;
if (state_counter >= stun_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_WALK;
}
_x = (_x - (2 * dir));
check_bounds_walking();
gotoAndStop ("stun");
}
function dieFire() {
state_counter++;
if (state_counter >= burn_time) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
gotoAndStop ("die_fire");
}
function hitFire() {
gotoAndStop ("hit_fire");
i = 0;
while (i < _root.friendly_array.length) {
if (this.hitArea.hitTest(_root.friendly_array[i].tgtArea)) {
_root.friendly_array[i].doHit(10, 15, 1);
}
i++;
}
if (((state_counter++) % 20) == 0) {
c_hp = c_hp - fire_hit_power;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
if (c_hp <= 0) {
state_counter = 0;
my_state = E_BURN;
}
newDir = (Math.random() * 2) * Math.PI;
dirX = Math.abs(Math.cos(newDir));
dirY = Math.sin(newDir);
dir = dir * -1;
}
faceDir();
check_bounds_walking();
_x = (_x + (((c_speed * dirX) * 2) * dir));
_y = (_y + ((c_speed * dirY) * 2));
if (state_counter >= fire_hit_duration) {
fire_hit_duration = 0;
state_counter = 0;
doHit(0, 5, 5);
}
}
function doHitFire(hitP, hitD) {
doHit(hitP / 2, 15, 1);
}
function hit() {
state_counter++;
_x = (_x - (((hit_duration - state_counter) * hit_slider) * dir));
check_bounds_walking();
if (state_counter > hit_duration) {
state_counter = 0;
my_ai_state = E_AI_ATTACK;
my_state = E_IDLE;
}
gotoAndStop ("hit");
}
function doRastle() {
my_ai_state = E_AI_OFF;
my_state = E_RASTLE;
}
function targetFacesMe(tgt) {
if ((_x > tgt._x) && (tgt._xscale > 0)) {
return(true);
}
if ((_x < tgt._x) && (tgt._xscale < 0)) {
return(true);
}
return(false);
}
function idle() {
gotoAndStop ("idle");
}
function rastle() {
gotoAndStop ("rastle_mid");
}
function walk() {
gotoAndStop(walkFrm);
walkFrm = "walk";
if (my_ai_state == E_AI_ATTACK) {
faceTarget(target);
if (Math.abs(_x - target._x) > c_longRange) {
_x = (_x + (c_speed * dir));
} else {
if (timer < reload) {
if (Math.random() > 0.5) {
my_ai_state = E_AI_DODGE;
} else {
my_ai_state = E_AI_WAIT;
}
} else if ((((Math.random() < _root.enemy_wait) && (timer >= reload)) && (Math.abs(target._y - _y) < c_yRange)) && (!((wannaRastle && (Math.abs(_x - target._x) < c_shortRange)) && (target.my_state != target.cs_rastle_mid_1)))) {
my_ai_state = E_AI_OFF;
my_state = E_SHOOT;
} else if (((((Math.abs(_x - target._x) <= c_shortRange) && (Math.abs(_y - target._y) < c_yRange)) && (wannaRastle)) && (!target.is_jumping())) && (target.tgtArea)) {
my_state = E_RASTLE;
my_ai_state = E_AI_OFF;
target.my_state = target.cs_rastle_mid_1;
doRastle();
target.rastle_partner = this;
_root.rastle_meter.startRastle(target, this);
} else {
walkFrm = "idle";
}
if ((Math.abs(_y - target._y) > c_yRange) && (Math.abs(_x - target._x) < c_longRange)) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y - c_speed);
} else {
_y = (_y + c_speed);
}
}
}
if (((!targetFacesMe(target)) || ((Math.abs(_x - target._x) < c_longRange) && (!wannaRastle))) || (Math.abs(_x - target._x) < c_shortRange)) {
if ((_y - target._y) > c_yRange) {
walkFrm = "walk";
_y = (_y - c_speed);
} else if ((_y - target._y) < (-c_yRange)) {
walkFrm = "walk";
_y = (_y + c_speed);
}
} else if ((Math.abs(_y - target._y) < c_yRange) && (caution || (wannaRastle))) {
walkFrm = "walk";
if (_y > target._y) {
_y = (_y + c_speed);
}
if (_y < target._y) {
_y = (_y - c_speed);
}
}
} else if (my_ai_state == E_AI_DODGE) {
if ((Math.random() < 0.02) && (timer > reload)) {
my_ai_state = E_AI_WAIT;
}
fleeTarget(target);
_x = (_x + (c_speed * dir));
if (Math.abs(_y - target._y) < (c_yRange * 3)) {
if (((_y > target._y) && (_y < (max_y - c_yRange))) || (_y < (min_y + c_yRange))) {
_y = (_y + c_speed);
} else {
_y = (_y - c_speed);
}
}
} else if (my_ai_state == E_AI_WANDER) {
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
if (targetInRange({_x:wander_x, _y:this._y}, c_shortRange, c_yRange)) {
my_ai_state = E_AI_ATTACK;
}
if (_x < wander_x) {
dir = 1;
} else {
dir = -1;
}
faceDir();
_x = (_x + (c_speed * dir));
}
check_bounds_walking();
}
function eaiWander() {
}
function check_bounds_walking() {
if (_x > max_x) {
_x = max_x;
my_ai_state = E_AI_WANDER;
wander_x = min_x + 200;
}
if (_x < min_x) {
_x = min_x;
my_ai_state = E_AI_WANDER;
wander_x = max_x - 200;
}
if (_y > max_y) {
_y = max_y;
}
if (_y < min_y) {
_y = min_y;
}
}
function spawnShot() {
targetArray = _root.friendly_array;
i = 0;
while (i < targetArray.length) {
if (this.hitArea.hitTest(targetArray[i].tgtArea) && (Math.abs(_y - targetArray[i]._y) < 16)) {
targetArray[i].doHit(c_pow, 15, 1);
return(true);
}
i++;
}
}
function shoot() {
my_ai_state = E_AI_OFF;
state_counter++;
if (state_counter == spawnShotTime) {
spawnShot();
}
reload = timer + reloadTime;
gotoAndStop ("shoot");
if (state_counter > shootDur) {
state_counter = 0;
my_state = E_IDLE;
my_ai_state = E_AI_DODGE;
}
}
function planAttack() {
if (Math.random() > 0.5) {
planXDist = c_longRange;
} else {
planXDist = c_shortRange;
}
}
function faceTarget(target) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function fleeTarget(target) {
if (target._x > _x) {
dir = -1;
} else {
dir = 1;
}
faceDir();
}
function faceDir() {
_xscale = (100 * dir);
}
function eaiTarget() {
target = _parent.cooter;
my_ai_state = E_AI_WAIT;
planAttack(target);
}
function eaiWait() {
faceTarget(target);
i = 0;
while (i < _root.enemy_array.length) {
if ((_root.enemy_array[i].my_ai_state == E_AI_ATTACK) && (_root.enemy_array[i].target == target)) {
attackers++;
}
i++;
}
if (((attackers < 3) && (timer > reload)) || (Math.random() < 0.02)) {
my_ai_state = E_AI_ATTACK;
} else {
my_state = E_IDLE;
}
if (targetInRange(target, c_longRange, c_yRange) && (timer > reload)) {
my_ai_state = E_AI_ATTACK;
}
}
function eaiAttack() {
my_state = E_WALK;
}
function eaiDodge() {
my_state = E_WALK;
}
function targetInRange(tgt, xD, yD) {
if ((Math.abs(tgt._x - _x) < xD) && (Math.abs(tgt._y - _y) < yD)) {
return(true);
}
return(false);
}
function doDie() {
my_ai_state = E_AI_OFF;
my_state = E_DIE;
}
function die() {
gotoAndStop ("die");
state_counter++;
if (state_counter > die_dur) {
_alpha = (_alpha - 2);
if (_alpha < 0) {
_root.num_enemies--;
cleanUp();
this.removeMovieClip();
}
}
}
function doHit(hitP, hitD, hitS) {
hit_power = hitP;
hit_duration = hitD;
hit_slider = hitS;
c_hp = c_hp - hit_power;
hpBar._visible = true;
hpBar.hpMask._yscale = (c_hp / c_maxHp) * 100;
hpBar.showTime = 50;
my_ai_state = E_AI_OFF;
my_state = E_HIT;
state_counter = 0;
clip.gotoAndPlay(1);
if (c_hp < 0) {
doDie();
}
}
function doGib() {
my_ai_state = E_AI_OFF;
my_state = E_GIB;
}
function gib() {
state_counter++;
gotoAndStop ("gib");
if (state_counter > 100) {
_alpha = (_alpha - 2);
}
if (_alpha < 0) {
_root.num_enemies--;
this.onEnterFrame = null;
cleanUp();
this.removeMovieClip();
}
}
stop();
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
rastlerScale = 1.8;
my_ai_state = E_AI_TARGET;
walkFrm = "walk";
dir = 1;
die_dur = 50;
c_maxHp = 250;
c_hp = c_maxHp;
c_pow = 80;
c_speed = 5;
c_longRange = 100;
c_shortRange = 100;
c_yRange = 16;
gun_reload = 15;
fire_hit_duration = 0;
rastler = false;
attackers = 0;
loaded = true;
target = null;
state_counter = 0;
caution = false;
wannaRastle = false;
if (Math.random() < 0.2) {
caution = true;
}
burn_time = 60;
hit_duration = 10;
hit_slider = 2;
shootDur = 11;
spawnShotTime = 8;
reloadTime = 25;
reload = -reloadTime;
this.onEnterFrame = main;
Symbol 1738 Button
on (release) {
getURL ("http://www.mofunzone.com/", "_blank");
}
Symbol 1799 MovieClip Frame 17
gotoAndPlay ("loop");
Symbol 1863 MovieClip [cutscene_1_clip] Frame 1
stop();
Instance of Symbol 1729 MovieClip in Symbol 1863 MovieClip [cutscene_1_clip] Frame 1
on (release) {
_parent.nextFrame();
}
Symbol 1863 MovieClip [cutscene_1_clip] Frame 6
_root.end_cutscene();
Symbol 1869 MovieClip [cutscene_2_clip] Frame 1
stop();
Instance of Symbol 1729 MovieClip in Symbol 1869 MovieClip [cutscene_2_clip] Frame 1
on (release) {
_parent.nextFrame();
}
Symbol 1869 MovieClip [cutscene_2_clip] Frame 2
_root.end_cutscene();
Symbol 1886 MovieClip [cutscene_3_clip] Frame 1
stop();
Instance of Symbol 1729 MovieClip in Symbol 1886 MovieClip [cutscene_3_clip] Frame 1
on (release) {
_parent.nextFrame();
}
Symbol 1886 MovieClip [cutscene_3_clip] Frame 3
_root.end_cutscene();
Symbol 1896 MovieClip [cutscene_4_clip] Frame 1
stop();
Instance of Symbol 1729 MovieClip in Symbol 1896 MovieClip [cutscene_4_clip] Frame 1
on (release) {
_parent.nextFrame();
}
Symbol 1896 MovieClip [cutscene_4_clip] Frame 3
_root.end_cutscene();
Symbol 1903 Button
on (release) {
getURL ("http://www.mofunzone.com/", "_blank");
}
Symbol 1904 MovieClip [cutscene_5_clip] Frame 1
stop();
Instance of Symbol 1729 MovieClip in Symbol 1904 MovieClip [cutscene_5_clip] Frame 1
on (release) {
_parent.nextFrame();
}
Symbol 1904 MovieClip [cutscene_5_clip] Frame 3
_root.completed = true;
_root.restart();
this.removeMovieClip();
Symbol 1920 MovieClip Frame 2
stop();
Symbol 1933 MovieClip [alienBeast] Frame 1
function pick_x() {
pos_x = (Math.random() * (max_x - min_x)) + min_x;
}
function pick_y() {
pos_y = (Math.random() * (max_y - min_y)) + min_y;
}
function flash() {
hitStart = demonCounter;
hit = true;
}
function vehicleDemon() {
counter++;
demonCounter++;
if (hit) {
vehicleColor.setTransform(hitColor);
if (demonCounter > (hitStart + hitDuration)) {
vehicleColor.setTransform(normalColor);
hit = false;
}
}
}
function die() {
this.onEnterFrame = null;
vehicleColor.setTransform(normalColor);
hit = false;
counter = 0;
gotoAndPlay ("die");
}
function doHit(pow, dur, s) {
hp = hp - pow;
if (hp < 0) {
die();
}
flash();
}
function doHitFire(pow, dur) {
hp = hp - pow;
if (hp < 0) {
die();
}
flash();
}
function doStun(pow, stun) {
hp = hp - pow;
if (hp < 0) {
die();
}
flash();
}
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
attack_freq = 80;
counter = 0;
speed = 4;
hitColor = {ga:0, ba:0};
normalColor = {ra:100, ga:100, ba:100, rb:0, gb:0, bb:0};
demonCounter = 0;
hitDuration = 3;
hp = 700;
target = _root.viewport.cooter;
power = 120;
hit = false;
vehicleColor = new Color(this);
dir = 1;
this.onEnterFrame = function () {
_xscale = (100 * dir);
if (counter > attack_freq) {
if (target._x < _x) {
dir = -1;
} else {
dir = 1;
}
counter = 0;
if (hp > 0) {
gotoAndPlay ("attack_1");
}
}
if (Math.abs(pos_x - _x) <= speed) {
pick_x();
}
if (Math.abs(pos_y - _y) <= speed) {
pick_y();
}
if (counter > 27) {
if (_x < pos_x) {
dir = 1;
}
if (_y < pos_y) {
_y = (_y + speed);
}
if (_x > pos_x) {
dir = -1;
}
if (_y > pos_y) {
_y = (_y - speed);
}
_x = (_x + (speed * dir));
}
vehicleDemon();
if ((!target.is_jumping()) && (hitArea.hitTest(target.tgtArea) && (Math.abs(_y - target._y) < 20))) {
target.doHit(power, 15, 1);
}
};
Symbol 1933 MovieClip [alienBeast] Frame 6
stop();
Symbol 1933 MovieClip [alienBeast] Frame 29
gotoAndStop ("move");
Symbol 1933 MovieClip [alienBeast] Frame 51
gotoAndStop ("move");
Symbol 1933 MovieClip [alienBeast] Frame 77
stop();
_root.num_enemies--;
Symbol 1945 MovieClip Frame 10
stop();
Symbol 1946 MovieClip [boss_brain] Frame 1
function pick_y() {
pos_y = (Math.random() * (max_y - min_y)) + min_y;
}
function flash() {
hitStart = demonCounter;
hit = true;
}
function vehicleDemon() {
counter++;
demonCounter++;
if (hit) {
vehicleColor.setTransform(hitColor);
if (demonCounter > (hitStart + hitDuration)) {
vehicleColor.setTransform(normalColor);
hit = false;
}
}
}
function die() {
vehicleColor.setTransform(normalColor);
hit = false;
counter = 0;
_root.next_level(false);
}
function doHit(pow, dur, ss) {
hp = hp - pow;
if (hp < 0) {
die();
}
flash();
}
function doStun(pow, dur) {
doHit(pow, dur, null);
}
function doHitFire(pow, dur) {
doHit(pow, dur, null);
}
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
attack_freq = 65;
counter = 0;
speed = 2.5;
hitColor = {ga:0, ba:0};
normalColor = {ra:100, ga:100, ba:100, rb:0, gb:0, bb:0};
demonCounter = 0;
hitDuration = 3;
hp = 700;
target = _root.viewport.cooter;
power = 125;
hit = false;
vehicleColor = new Color(this);
this.onEnterFrame = function () {
if (target._x > _x) {
target._x = _x;
}
if (counter > attack_freq) {
counter = 0;
if (Math.random() > 0.5) {
gotoAndPlay ("attack_1");
} else {
gotoAndPlay ("attack_2");
}
}
if (Math.abs(pos_y - _y) <= speed) {
pick_y();
}
if (_y < pos_y) {
_y = (_y + speed);
}
if (_y > pos_y) {
_y = (_y - speed);
}
vehicleDemon();
if ((!target.is_jumping()) && (hitArea.hitTest(target.tgtArea) && (Math.abs(_y - target._y) < 20))) {
target.doHit(power, 15, 1);
}
};
Symbol 1946 MovieClip [boss_brain] Frame 69
stop();
Symbol 1946 MovieClip [boss_brain] Frame 80
gotoAndStop ("move");
Symbol 1965 MovieClip Frame 1
function doHit(pow, dur, scale) {
if (hp > 0) {
hp = hp - pow;
if (hp < 0) {
hp = 0;
}
_parent.flash();
updateHP();
}
}
function doHitFire(pow, dur) {
doHit(pow);
}
function doStun(pow, dur) {
doHit(pow);
}
function updateHP() {
_parent.updateHP();
}
hp = 200;
pow = 65;
any_y = true;
target = _root.viewport.cooter;
earl = _root.enemy_array.length;
_root.enemy_array[earl] = this;
enemy_array_ndx = earl;
this.onEnterFrame = function () {
if (hp > 0) {
gotoAndStop ("on");
if (this.hitArea.hitTest(target.tgtArea)) {
target.dir = 1;
target._x = target._x - 30;
target.doHit(pow, 15, 1.5);
}
} else {
gotoAndStop ("off");
}
};
Symbol 1966 MovieClip Frame 1
function flash() {
hitStart = demonCounter;
hit = true;
}
function vehicleDemon() {
demonCounter++;
if (hit) {
vehicleColor.setTransform(hitColor);
if (demonCounter > (hitStart + hitDuration)) {
vehicleColor.setTransform(normalColor);
hit = false;
}
}
if (hp <= 0) {
hit = false;
vehicleColor.setTransform(normalColor);
_parent.die();
}
}
function updateHP() {
hp = 0;
i = 0;
while (i < blade_array.length) {
hp = hp + blade_array[i].hp;
i++;
}
}
hitColor = {ga:0, ba:0, rb:100};
normalColor = {ra:100, ga:100, ba:100, rb:0, gb:0, bb:0};
demonCounter = 0;
hitDuration = 2;
blade_array = new Array(blade_0, blade_1, blade_2, blade_3);
hp = 1000;
vehicleColor = new Color(_parent);
this.onEnterFrame = vehicleDemon;
Symbol 1971 MovieClip [boss_combine] Frame 1
function flash() {
hitStart = demonCounter;
hit = true;
}
function vehicleDemon() {
i = 0;
while (i < _root.enemy_array.length) {
if (_root.enemy_array[i].rastler && (_root.enemy_array[i]._x > (_x + 70))) {
_root.enemy_array[i]._x = _x + 70;
}
i++;
}
if (target._x > (_x + 70)) {
target._x = _x + 70;
}
counter++;
demonCounter++;
if (hit) {
vehicleColor.setTransform(hitColor);
if (demonCounter > (hitStart + hitDuration)) {
vehicleColor.setTransform(normalColor);
hit = false;
}
}
if (counter > attack_freq) {
gotoAndPlay ("attack");
counter = 0;
}
_x = (_x + (speed * dir));
if ((dir == -1) && (_x < pos_2)) {
dir = 1;
}
if ((dir == 1) && (_x > pos_1)) {
dir = -1;
}
}
function die() {
hit = false;
counter = 0;
vehicleColor.setTransform(normalColor);
hit = false;
this.onEnterFrame = function () {
gotoAndStop ("die");
_x = (_x + 5);
if (_x > off_screen) {
_root.next_level(true);
this.onEnterFrame = null;
this.removeMovieClip();
}
};
}
target = _root.viewport.cooter;
hitColor = {ga:0, ba:0};
normalColor = {ra:100, ga:100, ba:100, rb:0, gb:0, bb:0};
demonCounter = 0;
hitDuration = 10;
start_x = _x;
off_screen = start_x;
pos_1 = start_x - 300;
pos_2 = pos_1 - 250;
attack_freq = 95;
counter = 0;
dir = -1;
speed = 3;
this.onEnterFrame = vehicleDemon;
Symbol 1971 MovieClip [boss_combine] Frame 29
stop();
Symbol 1990 MovieClip [boss_robot] Frame 1
function pick_x() {
pos_x = (Math.random() * (max_x - min_x)) + min_x;
}
function pick_y() {
pos_y = (Math.random() * (max_y - min_y)) + min_y;
}
function flash() {
hitStart = demonCounter;
hit = true;
}
function vehicleDemon() {
counter++;
demonCounter++;
if (hit) {
vehicleColor.setTransform(hitColor);
if (demonCounter > (hitStart + hitDuration)) {
vehicleColor.setTransform(normalColor);
hit = false;
}
}
}
function die() {
vehicleColor.setTransform(normalColor);
hit = false;
counter = 0;
_root.next_level(false);
}
function doHit() {
}
function doStun(pow, dur) {
hp = hp - (pow * 25);
if (hp < 0) {
die();
}
flash();
}
enemy_array_ndx = _root.enemy_array.push(this) - 1;
object_array_ndx = _root.object_array.push(this) - 1;
attack_freq = 75;
counter = 0;
speed = 4;
hitColor = {ga:0, ba:0};
normalColor = {ra:100, ga:100, ba:100, rb:0, gb:0, bb:0};
demonCounter = 0;
hitDuration = 10;
hp = 700;
target = _root.viewport.cooter;
power = 100;
hit = false;
vehicleColor = new Color(this);
this.onEnterFrame = function () {
if (counter > attack_freq) {
counter = 0;
if (Math.random() > 0.5) {
gotoAndPlay ("attack_1");
} else {
gotoAndPlay ("attack_2");
}
}
if (Math.abs(pos_x - _x) <= speed) {
pick_x();
}
if (Math.abs(pos_y - _y) <= speed) {
pick_y();
}
if (_x < pos_x) {
_x = (_x + speed);
}
if (_y < pos_y) {
_y = (_y + speed);
}
if (_x > pos_x) {
_x = (_x - speed);
}
if (_y > pos_y) {
_y = (_y - speed);
}
vehicleDemon();
if ((!target.is_jumping()) && (hitArea.hitTest(target.tgtArea) && (Math.abs(_y - target._y) < 20))) {
if (target._x > _x) {
target._x = _x + 100;
} else {
target._x = _x - 100;
}
target.doHit(power, 15, 1);
}
};
Symbol 1990 MovieClip [boss_robot] Frame 6
stop();
Symbol 1990 MovieClip [boss_robot] Frame 18
gotoAndStop ("move");
Symbol 1990 MovieClip [boss_robot] Frame 40
gotoAndStop ("move");
Symbol 1991 MovieClip Frame 1
stop();
Symbol 1996 MovieClip Frame 6
stop();
Symbol 2002 Button
on (release) {
_root.game_state = gs_cutscene;
}
Symbol 2008 Button
on (release) {
_root.game_state = gs_instructions;
}
Symbol 2013 Button
on (release) {
getURL ("http://www.mofunzone.com", "_blank");
}
Symbol 2018 Button
on (release) {
getURL ("http://www.mofunzone.com/", "_blank");
}
Symbol 2019 Button
on (release) {
getURL ("http://www.mofunzone.com", "_blank");
}
Symbol 2029 Button
on (release) {
getURL ("http://www.mofunzone.com", "_blank");
}
Symbol 2035 MovieClip Frame 1
stop();
Instance of Symbol 1729 MovieClip in Symbol 2035 MovieClip Frame 1
on (release) {
_parent.nextFrame();
}
Symbol 2035 MovieClip Frame 4
_root.game_state = gs_menu;