diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index da4d95ea98..714beea7ae 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",},}, @@ -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_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 d7e5af6db0..a607860f0d 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,35 +15,119 @@ 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 (injured>0) then part8=$"Marines Critically Injured: {injured}"; + +with (obj_pnunit) { + after_battle_part1(); +} + +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(); + } + + 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; + var _unit = _candidate.unit; + var _constitution_test_mod = _unit.hp() * -1; + var _constitution_test = global.character_tester.standard_test(_unit, "constitution", _constitution_test_mod); + + 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 i=0; - for (var i=1;i0) and (post_unit_veh[i]=0){ - part2+=$"{post_units_lost[i]}x {post_unit_lost[i]},"; + var survival_test = global.character_tester.standard_test(_unit, "constitution", survival_mod); + if (survival_test[0]) { + _column_id.marine_dead[_unit_id] = false; + injured++; + } + } } } - part2=string_delete(part2,string_length(part2)-1,2); - part2+=".";i=0; + ds_priority_destroy(marines_to_recover); + + 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; - if (injured>0){ - newline=part8; + 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[_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; + } + } + + 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_part2(); +} + +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 (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(); + } + + 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=part1; - scr_newtext(); - newline=part2; - newline_color="red"; - scr_newtext(); - newline=" "; - scr_newtext(); } + if (ground_mission){ if (apothecaries_alive < 0){ obj_ground_mission.apothecary_present = apothecaries_alive; @@ -64,7 +148,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 += "%)"; @@ -83,29 +167,43 @@ if (red_thirst>2){ newline=voodoo;newline_color="red"; scr_newtext(); - newline=" ";scr_newtext(); + 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])+", "; + + +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}."; + + 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(_vehicle_types) - 1) { + newline += ","; + } else { + newline += "."; } } - part5=string_delete(part5,string_length(part5)-1,2);part5+=".";i=0; - - newline=part4;scr_newtext(); - newline=part5;scr_newtext(); - newline=" ";scr_newtext(); + + newline_color="red"; + scr_newtext(); + newline = " "; + scr_newtext(); } + if (post_equipment_lost[1]!=""){ part6="Equipment Lost: "; @@ -126,7 +224,13 @@ if (post_equipment_lost[1]!=""){ newline=" "; scr_newtext(); } + + + if (total_battle_exp_gain>0){ + with (obj_pnunit) { + 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."; scr_newtext(); @@ -137,7 +241,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 +255,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..4a35ae7b2a 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 = 0; +vehicles_to_recover = 0; end_alive_units = []; average_battle_exp_gain=0; upgraded_librarians=[]; @@ -115,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]=""; @@ -125,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; @@ -147,11 +150,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..1c1087c2fc 100644 --- a/objects/obj_ncombat/KeyPress_13.gml +++ b/objects/obj_ncombat/KeyPress_13.gml @@ -49,10 +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; - obj_pnunit.alarm[5]=3; - } total_battle_exp_gain = threat * 50; if (instance_exists(obj_enunit)){obj_enunit.alarm[1]=1;} instance_activate_object(obj_star); diff --git a/objects/obj_pnunit/Alarm_4.gml b/objects/obj_pnunit/Alarm_4.gml deleted file mode 100644 index 93a7cd3815..0000000000 --- a/objects/obj_pnunit/Alarm_4.gml +++ /dev/null @@ -1,75 +0,0 @@ - -// -var unit; -var skill_level; -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){ - 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){ - // show_message(string(marine_type[i])+" mans up#Roll: "+string(rand1)+"#Needed: "+string(survival)+"-"); - marine_dead[i]=0; - //unit.update_health(2); - obj_ncombat.injured+=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 && _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; +} + +/// @mixin +function after_battle_part2() { + 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; + + var _unit_role = _unit.role(); + if (!struct_exists(obj_ncombat.units_lost_counts, _unit_role)) { + obj_ncombat.units_lost_counts[$ _unit_role] = 1; + } else { + obj_ncombat.units_lost_counts[$ _unit_role]++; + } + + // Determine which companies to crunch + obj_ncombat.crunch[marine_co[i]]=1; + destroy=1; + } + + if (marine_armour[i]="") and (marine_wep1[i]="") and (marine_wep2[i]="") and (marine_gear[i]="") and (marine_mobi[i]="") and (marine_type[i]!="") then destroy=2; + + if (destroy>0) 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; -} diff --git a/scripts/scr_flavor2/scr_flavor2.gml b/scripts/scr_flavor2/scr_flavor2.gml index cfb97a3a8f..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 > 1) then m2 += " have been lost."; + if (lost_units_count > 0) then m2 += " critically damaged."; // 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 damaged."; } if (string_count(", ", m2) = 1) and(unce = 0) and(hostile_weapon = "Web Spinner") { var lis, y1, y2;