Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 8 additions & 32 deletions objects/obj_enunit/Alarm_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,17 @@ var leftest,charge=0,enemy2=0,chapter_fuck=1,unit;

// with(obj_pnunit){if (x<-4000) or (defenses=1) then instance_deactivate_object(id);}

var _local_fort = instance_exists(obj_nfort);
if (!flank){
leftest=get_leftmost(obj_enunit, false);// Left most enunit
enemy=get_rightmost();// Right most enemy
enemy2=enemy;
if (enemy=="none"||leftest=="none"){
if (enemy=="none"){
exit;
}
// if (collision_point(x-10,y,obj_pnunit,0,1)) then engaged=1;
// if (!collision_point(x-10,y,obj_pnunit,0,1)) then engaged=0;


if (leftest.id=self.id) and (!instance_exists(obj_nfort)){
if (position_empty(x-10,y)) and (point_distance(x,y,enemy.x,enemy.y)>=10){
with(obj_enunit){
move_unit_block("west");
}
}
if (!_local_fort){
move_unit_block("west");
}


//if (point_distance(x,0,enemy.x,0)<5) then x+=10;
// instance_activate_object(obj_cursor);
}
Expand All @@ -42,11 +33,10 @@ else if (flank=1){
}
// if (collision_point(x+10,y,obj_pnunit,0,1)) then engaged=1;
// if (!collision_point(x+10,y,obj_pnunit,0,1)) then engaged=0;
if (position_empty(x+10,y)){
if (!_local_fort){
move_unit_block("east");
} else if (!position_empty(x+10,y)){
engaged=true;// Quick smash
}

// instance_activate_object(obj_cursor);
}

Expand Down Expand Up @@ -325,29 +315,15 @@ with(obj_pnunit){
}

if (flank=0){
leftest=get_leftmost(obj_enunit, false);// Left most enunit
enemy=instance_nearest(4000,y,obj_pnunit);// Right most enemy
enemy2=enemy;
// if (collision_point(x-10,y,obj_pnunit,0,1)) then engaged=1;
// if (!collision_point(x-10,y,obj_pnunit,0,1)) then engaged=0;
if (leftest.id=self.id) and (!instance_exists(obj_nfort)){
// instance_deactivate_object(obj_cursor);
if (position_empty(x-10,y)){
with(obj_enunit){
x-=10;
}
}
}
move_unit_block("west");
// instance_activate_object(obj_cursor);
}
if (flank=1){
enemy=instance_nearest(x,y,obj_pnunit);// Right most enemy
enemy2=enemy;
// if (collision_point(x+10,y,obj_pnunit,0,1)) then engaged=1;
// if (!collision_point(x+10,y,obj_pnunit,0,1)) then engaged=0;
if (position_empty(x+10,y)){
move_unit_block();
}
move_unit_block();

if (!position_empty(x+10,y)) then engaged=1;// Quick smash
// instance_activate_object(obj_cursor);
Expand Down
8 changes: 5 additions & 3 deletions objects/obj_enunit/Alarm_5.gml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@


if (obj_ncombat.enemy=1){
/*if (obj_ncombat.enemy=1){
repeat(10){
if (!collision_point(x-10,y,obj_pnunit,0,1)) and (!collision_point(x-10,y,obj_enunit,0,1)) then x-=10;
if (!collision_point(x-10,y,obj_pnunit,0,1)) and (!collision_point(x-10,y,obj_enunit,0,1)){
move_unit_block("west");
}
}
}
}*/



Expand Down
8 changes: 5 additions & 3 deletions objects/obj_enunit/Alarm_6.gml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

repeat(10){
if (!collision_point(x-10,y,obj_pnunit,0,1)) and (!collision_point(x-10,y,obj_enunit,0,1)) then x-=10;
}
/*repeat(10){
if (!collision_point(x-10,y,obj_pnunit,0,1)) and (!collision_point(x-10,y,obj_enunit,0,1)) {
move_unit_block("west");
}
}*/


10 changes: 7 additions & 3 deletions objects/obj_enunit/Destroy_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
// if (dudes[1]!="") then show_message(string(dudes[1])+"|"+string(dudes_num[1])+"|"+string(men+medi)+"|"+string(dudes_hp[1]));



/*
if (obj_ncombat.started=1){
// show_message(string(dudes[1])+"|"+string(dudes_num[1])+"|"+string(men+medi)+"|"+string(dudes_hp[1]));
with(obj_enunit){if (flank=0) then x-=10;}
with(obj_enunit){
if (flank=0) {
move_unit_block("west");
}
}
}


*/
// show_message(men);

23 changes: 1 addition & 22 deletions objects/obj_ncombat/Alarm_2.gml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,7 @@ enemy_max=enemy_forces;
instance_activate_object(obj_enunit);

if (dropping){
var _player_front_row=get_rightmost();
if (_player_front_row!="none"){
if (!collision_point(_player_front_row.x+10,_player_front_row.y,obj_enunit,0,1)) then with(obj_pnunit){
var _enemy_front = get_leftmost(obj_enunit, false);
if (_enemy_front!="none"){
_player_front_row.x = _enemy_front.x-10;
}
}
}
repeat(10){
with(obj_enunit){
if (!flank){
if (!collision_point(x-10,y,obj_pnunit,0,1)) and (!collision_point(x-10,y,obj_enunit,0,1)){
move_unit_block("west");
}
} else {
if (!collision_point(x+10,y,obj_pnunit,0,1)) and (!collision_point(x+10,y,obj_enunit,0,1)){
move_unit_block("east");
}
}
}
}
squeeze_map_forces();
}


Expand Down
14 changes: 3 additions & 11 deletions objects/obj_pnunit/Alarm_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ enemy=instance_nearest(0,y,obj_enunit);// Left most enemy
enemy2=enemy;

if (obj_ncombat.defending=false) or (obj_ncombat.dropping=1){
if (!collision_point(rightest.x+10,y+1,obj_enunit,0,1)) and (collision_line(x,y+1,x+1000,y,obj_enunit,0,1)){
move_unit_block();
}
if (self.id!=rightest.id) and (!collision_point(x+10,y,obj_pnunit,0,1)) and (collision_line(x,y,x+1000,y,obj_enunit,0,1)){
move_unit_block();
}

if (!collision_line(x,y,x+1000,y,obj_enunit,0,1)) and (collision_line(x,y,x-1000,y,obj_enunit,0,1)){
if (!collision_point(x-10,y,obj_pnunit,0,1)) then x-=10;
}
move_unit_block();
}

if (!instance_exists(enemy)) then exit;
Expand Down Expand Up @@ -92,7 +83,8 @@ if (instance_exists(obj_enunit)){
var x2=enemy.x;
repeat(instance_number(obj_enunit)-1){
if (good=0){
x2+=10;enemy2=instance_nearest(x2,y,obj_enunit);
x2+=10;
enemy2=instance_nearest(x2,y,obj_enunit);
if (enemy2.veh>0) and (good=0){
good=scr_target(enemy2,"veh");// This target has vehicles, blow it to hell
scr_shoot(i,enemy2,good,"arp","ranged");
Expand Down
8 changes: 1 addition & 7 deletions scripts/scr_clean/scr_clean.gml
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,8 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam
// ### Cleanup ###
// If the target_object got wiped out, move it off-screen
if ((men + veh + dreads) <= 0) {

var right = get_rightmost(obj_pnunit);
if (right.id == self.id) {
with (obj_pnunit) {
move_unit_block();
}
}
x = -5000;
instance_deactivate_object(id);
}
}
}
104 changes: 92 additions & 12 deletions scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
// Script assets have changed for v2.3.0 see
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information

function squeeze_map_forces(){
var _player_front_row=get_rightmost();
var _enemy_front = get_leftmost(obj_enunit, false);
if (_player_front_row!="none" && _enemy_front!="none"){
if (!collision_point(_player_front_row.x+10,_player_front_row.y,obj_enunit,0,1)){
var _enemy_front = get_leftmost(obj_enunit, false);
if (_enemy_front!="none"){
var _move_distance = calculate_block_distances(_player_front_row, _enemy_front) -2;
with (obj_pnunit){
move_unit_block("east", _move_distance, true);
}
}
}
}

/* var _enemy_front = get_leftmost(obj_enunit, false);
if (_enemy_front!="none"){
var _player_front_row=get_rightmost();
if (_player_front_row!="none"){
var _move_distance = calculate_block_distances(_player_front_row, _enemy_front) -1;
with (obj_enunit){
if (!flank && _player_front_row.x<x){
move_unit_block("west", _move_distance);
}
}
}
}*/

var _player_rear = get_leftmost();
if (_player_rear!="none"){
var _enemy_flank = get_rightmost(obj_enunit, true, false);
if (_enemy_flank!="none"){
if (_enemy_flank.flank){
var _move_distance = calculate_block_distances(_player_rear, _enemy_flank) -1;
with (obj_enunit){
if (flank && _player_rear.x>x){
move_unit_block("east", _move_distance, true);
}
}
}
}
}
}
function target_block_is_valid(target, desired_type){
var _is_valid = false
if (target=="none") then return false;
Expand All @@ -19,15 +61,19 @@ function target_block_is_valid(target, desired_type){
return _is_valid;
}

function get_rightmost(block_type=obj_pnunit){
function get_rightmost(block_type=obj_pnunit,include_flanking=true, include_main_force=true){
var rightmost = "none";
if (instance_exists(block_type)){
with (block_type){
if (!include_flanking && flank) then continue;
if (!include_main_force && !flank) then continue;
if x<=0 then continue;
if (men+veh+dreads<=0){
x=-5000;
instance_deactivate_object(id);
continue;
if (block_type==obj_pnunit){
if (men+veh+dreads<=0){
x=-5000;
instance_deactivate_object(id);
continue;
}
}
if(rightmost=="none" && x >0){
rightmost=block_type.id;
Expand All @@ -51,10 +97,12 @@ function get_leftmost(block_type=obj_pnunit, include_flanking=true){
with (block_type){
if (!include_flanking && flank) then continue;
if x<=0 then continue;
if (men+veh+dreads<=0){
x=-5000;
instance_deactivate_object(id);
continue;
if (block_type==obj_pnunit){
if (men+veh+dreads<=0){
x=-5000;
instance_deactivate_object(id);
continue;
}
}
if(left_most=="none" && x >0){
left_most=block_type.id;
Expand All @@ -70,12 +118,44 @@ function get_leftmost(block_type=obj_pnunit, include_flanking=true){
function get_block_distance(block){
return point_distance(x,y,block.x,block.y)/10;
}
function move_unit_block(direction="east", blocks=1){

function calculate_block_distances(first_block, second_block){
if (first_block.x==second_block.x){
return 0;
} else {
if (first_block.x<second_block.x){
var _temp_holder = second_block;
second_block = first_block;
first_block = _temp_holder;
}
}
return floor(floor(((first_block.x - second_block.x))/10));
}

function block_position_collision(position_x, position_y){
return collision_point(position_x, position_y,obj_enunit,0,1) || collision_point(position_x, position_y,obj_pnunit,0,1);
}

function move_unit_block(direction="east", blocks=1, allow_collision=false, allow_passing=false){
distance = 10*blocks;
if (direction=="east"){
x+=distance;
var _new_pos = x+distance;
if (allow_collision=false){
if (!block_position_collision(_new_pos, y)){
x=_new_pos;
}
} else {
x=_new_pos;
}
}
else if (direction=="west"){
x-=distance;
var _new_pos = x-distance;
if (allow_collision=false){
if (!block_position_collision(_new_pos, y)){
x=_new_pos;
}
} else {
x=_new_pos;
}
}
}