diff --git a/objects/obj_enunit/Alarm_0.gml b/objects/obj_enunit/Alarm_0.gml index 4697066da4..8c995e9fc8 100644 --- a/objects/obj_enunit/Alarm_0.gml +++ b/objects/obj_enunit/Alarm_0.gml @@ -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); } @@ -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); } @@ -325,19 +315,7 @@ 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){ @@ -345,9 +323,7 @@ if (flank=1){ 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); diff --git a/objects/obj_enunit/Alarm_5.gml b/objects/obj_enunit/Alarm_5.gml index dbfd8710c3..95c294f2e2 100644 --- a/objects/obj_enunit/Alarm_5.gml +++ b/objects/obj_enunit/Alarm_5.gml @@ -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"); + } } -} +}*/ diff --git a/objects/obj_enunit/Alarm_6.gml b/objects/obj_enunit/Alarm_6.gml index b51f71e83b..f2f6b0c758 100644 --- a/objects/obj_enunit/Alarm_6.gml +++ b/objects/obj_enunit/Alarm_6.gml @@ -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"); + } +}*/ diff --git a/objects/obj_enunit/Destroy_0.gml b/objects/obj_enunit/Destroy_0.gml index 27ef8d32b5..3418e36ac4 100644 --- a/objects/obj_enunit/Destroy_0.gml +++ b/objects/obj_enunit/Destroy_0.gml @@ -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); diff --git a/objects/obj_ncombat/Alarm_2.gml b/objects/obj_ncombat/Alarm_2.gml index 4b075d7692..bf67e79f26 100644 --- a/objects/obj_ncombat/Alarm_2.gml +++ b/objects/obj_ncombat/Alarm_2.gml @@ -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(); } diff --git a/objects/obj_pnunit/Alarm_0.gml b/objects/obj_pnunit/Alarm_0.gml index e1088f1d71..31d67dd0ac 100644 --- a/objects/obj_pnunit/Alarm_0.gml +++ b/objects/obj_pnunit/Alarm_0.gml @@ -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; @@ -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"); diff --git a/scripts/scr_clean/scr_clean.gml b/scripts/scr_clean/scr_clean.gml index 2e7d62c30b..df33a6c091 100644 --- a/scripts/scr_clean/scr_clean.gml +++ b/scripts/scr_clean/scr_clean.gml @@ -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); } } } diff --git a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml index ad4cc18b68..428c5e6479 100644 --- a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml +++ b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml @@ -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.xx){ + 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; @@ -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; @@ -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; @@ -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