From ea2e004bd44274ab250aa58b34ab867293c0c83d Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 04:18:17 +0300 Subject: [PATCH 1/5] feat: A bunch of changes to battle columns --- objects/obj_centerline/Step_0.gml | 4 +- objects/obj_enunit/Alarm_0.gml | 4 +- objects/obj_enunit/Create_0.gml | 17 ++- objects/obj_enunit/Draw_0.gml | 120 +++++++++++++----- objects/obj_enunit/Step_0.gml | 77 +---------- objects/obj_pnunit/Create_0.gml | 15 ++- objects/obj_pnunit/Draw_0.gml | 89 ++++++------- objects/obj_pnunit/Step_0.gml | 42 +----- .../scr_punit_combat_heplers.gml | 35 +++++ .../scr_string_functions.gml | 10 ++ 10 files changed, 196 insertions(+), 217 deletions(-) diff --git a/objects/obj_centerline/Step_0.gml b/objects/obj_centerline/Step_0.gml index ba65dc90c0..d05a341736 100644 --- a/objects/obj_centerline/Step_0.gml +++ b/objects/obj_centerline/Step_0.gml @@ -1,7 +1,7 @@ - +/* if (instance_exists(obj_pnunit)){ var _nearest = instance_nearest(-100,240,obj_pnunit); if (instance_exists(_nearest)){ x = _nearest.x; } -} +} */ diff --git a/objects/obj_enunit/Alarm_0.gml b/objects/obj_enunit/Alarm_0.gml index ed57151427..51479cc94d 100644 --- a/objects/obj_enunit/Alarm_0.gml +++ b/objects/obj_enunit/Alarm_0.gml @@ -129,7 +129,7 @@ if (!engaged){ // Shooting continue; } else if (instance_number(obj_pnunit) > 1) { // There were no marines in the first column, looking behind; - var _column_size_value = (enemy.veh * 2.5) + (enemy.dreads * 2) + (enemy.men * 0.5); + var _column_size_value = enemy.column_size; var x2 = enemy.x; repeat (instance_number(obj_pnunit) - 1) { @@ -145,7 +145,7 @@ if (!engaged){ // Shooting break; } - var _back_column_size_value = (enemy2.veh * 2.5) + (enemy2.dreads * 2) + (enemy2.men * 0.5); + var _back_column_size_value = enemy2.column_size; if (_back_column_size_value < _column_size_value) { // show_debug_message($"Protection value is too big!"); continue; diff --git a/objects/obj_enunit/Create_0.gml b/objects/obj_enunit/Create_0.gml index 5c129c30b6..1518eb8530 100644 --- a/objects/obj_enunit/Create_0.gml +++ b/objects/obj_enunit/Create_0.gml @@ -11,9 +11,16 @@ flank=0; flyer=0;// Works same as flank, but does not get denoted as such neww=0; -highlight=0; -highlight2=0; -highlight3=""; +column_size=0; + +unit_count=0; +unit_count_old=0; +composition_string=""; + +pos = 880; +centerline_offset = 0; +draw_size = 0; + enemy=0; enemy2=0; @@ -72,7 +79,3 @@ if (obj_ncombat.enemy=1) then alarm[6]=10; // if (obj_ncombat.enemy=1){alarm[1]=8;alarm[5]=10;} - -pos = 0; -diff = 0; -siz = 0; diff --git a/objects/obj_enunit/Draw_0.gml b/objects/obj_enunit/Draw_0.gml index acc1e69544..11eeeaa12b 100644 --- a/objects/obj_enunit/Draw_0.gml +++ b/objects/obj_enunit/Draw_0.gml @@ -1,43 +1,93 @@ +draw_size = min(400, column_size); -if (instance_exists(obj_pnunit)){ - diff=0;pos=880; - siz=min(400,(men*0.5)+(medi)+(veh*2.5)+(dreads*2)); -} +if (draw_size > 0){ + draw_set_alpha(1); + draw_set_color(c_maroon); + if (obj_ncombat.enemy=2) then draw_set_color(8307806); + if (obj_ncombat.enemy=3) then draw_set_color(16512); + if (obj_ncombat.enemy=5) then draw_set_color(c_silver); + if (obj_ncombat.enemy=6) then draw_set_color(33023); + if (obj_ncombat.enemy=7) then draw_set_color(38144); + if (obj_ncombat.enemy=8) then draw_set_color(117758); + if (obj_ncombat.enemy=9) then draw_set_color(7492269); + if (obj_ncombat.enemy=10) then draw_set_color(c_purple); + if (obj_ncombat.enemy=13) then draw_set_color(65408); + if (instance_exists(obj_centerline)){ + centerline_offset=x-obj_centerline.x; + } -draw_set_color(c_white); -if (instance_exists(obj_centerline)) and (instance_exists(obj_pnunit)){ - diff=x-obj_centerline.x; -} + var _hit = scr_hit(pos+(centerline_offset*2),450-(draw_size/2),pos+(centerline_offset*2)+10,450+(draw_size/2)) && obj_ncombat.fadein<=0; + if (_hit) { + draw_set_alpha(0.8); + } + draw_rectangle(pos+(centerline_offset*2),450-(draw_size/2),pos+(centerline_offset*2)+10,450+(draw_size/2),0); -draw_set_color(c_maroon); -if (obj_ncombat.enemy=2) then draw_set_color(8307806); -if (obj_ncombat.enemy=3) then draw_set_color(16512); -if (obj_ncombat.enemy=5) then draw_set_color(c_silver); -if (obj_ncombat.enemy=6) then draw_set_color(33023); -if (obj_ncombat.enemy=7) then draw_set_color(38144); -if (obj_ncombat.enemy=8) then draw_set_color(117758); -if (obj_ncombat.enemy=9) then draw_set_color(7492269); -if (obj_ncombat.enemy=10) then draw_set_color(c_purple); -if (obj_ncombat.enemy=13) then draw_set_color(65408); + if (_hit) { + if (unit_count != unit_count_old) { + unit_count_old = unit_count; + if (obj_ncombat.enemy!=1){ + composition_string += string_unit_composition(); + } else { + var variety, variety_num, stop, sofar, compl, vas; + stop = 0; + variety = []; + variety_num = []; + sofar = 0; + compl = ""; + vas = ""; + + var variety_len = array_length(variety); + for (var q = 0; q < variety_len; q++) { + variety[q] = ""; + variety_num[q] = 0; + } + var dudes_len = array_length(dudes); + for (var q = 0; q < dudes_len; q++) { + if (dudes[q] != "") and(string_count(string(dudes[q]) + "|", compl) = 0) { + compl += string(dudes[q]) + "|"; + variety[sofar] = dudes[q]; + variety_num[sofar] = 0; + sofar += 1; + } + } + var dudes_len = array_length(dudes); + for (var q = 0; q < dudes_len; q++) { + if (dudes[q] != "") { + var variety_len = array_length(variety); + for (var i = 0; i < variety_len; i++) { + if (dudes[q] = variety[i]) then variety_num[i] += dudes_num[q]; + } + } + + } + stop = 0; + var variety_num_len = array_length(variety_num); + for (var i = 0; i < variety_num_len; i++) { + if (stop = 0) { + if (variety_num[i] > 0) and(variety_num[i + 1] > 0) then composition_string += string(variety_num[i]) + "x " + string(variety[i]) + ", "; + if (variety_num[i] > 0) and(variety_num[i + 1] <= 0) { + composition_string += string(variety_num[i]) + "x " + string(variety[i]) + ". "; + stop = 1; + } + } + } + } + } -if (siz>0){ - draw_set_alpha(1); - if (highlight>0) then draw_set_alpha(0.8); - if ((pos+(diff*2))>817) and ((pos+(diff*2))<1575){ - draw_rectangle(pos+(diff*2),450-(siz/2),pos+(diff*2)+10,450+(siz/2),0); + draw_set_alpha(1); + draw_set_color(38144); + draw_line_width(pos+(centerline_offset*2)+5,450,817,685, 2); + draw_set_font(fnt_40k_14b); + draw_text(817,688,"Row Composition:"); + draw_set_font(fnt_40k_14); + draw_text_ext(817,710,composition_string,-1,758); } - draw_set_alpha(1); -} -if (highlight>0) and (obj_ncombat.fadein<=0){ - draw_set_color(38144); - draw_line(pos+(diff*2)+5,450,817,685); - draw_set_font(fnt_40k_14b); - draw_text(817,688,string_hash_to_newline("Row Composition:")); - draw_set_font(fnt_40k_14); - draw_text_ext(817,706,string_hash_to_newline(string(highlight3)),-1,758); + if (obj_ncombat.fadein > 0) { + draw_set_color(c_black); + draw_set_alpha(obj_ncombat.fadein/30); + draw_rectangle(822,239,1574,662,0); + draw_set_alpha(1); + } } - - - diff --git a/objects/obj_enunit/Step_0.gml b/objects/obj_enunit/Step_0.gml index 5332b33ae1..adc2902dd2 100644 --- a/objects/obj_enunit/Step_0.gml +++ b/objects/obj_enunit/Step_0.gml @@ -1,76 +1,3 @@ +column_size = (men*0.5)+(medi)+(dreads*2)+(veh*2.5); -highlight=0; -var diff,siz,pos; -diff=0;pos=880;siz=min(400,(men*0.5)+(medi)+(veh*2.5)+(dreads*2)); -if (instance_exists(obj_centerline)){ - diff=x-obj_centerline.x; -} -if (siz>0){ - if ((pos+(diff*2))>817) and ((pos+(diff*2))<1575){ - if (mouse_x>=pos+(diff*2)) and (mouse_y>=450-(siz/2)) - and (mouse_x0) and (dudes_num[i+1]>0) then highlight3+=string(dudes_num[i])+"x "+string(dudes[i])+", "; - if (dudes_num[i]>0) and (dudes_num[i+1]<=0){highlight3+=string(dudes_num[i])+"x "+string(dudes[i])+". ";stop=1;} - } - } - } - - if (obj_ncombat.enemy = 1) { - var variety, variety_num, stop, sofar, compl, vas; - stop = 0; - variety = []; - variety_num = []; - sofar = 0; - compl = ""; - vas = ""; - - var variety_len = array_length(variety); - for (var q = 0; q < variety_len; q++) { - variety[q] = ""; - variety_num[q] = 0; - } - var dudes_len = array_length(dudes); - for (var q = 0; q < dudes_len; q++) { - if (dudes[q] != "") and(string_count(string(dudes[q]) + "|", compl) = 0) { - compl += string(dudes[q]) + "|"; - variety[sofar] = dudes[q]; - variety_num[sofar] = 0; - sofar += 1; - } - } - var dudes_len = array_length(dudes); - for (var q = 0; q < dudes_len; q++) { - if (dudes[q] != "") { - var variety_len = array_length(variety); - for (var i = 0; i < variety_len; i++) { - if (dudes[q] = variety[i]) then variety_num[i] += dudes_num[q]; - } - } - - } - stop = 0; - var variety_num_len = array_length(variety_num); - for (var i = 0; i < variety_num_len; i++) { - if (stop = 0) { - if (variety_num[i] > 0) and(variety_num[i + 1] > 0) then highlight3 += string(variety_num[i]) + "x " + string(variety[i]) + ", "; - if (variety_num[i] > 0) and(variety_num[i + 1] <= 0) { - highlight3 += string(variety_num[i]) + "x " + string(variety[i]) + ". "; - stop = 1; - } - } - } - } -} - - +unit_count = men + medi + dreads + veh; diff --git a/objects/obj_pnunit/Create_0.gml b/objects/obj_pnunit/Create_0.gml index e4f8464563..ce4ca4dc69 100644 --- a/objects/obj_pnunit/Create_0.gml +++ b/objects/obj_pnunit/Create_0.gml @@ -10,11 +10,16 @@ attacked_dudes=0; dreads=0; jetpack_destroy=0; defenses=0; -highlight=0; -highlight2=0; -highlight3=""; -siz = 0; -x_offset = 0; + +unit_count=0; +unit_count_old=0; +composition_string=""; + +column_size = 0; + +centerline_offset = 0; +pos = 880; +draw_size = 0; // let="";let=string_delete(obj_ini.psy_powers,2,string_length(obj_ini.psy_powers)-1);let=string_upper(let); // LET might be different for each marine; need a way of determining this diff --git a/objects/obj_pnunit/Draw_0.gml b/objects/obj_pnunit/Draw_0.gml index 78acb60174..a1cb2f7c42 100644 --- a/objects/obj_pnunit/Draw_0.gml +++ b/objects/obj_pnunit/Draw_0.gml @@ -1,60 +1,43 @@ +draw_size = min(400, column_size); -/*if (engaged=1) then image_index=1; -if (engaged=0) then image_index=0; -draw_self();*/ - -var diff=0,pos=880; -if (veh_type[1]="Defenses"){ - siz=0; - if (instance_exists(obj_nfort)) then siz=400; -} -draw_set_color(c_white); -if (instance_exists(obj_centerline)){ - diff=x-obj_centerline.x; +if (draw_size > 0){ + draw_set_alpha(1); draw_set_color(c_red); + + if (instance_exists(obj_centerline)){ + centerline_offset=x-obj_centerline.x; + } + if (veh_type[1]=="Defenses"){ - diff=135; + draw_size=0; + if (instance_exists(obj_nfort)) then draw_size=400; + centerline_offset=135; draw_set_color(c_gray); } -} -siz=min(400,(men*0.5)+(veh*2.5)+(dreads*2)); -x_offset = pos+(diff*2); -if (siz>0){ - draw_set_alpha(1); - if (highlight>0) then draw_set_alpha(0.8); - if (x_offset>817) and (x_offset<1575){ - draw_rectangle(x_offset,450-(siz/2),x_offset+10,450+(siz/2),0); - } - draw_set_alpha(1); -} - -if (highlight>0) and (obj_ncombat.fadein<=0){ - draw_set_color(38144); - draw_line(x_offset+5,450,817,685); - draw_set_font(fnt_40k_14b); - draw_text(817,688,"Row Composition:"); - draw_set_font(fnt_40k_14); - draw_text_ext(817,706,string_hash_to_newline(string(highlight3)),-1,758); -} - -// draw_text(800,(x*18)-400,string(diff)); - + var _hit = scr_hit(pos+(centerline_offset*2),450-(draw_size/2),pos+(centerline_offset*2)+10,450+(draw_size/2)) && obj_ncombat.fadein<=0; + if (_hit) { + draw_set_alpha(0.8); + } + draw_rectangle(pos+(centerline_offset*2),450-(draw_size/2),pos+(centerline_offset*2)+10,450+(draw_size/2),0); + if (_hit) { + if (unit_count != unit_count_old) { + unit_count_old = unit_count; + composition_string = string_unit_composition(); + } + draw_set_alpha(1); + draw_set_color(38144); + draw_line_width(pos+(centerline_offset*2)+5,450,817,685, 2); + draw_set_font(fnt_40k_14b); + draw_text(817,688,"Row Composition:"); + draw_set_font(fnt_40k_14); + draw_text_ext(817,710,composition_string,-1,758); + } -draw_set_color(c_black); -draw_set_alpha(obj_ncombat.fadein/30); -draw_rectangle(822,239,1574,662,0); -draw_set_alpha(1); - - - -exit; - -draw_set_color(255); -draw_text((x*18)-400,300,string_hash_to_newline(string(men)+"|"+string(veh)+"#"+string(dudes_num[1])+"x "+string(dudes[1])+"#"+string(dudes_num[2])+"x "+string(dudes[2])+"#"+string(dudes_num[3])+"x "+string(dudes[3])+"#"+string(dudes_num[4])+"x "+string(dudes[4])+"#"+string(dudes_num[5])+"x "+string(dudes[5]))); - - -draw_text((x*18)-400,420,string_hash_to_newline("1: "+string(veh_type[1])+"#2: "+string(veh_type[2])+"#3: "+string(veh_type[3])+"#4: "+string(veh_type[4])+"#5: "+string(veh_type[5])+"#6: "+string(veh_type[6]))); - -/* */ -/* */ + if (obj_ncombat.fadein > 0) { + draw_set_color(c_black); + draw_set_alpha(obj_ncombat.fadein/30); + draw_rectangle(822,239,1574,662,0); + draw_set_alpha(1); + } +} \ No newline at end of file diff --git a/objects/obj_pnunit/Step_0.gml b/objects/obj_pnunit/Step_0.gml index c97d5542bc..9e62597259 100644 --- a/objects/obj_pnunit/Step_0.gml +++ b/objects/obj_pnunit/Step_0.gml @@ -1,44 +1,10 @@ // These arrays are the losses on any one frame. // Instead of resetting in a bunch of places, we reset here. -array_resize(lost, 0) -array_resize(lost_num, 0) +array_resize(lost, 0); +array_resize(lost_num, 0); -highlight=0; -var diff=0; -var pos=880; - -if (instance_exists(obj_centerline)){ - diff=x-obj_centerline.x; -} -if (instance_exists(obj_enunit)) { - siz=min(400,(men*0.5)+(medi)+(veh*2.5)+(dreads*2)); -} else { - siz = 0; -} -if (siz>0){ - if ((x_offset)>817) and ((x_offset)<1575){ - if (scr_hit([x_offset,450-(siz/2),x_offset+10,450+(siz/2)])){ - highlight=men+medi+dreads+veh; - } - } -} - -if (highlight2!=highlight){ - highlight2=highlight; - highlight3=""; - - var dudes_len = array_length(dudes_num); - for (var i = 0; i < dudes_len; i++){ - - if (dudes_num[i] > 0 and dudes_num[i+1] > 0) { - highlight3+=$"{dudes_num[i]}X {dudes[i]}, " - } else if (dudes_num[i] > 0 and dudes_num[i+1] <= 0) { - highlight3+=$"{dudes_num[i]}X {dudes[i]}."; - break; - } - - } -} +column_size = (men*0.5)+(medi)+(dreads*2)+(veh*2.5); +unit_count = men + medi + dreads + veh; 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 440712a2bc..da25f4d339 100644 --- a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml +++ b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml @@ -238,3 +238,38 @@ function move_enemy_blocks() { } ds_priority_destroy(_enemy_movement_queue); } + +/// @mixin +function string_unit_composition() { + var _composition_string = ""; + + _composition_string = $"{unit_count}x Total; "; + if (men > 0) { + _composition_string += $"{string_plural_count("Normal Unit", men)}; "; + } + if (medi > 0) { + _composition_string += $"{string_plural_count("Big Unit", medi)}; "; + } + if (dreads > 0) { + _composition_string += $"{string_plural_count("Walker", dreads)}; "; + } + if (veh > 0) { + _composition_string += $"{string_plural_count("Vehicle", veh)}; "; + } + _composition_string += $"\n"; + + var dudes_len = array_length(dudes_num); + for(var i = 0; i < dudes_len; i++) { + if (dudes_num[i] == 0) { + continue; + } + _composition_string += $"{dudes_num[i]}x {dudes[i]}"; + if (i < dudes_len - 1) { + _composition_string += ", "; + } else { + _composition_string += ". "; + } + } + + return _composition_string; +} diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index c2c86c5f7b..2c4569d909 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -45,6 +45,16 @@ function string_plural(_string, _variable = 2) { } } +/// @function string_plural_count +/// @description This function formats a string into a plural form by adding affixes following common rules, and adds the x(variable) text at the start. +/// @param {string} _string +/// @param {real} _variable Variable to check if more than 1 before converting to plural, and add at the start. +/// @returns {string} Modified string. +function string_plural_count(_string, _variable) { + var _modified_string = $"{_variable}x {string_plural(_string, _variable)}"; + return _modified_string; +} + /// @function string_truncate /// @description Truncates a string to fit within a specified pixel width, appending "..." if the string was truncated. /// @param {string} _string From 499284c7f0c624d994085ceaeacd5f079a2ddc76 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 04:46:50 +0300 Subject: [PATCH 2/5] Optimize some minor stuff --- objects/obj_enunit/Draw_0.gml | 56 +++++++++++++++++++++++++++-------- objects/obj_pnunit/Draw_0.gml | 15 ++++++++-- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/objects/obj_enunit/Draw_0.gml b/objects/obj_enunit/Draw_0.gml index 11eeeaa12b..038a57ec33 100644 --- a/objects/obj_enunit/Draw_0.gml +++ b/objects/obj_enunit/Draw_0.gml @@ -2,26 +2,56 @@ draw_size = min(400, column_size); if (draw_size > 0){ draw_set_alpha(1); - draw_set_color(c_maroon); - if (obj_ncombat.enemy=2) then draw_set_color(8307806); - if (obj_ncombat.enemy=3) then draw_set_color(16512); - if (obj_ncombat.enemy=5) then draw_set_color(c_silver); - if (obj_ncombat.enemy=6) then draw_set_color(33023); - if (obj_ncombat.enemy=7) then draw_set_color(38144); - if (obj_ncombat.enemy=8) then draw_set_color(117758); - if (obj_ncombat.enemy=9) then draw_set_color(7492269); - if (obj_ncombat.enemy=10) then draw_set_color(c_purple); - if (obj_ncombat.enemy=13) then draw_set_color(65408); + switch (obj_ncombat.enemy) { + case 2: + draw_set_color(8307806); + break; + case 3: + draw_set_color(16512); + break; + case 5: + draw_set_color(c_silver); + break; + case 6: + draw_set_color(33023); + break; + case 7: + draw_set_color(38144); + break; + case 8: + draw_set_color(117758); + break; + case 9: + draw_set_color(7492269); + break; + case 10: + draw_set_color(c_purple); + break; + case 13: + draw_set_color(65408); + break; + default: + draw_set_color(c_maroon); + break; + } if (instance_exists(obj_centerline)){ centerline_offset=x-obj_centerline.x; } - var _hit = scr_hit(pos+(centerline_offset*2),450-(draw_size/2),pos+(centerline_offset*2)+10,450+(draw_size/2)) && obj_ncombat.fadein<=0; + var _draw_coords = { + x1: pos + (centerline_offset * 2), + y1: 450 - (draw_size / 2), + x2: pos + (centerline_offset * 2) + 10, + y2: 450 + (draw_size / 2) + }; + + var _hit = scr_hit(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2) && obj_ncombat.fadein <= 0; + if (_hit) { draw_set_alpha(0.8); } - draw_rectangle(pos+(centerline_offset*2),450-(draw_size/2),pos+(centerline_offset*2)+10,450+(draw_size/2),0); + draw_rectangle(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2, 0); if (_hit) { if (unit_count != unit_count_old) { @@ -77,7 +107,7 @@ if (draw_size > 0){ draw_set_alpha(1); draw_set_color(38144); - draw_line_width(pos+(centerline_offset*2)+5,450,817,685, 2); + draw_line_width(_draw_coords.x1+5,450,817,685, 2); draw_set_font(fnt_40k_14b); draw_text(817,688,"Row Composition:"); draw_set_font(fnt_40k_14); diff --git a/objects/obj_pnunit/Draw_0.gml b/objects/obj_pnunit/Draw_0.gml index a1cb2f7c42..c8069f73c1 100644 --- a/objects/obj_pnunit/Draw_0.gml +++ b/objects/obj_pnunit/Draw_0.gml @@ -15,11 +15,20 @@ if (draw_size > 0){ draw_set_color(c_gray); } - var _hit = scr_hit(pos+(centerline_offset*2),450-(draw_size/2),pos+(centerline_offset*2)+10,450+(draw_size/2)) && obj_ncombat.fadein<=0; + var _draw_coords = { + x1: pos + (centerline_offset * 2), + y1: 450 - (draw_size / 2), + x2: pos + (centerline_offset * 2) + 10, + y2: 450 + (draw_size / 2) + }; + + var _hit = scr_hit(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2) && obj_ncombat.fadein <= 0; + if (_hit) { draw_set_alpha(0.8); } - draw_rectangle(pos+(centerline_offset*2),450-(draw_size/2),pos+(centerline_offset*2)+10,450+(draw_size/2),0); + draw_rectangle(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2, 0); + if (_hit) { if (unit_count != unit_count_old) { unit_count_old = unit_count; @@ -27,7 +36,7 @@ if (draw_size > 0){ } draw_set_alpha(1); draw_set_color(38144); - draw_line_width(pos+(centerline_offset*2)+5,450,817,685, 2); + draw_line_width(_draw_coords.x1+5,450,817,685, 2); draw_set_font(fnt_40k_14b); draw_text(817,688,"Row Composition:"); draw_set_font(fnt_40k_14); From f26fd223dbd86568d0602b7bc22efa00f0791854 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 04:57:27 +0300 Subject: [PATCH 3/5] A little bit of DRY --- objects/obj_enunit/Draw_0.gml | 17 ++-------- objects/obj_enunit/Step_0.gml | 5 ++- objects/obj_pnunit/Draw_0.gml | 17 ++-------- objects/obj_pnunit/Step_0.gml | 5 ++- .../scr_punit_combat_heplers.gml | 31 ++++++++++++++++++- 5 files changed, 40 insertions(+), 35 deletions(-) diff --git a/objects/obj_enunit/Draw_0.gml b/objects/obj_enunit/Draw_0.gml index 038a57ec33..0c42a6a13a 100644 --- a/objects/obj_enunit/Draw_0.gml +++ b/objects/obj_enunit/Draw_0.gml @@ -57,7 +57,7 @@ if (draw_size > 0){ if (unit_count != unit_count_old) { unit_count_old = unit_count; if (obj_ncombat.enemy!=1){ - composition_string += string_unit_composition(); + composition_string += block_composition_string(); } else { var variety, variety_num, stop, sofar, compl, vas; stop = 0; @@ -105,19 +105,8 @@ if (draw_size > 0){ } } - draw_set_alpha(1); - draw_set_color(38144); - draw_line_width(_draw_coords.x1+5,450,817,685, 2); - draw_set_font(fnt_40k_14b); - draw_text(817,688,"Row Composition:"); - draw_set_font(fnt_40k_14); - draw_text_ext(817,710,composition_string,-1,758); + draw_block_composition(_draw_coords.x1, composition_string); } - if (obj_ncombat.fadein > 0) { - draw_set_color(c_black); - draw_set_alpha(obj_ncombat.fadein/30); - draw_rectangle(822,239,1574,662,0); - draw_set_alpha(1); - } + draw_block_fadein(); } diff --git a/objects/obj_enunit/Step_0.gml b/objects/obj_enunit/Step_0.gml index adc2902dd2..e73945c5f9 100644 --- a/objects/obj_enunit/Step_0.gml +++ b/objects/obj_enunit/Step_0.gml @@ -1,3 +1,2 @@ -column_size = (men*0.5)+(medi)+(dreads*2)+(veh*2.5); - -unit_count = men + medi + dreads + veh; +update_block_size(); +update_block_unit_count(); diff --git a/objects/obj_pnunit/Draw_0.gml b/objects/obj_pnunit/Draw_0.gml index c8069f73c1..f1c54db601 100644 --- a/objects/obj_pnunit/Draw_0.gml +++ b/objects/obj_pnunit/Draw_0.gml @@ -32,21 +32,10 @@ if (draw_size > 0){ if (_hit) { if (unit_count != unit_count_old) { unit_count_old = unit_count; - composition_string = string_unit_composition(); + composition_string = block_composition_string(); } - draw_set_alpha(1); - draw_set_color(38144); - draw_line_width(_draw_coords.x1+5,450,817,685, 2); - draw_set_font(fnt_40k_14b); - draw_text(817,688,"Row Composition:"); - draw_set_font(fnt_40k_14); - draw_text_ext(817,710,composition_string,-1,758); + draw_block_composition(_draw_coords.x1, composition_string); } - if (obj_ncombat.fadein > 0) { - draw_set_color(c_black); - draw_set_alpha(obj_ncombat.fadein/30); - draw_rectangle(822,239,1574,662,0); - draw_set_alpha(1); - } + draw_block_fadein() } \ No newline at end of file diff --git a/objects/obj_pnunit/Step_0.gml b/objects/obj_pnunit/Step_0.gml index 9e62597259..e7e5f44c3a 100644 --- a/objects/obj_pnunit/Step_0.gml +++ b/objects/obj_pnunit/Step_0.gml @@ -5,6 +5,5 @@ array_resize(lost, 0); array_resize(lost_num, 0); -column_size = (men*0.5)+(medi)+(dreads*2)+(veh*2.5); - -unit_count = men + medi + dreads + veh; +update_block_size(); +update_block_unit_count(); 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 da25f4d339..85a685e60a 100644 --- a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml +++ b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml @@ -240,7 +240,7 @@ function move_enemy_blocks() { } /// @mixin -function string_unit_composition() { +function block_composition_string() { var _composition_string = ""; _composition_string = $"{unit_count}x Total; "; @@ -273,3 +273,32 @@ function string_unit_composition() { return _composition_string; } + +function draw_block_composition(_x1, _composition_string) { + draw_set_alpha(1); + draw_set_color(38144); + draw_line_width(_x1+5,450,817,685, 2); + draw_set_font(fnt_40k_14b); + draw_text(817,688,"Row Composition:"); + draw_set_font(fnt_40k_14); + draw_text_ext(817,710,_composition_string,-1,758); +} + +function draw_block_fadein() { + if (obj_ncombat.fadein > 0) { + draw_set_color(c_black); + draw_set_alpha(obj_ncombat.fadein/30); + draw_rectangle(822,239,1574,662,0); + draw_set_alpha(1); + } +} + +/// @mixin +function update_block_size() { + column_size = (men*0.5)+(medi)+(dreads*2)+(veh*2.5); +} + +/// @mixin +function update_block_unit_count() { + unit_count = men + medi + dreads + veh; +} From d348051db0331fd4b19bb12755cc0b57976ddf7e Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Tue, 1 Apr 2025 04:04:08 +0300 Subject: [PATCH 4/5] Use planet colors for columns --- objects/obj_enunit/Draw_0.gml | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/objects/obj_enunit/Draw_0.gml b/objects/obj_enunit/Draw_0.gml index 0c42a6a13a..a4a5f39e7d 100644 --- a/objects/obj_enunit/Draw_0.gml +++ b/objects/obj_enunit/Draw_0.gml @@ -2,38 +2,7 @@ draw_size = min(400, column_size); if (draw_size > 0){ draw_set_alpha(1); - switch (obj_ncombat.enemy) { - case 2: - draw_set_color(8307806); - break; - case 3: - draw_set_color(16512); - break; - case 5: - draw_set_color(c_silver); - break; - case 6: - draw_set_color(33023); - break; - case 7: - draw_set_color(38144); - break; - case 8: - draw_set_color(117758); - break; - case 9: - draw_set_color(7492269); - break; - case 10: - draw_set_color(c_purple); - break; - case 13: - draw_set_color(65408); - break; - default: - draw_set_color(c_maroon); - break; - } + draw_set_color(global.star_name_colors[obj_ncombat.enemy]); if (instance_exists(obj_centerline)){ centerline_offset=x-obj_centerline.x; From 509eb58cab945d873991ab765e3bc6ba3f86f167 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Tue, 1 Apr 2025 04:51:56 +0300 Subject: [PATCH 5/5] Stop using the weird coord struct and add a hit method --- objects/obj_enunit/Create_0.gml | 9 ++++++++- objects/obj_enunit/Draw_0.gml | 21 +++++++++------------ objects/obj_pnunit/Create_0.gml | 9 +++++++++ objects/obj_pnunit/Draw_0.gml | 21 +++++++++------------ 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/objects/obj_enunit/Create_0.gml b/objects/obj_enunit/Create_0.gml index 1518eb8530..17482e5622 100644 --- a/objects/obj_enunit/Create_0.gml +++ b/objects/obj_enunit/Create_0.gml @@ -20,7 +20,10 @@ composition_string=""; pos = 880; centerline_offset = 0; draw_size = 0; - +x1 = pos + (centerline_offset * 2); +y1 = 450 - (draw_size / 2); +x2 = pos + (centerline_offset * 2) + 10; +y2 = 450 + (draw_size / 2); enemy=0; enemy2=0; @@ -79,3 +82,7 @@ if (obj_ncombat.enemy=1) then alarm[6]=10; // if (obj_ncombat.enemy=1){alarm[1]=8;alarm[5]=10;} + +hit = function() { + return scr_hit(x1, y1, x2, y2) && obj_ncombat.fadein <= 0; +}; diff --git a/objects/obj_enunit/Draw_0.gml b/objects/obj_enunit/Draw_0.gml index a4a5f39e7d..791cfcc9ac 100644 --- a/objects/obj_enunit/Draw_0.gml +++ b/objects/obj_enunit/Draw_0.gml @@ -8,21 +8,18 @@ if (draw_size > 0){ centerline_offset=x-obj_centerline.x; } - var _draw_coords = { - x1: pos + (centerline_offset * 2), - y1: 450 - (draw_size / 2), - x2: pos + (centerline_offset * 2) + 10, - y2: 450 + (draw_size / 2) - }; + x1 = pos + (centerline_offset * 2); + y1 = 450 - (draw_size / 2); + x2 = pos + (centerline_offset * 2) + 10; + y2 = 450 + (draw_size / 2); - var _hit = scr_hit(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2) && obj_ncombat.fadein <= 0; - - if (_hit) { + if (hit()) { draw_set_alpha(0.8); } - draw_rectangle(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2, 0); - if (_hit) { + draw_rectangle(x1, y1, x2, y2, 0); + + if (hit()) { if (unit_count != unit_count_old) { unit_count_old = unit_count; if (obj_ncombat.enemy!=1){ @@ -74,7 +71,7 @@ if (draw_size > 0){ } } - draw_block_composition(_draw_coords.x1, composition_string); + draw_block_composition(x1, composition_string); } draw_block_fadein(); diff --git a/objects/obj_pnunit/Create_0.gml b/objects/obj_pnunit/Create_0.gml index ce4ca4dc69..9a02730af4 100644 --- a/objects/obj_pnunit/Create_0.gml +++ b/objects/obj_pnunit/Create_0.gml @@ -20,6 +20,11 @@ column_size = 0; centerline_offset = 0; pos = 880; draw_size = 0; +x1 = pos + (centerline_offset * 2); +y1 = 450 - (draw_size / 2); +x2 = pos + (centerline_offset * 2) + 10; +y2 = 450 + (draw_size / 2); + // let="";let=string_delete(obj_ini.psy_powers,2,string_length(obj_ini.psy_powers)-1);let=string_upper(let); // LET might be different for each marine; need a way of determining this @@ -117,3 +122,7 @@ hostile_splash=0; alarm[1]=4; action_set_alarm(1, 3); + +hit = function() { + return scr_hit(x1, y1, x2, y2) && obj_ncombat.fadein <= 0; +}; diff --git a/objects/obj_pnunit/Draw_0.gml b/objects/obj_pnunit/Draw_0.gml index f1c54db601..124debc521 100644 --- a/objects/obj_pnunit/Draw_0.gml +++ b/objects/obj_pnunit/Draw_0.gml @@ -15,26 +15,23 @@ if (draw_size > 0){ draw_set_color(c_gray); } - var _draw_coords = { - x1: pos + (centerline_offset * 2), - y1: 450 - (draw_size / 2), - x2: pos + (centerline_offset * 2) + 10, - y2: 450 + (draw_size / 2) - }; + x1 = pos + (centerline_offset * 2); + y1 = 450 - (draw_size / 2); + x2 = pos + (centerline_offset * 2) + 10; + y2 = 450 + (draw_size / 2); - var _hit = scr_hit(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2) && obj_ncombat.fadein <= 0; - - if (_hit) { + if (hit()) { draw_set_alpha(0.8); } - draw_rectangle(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2, 0); - if (_hit) { + draw_rectangle(x1, y1, x2, y2, 0); + + if (hit()) { if (unit_count != unit_count_old) { unit_count_old = unit_count; composition_string = block_composition_string(); } - draw_block_composition(_draw_coords.x1, composition_string); + draw_block_composition(x1, composition_string); } draw_block_fadein()