From 2b96954066e89a52ef553f4ef0e5683319941f71 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 10 Nov 2024 19:38:14 +0000 Subject: [PATCH] add timer to combat fix enemy phasing through and fix captains fighting --- objects/obj_enunit/Alarm_0.gml | 20 ++++++++++------ objects/obj_ncombat/Alarm_2.gml | 23 ++++++++++++++----- objects/obj_ncombat/Alarm_5.gml | 10 ++++++-- objects/obj_ncombat/Alarm_7.gml | 9 +++++--- objects/obj_ncombat/Create_0.gml | 2 +- objects/obj_ncombat/KeyPress_13.gml | 9 ++++++++ .../scr_player_combat_weapon_stacks.gml | 16 +++++++------ .../scr_punit_combat_heplers.gml | 3 ++- 8 files changed, 65 insertions(+), 27 deletions(-) diff --git a/objects/obj_enunit/Alarm_0.gml b/objects/obj_enunit/Alarm_0.gml index 6b387f3f85..4697066da4 100644 --- a/objects/obj_enunit/Alarm_0.gml +++ b/objects/obj_enunit/Alarm_0.gml @@ -12,7 +12,7 @@ var leftest,charge=0,enemy2=0,chapter_fuck=1,unit; // with(obj_pnunit){if (x<-4000) or (defenses=1) then instance_deactivate_object(id);} if (!flank){ - leftest=get_leftmost(obj_enunit);// Left most enunit + leftest=get_leftmost(obj_enunit, false);// Left most enunit enemy=get_rightmost();// Right most enemy enemy2=enemy; if (enemy=="none"||leftest=="none"){ @@ -23,7 +23,7 @@ if (!flank){ 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){ + if (position_empty(x-10,y)) and (point_distance(x,y,enemy.x,enemy.y)>=10){ with(obj_enunit){ move_unit_block("west"); } @@ -318,12 +318,14 @@ if __b__ -var leftest,charge,enemy2;charge=0;enemy2=0; +var leftest,charge=0,enemy2=0; -with(obj_pnunit){if (x<-4000) then instance_deactivate_object(id);} +with(obj_pnunit){ + if (x<-4000) then instance_deactivate_object(id); +} if (flank=0){ - leftest=get_leftmost(obj_enunit);// Left most enunit + 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; @@ -331,7 +333,9 @@ if (flank=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;} + with(obj_enunit){ + x-=10; + } } } // instance_activate_object(obj_cursor); @@ -341,7 +345,9 @@ 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)) then x+=10; + if (position_empty(x+10,y)){ + move_unit_block(); + } if (!position_empty(x+10,y)) then engaged=1;// Quick smash // instance_activate_object(obj_cursor); diff --git a/objects/obj_ncombat/Alarm_2.gml b/objects/obj_ncombat/Alarm_2.gml index 4dd7fe8bec..4b075d7692 100644 --- a/objects/obj_ncombat/Alarm_2.gml +++ b/objects/obj_ncombat/Alarm_2.gml @@ -4,16 +4,27 @@ enemy_max=enemy_forces; instance_activate_object(obj_enunit); -if (dropping=1){ - repeat(10){ - var mm=instance_nearest(5000,240,obj_pnunit); - if (!collision_point(mm.x+10,mm.y,obj_enunit,0,1)) then with(obj_pnunit){ - x+=10; +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 (!collision_point(x-10,y,obj_pnunit,0,1)) and (!collision_point(x-10,y,obj_enunit,0,1)) then x-=10; + 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"); + } + } } } } diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 728f0908cb..3e75e54fc9 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -9,11 +9,14 @@ alarm[8]=999999; // show_message("Final Deaths: "+string(final_deaths)); +if (turn_count >= 50){ + part1 = "Your forces make a fighting retreat \n" +} // check for wounded marines here to finish off, if defeated defending var roles = obj_ini.role[100]; var ground_mission = (instance_exists(obj_ground_mission)); if (final_deaths+final_command_deaths>0){ - part1=$"Marines Lost: {final_deaths+final_command_deaths}"; + part1+=$"Marines Lost: {final_deaths+final_command_deaths}"; if (units_saved > 0){ part1+=$" ({roles[Role.APOTHECARY]}{apothecaries_alive>1?"s":""} prevented the death of {units_saved})"; } @@ -28,7 +31,10 @@ if (final_deaths+final_command_deaths>0){ part2=string_delete(part2,string_length(part2)-1,2); part2+=".";i=0; - if (injured>0){newline=part8;scr_newtext();} + if (injured>0){ + newline=part8; + scr_newtext(); + } newline=part1; scr_newtext(); newline=part2; diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 13ec4fe617..e84a628a7b 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -267,12 +267,15 @@ if (scr_role_count("Chapter Master","")=0){ } +if (turn_count < 20){ + if (defeat=0) and (threat>=4) then scr_recent("battle_victory",string(battle_loc)+" "+scr_roman(battle_id),enemy); -if (defeat=0) and (threat>=4) then scr_recent("battle_victory",string(battle_loc)+" "+scr_roman(battle_id),enemy); - -if (defeat=1) and (final_deaths+final_command_deaths>=10) then scr_recent("battle_defeat",string(enemy),final_deaths+final_command_deaths); + if (defeat=1) and (final_deaths+final_command_deaths>=10) then scr_recent("battle_defeat",string(enemy),final_deaths+final_command_deaths); +} else { + scr_recent("battle_defeat",string(enemy),final_deaths+final_command_deaths); +} diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index 865f4cb397..57cedd8c9c 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -9,7 +9,7 @@ repeat(15){co+=1;i=-1; } }co=0;i=0;hue=0; - +turn_count = 0; debugl("Ground Combat Started"); audio_stop_sound(snd_royal); diff --git a/objects/obj_ncombat/KeyPress_13.gml b/objects/obj_ncombat/KeyPress_13.gml index f4aa2a6e88..6c80120e0a 100644 --- a/objects/obj_ncombat/KeyPress_13.gml +++ b/objects/obj_ncombat/KeyPress_13.gml @@ -36,6 +36,11 @@ if (started=3){ // if (done>=1) then exit; + + +if (turn_count >= 50){ + started=2; +} if ((started=2) or (started=4)){ instance_activate_object(obj_pnunit); instance_activate_object(obj_enunit); @@ -99,6 +104,7 @@ if (timer_stage=1) or (timer_stage=5){ if (instance_exists(obj_pnunit)){ obj_pnunit.alarm[3]=2; obj_pnunit.alarm[1]=3; + turn_count++; obj_pnunit.alarm[0]=4; } // alarm[9]=5; @@ -111,6 +117,7 @@ if (timer_stage=1) or (timer_stage=5){ } if (instance_exists(obj_pnunit)){ obj_pnunit.alarm[1]=1; + turn_count++; } } messages=0;messages_to_show=8;largest=0;random_messages=0;priority=0;messages_shown=0; @@ -127,6 +134,7 @@ else if (timer_stage=3){ if (enemy!=6){ if (instance_exists(obj_pnunit)){ obj_pnunit.alarm[1]=1; + turn_count++; } if (instance_exists(obj_enunit)){ obj_enunit.alarm[1]=2; @@ -142,6 +150,7 @@ else if (timer_stage=3){ if (instance_exists(obj_pnunit)){ obj_pnunit.alarm[3]=2; obj_pnunit.alarm[1]=3; + turn_count++; obj_pnunit.alarm[0]=4; turns+=1; } diff --git a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml index f7b6820053..34a633cbfc 100644 --- a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml +++ b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml @@ -98,9 +98,11 @@ function scr_player_combat_weapon_stacks() { if (defenses=1) then exit; - var i,g=0;men=0;dreads=0; - veh=0 - for (i=1;i=0) then marine_casting[g]=0; if (marine_casting[g]<0) then marine_casting[g]+=1;//timer for libs to be able to cast - if ((marine_id[g]>0) or (ally[g]=true)) and (unit.hp()>0) then marine_dead[g]=0; - if ((marine_id[g]>0) or (ally[g]=true)) and (unit.hp()>0) and (marine_dead[g]!=1){ + if (unit.hp()>0) then marine_dead[g]=0; + if (unit.hp()>0 && marine_dead[g]!=true){ var head_role = unit.IsSpecialist(); var armour_data = unit.get_armour_data(); var is_dreadnought = false; @@ -183,7 +185,7 @@ function scr_player_combat_weapon_stacks() { } var j=0,good=0,open=0;// Counts the number and types of marines within this object - for (j=1;j<=40;j++){ + for (j=0;j<=40;j++){ if (dudes[j]=="") and (open==0){ open=j;// Determine if vehicle here @@ -258,7 +260,7 @@ function scr_player_combat_weapon_stacks() { if (weapon_check!=""){ weapon=gear_weapon_data("weapon",weapon_check,"all", false, "standard"); if (is_struct(weapon)){ - for (j=1;j<=40;j++){ + for (j=0;j<=40;j++){ if (wep[j]==""||wep[j]==weapon.name){ add_data_to_stack(j,weapon); break; 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 25bb808e0a..ad4cc18b68 100644 --- a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml +++ b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml @@ -45,10 +45,11 @@ function block_has_armour(target){ return target.veh+target.dreads; } -function get_leftmost(block_type=obj_pnunit){ +function get_leftmost(block_type=obj_pnunit, include_flanking=true){ var left_most = "none"; if (instance_exists(block_type)){ with (block_type){ + if (!include_flanking && flank) then continue; if x<=0 then continue; if (men+veh+dreads<=0){ x=-5000;