Frame 1
function create_yiffingField() {
this.createEmptyMovieClip("yiff", 0);
yiff._x = game_location_x;
yiff._y = game_location_y;
yiff.createEmptyMovieClip("corpse_shell", _root.corpse_shell_depth);
}
function place_destination(cell_num_x, cell_num_y) {
_root.yiff.attachMovie("destination", "destination", _root.destination_depth);
_root.yiff.destination._x = (cell_num_x - 1) * spacing;
_root.yiff.destination._y = (cell_num_y - 1) * spacing;
}
function place_character(cell_num_x, cell_num_y) {
_root.yiff.attachMovie("character", "character", _root.character_depth);
trgt = _root.yiff.character;
xx = (cell_num_x - 1) * spacing;
yy = (cell_num_y - 1) * spacing;
trgt._x = xx;
trgt._y = yy;
trgt.xx = xx;
trgt.yy = yy;
trgt.speed = _root.character_speed;
trgt.radius = _root.character_radius;
trgt.initiative = _root.character_initiative;
trgt.movepoints = _root.character_movepoints;
trgt.movepoints_max = trgt.movepoints;
trgt.actpoints_max = _root.character_actpoints;
trgt.actpoints = trgt.actpoints_max;
trgt.visibility_radius = _root.character_visibility_radius;
trgt.hp = _root.character_hp;
trgt.dmg = 0;
trgt.dmg_min = _root.character_dmg_min;
trgt.dmg_max = _root.character_dmg_max;
trgt.team = _root.character_team;
trgt.attack_radius = _root.character_attack_radius;
}
function initialize_enemies() {
_root.enemy_depth_local = _root.enemy_depth;
skolko_bragov = map_enemy_array_1.length;
i = 0;
while (i < skolko_bragov) {
cellx = map_enemy_array_1[i][1];
celly = map_enemy_array_1[i][2];
en_id = map_enemy_array_1[i][0];
cellname = (("cell" + cellx) + "_") + celly;
enemy_loc_x = _root.yiff[cellname]._x;
enemy_loc_y = _root.yiff[cellname]._y;
_root.yiff.attachMovie("enemy_type_" + en_id, "enemy_" + i, ++_root.enemy_depth_local);
trgt = _root.yiff["enemy_" + i];
trgt.en_id = en_id;
trgt._x = enemy_loc_x;
trgt._y = enemy_loc_y;
trgt._rotation = random(360);
trgt.hp_max = _root["enemy_hp_" + en_id];
trgt.speed = _root["enemy_speed_" + en_id];
trgt.initiative = _root["enemy_initiative_" + en_id];
trgt.movepoints_max = _root["enemy_movepoints_" + en_id];
trgt.movepoints = trgt.movepoints_max;
trgt.actpoints_max = _root["enemy_actpoints_" + en_id];
trgt.actpoints = trgt.actpoints_max;
trgt.visibility_radius = _root["enemy_visibility_radius_" + en_id];
trgt.hp = _root["enemy_hp_" + en_id];
trgt.dmg = 0;
trgt.dmg_min = _root["enemy_dmg_min_" + en_id];
trgt.dmg_max = _root["enemy_dmg_max_" + en_id];
trgt.team = _root["enemy_team_" + en_id];
trgt.attack_radius = _root["enemy_attack_radius_" + en_id];
i++;
}
}
function buildGrid() {
var _local4 = 1;
while (_local4 <= _root.field_height) {
var _local3 = 1;
while (_local3 <= _root.field_length) {
var _local2 = (("cell" + _local3) + "_") + _local4;
var _local7 = ((_local3 - 1) * spacing) + (spacing / 2);
var _local6 = ((_local4 - 1) * spacing) + (spacing / 2);
var _local5 = map_array_1[_local4 - 1][_local3 - 1];
if (_local5 eq 1) {
whichtile = "tile_block";
} else {
whichtile = "tile_empty";
}
_root.yiff.attachMovie(whichtile, _local2, ++_root.cells_depth);
_root.yiff[_local2]._x = _local7;
_root.yiff[_local2]._y = _local6;
_root.yiff[_local2].xx = _local7;
_root.yiff[_local2].yy = _local6;
_root.yiff[_local2].cellname = _local2;
_root.yiff[_local2]._type_ = _local5;
_root.yiff[_local2].clip = _root.yiff[_local2];
_local3++;
}
_local4++;
}
}
function character_movement(dir) {
trgt = _root.yiff.character;
if (dir == "right") {
var _local6 = (trgt.xx + trgt.radius) + trgt.speed;
var _local5 = trgt.yy;
var _local7 = Math.ceil(_local6 / spacing);
var _local2 = Math.ceil(_local5 / spacing);
trgt.current_cell = [_local7, _local2];
dontgo = 0;
if (_local7 > 28) {
dontgo = 1;
}
var _local4 = _root.yiff[(("cell" + _local7) + "_") + _local2];
if ((_local4._type_ != 1) and (dontgo != 1)) {
trgt.xx = trgt.xx + trgt.speed;
trgt._x = trgt.xx;
// unexpected jump
}
return(undefined);
}
if (dir == "left") {
var _local6 = (trgt.xx - trgt.radius) - trgt.speed;
var _local5 = trgt.yy;
var _local7 = Math.ceil(_local6 / spacing);
var _local2 = Math.ceil(_local5 / spacing);
var _local4 = _root.yiff[(("cell" + _local7) + "_") + _local2];
dontgo = 0;
if (_local7 < 1) {
dontgo = 1;
}
if ((_local4._type_ != 1) and (dontgo != 1)) {
trgt.xx = trgt.xx - trgt.speed;
trgt._x = trgt.xx;
// unexpected jump
}
return(undefined);
}
if (dir == "up") {
var _local6 = trgt.xx;
var _local5 = (trgt.yy - trgt.radius) - trgt.speed;
var _local7 = Math.ceil(_local6 / spacing);
var _local2 = Math.ceil(_local5 / spacing);
var _local4 = _root.yiff[(("cell" + _local7) + "_") + _local2];
dontgo = 0;
if (_local2 < 1) {
dontgo = 1;
}
if ((_local4._type_ != 1) and (dontgo != 1)) {
trgt.yy = trgt.yy - trgt.speed;
trgt._y = trgt.yy;
// unexpected jump
}
return(undefined);
}
if (dir == "down") {
var _local6 = trgt.xx;
var _local5 = (trgt.yy + trgt.radius) + trgt.speed;
var _local7 = Math.ceil(_local6 / spacing);
var _local2 = Math.ceil(_local5 / spacing);
var _local4 = _root.yiff[(("cell" + _local7) + "_") + _local2];
dontgo = 0;
if (_local2 > 17) {
dontgo = 1;
}
if ((_local4._type_ != 1) and (dontgo != 1)) {
trgt.yy = trgt.yy + trgt.speed;
trgt._y = trgt.yy;
} else {
return(undefined);
}
}
}
spacing = 26;
field_length = 28;
field_height = 17;
game_location_x = 40;
game_location_y = 20;
_root.cells_depth = 1;
_root.corpse_shell_depth = 999;
_root.destination_depth = 1000;
_root.character_depth = 5200;
_root.pathpointer_depth = 1500;
_root.enemy_depth = 4000;
_root.idle_time_max = 0.5;
dotrace = 0;
_root.character_visibility_radius = 500;
_root.character_speed = 3;
_root.character_radius = 3;
_root.character_attack_radius = 1.4 * spacing;
_root.character_movepoints = 5;
_root.character_initiative = 2;
_root.character_hp = 300;
_root.character_team = 1;
_root.character_actpoints = 2;
_root.character_dmg_min = 5;
_root.character_dmg_max = 10;
_root.enemy_hp_1 = 100;
_root.enemy_speed_1 = 5;
_root.enemy_initiative_1 = 1;
_root.enemy_movepoints_1 = 4;
_root.enemy_actpoints_1 = 2;
_root.enemy_visibility_radius_1 = 1500;
_root.enemy_team_1 = 2;
_root.enemy_attack_radius_1 = 1.6 * spacing;
_root.enemy_dmg_min_1 = 25;
_root.enemy_dmg_max_1 = 50;
_root.enemy_hp_2 = 140;
_root.enemy_speed_2 = 5;
_root.enemy_initiative_2 = 3;
_root.enemy_movepoints_2 = 6;
_root.enemy_actpoints_2 = 2;
_root.enemy_visibility_radius_2 = 1500;
_root.enemy_team_2 = 3;
_root.enemy_attack_radius_2 = 1.6 * spacing;
_root.enemy_dmg_min_2 = 20;
_root.enemy_dmg_max_2 = 50;
_root.docharactermovement = 0;
_root.lockcharcontrolz = 1;
roundprogress_step1 = "done";
empty_row = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row4 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row5 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row6 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row7 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row9 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row10 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row11 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row12 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row13 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row14 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row15 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row16 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
row17 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var map_array_1 = new Array();
i = 1;
while (i <= field_height) {
map_array_1.push(this["row" + i]);
i++;
}
var map_enemy_array_1 = new Array();
_root.enemy_ammount_map_1 = 30;
i = 1;
while (i <= _root.enemy_ammount_map_1) {
this["map_1_enemy_" + i] = [1 + random(2), 1 + random(28), 1 + random(17)];
i++;
}
i = 1;
while (i <= _root.enemy_ammount_map_1) {
map_enemy_array_1.push(this["map_1_enemy_" + i]);
i++;
}
function initialize_obstacles() {
yy = 0;
var _local2 = 1;
while (_local2 <= _root.field_length) {
name_ = (("node" + _local2) + "_") + yy;
_root.astar.nodes[name_] = _root.astar.solidOb;
_local2++;
}
yy = 18;
_local2 = 1;
while (_local2 <= _root.field_length) {
name_ = (("node" + _local2) + "_") + yy;
_root.astar.nodes[name_] = _root.astar.solidOb;
_local2++;
}
xx = 0;
_local2 = 1;
while (_local2 <= _root.field_height) {
name_ = (("node" + xx) + "_") + _local2;
_root.astar.nodes[name_] = _root.astar.solidOb;
_local2++;
}
xx = 29;
_local2 = 1;
while (_local2 <= _root.field_height) {
name_ = (("node" + xx) + "_") + _local2;
_root.astar.nodes[name_] = _root.astar.solidOb;
_local2++;
}
var _local3 = 1;
while (_local3 <= _root.field_height) {
_local2 = 1;
while (_local2 <= _root.field_length) {
var _local4 = map_array_1[_local3 - 1][_local2 - 1];
if (_local4 eq 1) {
name_ = (("node" + _local2) + "_") + _local3;
_root.astar.nodes[name_] = _root.astar.solidOb;
}
_local2++;
}
_local3++;
}
_local2 = 0;
while (_local2 < enemy_ammount) {
trgt1 = _root.yiff["enemy_" + _local2];
if (trgt1 and (trgt1.dmg < trgt1.hp)) {
xx = cell_name_calculation(trgt1._x, trgt1._y)[0];
yy = cell_name_calculation(trgt1._x, trgt1._y)[1];
name_ = (("node" + xx) + "_") + yy;
_root.astar.nodes[name_] = _root.astar.solidOb;
}
_local2++;
}
trgt1 = _root.yiff.character;
if (trgt1 and (trgt1.dmg < trgt1.hp)) {
xx = cell_name_calculation(trgt1._x, trgt1._y)[0];
yy = cell_name_calculation(trgt1._x, trgt1._y)[1];
name_ = (("node" + xx) + "_") + yy;
_root.astar.nodes[name_] = _root.astar.solidOb;
}
}
function obstacle_exclude(trgt1) {
xx = cell_name_calculation(trgt1._x, trgt1._y)[0];
yy = cell_name_calculation(trgt1._x, trgt1._y)[1];
name_ = (("node" + xx) + "_") + yy;
_root.astar.nodes[name_] = _root.astar.passableFloor;
}
function delete_shownpath() {
var _local2 = 0;
while (_local2 <= 500) {
trgt = _root.yiff["pathpointer" + _local2];
if (trgt) {
removeMovieClip(trgt);
}
_local2++;
}
}
function showpath(path_array) {
delete_shownpath();
pathlength = path_array.length;
_root.pathpointer_depth_local = _root.pathpointer_depth;
var _local2 = 0;
while (_local2 <= pathlength) {
xx = path_array[_local2][0];
yy = path_array[_local2][1];
var _local4 = ((xx - 1) * spacing) + (spacing / 2);
var _local3 = ((yy - 1) * spacing) + (spacing / 2);
if (_local4 and _local3) {
_root.yiff.attachMovie("pathpointer", "pathpointer" + _local2, ++_root.pathpointer_depth_local);
_root.yiff["pathpointer" + _local2]._x = _local4;
_root.yiff["pathpointer" + _local2]._y = _local3;
}
_local2++;
}
}
function astarCalcAndShowPath(start_x, start_y, end_x, end_y, doshowpath) {
xx = cell_name_calculation(start_x, start_y)[0];
yy = cell_name_calculation(start_x, start_y)[1];
astar.s.x = xx;
astar.s.y = yy;
xx = cell_name_calculation(end_x, end_y)[0];
yy = cell_name_calculation(end_x, end_y)[1];
astar.g.x = xx;
astar.g.y = yy;
thepath = astar.search();
if ((_root.astarfailed != 1) and (doshowpath eq "true")) {
showpath(thepath);
}
if (_root.astarfailed eq 1) {
thepath = "none";
}
return(thepath);
}
astar = {};
astar.initialize = function () {
this.solidOb = {solid:true, exists:true};
this.passableFloor = {solid:false, exists:false};
this.maxSearchTime = 333;
this.s = {};
this.g = {};
this.open = [];
this.closed = [];
this.nodes = {};
this.preventClipping = true;
};
astar.findHeuristic = function (x, y) {
var _local3 = Math.abs(x - this.g.x);
var _local2 = Math.abs(y - this.g.y);
var _local5 = Math.min(_local3, _local2) * 1.41;
var _local4 = Math.max(_local3, _local2) - Math.min(_local3, _local2);
return(_local5 + _local4);
};
astar.cost = function (who, newx, newy) {
var _local3 = 1;
if (((who.x - newx) != 0) && ((who.y - newy) != 0)) {
_local3 = 1.41;
if (this.preventClipping) {
var _local4 = (who.x - newx) / Math.abs(who.x - newx);
var _local5 = (who.y - newy) / Math.abs(who.y - newy);
var _local9 = who.x - _local4;
var _local7 = who.y;
var _local12 = this.nodes[(("node" + _local9) + "_") + _local7];
var _local8 = who.x;
var _local6 = who.y - _local5;
var _local10 = this.nodes[(("node" + _local8) + "_") + _local6];
if (_local12.solid || (_local10.solid)) {
_local3 = 100000 /* 0x0186A0 */;
}
}
}
return(_local3);
};
astar.checkNode = function (newx, newy, whoName) {
var _local7 = this.nodes[whoName];
var _local4 = (("node" + newx) + "_") + newy;
var _local8 = _local7.g + this.cost(_local7, newx, newy);
if ((_local7.x == this.g.x) && (_local7.y == this.g.y)) {
this.keepSearching = false;
}
if (!this.nodes[_local4].exists) {
this.addOpen(newx, newy, _local8, whoName);
} else if (!this.nodes[_local4].solid) {
if (_local8 < this.nodes[_local4].g) {
var _local5 = this.nodes[_local4];
_local5.parent = whoName;
_local5.g = _local8;
_local5.f = _local5.h + _local8;
var _local6 = _local5.f;
if (this.nodes[_local4].where == "open") {
var _local3 = 0;
while (_local3 < this.open.length) {
if (this.open[_local3].name == _local4) {
this.open.splice(_local3, 1);
}
_local3++;
}
var _local2 = 0;
while (_local2 < this.open.length) {
if (_local6 < this.open[_local2].f) {
this.open.splice(_local2, 0, _local5);
this.nodes[_local4] = this.open[_local2];
break;
}
if (_local2 == (this.open.length - 1)) {
this.open.push(_local5);
this.nodes[_local4] = astar.open[_local2 + 1];
break;
}
_local2++;
}
}
if (this.nodes[_local4].where == "closed") {
var _local3 = 0;
while (_local3 < this.closed.length) {
if (this.closed[_local3].name == _local4) {
this.closed.splice(_local3, 1);
}
_local3++;
}
}
}
}
};
astar.buildPath = function (name) {
name = (("node" + this.g.x) + "_") + this.g.y;
var _local2 = this.nodes[name].parent;
this.path = [];
while (_local2 != null) {
this.path.push([this.nodes[_local2].x, this.nodes[_local2].y]);
_local2 = this.nodes[_local2].parent;
}
this.path.reverse();
this.path.shift();
this.path.push([this.g.x, this.g.y]);
};
astar.expandNode = function (index) {
var _local6 = this.open[index];
var _local3 = _local6.x;
var _local2 = _local6.y;
var _local4 = (("node" + _local3) + "_") + _local2;
this.checkNode(_local3 + 1, _local2, _local4);
this.checkNode(_local3 + 1, _local2 - 1, _local4);
this.checkNode(_local3, _local2 - 1, _local4);
this.checkNode(_local3 - 1, _local2 - 1, _local4);
this.checkNode(_local3 - 1, _local2, _local4);
this.checkNode(_local3 - 1, _local2 + 1, _local4);
this.checkNode(_local3, _local2 + 1, _local4);
this.checkNode(_local3 + 1, _local2 + 1, _local4);
var _local5 = this.open[index];
_local5.where = "closed";
this.open.splice(index, 1);
this.closed.push(_local5);
if (!this.keepSearching) {
this.buildPath();
}
};
astar.addOpen = function (x, y, g, parent) {
var _local9 = this.findHeuristic(x, y);
var _local5 = g + _local9;
var _local3 = (("node" + x) + "_") + y;
var _local4 = {x:x, y:y, g:g, h:_local9, f:_local5, name:_local3, parent:parent, exists:true, where:"open"};
if (parent == null) {
this.open.push(_local4);
this.nodes[_local3] = open[0];
}
var _local2 = 0;
while (_local2 < this.open.length) {
if (_local5 < this.open[_local2].f) {
this.open.splice(_local2, 0, _local4);
this.nodes[_local3] = this.open[_local2];
break;
}
if (_local2 == (this.open.length - 1)) {
this.open.push(_local4);
this.nodes[_local3] = astar.open[_local2 + 1];
break;
}
_local2++;
}
};
astar.search = function () {
delete this.path;
this.now = getTimer();
this.addOpen(astar.s.x, astar.s.y, 0, null);
this.keepSearching = true;
while (this.keepSearching) {
this.expandNode(0);
_root.astarfailed = 0;
if ((getTimer() - this.now) > this.maxSearchTime) {
trace("no solution");
this.keepSearching = false;
_root.astarfailed = 1;
}
}
st.text = getTimer() - this.now;
this.initialize();
return(this.path);
};
function check_for_obstacle_between_2_points(x1, y1, x2, y2) {
shag = spacing / 3;
yiffdgdfg = CALC_Dist_Xv_Yv(x2, y2, x1, y1);
xmod = yiffdgdfg[1];
ymod = yiffdgdfg[2];
xmod_ = xmod;
ymod_ = ymod;
distance = yiffdgdfg[0];
aaayiff = distance;
var _local2 = 1;
while (_local2 < 990) {
checkx = x1 + ((xmod_ * shag) * _local2);
checky = y1 + ((ymod_ * shag) * _local2);
cellname = cell_name_calculation(checkx, checky)[2];
walldetected = 0;
if (_root.yiff[cellname]._type_ eq 1) {
walldetected = 1;
break;
}
distcheck = CALC_Dist_Xv_Yv(checkx, checky, x1, y1)[0];
if (aaayiff < distcheck) {
break;
}
_local2++;
}
return(walldetected);
}
function cell_name_calculation(xx, yy) {
var _local2 = Math.ceil(xx / spacing);
var _local1 = Math.ceil(yy / spacing);
cellname = (("cell" + _local2) + "_") + _local1;
return([_local2, _local1, cellname]);
}
function CALC_Dist_Xv_Yv(x1, y1, x2, y2) {
A = {};
B = {};
A.xx = x1;
A.yy = y1;
B.xx = x2;
B.yy = y2;
dx = A.xx - B.xx;
dy = A.yy - B.yy;
distance = Math.sqrt((dx * dx) + (dy * dy));
dx_a = Math.abs(dx);
dy_a = Math.abs(dy);
if ((dx > 0) or (dx eq 0)) {
xmod = 1;
} else {
xmod = -1;
}
if ((dy > 0) or (dy eq 0)) {
ymod = 1;
} else {
ymod = -1;
}
if (dx_a > dy_a) {
spdmod = dy_a / dx_a;
x_modifier = xmod;
y_modifier = ymod * spdmod;
} else if (dx_a < dy_a) {
spdmod = dx_a / dy_a;
x_modifier = xmod * spdmod;
y_modifier = ymod;
} else {
x_modifier = xmod;
y_modifier = ymod;
}
return([distance, x_modifier, y_modifier, dx, dy]);
}
function rotation_towards_movement(trg, xspeed, yspeed) {
speedpovorota = 0.4;
dx = xspeed;
dy = yspeed;
angle1 = Math.atan2(dy, dx) * 57.2957795130823;
angle2 = trg._rotation;
if (angle2 < 0) {
angle2 = angle2 + 360;
}
if (angle1 < 0) {
angle1 = angle1 + 360;
}
aa = angle2 - angle1;
if (aa > 180) {
aa = aa - 360;
} else if (aa < -180) {
aa = aa + 360;
}
aa = aa * speedpovorota;
if (Math.abs(aa) > 0.01) {
trg._rotation = trg._rotation - aa;
} else {
trg._rotation = angle1;
}
}
function rotation_face_target(trgt1, trgt2) {
mewmewmewmewmewmew = CALC_Dist_Xv_Yv(trgt2._x, trgt2._y, trgt1._x, trgt1._y);
speedpovorota = 1;
trg = trgt1;
dx = mewmewmewmewmewmew[3];
dy = mewmewmewmewmewmew[4];
angle1 = Math.atan2(dy, dx) * 57.2957795130823;
angle2 = trg._rotation;
if (angle2 < 0) {
angle2 = angle2 + 360;
}
if (angle1 < 0) {
angle1 = angle1 + 360;
}
aa = angle2 - angle1;
if (aa > 180) {
aa = aa - 360;
} else if (aa < -180) {
aa = aa + 360;
}
aa = aa * speedpovorota;
if (Math.abs(aa) > 0.01) {
trg._rotation = trg._rotation - aa;
} else {
trg._rotation = angle1;
}
}
function poisk_blijaishei_vidimoi_celi(watcher) {
skolko_bragov = map_enemy_array_1.length;
var _local4 = new Array();
i = 0;
while (i < skolko_bragov) {
trgt = _root.yiff["enemy_" + i];
if (trgt and (trgt != watcher)) {
tr1 = trgt;
tr2 = watcher;
distance = CALC_Dist_Xv_Yv(tr1._x, tr1._y, tr2._x, tr2._y)[0];
tr1.tempvar_distance = distance;
if ((distance < watcher.visibility_radius) and (tr1.team != tr2.team)) {
_local4.push(trgt);
}
}
i++;
}
if (watcher != _root.yiff.character) {
tr1 = _root.yiff.character;
tr2 = watcher;
distance = CALC_Dist_Xv_Yv(tr1._x, tr1._y, tr2._x, tr2._y)[0];
tr1.tempvar_distance = distance;
if ((distance < watcher.visibility_radius) and (tr1.team != tr2.team)) {
_local4.push(_root.yiff.character);
}
}
if (_local4.length eq 0) {
return("none");
}
thelengthyiff666 = _local4.length;
var _local5 = new Array();
i = 0;
while (i < thelengthyiff666) {
trgt1 = _local4[i];
this["targetobj" + i] = {};
this["targetobj" + i].distance = trgt1.tempvar_distance;
this["targetobj" + i].id_absolute = trgt1;
_local5.push(this["targetobj" + i]);
i++;
}
_local5.sortOn("distance", Array.NUMERIC);
thelengthyiff666 = _local5.length;
returnresult = "none";
i = 0;
while (i < thelengthyiff666) {
trgt1 = _local5[i];
chk = check_for_obstacle_between_2_points(watcher._x, watcher._y, trgt1.id_absolute._x, trgt1.id_absolute._y);
if (chk eq 0) {
returnresult = trgt1.id_absolute;
break;
}
i++;
}
return(returnresult);
}
function set_character_movement_disabled() {
cell_clicked = cell_name_calculation(_root.yiff._xmouse, _root.yiff._ymouse)[2];
if (_root.yiff[cell_clicked].being_targeted_by_char eq 1) {
_root.docharactermovement = 1;
_root.lockcharcontrolz = 1;
delete_shownpath();
var _local4 = 1;
while (_local4 <= _root.field_height) {
var _local2 = 1;
while (_local2 <= _root.field_length) {
var _local3 = (("cell" + _local2) + "_") + _local4;
_root.yiff[_local3].being_targeted_by_char = 0;
_local2++;
}
_local4++;
}
} else {
var _local4 = 1;
while (_local4 <= _root.field_height) {
var _local2 = 1;
while (_local2 <= _root.field_length) {
var _local3 = (("cell" + _local2) + "_") + _local4;
_root.yiff[_local3].being_targeted_by_char = 0;
_local2++;
}
_local4++;
}
_root.yiff[cell_clicked].being_targeted_by_char = 1;
trgt1 = _root.yiff.character;
trgt2 = _root.yiff[cell_clicked];
trgt1.path = astarCalcAndShowPath(trgt1._x, trgt1._y, trgt2._x, trgt2._y, "true");
}
}
function charatcer_movement() {
if (movement_step_0 != "done") {
movement_step_0 = "done";
trgt = _root.yiff.character;
if (trgt.movepoints > 0) {
} else {
trgt.movepoints = trgt.movepoints_max;
_root.lockcharcontrolz = 0;
_root.docharactermovement = 0;
return(undefined);
}
cellarray = trgt.path.shift();
trgt.gowhere = _root.yiff[(("cell" + cellarray[0]) + "_") + cellarray[1]];
}
if (movement_step_1 != "done") {
movement_step_1 = "done";
movement_step_2 = 0;
trgt1 = trgt;
trgt2 = trgt1.gowhere;
yiffdgdfg = CALC_Dist_Xv_Yv(trgt2._x, trgt2._y, trgt1._x, trgt1._y);
trgt1.xmod = yiffdgdfg[1];
trgt1.ymod = yiffdgdfg[2];
}
if (movement_step_2 != "done") {
trgt1 = trgt;
trgt2 = trgt1.gowhere;
yiffdgdfg = CALC_Dist_Xv_Yv(trgt2._x, trgt2._y, trgt1._x, trgt1._y);
trgt1.distance = yiffdgdfg[0];
if (trgt1.distance <= trgt1.speed) {
trgt1._x = trgt2._x;
trgt1._y = trgt2._y;
movement_step_2 = "done";
movement_step_0 = "0";
movement_step_1 = "0";
trgt.movepoints--;
} else {
trgt1._x = trgt1._x + (trgt1.speed * trgt1.xmod);
trgt1._y = trgt1._y + (trgt1.speed * trgt1.ymod);
}
}
}
function roundProgressing_integrity() {
if (roundprogress_RoundEnd eq "go") {
roundprogress_RoundEnd = "done";
starttrace = 1;
roundprogress_step1 = "go";
roundprogress_step2 = "done";
roundprogress_step3 = "done";
roundprogress_step4 = "done";
roundprogress_step5 = "done";
roundprogress_step6 = "done";
roundprogress_step7 = "done";
roundprogress_step8 = "done";
roundprogress_step9 = "done";
roundprogress_step10 = "done";
roundprogress_step11 = "done";
roundprogress_step12 = "done";
roundprogress_step12_5 = "done";
roundprogress_step13 = "done";
roundprogress_step14 = "done";
roundprogress_step15 = "done";
roundprogress_step16 = "done";
}
if (roundprogress_AIdone eq "go") {
roundprogress_AIdone = "done";
roundprogress_step2 = "go";
roundprogress_step1 = "done";
roundprogress_step3 = "done";
roundprogress_step4 = "done";
roundprogress_step5 = "done";
roundprogress_step6 = "done";
roundprogress_step7 = "done";
roundprogress_step8 = "done";
roundprogress_step9 = "done";
roundprogress_step10 = "done";
roundprogress_step11 = "done";
roundprogress_step12 = "done";
roundprogress_step12_5 = "done";
roundprogress_step13 = "done";
roundprogress_step14 = "done";
roundprogress_step15 = "done";
roundprogress_step16 = "done";
}
if (roundprogress_step1 eq "go") {
roundprogress_step1 = "done";
enemy_ammount = _root.enemy_ammount_map_1;
initial_participants = [];
i = 0;
while (i < enemy_ammount) {
trgt1 = _root.yiff["enemy_" + i];
if (trgt1 and (trgt1.dmg < trgt1.hp)) {
this["enemy_identificator" + i] = {};
this["enemy_identificator" + i].initiative = trgt1.initiative;
this["enemy_identificator" + i].id = "enemy_" + i;
_root.initial_participants.push(this["enemy_identificator" + i]);
}
i++;
}
i = current_participants.length;
this["enemy_identificator" + i] = {};
this["enemy_identificator" + i].initiative = _root.yiff.character.initiative;
this["enemy_identificator" + i].id = "character";
_root.initial_participants.push(this["enemy_identificator" + i]);
_root.initial_participants.sortOn("initiative", Array.NUMERIC);
_root.initial_participants.reverse();
roundprogress_step2 = "go";
}
if (roundprogress_step2 eq "go") {
roundprogress_step2 = "done";
if (_root.initial_participants.length > 0) {
current_participant = _root.initial_participants.shift();
} else {
roundprogress_RoundEnd = "go";
}
current_participant = current_participant.id;
trtrgt = _root.yiff[current_participant];
if (trtrgt.dmg < trtrgt.hp) {
roundprogress_step2_5 = "go";
} else {
roundprogress_step2 = "go";
}
}
if (roundprogress_step2_5 eq "go") {
roundprogress_step2_5 = "done";
trtrgt.actpoints = trtrgt.actpoints_max;
trtrgt.movepoints = trtrgt.movepoints_max;
roundprogress_step3 = "go";
}
if (roundprogress_step3 eq "go") {
trtrgt = _root.yiff[current_participant];
trgt = trtrgt;
if (trtrgt eq _root.yiff.character) {
roundprogress_step3 = "done";
roundprogress_step2 = "go";
} else {
if (!trgt.idletime) {
trgt.idletime = 0;
}
trgt.idletime = trgt.idletime + 0.0333333333333333;
if (trgt.idletime > _root.idle_time_max) {
trgt.idletime = 0;
roundprogress_step3 = "done";
roundprogress_step4 = "go";
trgt.ring._visible = false;
} else {
trgt.ring._visible = true;
}
}
}
if (roundprogress_step4 eq "go") {
roundprogress_step4 = "done";
current_participant = trgt;
current_participant.current_target = poisk_blijaishei_vidimoi_celi(trgt);
if (current_participant.current_target eq "none") {
roundprogress_step12 = "go";
if (dotrace eq 1) {
trace(("step4 :" + current_participant) + " goto step 12");
}
} else {
roundprogress_step5 = "go";
if (dotrace eq 1) {
trace(("step4 :" + current_participant) + " goto step 5");
}
}
}
if (roundprogress_step5 eq "go") {
roundprogress_step5 = "done";
tr1 = current_participant.current_target;
tr2 = current_participant;
yiffdgdfg6786 = CALC_Dist_Xv_Yv(tr1._x, tr1._y, tr2._x, tr2._y);
distance = yiffdgdfg6786[0];
if (distance < tr2.attack_radius) {
roundprogress_step8 = "go";
if (dotrace eq 1) {
trace(((((("step5 :" + current_participant) + " distance: ") + distance) + " attackradius: ") + tr2.attack_radius) + " goto step 8");
}
} else {
roundprogress_step6 = "go";
if (dotrace eq 1) {
trace(((((("step5 :" + current_participant) + " distance: ") + distance) + " attackradius: ") + tr2.attack_radius) + " goto step 6");
}
}
}
if (roundprogress_step6 eq "go") {
roundprogress_step6 = "done";
if (current_participant.movepoints > 0) {
roundprogress_step6_5 = "go";
} else {
roundprogress_AIdone = "go";
}
}
if (roundprogress_step6_5 eq "go") {
roundprogress_step6_5 = "done";
ourtrg = current_participant.current_target;
yifxxx = cell_name_calculation(ourtrg._x, ourtrg._y)[0];
yifyyy = cell_name_calculation(ourtrg._x, ourtrg._y)[1];
trgtcell = _root.yiff[(("cell" + yifxxx) + "_") + yifyyy];
recalculate_map_obstacles();
astar.initialize();
initialize_obstacles();
obstacle_exclude(current_participant);
obstacle_exclude(ourtrg);
tr1 = current_participant;
tr2 = trgtcell;
thepath = astarCalcAndShowPath(tr1._x, tr1._y, tr2._x, tr2._y, "true");
current_participant.thepath = thepath;
if (thepath eq "none") {
roundprogress_step12 = "go";
} else {
roundprogress_step7 = "go";
rndstep7_sidestep1 = "go";
}
}
if (roundprogress_step7 eq "go") {
if (rndstep7_sidestep1 eq "go") {
rndstep7_sidestep1 = "done";
trgt1 = current_participant;
rndstep7_sidestep4 = "go";
rndstep7_sidestep2 = "done";
if (trgt1.thepath.length > 0) {
rndstep7_sidestep2 = "go";
} else {
rndstep7_sidestep2 = "done";
roundprogress_step7 = "done";
roundprogress_step4 = "go";
}
cellarray = trgt1.thepath.shift();
trgt1.gowhere = _root.yiff[(("cell" + cellarray[0]) + "_") + cellarray[1]];
trgt2 = trgt1.gowhere;
yiffdgdfg = CALC_Dist_Xv_Yv(trgt2._x, trgt2._y, trgt1._x, trgt1._y);
trgt1.xmod = yiffdgdfg[1];
trgt1.ymod = yiffdgdfg[2];
}
if (rndstep7_sidestep2 eq "go") {
yiffdgdfg = CALC_Dist_Xv_Yv(trgt2._x, trgt2._y, trgt1._x, trgt1._y);
trgt1.distance = yiffdgdfg[0];
if (trgt1.distance <= trgt1.speed) {
trgt1._x = trgt2._x;
trgt1._y = trgt2._y;
trgt1.movepoints--;
roundprogress_step7 = "done";
rndstep7_sidestep2 = "done";
roundprogress_step5 = "go";
trgt1.gotoAndStop(1);
} else {
if (rndstep7_sidestep4 eq "go") {
rndstep7_sidestep4 = "done";
trgt1.gotoAndStop(2);
}
xspeed = trgt1.speed * trgt1.xmod;
yspeed = trgt1.speed * trgt1.ymod;
trgt1._x = trgt1._x + xspeed;
trgt1._y = trgt1._y + yspeed;
rotation_towards_movement(trgt1, xspeed, yspeed);
}
}
}
if (roundprogress_step8 eq "go") {
roundprogress_step8 = "done";
if (current_participant.actpoints > 0) {
roundprogress_step9 = "go";
} else {
current_participant.actpoints = current_participant.actpoints_max;
roundprogress_AIdone = "go";
}
}
if (roundprogress_step9 eq "go") {
current_participant.current_target.gotoAndStop(1);
current_participant.current_target.idle.play();
current_participant.gotoAndStop(3);
rotation_face_target(current_participant, current_participant.current_target);
if (current_participant.animation.ended eq 1) {
roundprogress_step9 = "done";
roundprogress_step10 = "go";
current_participant.gotoAndStop(1);
current_participant.actpoints--;
tr1 = current_participant;
tr2 = current_participant.current_target;
tr2.dmg = tr2.dmg + ((tr1.dmg_min + 1) + random(tr1.dmg_max - tr1.dmg_min));
trace(tr2.dmg);
}
}
if (roundprogress_step10 eq "go") {
roundprogress_step10 = "done";
ttrtr = current_participant.current_target;
if (ttrtr.dmg < ttrtr.hp) {
roundprogress_step5 = "go";
} else {
iyiff = _root.yiff.corpse_shell.getNextHighestDepth();
_root.yiff.corpse_shell.attachMovie("dead_enemy_type_" + ttrtr.en_id, "enemy_" + iyiff, iyiff);
trgtrtrt = _root.yiff.corpse_shell["enemy_" + iyiff];
trgtrtrt._x = ttrtr._x;
trgtrtrt._y = ttrtr._y;
removeMovieClip(ttrtr);
roundprogress_step4 = "go";
}
}
if (roundprogress_step12 eq "go") {
roundprogress_step12 = "done";
yifxxx = 1 + random(28);
yifyyy = 1 + random(17);
trgtcell = _root.yiff[(("cell" + yifxxx) + "_") + yifyyy];
recalculate_map_obstacles();
astar.initialize();
initialize_obstacles();
obstacle_exclude(current_participant);
if (starttrace eq 1) {
}
tr1 = current_participant;
tr2 = trgtcell;
thepath = astarCalcAndShowPath(tr1._x, tr1._y, tr2._x, tr2._y, "true");
current_participant.thepath = thepath;
if (thepath eq "none") {
roundprogress_AIdone = "go";
} else {
roundprogress_step12_5 = "go";
}
}
if (roundprogress_step12_5 eq "go") {
roundprogress_step12_5 = "done";
if (current_participant.movepoints > 0) {
roundprogress_step13 = "go";
rndstep13_sidestep1 = "go";
rndstep13_sidestep2 = "done";
} else {
current_participant.movepoints = current_participant.movepoints_max;
roundprogress_AIdone = "go";
}
}
if (roundprogress_step13 eq "go") {
if (rndstep13_sidestep1 eq "go") {
rndstep13_sidestep1 = "done";
trgt1 = current_participant;
rndstep13_sidestep4 = "go";
if (trgt1.thepath.length > 0) {
rndstep13_sidestep2 = "go";
} else {
roundprogress_step12 = "go";
rndstep13_sidestep2 = "done";
}
cellarray = trgt1.thepath.shift();
trgt1.gowhere = _root.yiff[(("cell" + cellarray[0]) + "_") + cellarray[1]];
trgt2 = trgt1.gowhere;
yiffdgdfg = CALC_Dist_Xv_Yv(trgt2._x, trgt2._y, trgt1._x, trgt1._y);
trgt1.xmod = yiffdgdfg[1];
trgt1.ymod = yiffdgdfg[2];
}
if (rndstep13_sidestep2 eq "go") {
yiffdgdfg = CALC_Dist_Xv_Yv(trgt2._x, trgt2._y, trgt1._x, trgt1._y);
trgt1.distance = yiffdgdfg[0];
if (trgt1.distance <= trgt1.speed) {
trgt1._x = trgt2._x;
trgt1._y = trgt2._y;
trgt1.movepoints--;
roundprogress_step13 = "done";
roundprogress_step12_5 = "go";
rndstep13_sidestep2 = "done";
trgt1.gotoAndStop(1);
} else {
if (rndstep13_sidestep4 eq "go") {
rndstep13_sidestep4 = "done";
trgt1.gotoAndStop(2);
}
xspeed = trgt1.speed * trgt1.xmod;
yspeed = trgt1.speed * trgt1.ymod;
trgt1._x = trgt1._x + xspeed;
trgt1._y = trgt1._y + yspeed;
rotation_towards_movement(trgt1, xspeed, yspeed);
}
}
}
}
create_yiffingField();
buildGrid();
place_destination(26, 8);
place_character(3, 9);
astar.initialize();
initialize_walls();
initialize_enemies();
onMouseDown = function () {
if (_root.lockcharcontrolz != 1) {
if (set_character_movement_FNACTIVE != 1) {
set_character_movement_FNACTIVE = 1;
set_character_movement();
}
}
};
onMouseUp = function () {
set_character_movement_FNACTIVE = 0;
};
onEnterFrame = function () {
if (_root.docharactermovement eq 1) {
charatcer_movement();
}
roundProgressing_integrity();
if (_root.lockcharcontrolz eq 1) {
}
};
Symbol 12 Button
on (release) {
roundprogress_step1 = "go";
}
Symbol 18 MovieClip Frame 1
stop();
Symbol 22 MovieClip Frame 9
gotoAndPlay (2);
Symbol 23 MovieClip Frame 2
ended = 0;
Symbol 23 MovieClip Frame 10
ended = 1;
Symbol 24 MovieClip [enemy_type_2] Frame 1
stop();
Instance of Symbol 21 MovieClip "ring" in Symbol 24 MovieClip [enemy_type_2] Frame 1
onClipEvent (load) {
_visible = false;
}
Symbol 27 MovieClip Frame 1
stop();
Symbol 29 Button
on (release) {
trace(_name);
}
Symbol 46 MovieClip Frame 2
ended = 0;
Symbol 46 MovieClip Frame 10
ended = 1;
Symbol 47 MovieClip [enemy_type_1] Frame 1
stop();
Instance of Symbol 21 MovieClip "ring" in Symbol 47 MovieClip [enemy_type_1] Frame 1
onClipEvent (load) {
_visible = false;
}
Symbol 50 MovieClip [dead_enemy_type_1] Frame 40
stop();
Symbol 53 MovieClip [dead_enemy_type_2] Frame 59
stop();