From 4ba24b814ed158b3906b6c4bb3c65df92d0dc0a7 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Fri, 28 Mar 2025 01:01:48 +0300 Subject: [PATCH 01/14] feat: Marine and Vehicle recovery priorities --- ChapterMaster.yyp | 2 +- objects/obj_ncombat/Alarm_5.gml | 169 ++++++-- objects/obj_ncombat/Alarm_7.gml | 6 +- objects/obj_ncombat/Create_0.gml | 5 +- objects/obj_ncombat/KeyPress_13.gml | 1 - objects/obj_pnunit/Alarm_5.gml | 360 ----------------- objects/obj_pnunit/obj_pnunit.yy | 5 +- scripts/scr_after_combat/scr_after_combat.gml | 377 ++++++++++++++++++ .../scr_after_combat.yy} | 4 +- .../scr_distribute_experience.gml | 22 - 10 files changed, 515 insertions(+), 436 deletions(-) delete mode 100644 objects/obj_pnunit/Alarm_5.gml create mode 100644 scripts/scr_after_combat/scr_after_combat.gml rename scripts/{scr_distribute_experience/scr_distribute_experience.yy => scr_after_combat/scr_after_combat.yy} (72%) delete mode 100644 scripts/scr_distribute_experience/scr_distribute_experience.gml diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index da4d95ea98..fa151d0b6f 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -661,6 +661,7 @@ {"id":{"name":"scr_add_man","path":"scripts/scr_add_man/scr_add_man.yy",},}, {"id":{"name":"scr_add_stc_fragment","path":"scripts/scr_add_stc_fragment/scr_add_stc_fragment.yy",},}, {"id":{"name":"scr_add_vehicle","path":"scripts/scr_add_vehicle/scr_add_vehicle.yy",},}, + {"id":{"name":"scr_after_combat","path":"scripts/scr_after_combat/scr_after_combat.yy",},}, {"id":{"name":"scr_alert","path":"scripts/scr_alert/scr_alert.yy",},}, {"id":{"name":"scr_ancient_ruins","path":"scripts/scr_ancient_ruins/scr_ancient_ruins.yy",},}, {"id":{"name":"scr_animated_scanline","path":"scripts/scr_animated_scanline/scr_animated_scanline.yy",},}, @@ -707,7 +708,6 @@ {"id":{"name":"scr_dialogue","path":"scripts/scr_dialogue/scr_dialogue.yy",},}, {"id":{"name":"scr_diplomacy_helpers","path":"scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.yy",},}, {"id":{"name":"scr_display_number","path":"scripts/scr_display_number/scr_display_number.yy",},}, - {"id":{"name":"scr_distribute_experience","path":"scripts/scr_distribute_experience/scr_distribute_experience.yy",},}, {"id":{"name":"scr_distributions","path":"scripts/scr_distributions/scr_distributions.yy",},}, {"id":{"name":"scr_draw_armentarium","path":"scripts/scr_draw_armentarium/scr_draw_armentarium.yy",},}, {"id":{"name":"scr_draw_management_unit","path":"scripts/scr_draw_management_unit/scr_draw_management_unit.yy",},}, diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index d7e5af6db0..768f7b7720 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -6,7 +6,7 @@ battle_over=1; alarm[8]=999999; var line_break = "------------------------------------------------------------------------------"; -// show_message("Final Deaths: "+string(final_deaths)); +// show_message("Final Deaths: "+string(final_marine_deaths)); if (turn_count >= 50){ @@ -15,33 +15,102 @@ if (turn_count >= 50){ // 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}"; - if (units_saved > 0){ - part1+=$" ({roles[eROLE.Apothecary]}{apothecaries_alive>1?"s":""} prevented the death of {units_saved})"; + + +if (obj_ncombat.defeat == 0) { + with (obj_pnunit) { + add_marines_to_recovery(self); + add_vehicles_to_recovery(self); } - if (injured>0) then part8=$"Marines Critically Injured: {injured}"; - - var i=0; - for (var i=1;i0) and (post_unit_veh[i]=0){ - part2+=$"{post_units_lost[i]}x {post_unit_lost[i]},"; +} + +if (array_length(marines_to_recover) > 0) { + var _recovery_queue = ds_priority_create(); + + for (var i = 0; i < array_length(marines_to_recover); i++) { + ds_priority_add(_recovery_queue, marines_to_recover[i], marines_to_recover[i].priority); + } + + while (!ds_priority_empty(_recovery_queue) && unit_recovery_score > 0) { + var _candidate = ds_priority_delete_max(_recovery_queue); + var _column_id = _candidate.column_id; + var _unit_id = _candidate.id; + _candidate.unit.update_health(irandom(10)); + _column_id.marine_dead[_unit_id] = false; + unit_recovery_score -= 1; + units_saved += 1; + } + + ds_priority_destroy(_recovery_queue); +} + + +if (array_length(vehicles_to_recover) > 0) { + var _vehicle_recovery_queue = ds_priority_create(); + + for (var i = 0; i < array_length(vehicles_to_recover); i++) { + ds_priority_add(_vehicle_recovery_queue, vehicles_to_recover[i], vehicles_to_recover[i].priority); + } + + while (!ds_priority_empty(_vehicle_recovery_queue) && vehicle_recovery_score > 0) { + var _candidate = ds_priority_delete_max(_vehicle_recovery_queue); + var _column_id = _candidate.column_id; + var _unit_id = _candidate.id; + + if (obj_controller.stc_bonus[3] = 4) { + var _survival_roll = 80 + _candidate.priority; + var _dice_roll = roll_dice(1, 100, "high"); + if (_dice_roll >= _survival_roll) && (_column_id.veh_dead[_unit_id] != 2) { + _column_id.veh_hp[_unit_id] = 10; + _column_id.veh_dead[_unit_id] = false; + vehicles_saved++; + vehicle_deaths--; + continue; + } } + + _column_id.veh_hp[_unit_id] = 10; + _column_id.veh_dead[_unit_id] = false; + vehicle_recovery_score -= _candidate.priority; + vehicles_saved++; + vehicle_deaths--; } - part2=string_delete(part2,string_length(part2)-1,2); - part2+=".";i=0; - - if (injured>0){ - newline=part8; - scr_newtext(); + + ds_priority_destroy(_vehicle_recovery_queue); +} + +with (obj_pnunit) { + after_battle_part1() +} + +var _total_deaths = (final_marine_deaths + final_command_deaths) - units_saved; +if (_total_deaths > 0) { + newline = $"Marines lost: {_total_deaths}!"; + if (array_length(post_unit_lost) > 0) { + for (var i = 0; i < array_length(post_unit_lost); i++) { + if ((post_unit_lost[i] != "") && (post_units_lost[i] > 0) && (post_unit_veh[i] == 0)) { + newline += $" {post_units_lost[i]}x {post_unit_lost[i]}"; + if (i < array_length(post_unit_lost) - 1) { + newline += ","; + } else { + newline += "."; + } + } + } } - newline=part1; - scr_newtext(); - newline=part2; - newline_color="red"; - scr_newtext(); - newline=" "; - scr_newtext(); + newline_color = "red"; + scr_newtext(); +} + +if (units_saved > 0) { + newline = $"{string_plural(roles[eROLE.Apothecary])} saved {units_saved} marines."; + scr_newtext(); +} + +if (injured > 0) { + newline = $"Marines critically injured: {injured}!"; + newline_color = "red"; + scr_newtext(); } if (ground_mission){ @@ -64,7 +133,7 @@ if (obj_ini.doomed && !apothecaries_alive){ part3=$"No able-bodied {roles[eROLE.Apothecary]}. {seed_max} Gene-Seed lost."; newline=part3;scr_newtext(); newline=" ";scr_newtext(); -}else if (apothecaries_alive>0 && final_deaths+final_command_deaths>0 && !obj_ini.doomed){ +}else if (apothecaries_alive>0 && final_marine_deaths+final_command_deaths>0 && !obj_ini.doomed){ part3=$"Gene-Seed Recovered: {seed_saved}("; part3 += seed_saved ? $"{round((seed_saved/seed_max)*100)}" : "0"; part3 += "%)"; @@ -86,25 +155,34 @@ if (red_thirst>2){ newline=" ";scr_newtext(); } +newline = " "; +scr_newtext(); -if (vehicle_deaths>0 || vehicles_saved>0){ - part4="Vehicles Lost: "+string(vehicle_deaths); - if (techmarines_alive=1) then part4+=" ("+string(roles[16])+" prevented the destruction of "+string(vehicles_saved)+")"; - if (techmarines_alive>1) then part4+=" ("+string(roles[16])+"s prevented the destruction of "+string(vehicles_saved)+")"; - - var i;i=0; - repeat(30){i+=1; - if (post_unit_lost[i]!="") and (post_units_lost[i]>0) and (post_unit_veh[i]=1){ - part5+=string(post_units_lost[i])+"x "+string(post_unit_lost[i])+", "; - } - } - part5=string_delete(part5,string_length(part5)-1,2);part5+=".";i=0; - - newline=part4;scr_newtext(); - newline=part5;scr_newtext(); - newline=" ";scr_newtext(); + + +if (vehicles_saved > 0) { + newline = $"{string_plural(roles[eROLE.Techmarine], techmarines_alive)} were able to recover {vehicles_saved} vehicles."; + scr_newtext(); } +if (vehicle_deaths > 0) { + newline = $"Vehicles Lost: {vehicle_deaths}."; + + for (var i = 0; i < array_length(post_unit_lost); i++) { + if ((post_unit_lost[i] != "") && (post_units_lost[i] > 0) && (post_unit_veh[i] == 1)) { + newline += $" x{post_units_lost[i]}"; + if (i < array_length(post_unit_lost) - 1) { + newline += ","; + } else { + newline += "."; + } + } + } + newline_color="red"; + scr_newtext(); +} + + if (post_equipment_lost[1]!=""){ part6="Equipment Lost: "; @@ -126,7 +204,13 @@ if (post_equipment_lost[1]!=""){ newline=" "; scr_newtext(); } + + + if (total_battle_exp_gain>0){ + with (obj_pnunit) { + assemble_alive_units(self); + } average_battle_exp_gain = distribute_experience(end_alive_units, total_battle_exp_gain); // Due to cool alarm timer shitshow, I couldn't think of anything but to put it here. newline = $"Each marine gained {average_battle_exp_gain} experience, reduced by their total experience."; scr_newtext(); @@ -137,7 +221,7 @@ if (total_battle_exp_gain>0){ if (i > 0) { newline += ", "; } - newline += $"{upgraded_librarians[i].name()}"; + newline += $"{upgraded_librarians[i].name_role()}"; } newline += " learned new psychic powers after gaining enough experience." scr_newtext(); @@ -151,6 +235,7 @@ if (ground_mission){ obj_ground_mission.post_equipment_lost = post_equipment_lost obj_ground_mission.post_equipments_lost = post_equipments_lost } + if (slime>0){ var compan_slime; compan_slime=0; diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index db78996fc9..467ead9d9e 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -255,7 +255,7 @@ try { obj_controller.x=view_x; obj_controller.y=view_y; obj_controller.combat=0; - obj_controller.marines-=final_deaths; + obj_controller.marines-=final_marine_deaths; obj_controller.command-=final_command_deaths; instance_activate_all(); @@ -266,9 +266,9 @@ try { - if (defeat=1) and (final_deaths+final_command_deaths>=10) then scr_recent("battle_defeat", $"{enemy}, {final_deaths+final_command_deaths}"); + if (defeat=1) and (final_marine_deaths+final_command_deaths>=10) then scr_recent("battle_defeat", $"{enemy}, {final_marine_deaths+final_command_deaths}"); } else { - scr_recent("battle_defeat",$"{enemy}, {final_deaths+final_command_deaths}"); + scr_recent("battle_defeat",$"{enemy}, {final_marine_deaths+final_command_deaths}"); } diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index 9148117aad..c5a4bc83df 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -28,6 +28,8 @@ on_ship=false; alpha_strike=0; Warlord = 0; total_battle_exp_gain=0; +marines_to_recover = []; +vehicles_to_recover = []; end_alive_units = []; average_battle_exp_gain=0; upgraded_librarians=[]; @@ -147,11 +149,10 @@ seed_max=0; units_saved=0; command_saved=0; vehicles_saved=0; -final_deaths=0; +final_marine_deaths=0; final_command_deaths=0; vehicle_deaths=0; casualties=0; -command_casualties=0; dead_jims=0; newline=""; newline_color=""; diff --git a/objects/obj_ncombat/KeyPress_13.gml b/objects/obj_ncombat/KeyPress_13.gml index 3050e8394f..412fc2a8a3 100644 --- a/objects/obj_ncombat/KeyPress_13.gml +++ b/objects/obj_ncombat/KeyPress_13.gml @@ -51,7 +51,6 @@ if ((started=2) or (started=4)){ // obj_pnunit.alarm[4]=2;obj_pnunit.alarm[5]=3;obj_enunit.alarm[1]=1; if (instance_exists(obj_pnunit)){ obj_pnunit.alarm[4]=2; - obj_pnunit.alarm[5]=3; } total_battle_exp_gain = threat * 50; if (instance_exists(obj_enunit)){obj_enunit.alarm[1]=1;} diff --git a/objects/obj_pnunit/Alarm_5.gml b/objects/obj_pnunit/Alarm_5.gml deleted file mode 100644 index 904c672d30..0000000000 --- a/objects/obj_pnunit/Alarm_5.gml +++ /dev/null @@ -1,360 +0,0 @@ -var _unit; - -if (obj_ncombat.defeat == 0) { - var _current_exp; - var _exp_mod = 1; - var _unit_xp_data = []; - var _unit_recovery_score = obj_ncombat.unit_recovery_score; - - for (var i = 0; i < array_length(unit_struct); i++) { - _unit = unit_struct[i]; - if (is_struct(_unit) && ally[i] == false) { - if (marine_dead[i] == 1 && marine_type[i] != "" && _unit_recovery_score > 0) { // Apothecaries saving marines - obj_ncombat.unit_recovery_score -= 1; - _unit.update_health(irandom(20) - 10); - marine_dead[i] = false; - obj_ncombat.units_saved += 1; - } - - if (!marine_dead[i]) { // EXP allocation - _current_exp = _unit.experience; - - _exp_mod = max(1 - (_current_exp / 200), 0.03); - - _unit_xp_data = [_unit, _exp_mod]; - array_push(obj_ncombat.end_alive_units, _unit_xp_data); - } - } - } - - // Techmarines saving vehicles - if (obj_ncombat.techmarines_alive > 0) { - //show_debug_message($"vehicle_recovery_score: {obj_ncombat.vehicle_recovery_score}"); - var _dice_roll; - var _survival_roll; - var _dead_vehicles_pq = ds_priority_create(); - var _vehicles_priority = { - "Land Raider": 10, - "Predator": 5, - "Whirlwind": 4, - "Rhino": 3, - "Land Speeder": 3, - "Bike": 1 - } - - for (var i = 0; i < array_length(veh_dead); i++) { - if (struct_exists(_vehicles_priority, veh_type[i])) && (veh_dead[i]) && (!veh_ally[i] ) { - ds_priority_add(_dead_vehicles_pq, i, _vehicles_priority[$ veh_type[i]]); - } - } - - while (!ds_priority_empty(_dead_vehicles_pq)) { - var i = ds_priority_delete_max(_dead_vehicles_pq); - - if (obj_controller.stc_bonus[3] = 4) { - _survival_roll = 80 + _vehicles_priority[$ veh_type[i]]; - _dice_roll = irandom_range(1, 100); - if (_dice_roll > _survival_roll) && (veh_dead[i] != 2) { - veh_hp[i] = 10; - veh_dead[i] = 0; - obj_ncombat.vehicles_saved += 1; - } - } - if (obj_ncombat.vehicle_recovery_score > 0) { - obj_ncombat.vehicle_recovery_score -= _vehicles_priority[$ veh_type[i]]; - veh_hp[i] = 10; - veh_dead[i] = 0; - obj_ncombat.vehicles_saved += 1; - } - } - - ds_priority_destroy(_dead_vehicles_pq); - } -} - -for (var i=0;i0) or (obj_ncombat.defeat!=0)) and (marine_type[i]!="") and (ally[i]=false){ - - var comm=false; - if (_unit.IsSpecialist("standard",true)){ - obj_ncombat.final_command_deaths+=1; - var recent=true; - if (is_specialist(_unit.role, "trainee")){ - recent=false - } else if (array_contains([string("Venerable {0}",obj_ini.role[100][6]), "Codiciery", "Lexicanum"], _unit.role())){ - recent=false - } - if (recent=true) then scr_recent("death_"+string(marine_type[i]),string(obj_ini.name[marine_co[i],marine_id[i]]),marine_co[i]); - } else { - obj_ncombat.final_deaths+=1; - } - // obj_ncombat.final_deaths+=1; - - // show_message("ded; increase final deaths"); - - if (obj_controller.blood_debt=1){ - if (_unit.role()==obj_ini.role[100][12]){ - obj_controller.penitent_current+=2 - } else {obj_controller.penitent_current+=4;} - obj_controller.penitent_turn=0; - obj_controller.penitent_turnly=0; - } - - if (obj_ini.race[marine_co[i], marine_id[i]] == 1) { - var _birthday = obj_ini.age[marine_co[i], marine_id[i]]; - var _current_year = (obj_controller.millenium * 1000) + obj_controller.year; - var _harvestable_seed = 0; - - if (_birthday <= (_current_year - 10) && obj_ini.zygote == 0) { - if (irandom_range(1, 20) > 1) { - _harvestable_seed++; - } - } - if (_birthday <= (_current_year - 5)) { - if (irandom_range(1, 20) > 1) { - _harvestable_seed++; - } - } - obj_ncombat.seed_max += _harvestable_seed; - } - - var last=0; - for (var o=1;o0) and (marine_type[i]!="") and (ally[i]=false){// 135 - var wah=0,artif=false; - repeat(5){ - wah+=1; - artif=false; - var eqp_chance, dece; - eqp_chance=50; - dece=floor(random(100))+1; - if (obj_ncombat.defending=false) then eqp_chance-=10; - if (obj_ncombat.dropping=1) then eqp_chance-=20; - if (obj_ncombat.dropping=1) and (obj_ncombat.defeat=1) then dece=9999; - if (marine_dead[i]=2) or (destroy=2) then dece=9999; - if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; - - // if (wah=1){show_message(obj_ini.armour[marine_co[i],marine_id[i]]);} - arti=!is_string(_unit.armour(true)); - var arm_data = _unit.get_armour_data(); - if (wah=1) and (is_struct(arm_data)){ - if (arm_data.has_tag("terminator")) then eqp_chance+=30; - if (string_count("&",marine_armour[i])>0){ - eqp_chance=90; - artif=true; - } - if (dece>eqp_chance){ - var last=0;o=0; - repeat(50){ - if (last=0){ - o+=1;artif=false; - if (obj_ncombat.post_equipment_lost[o]=marine_armour[i]){ - last=1; - obj_ncombat.post_equipments_lost[o]+=1; - artif=true; - } - if (obj_ncombat.post_equipment_lost[o]="") and (last=0){last=o; - obj_ncombat.post_equipment_lost[o]=marine_armour[i]; - obj_ncombat.post_equipments_lost[o]=1; - artif=true; - } - if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); - - obj_ini.armour[marine_co[i],marine_id[i]]=""; - // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; - } - } - } - if (dece<=eqp_chance) then scr_add_item(marine_armour[i],1); - } - if (wah=2) and (obj_ini.wep1[marine_co[i],marine_id[i]]!=""){ - if (string_count("&",marine_wep1[i])>0){eqp_chance=90;artif=true;} - if (marine_wep1[i]="Company Standard") then eqp_chance=99; - if (marine_dead[i]=2) or (destroy=2) then dece=9999; - if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; - - if (dece>eqp_chance){ - var last,o;last=0;o=0; - repeat(50){ - if (last=0){ - o+=1;artif=false; - - // show_message(string(o)+"]"+string(obj_ncombat.post_equipment_lost[o])+" "+string(i)+"]"+string(marine_wep1[i])); - - if (string(obj_ncombat.post_equipment_lost[o])=marine_wep1[i]){last=1;obj_ncombat.post_equipments_lost[o]+=1;artif=true;} - if (string(obj_ncombat.post_equipment_lost[o])="") and (last=0){last=o;obj_ncombat.post_equipment_lost[o]=marine_wep1[i];obj_ncombat.post_equipments_lost[o]=1;artif=true;} - if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); - obj_ini.wep1[marine_co[i],marine_id[i]]=""; - // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; - } - } - } - if (dece<=eqp_chance) then scr_add_item(marine_wep1[i],1); - } - if (wah=3) and (obj_ini.wep2[marine_co[i],marine_id[i]]!=""){ - if (string_count("&",marine_wep2[i])>0){eqp_chance=90;artif=true;} - if (marine_wep2[i]="Company Standard") then eqp_chance=99; - if (marine_dead[i]=2) or (destroy=2) then dece=9999; - if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; - - if (dece>eqp_chance){ - var last,o;last=0;o=0; - repeat(50){ - if (last=0){ - o+=1;artif=false; - if (string(obj_ncombat.post_equipment_lost[o])=marine_wep2[i]){last=1;obj_ncombat.post_equipments_lost[o]+=1;artif=true;} - if (string(obj_ncombat.post_equipment_lost[o])="") and (last=0){last=o;obj_ncombat.post_equipment_lost[o]=marine_wep2[i];obj_ncombat.post_equipments_lost[o]=1;artif=true;} - if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); - obj_ini.wep2[marine_co[i],marine_id[i]]=""; - // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; - } - } - } - if (dece<=eqp_chance) then scr_add_item(marine_wep2[i],1); - } - if (wah=4) and (obj_ini.gear[marine_co[i],marine_id[i]]!=""){ - if (string_count("&",marine_gear[i])>0){eqp_chance=90;artif=true;} - if (marine_dead[i]=2) or (destroy=2) then dece=9999; - if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; - - if (obj_ini.gear[marine_co[i],marine_id[i]]="Exterminatus"){ - if (obj_ncombat.defeat=0){ - dece=0; - if (obj_ncombat.dropping!=0) then obj_ncombat.exterminatus+=1; - } - if (obj_ncombat.defeat!=0) then dece=9999; - } - - if (dece>eqp_chance){ - var last,o;last=0;o=0; - repeat(50){ - if (last=0){ - o+=1;artif=false; - if (obj_ncombat.post_equipment_lost[o]=marine_gear[i]){last=1;obj_ncombat.post_equipments_lost[o]+=1;artif=true;} - if (obj_ncombat.post_equipment_lost[o]="") and (last=0){last=o;obj_ncombat.post_equipment_lost[o]=marine_gear[i];obj_ncombat.post_equipments_lost[o]=1;artif=true;} - if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); - obj_ini.gear[marine_co[i],marine_id[i]]=""; - // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; - } - } - } - if (dece<=eqp_chance) then scr_add_item(marine_gear[i],1); - } - if (wah=5) and (obj_ini.mobi[marine_co[i],marine_id[i]]!=""){ - if (string_count("&",marine_mobi[i])>0){ - eqp_chance=90; - artif=true; - } - if (marine_dead[i]=2) or (destroy=2) then dece=9999; - if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; - - if (dece>eqp_chance){ - var last,o;last=0;o=0; - repeat(50){ - if (last=0){ - o+=1; - artif=false; - if (obj_ncombat.post_equipment_lost[o]=marine_mobi[i]){ - last=1; - obj_ncombat.post_equipments_lost[o]+=1; - artif=true; - } - if (obj_ncombat.post_equipment_lost[o]="") and (last=0){last=o;obj_ncombat.post_equipment_lost[o]=marine_mobi[i];obj_ncombat.post_equipments_lost[o]=1;artif=true;} - if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); - obj_ini.mobi[marine_co[i],marine_id[i]]=""; - // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; - } - } - } - if (dece<=eqp_chance) then scr_add_item(marine_mobi[i],1); - } - } - - - - } -} - -for (var i=0;i 0) { + for (var i = 0; i < array_length(player_column.unit_struct); i++) { + var _unit = player_column.unit_struct[i]; + if (is_struct(_unit) && player_column.ally[i] == false) { + if (player_column.marine_dead[i] == 1 && player_column.marine_type[i] != "") { + var _recovery_candidate = { + "id": i, + "unit": _unit, + "column_id": player_column.id, + "priority": _unit.experience + }; + array_push(obj_ncombat.marines_to_recover, _recovery_candidate); + } + } + } + } + } +} + +function add_vehicles_to_recovery(player_column) { + if (instance_exists(player_column)) { + // Techmarines saving vehicles + if (obj_ncombat.vehicle_recovery_score > 0 && obj_ncombat.vehicle_deaths > 0) { + var _vehicles_priority = { + "Land Raider": 10, + "Predator": 5, + "Whirlwind": 4, + "Rhino": 3, + "Land Speeder": 3, + "Bike": 1 + } + + for (var i = 0; i < array_length(player_column.veh_dead); i++) { + if (struct_exists(_vehicles_priority, player_column.veh_type[i])) && (player_column.veh_dead[i]) && (!player_column.veh_ally[i] ) { + if (player_column.veh_dead[i]) { + var _recovery_candidate = { + "id": i, + "column_id": player_column.id, + "priority": _vehicles_priority[$ player_column.veh_type[i]] + }; + array_push(obj_ncombat.vehicles_to_recover, _recovery_candidate); + } + } + } + } + } +} + +function assemble_alive_units(player_column) { + if (instance_exists(player_column)) { + for (var i = 0; i < array_length(player_column.unit_struct); i++) { + var _unit = player_column.unit_struct[i]; + if (is_struct(_unit) && player_column.ally[i] == false) { + if (!player_column.marine_dead[i]) { + array_push(obj_ncombat.end_alive_units, _unit); + } + } + } + } +} + +function distribute_experience(_units, _exp_amount) { + var _eligible_units_count = array_length(_units); + var _average_exp = 0; + + if (_eligible_units_count > 0 && _exp_amount > 0) { + var _individual_exp = _exp_amount / _eligible_units_count; + _average_exp = _individual_exp; + for (var i = 0; i < _eligible_units_count; i++) { + var _unit = _units[i]; + var _exp_mod = max(1 - (_unit.experience / 200), 0.1); + var _exp_update_data = _unit.add_exp(_individual_exp*_exp_mod); + + var _powers_learned = _exp_update_data[1]; + if (_powers_learned > 0) { + array_push(obj_ncombat.upgraded_librarians, _unit); + } + + } + } + + return _average_exp; +} + + +function after_battle_part1() { + var _unit; + + for (var i=0;i0) or (obj_ncombat.defeat!=0)) and (marine_type[i]!="") and (ally[i]=false){ + + var comm=false; + if (_unit.IsSpecialist("standard",true)){ + obj_ncombat.final_command_deaths+=1; + var recent=true; + if (is_specialist(_unit.role, "trainee")){ + recent=false + } else if (array_contains([string("Venerable {0}",obj_ini.role[100][6]), "Codiciery", "Lexicanum"], _unit.role())){ + recent=false + } + if (recent=true) then scr_recent("death_"+string(marine_type[i]),string(obj_ini.name[marine_co[i],marine_id[i]]),marine_co[i]); + } else { + obj_ncombat.final_marine_deaths+=1; + } + // obj_ncombat.final_marine_deaths+=1; + + // show_message("ded; increase final deaths"); + + if (obj_controller.blood_debt=1){ + if (_unit.role()==obj_ini.role[100][12]){ + obj_controller.penitent_current+=2 + } else {obj_controller.penitent_current+=4;} + obj_controller.penitent_turn=0; + obj_controller.penitent_turnly=0; + } + + if (obj_ini.race[marine_co[i], marine_id[i]] == 1) { + var _birthday = obj_ini.age[marine_co[i], marine_id[i]]; + var _current_year = (obj_controller.millenium * 1000) + obj_controller.year; + var _harvestable_seed = 0; + + if (_birthday <= (_current_year - 10) && obj_ini.zygote == 0) { + if (irandom_range(1, 20) > 1) { + _harvestable_seed++; + } + } + if (_birthday <= (_current_year - 5)) { + if (irandom_range(1, 20) > 1) { + _harvestable_seed++; + } + } + obj_ncombat.seed_max += _harvestable_seed; + } + + var last=0; + for (var o=1;o0) and (marine_type[i]!="") and (ally[i]=false){// 135 + var wah=0,artif=false; + repeat(5){ + wah+=1; + artif=false; + var eqp_chance, dece; + eqp_chance=50; + dece=floor(random(100))+1; + if (obj_ncombat.defending=false) then eqp_chance-=10; + if (obj_ncombat.dropping=1) then eqp_chance-=20; + if (obj_ncombat.dropping=1) and (obj_ncombat.defeat=1) then dece=9999; + if (marine_dead[i]=2) or (destroy=2) then dece=9999; + if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; + + // if (wah=1){show_message(obj_ini.armour[marine_co[i],marine_id[i]]);} + arti=!is_string(_unit.armour(true)); + var arm_data = _unit.get_armour_data(); + if (wah=1) and (is_struct(arm_data)){ + if (arm_data.has_tag("terminator")) then eqp_chance+=30; + if (string_count("&",marine_armour[i])>0){ + eqp_chance=90; + artif=true; + } + if (dece>eqp_chance){ + var last=0;o=0; + repeat(50){ + if (last=0){ + o+=1;artif=false; + if (obj_ncombat.post_equipment_lost[o]=marine_armour[i]){ + last=1; + obj_ncombat.post_equipments_lost[o]+=1; + artif=true; + } + if (obj_ncombat.post_equipment_lost[o]="") and (last=0){last=o; + obj_ncombat.post_equipment_lost[o]=marine_armour[i]; + obj_ncombat.post_equipments_lost[o]=1; + artif=true; + } + if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); + + obj_ini.armour[marine_co[i],marine_id[i]]=""; + // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; + } + } + } + if (dece<=eqp_chance) then scr_add_item(marine_armour[i],1); + } + if (wah=2) and (obj_ini.wep1[marine_co[i],marine_id[i]]!=""){ + if (string_count("&",marine_wep1[i])>0){eqp_chance=90;artif=true;} + if (marine_wep1[i]="Company Standard") then eqp_chance=99; + if (marine_dead[i]=2) or (destroy=2) then dece=9999; + if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; + + if (dece>eqp_chance){ + var last,o;last=0;o=0; + repeat(50){ + if (last=0){ + o+=1;artif=false; + + // show_message(string(o)+"]"+string(obj_ncombat.post_equipment_lost[o])+" "+string(i)+"]"+string(marine_wep1[i])); + + if (string(obj_ncombat.post_equipment_lost[o])=marine_wep1[i]){last=1;obj_ncombat.post_equipments_lost[o]+=1;artif=true;} + if (string(obj_ncombat.post_equipment_lost[o])="") and (last=0){last=o;obj_ncombat.post_equipment_lost[o]=marine_wep1[i];obj_ncombat.post_equipments_lost[o]=1;artif=true;} + if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); + obj_ini.wep1[marine_co[i],marine_id[i]]=""; + // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; + } + } + } + if (dece<=eqp_chance) then scr_add_item(marine_wep1[i],1); + } + if (wah=3) and (obj_ini.wep2[marine_co[i],marine_id[i]]!=""){ + if (string_count("&",marine_wep2[i])>0){eqp_chance=90;artif=true;} + if (marine_wep2[i]="Company Standard") then eqp_chance=99; + if (marine_dead[i]=2) or (destroy=2) then dece=9999; + if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; + + if (dece>eqp_chance){ + var last,o;last=0;o=0; + repeat(50){ + if (last=0){ + o+=1;artif=false; + if (string(obj_ncombat.post_equipment_lost[o])=marine_wep2[i]){last=1;obj_ncombat.post_equipments_lost[o]+=1;artif=true;} + if (string(obj_ncombat.post_equipment_lost[o])="") and (last=0){last=o;obj_ncombat.post_equipment_lost[o]=marine_wep2[i];obj_ncombat.post_equipments_lost[o]=1;artif=true;} + if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); + obj_ini.wep2[marine_co[i],marine_id[i]]=""; + // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; + } + } + } + if (dece<=eqp_chance) then scr_add_item(marine_wep2[i],1); + } + if (wah=4) and (obj_ini.gear[marine_co[i],marine_id[i]]!=""){ + if (string_count("&",marine_gear[i])>0){eqp_chance=90;artif=true;} + if (marine_dead[i]=2) or (destroy=2) then dece=9999; + if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; + + if (obj_ini.gear[marine_co[i],marine_id[i]]="Exterminatus"){ + if (obj_ncombat.defeat=0){ + dece=0; + if (obj_ncombat.dropping!=0) then obj_ncombat.exterminatus+=1; + } + if (obj_ncombat.defeat!=0) then dece=9999; + } + + if (dece>eqp_chance){ + var last,o;last=0;o=0; + repeat(50){ + if (last=0){ + o+=1;artif=false; + if (obj_ncombat.post_equipment_lost[o]=marine_gear[i]){last=1;obj_ncombat.post_equipments_lost[o]+=1;artif=true;} + if (obj_ncombat.post_equipment_lost[o]="") and (last=0){last=o;obj_ncombat.post_equipment_lost[o]=marine_gear[i];obj_ncombat.post_equipments_lost[o]=1;artif=true;} + if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); + obj_ini.gear[marine_co[i],marine_id[i]]=""; + // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; + } + } + } + if (dece<=eqp_chance) then scr_add_item(marine_gear[i],1); + } + if (wah=5) and (obj_ini.mobi[marine_co[i],marine_id[i]]!=""){ + if (string_count("&",marine_mobi[i])>0){ + eqp_chance=90; + artif=true; + } + if (marine_dead[i]=2) or (destroy=2) then dece=9999; + if (obj_ini.race[marine_co[i],marine_id[i]]!=1) then dece=9999; + + if (dece>eqp_chance){ + var last,o;last=0;o=0; + repeat(50){ + if (last=0){ + o+=1; + artif=false; + if (obj_ncombat.post_equipment_lost[o]=marine_mobi[i]){ + last=1; + obj_ncombat.post_equipments_lost[o]+=1; + artif=true; + } + if (obj_ncombat.post_equipment_lost[o]="") and (last=0){last=o;obj_ncombat.post_equipment_lost[o]=marine_mobi[i];obj_ncombat.post_equipments_lost[o]=1;artif=true;} + if (artif=true) then obj_ncombat.post_equipment_lost[o]=clean_tags(obj_ncombat.post_equipment_lost[o]); + obj_ini.mobi[marine_co[i],marine_id[i]]=""; + // wep2[0,i]="";armour[0,i]="";gear[0,i]="";mobi[0,i]=""; + } + } + } + if (dece<=eqp_chance) then scr_add_item(marine_mobi[i],1); + } + } + + + + } + } + + for (var i=0;i 0 && _exp_amount > 0) { - var _individual_exp = _exp_amount / _eligible_units_count; - _average_exp = _individual_exp; - for (var i = 0; i < _eligible_units_count; i++) { - var _unit = _units[i][0]; - var _exp_mod = _units[i][1]; - var _exp_update_data = _unit.add_exp(_individual_exp*_exp_mod); - - var _powers_learned = _exp_update_data[1]; - if (_powers_learned > 0) { - array_push(obj_ncombat.upgraded_librarians, _unit); - } - - } - } - - return _average_exp; -} From 6351f39bdc82b17e66641db259a7bdec914feb86 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Fri, 28 Mar 2025 20:45:35 +0300 Subject: [PATCH 02/14] Fix some stuff --- ChapterMaster.yyp | 2 +- objects/obj_ncombat/Alarm_5.gml | 10 +- scripts/scr_after_combat/scr_after_combat.gml | 92 +++++++++---------- 3 files changed, 46 insertions(+), 58 deletions(-) diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index fa151d0b6f..714beea7ae 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -1681,4 +1681,4 @@ "TextureGroups":[ {"$GMTextureGroup":"","%Name":"Default","autocrop":true,"border":2,"compressFormat":"bz2","customOptions":"","directory":"","groupParent":null,"isScaled":false,"loadType":"default","mipsToGenerate":0,"name":"Default","resourceType":"GMTextureGroup","resourceVersion":"2.0","targets":-1,}, ], -} +} \ No newline at end of file diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 768f7b7720..2e9c8beea5 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -16,11 +16,10 @@ if (turn_count >= 50){ var roles = obj_ini.role[100]; var ground_mission = (instance_exists(obj_ground_mission)); - if (obj_ncombat.defeat == 0) { with (obj_pnunit) { - add_marines_to_recovery(self); - add_vehicles_to_recovery(self); + add_marines_to_recovery(); + add_vehicles_to_recovery(); } } @@ -44,7 +43,6 @@ if (array_length(marines_to_recover) > 0) { ds_priority_destroy(_recovery_queue); } - if (array_length(vehicles_to_recover) > 0) { var _vehicle_recovery_queue = ds_priority_create(); @@ -170,7 +168,7 @@ if (vehicle_deaths > 0) { for (var i = 0; i < array_length(post_unit_lost); i++) { if ((post_unit_lost[i] != "") && (post_units_lost[i] > 0) && (post_unit_veh[i] == 1)) { - newline += $" x{post_units_lost[i]}"; + newline += $" x{post_units_lost[i]} {post_unit_lost[i]}"; if (i < array_length(post_unit_lost) - 1) { newline += ","; } else { @@ -209,7 +207,7 @@ if (post_equipment_lost[1]!=""){ if (total_battle_exp_gain>0){ with (obj_pnunit) { - assemble_alive_units(self); + assemble_alive_units(); } average_battle_exp_gain = distribute_experience(end_alive_units, total_battle_exp_gain); // Due to cool alarm timer shitshow, I couldn't think of anything but to put it here. newline = $"Each marine gained {average_battle_exp_gain} experience, reduced by their total experience."; diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index f6e8bf97b9..cde96d7d74 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -1,61 +1,51 @@ -function add_marines_to_recovery(player_column) { - if (instance_exists(player_column)) { - if (obj_ncombat.unit_recovery_score > 0) { - for (var i = 0; i < array_length(player_column.unit_struct); i++) { - var _unit = player_column.unit_struct[i]; - if (is_struct(_unit) && player_column.ally[i] == false) { - if (player_column.marine_dead[i] == 1 && player_column.marine_type[i] != "") { - var _recovery_candidate = { - "id": i, - "unit": _unit, - "column_id": player_column.id, - "priority": _unit.experience - }; - array_push(obj_ncombat.marines_to_recover, _recovery_candidate); - } - } - } - } - } +/// @mixin +function add_marines_to_recovery() { + for (var i = 0; i < array_length(unit_struct); i++) { + var _unit = unit_struct[i]; + if (is_struct(_unit) && ally[i] == false) { + if (marine_dead[i] == 1 && marine_type[i] != "") { + var _recovery_candidate = { + "id": i, + "unit": _unit, + "column_id": id, + "priority": _unit.experience + }; + array_push(obj_ncombat.marines_to_recover, _recovery_candidate); + } + } + } } -function add_vehicles_to_recovery(player_column) { - if (instance_exists(player_column)) { - // Techmarines saving vehicles - if (obj_ncombat.vehicle_recovery_score > 0 && obj_ncombat.vehicle_deaths > 0) { - var _vehicles_priority = { - "Land Raider": 10, - "Predator": 5, - "Whirlwind": 4, - "Rhino": 3, - "Land Speeder": 3, - "Bike": 1 - } +/// @mixin +function add_vehicles_to_recovery() { + var _vehicles_priority = { + "Land Raider": 10, + "Predator": 5, + "Whirlwind": 4, + "Rhino": 3, + "Land Speeder": 3, + "Bike": 1 + } - for (var i = 0; i < array_length(player_column.veh_dead); i++) { - if (struct_exists(_vehicles_priority, player_column.veh_type[i])) && (player_column.veh_dead[i]) && (!player_column.veh_ally[i] ) { - if (player_column.veh_dead[i]) { - var _recovery_candidate = { - "id": i, - "column_id": player_column.id, - "priority": _vehicles_priority[$ player_column.veh_type[i]] - }; - array_push(obj_ncombat.vehicles_to_recover, _recovery_candidate); - } - } - } + for (var i = 0; i < array_length(veh_dead); i++) { + if (struct_exists(_vehicles_priority, veh_type[i])) && (veh_dead[i]) && (!veh_ally[i] ) { + var _recovery_candidate = { + "id": i, + "column_id": id, + "priority": _vehicles_priority[$ veh_type[i]] + }; + array_push(obj_ncombat.vehicles_to_recover, _recovery_candidate); } } } -function assemble_alive_units(player_column) { - if (instance_exists(player_column)) { - for (var i = 0; i < array_length(player_column.unit_struct); i++) { - var _unit = player_column.unit_struct[i]; - if (is_struct(_unit) && player_column.ally[i] == false) { - if (!player_column.marine_dead[i]) { - array_push(obj_ncombat.end_alive_units, _unit); - } +/// @mixin +function assemble_alive_units() { + for (var i = 0; i < array_length(unit_struct); i++) { + var _unit = unit_struct[i]; + if (is_struct(_unit) && ally[i] == false) { + if (!marine_dead[i]) { + array_push(obj_ncombat.end_alive_units, _unit); } } } From 1675e291c450b26b5a77128c97a250901f564c26 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Fri, 28 Mar 2025 21:25:57 +0300 Subject: [PATCH 03/14] Fill the priority ds directly --- objects/obj_ncombat/Alarm_5.gml | 45 ++++++++----------- scripts/scr_after_combat/scr_after_combat.gml | 4 +- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 2e9c8beea5..4d406b2fdc 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -16,22 +16,19 @@ if (turn_count >= 50){ var roles = obj_ini.role[100]; var ground_mission = (instance_exists(obj_ground_mission)); + + if (obj_ncombat.defeat == 0) { + marines_to_recover = ds_priority_create(); + vehicles_to_recover = ds_priority_create(); + with (obj_pnunit) { add_marines_to_recovery(); add_vehicles_to_recovery(); } -} - -if (array_length(marines_to_recover) > 0) { - var _recovery_queue = ds_priority_create(); - for (var i = 0; i < array_length(marines_to_recover); i++) { - ds_priority_add(_recovery_queue, marines_to_recover[i], marines_to_recover[i].priority); - } - - while (!ds_priority_empty(_recovery_queue) && unit_recovery_score > 0) { - var _candidate = ds_priority_delete_max(_recovery_queue); + while (!ds_priority_empty(marines_to_recover) && unit_recovery_score > 0) { + var _candidate = ds_priority_delete_max(marines_to_recover); var _column_id = _candidate.column_id; var _unit_id = _candidate.id; _candidate.unit.update_health(irandom(10)); @@ -39,22 +36,13 @@ if (array_length(marines_to_recover) > 0) { unit_recovery_score -= 1; units_saved += 1; } + ds_priority_destroy(marines_to_recover); - ds_priority_destroy(_recovery_queue); -} - -if (array_length(vehicles_to_recover) > 0) { - var _vehicle_recovery_queue = ds_priority_create(); - - for (var i = 0; i < array_length(vehicles_to_recover); i++) { - ds_priority_add(_vehicle_recovery_queue, vehicles_to_recover[i], vehicles_to_recover[i].priority); - } - - while (!ds_priority_empty(_vehicle_recovery_queue) && vehicle_recovery_score > 0) { - var _candidate = ds_priority_delete_max(_vehicle_recovery_queue); + while (!ds_priority_empty(vehicles_to_recover) && vehicle_recovery_score > 0) { + var _candidate = ds_priority_delete_max(vehicles_to_recover); var _column_id = _candidate.column_id; var _unit_id = _candidate.id; - + if (obj_controller.stc_bonus[3] = 4) { var _survival_roll = 80 + _candidate.priority; var _dice_roll = roll_dice(1, 100, "high"); @@ -66,17 +54,17 @@ if (array_length(vehicles_to_recover) > 0) { continue; } } - + _column_id.veh_hp[_unit_id] = 10; _column_id.veh_dead[_unit_id] = false; vehicle_recovery_score -= _candidate.priority; vehicles_saved++; vehicle_deaths--; } - - ds_priority_destroy(_vehicle_recovery_queue); + ds_priority_destroy(vehicles_to_recover); } + with (obj_pnunit) { after_battle_part1() } @@ -150,7 +138,8 @@ if (red_thirst>2){ newline=voodoo;newline_color="red"; scr_newtext(); - newline=" ";scr_newtext(); + newline=" "; + scr_newtext(); } newline = " "; @@ -178,6 +167,8 @@ if (vehicle_deaths > 0) { } newline_color="red"; scr_newtext(); + newline = " "; + scr_newtext(); } diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index cde96d7d74..e8f1340060 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -10,7 +10,7 @@ function add_marines_to_recovery() { "column_id": id, "priority": _unit.experience }; - array_push(obj_ncombat.marines_to_recover, _recovery_candidate); + ds_priority_add(obj_ncombat.marines_to_recover, _recovery_candidate, _recovery_candidate.priority); } } } @@ -34,7 +34,7 @@ function add_vehicles_to_recovery() { "column_id": id, "priority": _vehicles_priority[$ veh_type[i]] }; - array_push(obj_ncombat.vehicles_to_recover, _recovery_candidate); + ds_priority_add(obj_ncombat.vehicles_to_recover, _recovery_candidate, _recovery_candidate.priority); } } } From 06b23181fb54762f920a7aef905e34ff4a6c2959 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Fri, 28 Mar 2025 21:37:59 +0300 Subject: [PATCH 04/14] A couple of dice rolls --- objects/obj_ncombat/Alarm_5.gml | 6 +++--- objects/obj_pnunit/Alarm_4.gml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 4d406b2fdc..b1d95d39ee 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -31,7 +31,7 @@ if (obj_ncombat.defeat == 0) { var _candidate = ds_priority_delete_max(marines_to_recover); var _column_id = _candidate.column_id; var _unit_id = _candidate.id; - _candidate.unit.update_health(irandom(10)); + _candidate.unit.update_health(roll_personal_dice(1, 10, "high", _candidate.unit)); _column_id.marine_dead[_unit_id] = false; unit_recovery_score -= 1; units_saved += 1; @@ -47,7 +47,7 @@ if (obj_ncombat.defeat == 0) { var _survival_roll = 80 + _candidate.priority; var _dice_roll = roll_dice(1, 100, "high"); if (_dice_roll >= _survival_roll) && (_column_id.veh_dead[_unit_id] != 2) { - _column_id.veh_hp[_unit_id] = 10; + _column_id.veh_hp[_unit_id] = roll_dice(1, 10, "high"); _column_id.veh_dead[_unit_id] = false; vehicles_saved++; vehicle_deaths--; @@ -55,7 +55,7 @@ if (obj_ncombat.defeat == 0) { } } - _column_id.veh_hp[_unit_id] = 10; + _column_id.veh_hp[_unit_id] = roll_dice(1, 10, "high"); _column_id.veh_dead[_unit_id] = false; vehicle_recovery_score -= _candidate.priority; vehicles_saved++; diff --git a/objects/obj_pnunit/Alarm_4.gml b/objects/obj_pnunit/Alarm_4.gml index 93a7cd3815..dda84c6cb1 100644 --- a/objects/obj_pnunit/Alarm_4.gml +++ b/objects/obj_pnunit/Alarm_4.gml @@ -51,7 +51,7 @@ for (var i=0;i0) and (marine_dead[i]<2) and (unit.hp()>-25) and (marine_type[i]!="") and ((obj_ncombat.dropping+obj_ncombat.defeat)!=2){ + } else if (marine_dead[i] == 1) and (unit.hp()>-25) and (marine_type[i]!="") and ((obj_ncombat.dropping+obj_ncombat.defeat)!=2){ var rand1, survival; onceh=0; survival=40; From 76d27f762efbf9e4675ffad2efe9d6901f2a0cbc Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Fri, 28 Mar 2025 21:44:58 +0300 Subject: [PATCH 05/14] Proper type declaration (no type) --- objects/obj_ncombat/Create_0.gml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index c5a4bc83df..2a4c9b7b46 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -28,8 +28,8 @@ on_ship=false; alpha_strike=0; Warlord = 0; total_battle_exp_gain=0; -marines_to_recover = []; -vehicles_to_recover = []; +marines_to_recover; +vehicles_to_recover; end_alive_units = []; average_battle_exp_gain=0; upgraded_librarians=[]; From b6d6a9c0f465185d68d9a29333b86425c230fdc3 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 19:31:53 +0300 Subject: [PATCH 06/14] Role bonus priority and fix compile fail (it worked before) --- objects/obj_ncombat/Create_0.gml | 4 +- scripts/scr_after_combat/scr_after_combat.gml | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index 2a4c9b7b46..8984d068ae 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -28,8 +28,8 @@ on_ship=false; alpha_strike=0; Warlord = 0; total_battle_exp_gain=0; -marines_to_recover; -vehicles_to_recover; +marines_to_recover = 0; +vehicles_to_recover = 0; end_alive_units = []; average_battle_exp_gain=0; upgraded_librarians=[]; diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index e8f1340060..b5d7c1b0c7 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -1,15 +1,61 @@ /// @mixin function add_marines_to_recovery() { + var _roles = active_roles(); for (var i = 0; i < array_length(unit_struct); i++) { var _unit = unit_struct[i]; if (is_struct(_unit) && ally[i] == false) { if (marine_dead[i] == 1 && marine_type[i] != "") { + var _role_priority_bonus = 0; + var _chief_librarian = $"Chief {_roles[eROLE.Librarian]}"; + switch (_unit.role()) { + case "Chapter Master": + _role_priority_bonus = 720; + break; + case "Forge Master": + case "Master of Sanctity": + case "Master of the Apothecarion": + case _chief_librarian: + _role_priority_bonus = 360; + break; + case _roles[eROLE.Captain]: + case _roles[eROLE.HonourGuard]: + case _roles[eROLE.Ancient]: + _role_priority_bonus = 160; + break; + case _roles[eROLE.VeteranSergeant]: + case _roles[eROLE.Terminator]: + _role_priority_bonus = 80; + break; + case _roles[eROLE.Veteran]: + case _roles[eROLE.Sergeant]: + case _roles[eROLE.Champion]: + case _roles[eROLE.Chaplain]: + case _roles[eROLE.Apothecary]: + case _roles[eROLE.Techmarine]: + case _roles[eROLE.Librarian]: + case "Codiciery": + case "Lexicanum": + _role_priority_bonus = 40; + break; + case _roles[eROLE.Tactical]: + case _roles[eROLE.Assault]: + case _roles[eROLE.Devastator]: + _role_priority_bonus = 20; + break; + case _roles[eROLE.Scout]: + default: + _role_priority_bonus = 0; + break; + } + + var _priority = _unit.experience + _role_priority_bonus; var _recovery_candidate = { "id": i, "unit": _unit, "column_id": id, "priority": _unit.experience }; + ds_priority_add(obj_ncombat.marines_to_recover, _recovery_candidate, _recovery_candidate.priority); } } From 1c94c2209018fc63494a4d35694b55b1d097888e Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 19:35:10 +0300 Subject: [PATCH 07/14] Refactor role lost counts --- objects/obj_ncombat/Alarm_5.gml | 56 ++++++++++--------- objects/obj_ncombat/Create_0.gml | 7 ++- scripts/scr_after_combat/scr_after_combat.gml | 35 ++++-------- 3 files changed, 44 insertions(+), 54 deletions(-) diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index b1d95d39ee..b14184e529 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -31,7 +31,8 @@ if (obj_ncombat.defeat == 0) { var _candidate = ds_priority_delete_max(marines_to_recover); var _column_id = _candidate.column_id; var _unit_id = _candidate.id; - _candidate.unit.update_health(roll_personal_dice(1, 10, "high", _candidate.unit)); + var _unit = _candidate.unit; + _unit.update_health(roll_personal_dice(1, 10, "high", _unit)); _column_id.marine_dead[_unit_id] = false; unit_recovery_score -= 1; units_saved += 1; @@ -41,22 +42,22 @@ if (obj_ncombat.defeat == 0) { while (!ds_priority_empty(vehicles_to_recover) && vehicle_recovery_score > 0) { var _candidate = ds_priority_delete_max(vehicles_to_recover); var _column_id = _candidate.column_id; - var _unit_id = _candidate.id; + var _vehicle_id = _candidate.id; if (obj_controller.stc_bonus[3] = 4) { var _survival_roll = 80 + _candidate.priority; var _dice_roll = roll_dice(1, 100, "high"); - if (_dice_roll >= _survival_roll) && (_column_id.veh_dead[_unit_id] != 2) { - _column_id.veh_hp[_unit_id] = roll_dice(1, 10, "high"); - _column_id.veh_dead[_unit_id] = false; + if (_dice_roll >= _survival_roll) && (_column_id.veh_dead[_vehicle_id] != 2) { + _column_id.veh_hp[_vehicle_id] = roll_dice(1, 10, "high"); + _column_id.veh_dead[_vehicle_id] = false; vehicles_saved++; vehicle_deaths--; continue; } } - _column_id.veh_hp[_unit_id] = roll_dice(1, 10, "high"); - _column_id.veh_dead[_unit_id] = false; + _column_id.veh_hp[_vehicle_id] = roll_dice(1, 10, "high"); + _column_id.veh_dead[_vehicle_id] = false; vehicle_recovery_score -= _candidate.priority; vehicles_saved++; vehicle_deaths--; @@ -72,16 +73,15 @@ with (obj_pnunit) { var _total_deaths = (final_marine_deaths + final_command_deaths) - units_saved; if (_total_deaths > 0) { newline = $"Marines lost: {_total_deaths}!"; - if (array_length(post_unit_lost) > 0) { - for (var i = 0; i < array_length(post_unit_lost); i++) { - if ((post_unit_lost[i] != "") && (post_units_lost[i] > 0) && (post_unit_veh[i] == 0)) { - newline += $" {post_units_lost[i]}x {post_unit_lost[i]}"; - if (i < array_length(post_unit_lost) - 1) { - newline += ","; - } else { - newline += "."; - } - } + var _units_lost = struct_get_names(units_lost_counts); + for (var i = 0; i < array_length(_units_lost); i++) { + var _unit_role = _units_lost[i]; + var _lost_count = units_lost_counts[$ _unit_role]; + newline += $" {_lost_count}x {_unit_role}"; + if (i < array_length(_units_lost) - 1) { + newline += ","; + } else { + newline += "."; } } newline_color = "red"; @@ -155,16 +155,18 @@ if (vehicles_saved > 0) { if (vehicle_deaths > 0) { newline = $"Vehicles Lost: {vehicle_deaths}."; - for (var i = 0; i < array_length(post_unit_lost); i++) { - if ((post_unit_lost[i] != "") && (post_units_lost[i] > 0) && (post_unit_veh[i] == 1)) { - newline += $" x{post_units_lost[i]} {post_unit_lost[i]}"; - if (i < array_length(post_unit_lost) - 1) { - newline += ","; - } else { - newline += "."; - } - } - } + var _vehicles_lost = struct_get_names(vehicles_lost_counts); + for (var i = 0; i < array_length(_vehicles_lost); i++) { + var _vehicle_type = _vehicles_lost[i]; + var _lost_count = vehicles_lost_counts[$ _vehicle_type]; + newline += $" {_lost_count}x {_vehicle_type}"; + if (i < array_length(_vehicles_lost) - 1) { + newline += ","; + } else { + newline += "."; + } + } + newline_color="red"; scr_newtext(); newline = " "; diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index 8984d068ae..4a35ae7b2a 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -117,6 +117,10 @@ hulk_forces=0; i=-1;messages=0;messages_to_show=24;messages_shown=0; largest=0;priority=0;random_messages=0;dead_enemies=0; + +units_lost_counts = {}; +vehicles_lost_counts = {}; + repeat(70){i+=1; lines[i]=""; lines_color[i]=""; @@ -127,9 +131,6 @@ repeat(70){i+=1; dead_ene[i]=""; dead_ene_n[i]=0; - post_unit_lost[i]=""; - post_unit_veh[i]=0; - post_units_lost[i]=0; post_equipment_lost[i]=""; post_equipments_lost[i]=0; diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index b5d7c1b0c7..67611fb7cf 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -211,15 +211,12 @@ function after_battle_part1() { } var last=0; - for (var o=1;o Date: Mon, 31 Mar 2025 19:59:05 +0300 Subject: [PATCH 08/14] Constitution tests --- objects/obj_ncombat/Alarm_5.gml | 5 ++++- objects/obj_pnunit/Alarm_4.gml | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index b14184e529..cc9ec18c58 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -32,7 +32,10 @@ if (obj_ncombat.defeat == 0) { var _column_id = _candidate.column_id; var _unit_id = _candidate.id; var _unit = _candidate.unit; - _unit.update_health(roll_personal_dice(1, 10, "high", _unit)); + var _constitution_test_mod = _unit.hp() * -1; + var _constitution_test = global.character_tester.standard_test(_unit, "constitution", _constitution_test_mod); + + _unit.update_health(_constitution_test[1]); _column_id.marine_dead[_unit_id] = false; unit_recovery_score -= 1; units_saved += 1; diff --git a/objects/obj_pnunit/Alarm_4.gml b/objects/obj_pnunit/Alarm_4.gml index dda84c6cb1..b3218589cb 100644 --- a/objects/obj_pnunit/Alarm_4.gml +++ b/objects/obj_pnunit/Alarm_4.gml @@ -51,15 +51,15 @@ for (var i=0;i-25) and (marine_type[i]!="") and ((obj_ncombat.dropping+obj_ncombat.defeat)!=2){ - var rand1, survival; - onceh=0; - survival=40; - if (obj_ncombat.membrane=1) then survival-=20; - rand1=floor(random(100))+1; - skill_level = irandom(unit.luck); - rand1-=skill_level; - if (rand1<=survival) and (marine_dead[i]!=2){ + } else if (marine_dead[i] == 1) and (marine_type[i]!="") and ((obj_ncombat.dropping+obj_ncombat.defeat)!=2){ + var survival_mod = unit.luck * -1; + if (obj_ncombat.membrane == 1) { + survival_mod += 20; + } + survival_mod += unit.hp() * -1; + + var survival_test = global.character_tester.standard_test(unit, "constitution", survival_mod); + if (survival_test[0]) { // show_message(string(marine_type[i])+" mans up#Roll: "+string(rand1)+"#Needed: "+string(survival)+"-"); marine_dead[i]=0; //unit.update_health(2); From 6c369bfffd085d3fb228603d062c6faf65277495 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:10:29 +0300 Subject: [PATCH 09/14] Move another alarm to a function, repair after battle text, move random survival to the recovery code, repair enemy kills display --- objects/obj_ncombat/Alarm_3.gml | 1 + objects/obj_ncombat/Alarm_5.gml | 87 ++++++++++++------- objects/obj_pnunit/Alarm_4.gml | 75 ---------------- objects/obj_pnunit/obj_pnunit.yy | 1 - scripts/scr_after_combat/scr_after_combat.gml | 74 ++++++++++++++-- scripts/scr_flavor2/scr_flavor2.gml | 5 +- 6 files changed, 124 insertions(+), 119 deletions(-) delete mode 100644 objects/obj_pnunit/Alarm_4.gml diff --git a/objects/obj_ncombat/Alarm_3.gml b/objects/obj_ncombat/Alarm_3.gml index 960ade494f..8c1092dcf2 100644 --- a/objects/obj_ncombat/Alarm_3.gml +++ b/objects/obj_ncombat/Alarm_3.gml @@ -94,6 +94,7 @@ if ((messages>0) and (messages_shown<24)) and (messages_shown<=100){ newline=message[that]; if (message_priority[that]>0) then newline_color="bright"; if (string_count("lost",newline)>0) then newline_color="red"; + if (string_count("critically injured",newline)>0) then newline_color="red"; if (string_count("^",newline)>0){ newline=string_replace(newline,"^",""); newline_color="white"; diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index cc9ec18c58..16ac70eadc 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -16,7 +16,9 @@ if (turn_count >= 50){ var roles = obj_ini.role[100]; var ground_mission = (instance_exists(obj_ground_mission)); - +with (obj_pnunit) { + after_battle_part1(); +} if (obj_ncombat.defeat == 0) { marines_to_recover = ds_priority_create(); @@ -27,7 +29,7 @@ if (obj_ncombat.defeat == 0) { add_vehicles_to_recovery(); } - while (!ds_priority_empty(marines_to_recover) && unit_recovery_score > 0) { + while (!ds_priority_empty(marines_to_recover)) { var _candidate = ds_priority_delete_max(marines_to_recover); var _column_id = _candidate.column_id; var _unit_id = _candidate.id; @@ -35,14 +37,30 @@ if (obj_ncombat.defeat == 0) { var _constitution_test_mod = _unit.hp() * -1; var _constitution_test = global.character_tester.standard_test(_unit, "constitution", _constitution_test_mod); - _unit.update_health(_constitution_test[1]); - _column_id.marine_dead[_unit_id] = false; - unit_recovery_score -= 1; - units_saved += 1; + if (unit_recovery_score > 0) { + _unit.update_health(_constitution_test[1]); + _column_id.marine_dead[_unit_id] = false; + unit_recovery_score--; + units_saved++; + continue; + } + + if (_unit.base_group == "astartes") { + if (!_unit.gene_seed_mutations[$ "membrane"]) { + var survival_mod = _unit.luck * -1; + survival_mod += _unit.hp() * -1; + + var survival_test = global.character_tester.standard_test(_unit, "constitution", survival_mod); + if (survival_test[0]) { + _column_id.marine_dead[_unit_id] = false; + injured++; + } + } + } } ds_priority_destroy(marines_to_recover); - while (!ds_priority_empty(vehicles_to_recover) && vehicle_recovery_score > 0) { + while (!ds_priority_empty(vehicles_to_recover)) { var _candidate = ds_priority_delete_max(vehicles_to_recover); var _column_id = _candidate.column_id; var _vehicle_id = _candidate.id; @@ -59,29 +77,43 @@ if (obj_ncombat.defeat == 0) { } } - _column_id.veh_hp[_vehicle_id] = roll_dice(1, 10, "high"); - _column_id.veh_dead[_vehicle_id] = false; - vehicle_recovery_score -= _candidate.priority; - vehicles_saved++; - vehicle_deaths--; + if (vehicle_recovery_score > 0) { + _column_id.veh_hp[_vehicle_id] = roll_dice(1, 10, "high"); + _column_id.veh_dead[_vehicle_id] = false; + vehicle_recovery_score -= _candidate.priority; + vehicles_saved++; + vehicle_deaths--; + } } ds_priority_destroy(vehicles_to_recover); } with (obj_pnunit) { - after_battle_part1() + after_battle_part2(); } -var _total_deaths = (final_marine_deaths + final_command_deaths) - units_saved; +if (units_saved > 0) { + newline = $"{units_saved}x were critically injured, but {string_plural(roles[eROLE.Apothecary])} were able to save them!"; + newline_color = "red"; + scr_newtext(); +} + +if (injured > 0) { + newline = $"{injured}x marines were critically injured, but barerly survived, thanks to the Sus-an Membrane!"; + newline_color = "red"; + scr_newtext(); +} + +var _total_deaths = final_marine_deaths + final_command_deaths; if (_total_deaths > 0) { - newline = $"Marines lost: {_total_deaths}!"; - var _units_lost = struct_get_names(units_lost_counts); - for (var i = 0; i < array_length(_units_lost); i++) { - var _unit_role = _units_lost[i]; + newline = $"{_total_deaths}x units succumbed to their wounds!"; + var _unit_roles = struct_get_names(units_lost_counts); + for (var i = 0; i < array_length(_unit_roles); i++) { + var _unit_role = _unit_roles[i]; var _lost_count = units_lost_counts[$ _unit_role]; newline += $" {_lost_count}x {_unit_role}"; - if (i < array_length(_units_lost) - 1) { + if (i < array_length(_unit_roles) - 1) { newline += ","; } else { newline += "."; @@ -91,16 +123,7 @@ if (_total_deaths > 0) { scr_newtext(); } -if (units_saved > 0) { - newline = $"{string_plural(roles[eROLE.Apothecary])} saved {units_saved} marines."; - scr_newtext(); -} -if (injured > 0) { - newline = $"Marines critically injured: {injured}!"; - newline_color = "red"; - scr_newtext(); -} if (ground_mission){ if (apothecaries_alive < 0){ @@ -158,12 +181,12 @@ if (vehicles_saved > 0) { if (vehicle_deaths > 0) { newline = $"Vehicles Lost: {vehicle_deaths}."; - var _vehicles_lost = struct_get_names(vehicles_lost_counts); - for (var i = 0; i < array_length(_vehicles_lost); i++) { - var _vehicle_type = _vehicles_lost[i]; + var _vehicle_types = struct_get_names(vehicles_lost_counts); + for (var i = 0; i < array_length(_vehicle_types); i++) { + var _vehicle_type = _vehicle_types[i]; var _lost_count = vehicles_lost_counts[$ _vehicle_type]; newline += $" {_lost_count}x {_vehicle_type}"; - if (i < array_length(_vehicles_lost) - 1) { + if (i < array_length(_vehicle_types) - 1) { newline += ","; } else { newline += "."; diff --git a/objects/obj_pnunit/Alarm_4.gml b/objects/obj_pnunit/Alarm_4.gml deleted file mode 100644 index b3218589cb..0000000000 --- a/objects/obj_pnunit/Alarm_4.gml +++ /dev/null @@ -1,75 +0,0 @@ - -// -var unit; -var skill_level; -for (var i=0;i0) or (obj_ncombat.defeat!=0)) and (marine_type[i]!="") and (ally[i]=false){ - var comm=false; if (_unit.IsSpecialist("standard",true)){ obj_ncombat.final_command_deaths+=1; @@ -214,9 +213,9 @@ function after_battle_part1() { var _unit_role = _unit.role(); if (!struct_exists(obj_ncombat.units_lost_counts, _unit_role)) { - obj_ncombat.units_lost_counts._unit_role = 1; + obj_ncombat.units_lost_counts[$ _unit_role] = 1; } else { - obj_ncombat.units_lost_counts._unit_role++; + obj_ncombat.units_lost_counts[$ _unit_role]++; } // Determine which companies to crunch @@ -387,9 +386,9 @@ function after_battle_part1() { var _vehicle_type = _veh_type[i]; if (!struct_exists(obj_ncombat.vehicles_lost_counts, _vehicle_type)) { - obj_ncombat.vehicles_lost_counts._vehicle_type = 1; + obj_ncombat.vehicles_lost_counts[$ _vehicle_type] = 1; } else { - obj_ncombat.vehicles_lost_counts._vehicle_type++; + obj_ncombat.vehicles_lost_counts[$ _vehicle_type]++; } // Determine which companies to crunch @@ -397,4 +396,63 @@ function after_battle_part1() { } } -} \ No newline at end of file +} + +/// @mixin +function after_battle_part1() { + var unit; + var skill_level; + for (var i=0;i 1) then m2 += " have been lost."; + if (lost_units_count > 0) then m2 += " critically injured."; // show_message(m2); @@ -376,8 +376,7 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo var lis, y1, y2; lis = string_rpos(", ", m2); m2 = string_delete(m2, lis, 3); - if (lost_units_count > 1) then m2 += " have been lost."; - if (lost_units_count = 1) then m2 += " has been lost."; + if (lost_units_count > 0) then m2 += " critically injured."; } if (string_count(", ", m2) = 1) and(unce = 0) and(hostile_weapon = "Web Spinner") { var lis, y1, y2; From bfd5a08faa85f3bfedfad43f635e9e6f458a4936 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:26:37 +0300 Subject: [PATCH 10/14] Additional adjustments --- objects/obj_ncombat/Alarm_5.gml | 49 +++++++++++++++-------------- scripts/scr_flavor2/scr_flavor2.gml | 4 +-- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 16ac70eadc..a607860f0d 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -93,38 +93,41 @@ with (obj_pnunit) { after_battle_part2(); } -if (units_saved > 0) { - newline = $"{units_saved}x were critically injured, but {string_plural(roles[eROLE.Apothecary])} were able to save them!"; +var _total_deaths = final_marine_deaths + final_command_deaths; +if (_total_deaths > 0 || injured > 0 || units_saved > 0) { + newline = $"{_total_deaths + injured + units_saved}x units were critically injured."; newline_color = "red"; scr_newtext(); -} -if (injured > 0) { - newline = $"{injured}x marines were critically injured, but barerly survived, thanks to the Sus-an Membrane!"; - newline_color = "red"; - scr_newtext(); -} + if (units_saved > 0) { + newline = $"{units_saved}x were saved by the {string_plural(roles[eROLE.Apothecary])}."; + scr_newtext(); + } + if (injured > 0) { + newline = $"{injured}x survived thanks to the Sus-an Membrane."; + newline_color = "red"; + scr_newtext(); + } -var _total_deaths = final_marine_deaths + final_command_deaths; -if (_total_deaths > 0) { - newline = $"{_total_deaths}x units succumbed to their wounds!"; - var _unit_roles = struct_get_names(units_lost_counts); - for (var i = 0; i < array_length(_unit_roles); i++) { - var _unit_role = _unit_roles[i]; - var _lost_count = units_lost_counts[$ _unit_role]; - newline += $" {_lost_count}x {_unit_role}"; - if (i < array_length(_unit_roles) - 1) { - newline += ","; - } else { - newline += "."; + if (_total_deaths > 0) { + newline = $"{_total_deaths}x units succumbed to their wounds!"; + var _unit_roles = struct_get_names(units_lost_counts); + for (var i = 0; i < array_length(_unit_roles); i++) { + var _unit_role = _unit_roles[i]; + var _lost_count = units_lost_counts[$ _unit_role]; + newline += $" {_lost_count}x {_unit_role}"; + if (i < array_length(_unit_roles) - 1) { + newline += ","; + } else { + newline += "."; + } } + newline_color = "red"; + scr_newtext(); } - newline_color = "red"; - scr_newtext(); } - if (ground_mission){ if (apothecaries_alive < 0){ obj_ground_mission.apothecary_present = apothecaries_alive; diff --git a/scripts/scr_flavor2/scr_flavor2.gml b/scripts/scr_flavor2/scr_flavor2.gml index 0a7f208a4a..5769971e44 100644 --- a/scripts/scr_flavor2/scr_flavor2.gml +++ b/scripts/scr_flavor2/scr_flavor2.gml @@ -355,7 +355,7 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo var lis, y1, y2; lis = string_rpos(", ", m2); m2 = string_delete(m2, lis, 3); // This clears the last ', ' and replaces it with the end statement - if (lost_units_count > 0) then m2 += " critically injured."; + if (lost_units_count > 0) then m2 += " critically damaged."; // show_message(m2); @@ -376,7 +376,7 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo var lis, y1, y2; lis = string_rpos(", ", m2); m2 = string_delete(m2, lis, 3); - if (lost_units_count > 0) then m2 += " critically injured."; + if (lost_units_count > 0) then m2 += " critically damaged."; } if (string_count(", ", m2) = 1) and(unce = 0) and(hostile_weapon = "Web Spinner") { var lis, y1, y2; From 7d8d42776477ed6861965438dc68c333fb1429ae Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:28:19 +0300 Subject: [PATCH 11/14] Typo fix --- scripts/scr_after_combat/scr_after_combat.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index 9c05aa1f7e..d0a3b710ef 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -384,7 +384,7 @@ function after_battle_part2() { if ((veh_dead[i]=1) or (obj_ncombat.defeat!=0)) and (veh_type[i]!="") and (veh_ally[i]=false){ obj_ncombat.vehicle_deaths+=1; - var _vehicle_type = _veh_type[i]; + var _vehicle_type = veh_type[i]; if (!struct_exists(obj_ncombat.vehicles_lost_counts, _vehicle_type)) { obj_ncombat.vehicles_lost_counts[$ _vehicle_type] = 1; } else { From 02e4876f6e748e0beb9449a6427c0f0744945a97 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:28:56 +0300 Subject: [PATCH 12/14] Another typo fix --- scripts/scr_after_combat/scr_after_combat.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index d0a3b710ef..fb4979c68c 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -53,7 +53,7 @@ function add_marines_to_recovery() { "id": i, "unit": _unit, "column_id": id, - "priority": _unit.experience + "priority": _priority }; ds_priority_add(obj_ncombat.marines_to_recover, _recovery_candidate, _recovery_candidate.priority); From 27ec14994a74cb88c001a5e47e6fd75b5461fe86 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:32:00 +0300 Subject: [PATCH 13/14] Fallback priority --- scripts/scr_after_combat/scr_after_combat.gml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index fb4979c68c..f1cf5ed558 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -74,13 +74,21 @@ function add_vehicles_to_recovery() { } for (var i = 0; i < array_length(veh_dead); i++) { - if (struct_exists(_vehicles_priority, veh_type[i])) && (veh_dead[i]) && (!veh_ally[i] ) { + if (veh_dead[i]) && (!veh_ally[i]) { + var _priority = 1; + if (struct_exists(_vehicles_priority, veh_type[i])) { + _priority = _vehicles_priority[$ veh_type[i]]; + } + var _recovery_candidate = { "id": i, "column_id": id, - "priority": _vehicles_priority[$ veh_type[i]] + "priority": _priority }; + ds_priority_add(obj_ncombat.vehicles_to_recover, _recovery_candidate, _recovery_candidate.priority); + } else { + continue; } } } From 545930a684b5edc125676423cecda31fc9110570 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:49:19 +0300 Subject: [PATCH 14/14] Forgotten alarm call --- objects/obj_ncombat/KeyPress_13.gml | 3 --- 1 file changed, 3 deletions(-) diff --git a/objects/obj_ncombat/KeyPress_13.gml b/objects/obj_ncombat/KeyPress_13.gml index 412fc2a8a3..1c1087c2fc 100644 --- a/objects/obj_ncombat/KeyPress_13.gml +++ b/objects/obj_ncombat/KeyPress_13.gml @@ -49,9 +49,6 @@ if ((started=2) or (started=4)){ // started=3;alarm[5]=3;obj_pnunit.alarm[4]=1;obj_pnunit.alarm[5]=2;obj_enunit.alarm[1]=3; started=3; // obj_pnunit.alarm[4]=2;obj_pnunit.alarm[5]=3;obj_enunit.alarm[1]=1; - if (instance_exists(obj_pnunit)){ - obj_pnunit.alarm[4]=2; - } total_battle_exp_gain = threat * 50; if (instance_exists(obj_enunit)){obj_enunit.alarm[1]=1;} instance_activate_object(obj_star);