diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 7b18105313..683ee7deca 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -942,7 +942,6 @@ {"id":{"name":"scr_secret_lair_view","path":"scripts/scr_secret_lair_view/scr_secret_lair_view.yy",},}, {"id":{"name":"scr_serialization_functions","path":"scripts/scr_serialization_functions/scr_serialization_functions.yy",},}, {"id":{"name":"scr_shader_initialize","path":"scripts/scr_shader_initialize/scr_shader_initialize.yy",},}, - {"id":{"name":"scr_ship_battle","path":"scripts/scr_ship_battle/scr_ship_battle.yy",},}, {"id":{"name":"scr_ship_count","path":"scripts/scr_ship_count/scr_ship_count.yy",},}, {"id":{"name":"scr_ship_functions","path":"scripts/scr_ship_functions/scr_ship_functions.yy",},}, {"id":{"name":"scr_ship_occupants","path":"scripts/scr_ship_occupants/scr_ship_occupants.yy",},}, diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index 04aabf7f11..df6984930b 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -32,10 +32,9 @@ var d7 = ""; var _newline = ""; var _newline_color = eMSG_COLOR.DEFAULT; -var temp = scouts + tacticals + veterans + devastators + assaults + librarians; -temp += techmarines + honors + dreadnoughts + terminators + captains; -temp += standard_bearers + champions + important_dudes + chaplains + apothecaries; -temp += sgts + vet_sgts; +var _marine_roles = active_roles(); + +var _marine_count = player_unit_index.sum_roles(_marine_roles); // Random variations; dark out, rain pooling down, dawn shining off of the armour, etc. var variation = choose("", "dawn", "rain"); @@ -73,24 +72,26 @@ if (battle_special == "space_hulk") { } } +var _dread_count = player_unit_index.sum_roles([_marine_roles[eROLE.DREADNOUGHT]]); + if (battle_special == "") { if (!dropping) { - if (temp - dreadnoughts > 0) { + if (_marine_count - _dread_count > 0) { if (variation == "") { - p1 = "Dirt crunches beneath the soles of " + string(temp) + " " + string(global.chapter_name) + " as they form up. Your ranks are made up of "; + p1 = "Dirt crunches beneath the soles of " + string(_marine_count) + " " + string(global.chapter_name) + " as they form up. Your ranks are made up of "; } if (variation == "rain") { - p1 = "Rain pelts the ground and fogs the air, partly veiling the " + string(temp) + " " + string(global.chapter_name) + ". Your ranks are made up of "; + p1 = "Rain pelts the ground and fogs the air, partly veiling the " + string(_marine_count) + " " + string(global.chapter_name) + ". Your ranks are made up of "; } if (variation == "dawn") { - p1 = "The bright light of dawn reflects off the " + string_lower(color_descr) + " ceremite of " + string(temp) + " " + string(global.chapter_name) + ". Your ranks are made up of "; + p1 = "The bright light of dawn reflects off the " + string_lower(color_descr) + " ceremite of " + string(_marine_count) + " " + string(global.chapter_name) + ". Your ranks are made up of "; } } } if (dropping) { - if (temp - dreadnoughts > 0) { + if (_marine_count - _dread_count > 0) { // lyman - p1 = "The air rumbles and quakes as " + string(temp) + " " + string(global.chapter_name) + " descend in drop-pods. "; + p1 = "The air rumbles and quakes as " + string(_marine_count) + " " + string(global.chapter_name) + " descend in drop-pods. "; } } } @@ -162,133 +163,51 @@ if (string_count("_attack", battle_special) > 0) { exit; } -if ((tacticals > 0) && (veterans > 0)) { - p2 = string(tacticals + veterans) + " " + string(obj_ini.player_role_data[eROLE.TACTICAL].role) + "s, "; -} -if ((tacticals > 0) && (veterans == 0)) { - if (tacticals == 1) { - p2 = string(tacticals) + " " + string(obj_ini.player_role_data[eROLE.TACTICAL].role) + ", "; - } - if (tacticals > 1) { - p2 = string(tacticals) + " " + string(obj_ini.player_role_data[eROLE.TACTICAL].role) + "s, "; - } -} -if ((tacticals == 0) && (veterans > 0)) { - if (veterans == 1) { - p2 = string(veterans) + " " + string(obj_ini.player_role_data[eROLE.VETERAN].role) + ", "; - } - if (veterans > 1) { - p2 = string(veterans) + " " + string(obj_ini.player_role_data[eROLE.VETERAN].role) + "s, "; - } -} -if (assaults > 0) { - if (assaults == 1) { - p2 += string(assaults) + " " + string(obj_ini.player_role_data[eROLE.ASSAULT].role) + ", "; - } - if (assaults > 1) { - p2 += string(assaults) + " " + string(obj_ini.player_role_data[eROLE.ASSAULT].role) + "s, "; - } -} -if (devastators > 0) { - if (devastators == 1) { - p2 += string(devastators) + " " + string(obj_ini.player_role_data[eROLE.DEVASTATOR].role) + ", "; - } - if (devastators > 1) { - p2 += string(devastators) + " " + string(obj_ini.player_role_data[eROLE.DEVASTATOR].role) + "s, "; - } -} -if ((temp < 200) && (terminators > 0)) { - if (terminators == 1) { - p2 += string(terminators) + " Terminator, "; - } - if (terminators > 1) { - p2 += string(terminators) + " Terminators, "; - } -} +p2 = ""; +var _auto_include = [ + _marine_roles[eROLE.TACTICAL], + _marine_roles[eROLE.VETERAN], + _marine_roles[eROLE.ASSAULT], + _marine_roles[eROLE.DEVASTATOR], +] -if ((temp < 200) && (chaplains > 0)) { - if (chaplains == 1) { - p2 += string(chaplains) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + ", "; - } - if (chaplains > 1) { - p2 += string(chaplains) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + ", "; +for (var i = 0; i < array_length(_auto_include); i++){ + var _role = _auto_include[i]; + if (player_unit_index.role_count(_role) > 0){ + p2 += player_unit_index.plural_string_role(_role) + ", "; } } -if ((temp < 200) && (apothecaries > 0)) { - if (apothecaries == 1) { - p2 += string(apothecaries) + " " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ", "; - } - if (apothecaries > 1) { - p2 += string(apothecaries) + " " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ", "; +var _small_include = [ + _marine_roles[eROLE.TERMINATOR], + _marine_roles[eROLE.CHAPLAIN], + _marine_roles[eROLE.APOTHECARY], + _marine_roles[eROLE.LIBRARIAN], + _marine_roles[eROLE.TECHMARINE], + _marine_roles[eROLE.SERGEANT], + _marine_roles[eROLE.VETERANSERGEANT], + _marine_roles[eROLE.SCOUT], +] +if (_marine_count < 200) { + for (var i = 0; i < array_length(_small_include); i++){ + var _role = _small_include[i]; + if (player_unit_index.role_count(_role) > 0){ + p2 += player_unit_index.plural_string_role(_role) + ", "; + } } -} +} else { -if ((temp < 200) && (librarians > 0)) { - if (librarians == 1) { - p2 += string(librarians) + " " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + ", "; - } - if (librarians > 1) { - p2 += string(librarians) + " " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + ", "; - } -} + var _other_count = _marine_count + - player_unit_index.sum_roles(_auto_include) + - _dread_count; -if ((temp < 200) && (techmarines > 0)) { - if (techmarines == 1) { - p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + ", "; - } - if (techmarines > 1) { - p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + ", "; - } -} -if ((temp < 200) && (sgts > 0)) { - if (techmarines == 1) { - p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.SERGEANT].role) + ", "; - } - if (techmarines > 1) { - p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.SERGEANT].role) + ", "; - } -} -if ((temp < 200) && (vet_sgts > 0)) { - if (techmarines == 1) { - p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.VETERANSERGEANT].role) + ", "; - } - if (techmarines > 1) { - p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.VETERANSERGEANT].role) + ", "; - } -} - -if (scouts > 0) { - if (scouts == 1) { - p2 += string(scouts) + " " + string(obj_ini.player_role_data[eROLE.SCOUT].role) + ", "; - } - if (scouts > 1) { - p2 += string(scouts) + " " + string(obj_ini.player_role_data[eROLE.SCOUT].role) + "s, "; + if (_other_count > 0) { + p2 += $"{_other_count} other various Astartes, "; } } -temp6 = honors + captains + important_dudes + standard_bearers; -if (temp >= 200) { - temp6 += terminators; -} -if (temp >= 200) { - temp6 += chaplains; -} -if (temp >= 200) { - temp6 += apothecaries; -} -if (temp >= 200) { - temp6 += techmarines; -} -if (temp >= 200) { - temp6 += librarians; -} -if (temp6 > 0) { - p2 += string(temp6) + " other various Astartes, "; -} - var woo = string_length(p2); p2 = string_delete(p2, woo - 1, 2); @@ -303,52 +222,40 @@ if (string_count(", ", p2) == 1) { } p2 += "."; -if ((standard_bearers > 1) && (!dropping)) { +if ((player_unit_index.role_count(_marine_roles[eROLE.ANCIENT]) > 1) && (!dropping)) { p5 = " Chapter Ancients hold your Chapter heraldry high and proud."; } -if (dreadnoughts + predators + land_raiders > 3) { - p6 = " Forming up the armoured division is "; - if (dreadnoughts == 1) { - p6 += string(dreadnoughts) + " " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role) + ", "; - } - if (dreadnoughts > 1) { - p6 += string(dreadnoughts) + " " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role) + "s, "; - } +if (_dread_count > 0) { + p6 = " Venerably inspiring the chapter stand "; + p6 += string_plural_count( + _marine_roles[eROLE.DREADNOUGHT], + _dread_count, + false + ) + "."; +} - if (rhinos == 1) { - p6 += string(rhinos) + " Rhino, "; - } - if (rhinos > 1) { - p6 += string(rhinos) + " Rhinos, "; - } +if (predators + land_raiders > 3) { + p6 += " Forming up the armoured division is "; - if (predators == 1) { - p6 += string(predators) + " Predator, "; + if (rhinos > 0) { + p6 += string_plural_count("Rhino", rhinos) + ", "; } - if (predators > 1) { - p6 += string(predators) + " Predators, "; + + if (predators > 0) { + p6 += string_plural_count("Predator", predators) + ", "; } - if (land_raiders == 1) { - p6 += string(land_raiders) + " Land Raider, "; - } - if (land_raiders > 1) { - p6 += string(land_raiders) + " Land Raiders, "; + if (land_raiders > 0) { + p6 += string_plural_count("Land Raider", land_raiders) + ", "; } - if (land_speeders == 1) { - p6 += string(land_speeders) + " Land Speeder, "; - } - if (land_speeders > 1) { - p6 += string(land_speeders) + " Land Speeders, "; + if (land_speeders > 0) { + p6 += string_plural_count("Land Speeder", land_speeders) + ", "; } - if (whirlwinds == 1) { - p6 += string(whirlwinds) + " Whirlwind, "; - } - if (whirlwinds > 1) { - p6 += string(whirlwinds) + " Whirlwinds, "; + if (whirlwinds > 0) { + p6 += string_plural_count("Whirlwind", whirlwinds) + ", "; } // Other vehicles here? @@ -589,8 +496,25 @@ if ((fortified > 1) && !dropping && !(enemy == eFACTION.CHAOS && threat == 7)) { combat_log.push(_newline, _newline_color); } +var _roles = active_roles(); +var _speech_giver_role_priority = [ + _roles[eROLE.CHAPTERMASTER], + _roles[eROLE.MASTERCHAPLAIN], + _roles[eROLE.CHIEFLIBRARIAN], + _roles[eROLE.CAPTAIN], + _roles[eROLE.CHAPLAIN], +] + +var _speech_giver_role = -1; +for (var i = 0; i < array_length(_speech_giver_role_priority); i++){ + if (player_unit_index.has_role(_speech_giver_role_priority[i])){ + _speech_giver_role = i; + break; + } +} + // Check for battlecry here -if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && !dropping) { +if ((_marine_count >= 100) && (threat > 1) && _speech_giver_role > -1 && !dropping) { p1 = ""; p2 = ""; p3 = ""; @@ -600,67 +524,62 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && !dropp temp4 = 0; temp5 = 0; - if (big_mofo == 1) { + var _r_name = _speech_giver_role_priority[_speech_giver_role]; + var _index = player_unit_index.role_index; + var _speech_giver = _index[$ _r_name][0]; + + var _cm_giving_speech = _speech_giver_role == 0; + if (_cm_giving_speech) { p1 = "You "; - } - if (big_mofo == 2) { - p1 = obj_ini.player_role_data[eROLE.MASTERCHAPLAIN].role + " "; - } - if (big_mofo == 3) { - p1 = obj_ini.player_role_data[eROLE.CHIEFLIBRARIAN].role + " "; - } - if (big_mofo == 5) { - p1 = "A Captain "; - } - if (big_mofo == 8) { - p1 = "A Chaplain "; + } else { + p1 = _speech_giver.name_role() + " "; } var standard_cry = 0; if (global.chapter_name == "Salamanders") { standard_cry = 1; rand = choose(1, 2, 3, 4, 5); - if ((rand == 1) && (big_mofo != 1)) { + if ((rand == 1) && (_cm_giving_speech != 1)) { p2 = "breaks the silence, begining the Chapter Battlecry-"; } - if ((rand == 1) && (big_mofo == 1)) { + if ((rand == 1) && (_cm_giving_speech == 1)) { p2 = "break the silence, begining the Chapter Battlecry-"; } - if ((rand == 2) && (big_mofo != 1)) { + if ((rand == 2) && (_cm_giving_speech != 1)) { p2 = "roars the first half of the Chapter Battlecry-"; } - if ((rand == 2) && (big_mofo == 1)) { + if ((rand == 2) && (_cm_giving_speech == 1)) { p2 = "roar the first half of the Chapter Battlecry-"; } - if ((rand == 3) && (big_mofo != 1)) { + if ((rand == 3) && (_cm_giving_speech != 1)) { p2 = "shouts the start of the Chapter Battlecry-"; } - if ((rand == 3) && (big_mofo == 1)) { + if ((rand == 3) && (_cm_giving_speech == 1)) { p2 = "shout the start of the Chapter Battlecry-"; } - if ((rand == 4) && (big_mofo != 1)) { + if ((rand == 4) && (_cm_giving_speech != 1)) { p2 = "calls out to your marines-"; } - if ((rand == 4) && (big_mofo == 1)) { + if ((rand == 4) && (_cm_giving_speech == 1)) { p2 = "call out to your marines-"; } - if ((rand == 5) && (big_mofo != 1)) { + if ((rand == 5) && (_cm_giving_speech != 1)) { p2 = "roars to your marines-"; } - if ((rand == 5) && (big_mofo == 1)) { + if ((rand == 5) && (_cm_giving_speech == 1)) { p2 = "roar to your marines-"; } p3 = "''Into the fires of battle!''"; - if ((temp >= 100) && (temp < 200)) { + if ((_marine_count >= 100) && (_marine_count < 200)) { p4 = "Over a hundred Astartes roar in return, their voice one-"; } - if ((temp >= 200) && (temp < 400)) { + if ((_marine_count >= 200) && (_marine_count < 400)) { p4 = "Several hundred Astartes roar in return, their voice one-"; } - if ((temp >= 500) && (temp < 800)) { + if ((_marine_count >= 500) && (_marine_count < 800)) { p4 = "Your battle brothers echoe the cry, a massive sound felt more than heard-"; } - if (temp > 800) { + if (_marine_count > 800) { p4 = "The sound is deafening as the " + string(global.chapter_name) + " shout in unison-"; } p5 = "''UNTO THE ANVIL OF WAR!''"; @@ -676,35 +595,35 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && !dropp if (obj_ini.battle_cry == "...") { standard_cry = 1; rand = choose(1, 2, 3); - if ((rand == 1) && (big_mofo != 1)) { + if ((rand == 1) && (_cm_giving_speech != 1)) { p2 = "remains silent as the Chapter forms for battle-"; } - if ((rand == 1) && (big_mofo == 1)) { + if ((rand == 1) && (_cm_giving_speech == 1)) { p2 = "remain silent as the Chapter forms for battle-"; } - if ((rand == 2) && (big_mofo != 1)) { + if ((rand == 2) && (_cm_giving_speech != 1)) { p2 = "remains silent and issues orders to the Chapter for battle-"; } - if ((rand == 2) && (big_mofo == 1)) { + if ((rand == 2) && (_cm_giving_speech == 1)) { p2 = "remain silent and issues orders to the Chapter for battle-"; } - if ((rand == 3) && (big_mofo != 1)) { + if ((rand == 3) && (_cm_giving_speech != 1)) { p2 = "issues orders to the Chapter over Vox-"; } - if ((rand == 3) && (big_mofo == 1)) { + if ((rand == 3) && (_cm_giving_speech == 1)) { p2 = "whisper to your brothers the plans for initial deployment over vox-"; } p3 = "''Sharp gestures and handsigns from officers direct the Marines''"; - if ((temp >= 100) && (temp < 200)) { + if ((_marine_count >= 100) && (_marine_count < 200)) { p4 = "Over a hundred Astartes nod in acknowledgement and move quickly-"; } - if ((temp >= 200) && (temp < 400)) { + if ((_marine_count >= 200) && (_marine_count < 400)) { p4 = "Several hundred Astartes nod in acknowledgement and move swiftly-"; } - if ((temp >= 500) && (temp < 800)) { + if ((_marine_count >= 500) && (_marine_count < 800)) { p4 = "Your battle brothers all nod in acknowledgement and move hastily-"; } - if (temp > 800) { + if (_marine_count > 800) { p4 = "The fluidity is astounding as the " + string(global.chapter_name) + " move seamlessly into position ready for battle-"; } p5 = "''They stand ready to engage the enemy''"; @@ -721,47 +640,47 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && !dropp if ((global.chapter_name == "Iron Warriors") && (global.custom == eCHAPTER_TYPE.PREMADE)) { standard_cry = 1; rand = choose(1, 2, 3, 4, 5); - if ((rand == 1) && (big_mofo != 1)) { + if ((rand == 1) && (_cm_giving_speech != 1)) { p2 = "breaks the silence, begining the Chapter Battlecry-"; } - if ((rand == 1) && (big_mofo == 1)) { + if ((rand == 1) && (_cm_giving_speech == 1)) { p2 = "break the silence, begining the Chapter Battlecry-"; } - if ((rand == 2) && (big_mofo != 1)) { + if ((rand == 2) && (_cm_giving_speech != 1)) { p2 = "roars the first half of the Chapter Battlecry-"; } - if ((rand == 2) && (big_mofo == 1)) { + if ((rand == 2) && (_cm_giving_speech == 1)) { p2 = "roar the first half of the Chapter Battlecry-"; } - if ((rand == 3) && (big_mofo != 1)) { + if ((rand == 3) && (_cm_giving_speech != 1)) { p2 = "shouts the start of the Chapter Battlecry-"; } - if ((rand == 3) && (big_mofo == 1)) { + if ((rand == 3) && (_cm_giving_speech == 1)) { p2 = "shout the start of the Chapter Battlecry-"; } - if ((rand == 4) && (big_mofo != 1)) { + if ((rand == 4) && (_cm_giving_speech != 1)) { p2 = "calls out to your marines-"; } - if ((rand == 4) && (big_mofo == 1)) { + if ((rand == 4) && (_cm_giving_speech == 1)) { p2 = "call out to your marines-"; } - if ((rand == 5) && (big_mofo != 1)) { + if ((rand == 5) && (_cm_giving_speech != 1)) { p2 = "roars to your marines-"; } - if ((rand == 5) && (big_mofo == 1)) { + if ((rand == 5) && (_cm_giving_speech == 1)) { p2 = "roar to your marines-"; } p3 = "''Iron within!''"; - if ((temp >= 100) && (temp < 200)) { + if ((_marine_count >= 100) && (_marine_count < 200)) { p4 = "Over a hundred Astartes roar in return, their voice one-"; } - if ((temp >= 200) && (temp < 400)) { + if ((_marine_count >= 200) && (_marine_count < 400)) { p4 = "Several hundred Astartes roar in return, their voice one-"; } - if ((temp >= 500) && (temp < 800)) { + if ((_marine_count >= 500) && (_marine_count < 800)) { p4 = "Your battle brothers echoe the cry, a massive sound felt more than heard-"; } - if (temp > 800) { + if (_marine_count > 800) { p4 = "The sound is deafening as the " + string(global.chapter_name) + " shout in unison-"; } p5 = "''IRON WITHOUT!''"; @@ -779,55 +698,55 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && !dropp standard_cry = 1; rand = choose(1, 2, 3, 4); if (rand == 1) { - if (big_mofo != 1) { + if (_cm_giving_speech != 1) { p2 = "breaks "; } - if (big_mofo == 1) { + if (_cm_giving_speech == 1) { p2 = "break "; } p2 += "the silence, calling out the Chapter Battlecry-"; } if (rand == 2) { - if (big_mofo != 1) { + if (_cm_giving_speech != 1) { p2 = "roars "; } - if (big_mofo == 1) { + if (_cm_giving_speech == 1) { p2 = "roar "; } p2 += "the Chapter Battlecry-"; } if (rand == 3) { - if (big_mofo != 1) { + if (_cm_giving_speech != 1) { p2 = "shouts "; } - if (big_mofo == 1) { + if (_cm_giving_speech == 1) { p2 = "shout "; } p2 += "the Chapter Battlecry-"; } if (rand == 4) { - if (big_mofo != 1) { + if (_cm_giving_speech != 1) { p2 = "roars "; } - if (big_mofo == 1) { + if (_cm_giving_speech == 1) { p2 = "roar "; } p2 += "to your marines-"; } p3 = "''" + string(obj_ini.battle_cry) + "!''"; - if ((temp >= 100) && (temp < 200)) { + if ((_marine_count >= 100) && (_marine_count < 200)) { p4 = "Over a hundred Astartes echoe the cry or let out shouts of their own."; } - if ((temp >= 200) && (temp < 400)) { + if ((_marine_count >= 200) && (_marine_count < 400)) { p4 = "Several hundred Astartes roar in return, echoing the cry."; } - if ((temp >= 500) && (temp < 800)) { + if ((_marine_count >= 500) && (_marine_count < 800)) { p4 = "Your battle brothers echoe the cry, a massive sound felt more than heard."; } - if ((temp > 800) && (rand >= 3)) { + if ((_marine_count > 800) && (rand >= 3)) { p4 = "The sound is deafening as the " + string(global.chapter_name) + " add their voices."; } - if ((temp > 800) && (rand <= 2)) { + if ((_marine_count > 800) && (rand <= 2)) { p4 = "The sound is deafening as the " + string(global.chapter_name) + " return the cry and magnify it a thousand times."; } _newline = p1 + p2; diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index a5facdb1f3..3cd7ddc0e1 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -188,6 +188,8 @@ timer_maxspeed = 1; timer_pause = -1; turns = 1; + +player_unit_index = new UnitIndex([]); scouts = 0; tacticals = 0; veterans = 0; @@ -204,8 +206,6 @@ champions = 0; important_dudes = 0; chaplains = 0; apothecaries = 0; -sgts = 0; -vet_sgts = 0; rhinos = 0; predators = 0; @@ -213,8 +213,6 @@ land_raiders = 0; land_speeders = 0; whirlwinds = 0; -big_mofo = 10; - enemy_dudes = ""; en_scouts = 0; diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index e7e1e5c5a5..911e9df484 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -205,29 +205,36 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, /// @desc Destroys the artifact. Daemonic artifacts destroyed while on a ship may trigger a demon summoning battle. /// @returns {Undefined} static destroy_artifact = function() { - if (has_tag("daemonic")) { - var _resolved = __resolve_location(); - if (_resolved.ship_id > -1) { - var demonSummonChance = roll_dice_chapter(1, 100, "high"); - - if ((demonSummonChance <= DEMON_SUMMON_THRESHOLD) && (obj_ini.ship_carrying[_resolved.ship_id] > 0)) { - instance_deactivate_all_safe(); - instance_activate_object(obj_star); - - /// @type {Asset.GMObject.obj_ncombat} - var _combat = instance_create_depth(0, 0, 0, obj_ncombat); - _combat.battle_special = "ship_demon"; - _combat.formation_set = 1; - _combat.enemy = DEMON_SUMMON_ENEMIES; - _combat.battle_id = _resolved.ship_id; - - instance_deactivate_object(obj_star); - setup_battle_formations(); - scr_ship_battle(_resolved.ship_id, 999); - main_map_defaults(); - } - } + if (!has_tag("daemonic")) { + return; + } + var _resolved = __resolve_location(); + + if (_resolved.ship_id < 0) { + return; } + + var _demon_summon_chance = roll_dice_chapter(1, 100, "high"); + + if (_demon_summon_chance <= DEMON_SUMMON_THRESHOLD && obj_ini.ship_carrying[_resolved.ship_id] > 0) { + instance_deactivate_all_safe(); + instance_activate_object(obj_star); + + /// @type {Asset.GMObject.obj_ncombat} + var _combat = instance_create_depth(0, 0, 0, obj_ncombat); + _combat.battle_special = "ship_demon"; + _combat.formation_set = 1; + _combat.enemy = DEMON_SUMMON_ENEMIES; + _combat.battle_id = _resolved.ship_id; + + instance_deactivate_object(obj_star); + setup_battle_formations(); + var _roster = new Roster(); + _roster.selected_units = collect_role_group("all", ["", 0, _resolved.ship_id], false, {}, false); + _roster.add_to_battle(); + main_map_defaults(); + } + }; /// @desc Unequips this artifact from its bearer, clearing the appropriate equipment slot. diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 0e80db3ed3..789f521c88 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -541,9 +541,21 @@ function UnitIndex(units) constructor { add_to_index(units); static role_count = function(role) { - return array_length(role_index[$ role]); + return struct_exists(role_index, role) ? array_length(role_index[$ role]) : 0; }; + static plural_string_role = function(role, use_x = false) { + return string_plural_count(role, role_count(role), use_x); + } + + static sum_roles = function(roles){ + var _sum = 0; + for (var i = 0; i < array_length(roles); i++){ + _sum += role_count(roles[i]); + } + return _sum; + } + static has_role = function(role) { return struct_exists(role_index, role) && array_length(role_index[$ role]) > 0; }; @@ -606,7 +618,7 @@ function UnitIndex(units) constructor { array_push(_strings_array, string(_keys[i])); } } else { - array_push(_strings_array, string_plural_count(_keys[i], role_count(_keys[i]), false)); + array_push(_strings_array, plural_string_role(_keys[i])); } } diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index 006f06f6b9..59597802dd 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -313,22 +313,18 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (_unit.role() == "Forge Master") { col = 22 - obj_controller.bat_command_column; - new_combat.en_important_dudes += 1; } if (_unit.role() == "Master of Sanctity") { col = 22 - obj_controller.bat_command_column; - new_combat.en_important_dudes += 1; if (new_combat.en_big_mofo > 2) { new_combat.en_big_mofo = 2; } } if (_unit.role() == "Master of the Apothecarion") { col = 22 - obj_controller.bat_command_column; - new_combat.en_important_dudes += 1; } if (_unit.role() == "Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role)) { col = 22 - obj_controller.bat_command_column; - new_combat.en_important_dudes += 1; if (new_combat.en_big_mofo > 3) { new_combat.en_big_mofo = 3; } @@ -588,9 +584,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { new_combat.chaplains += 1; - if (new_combat.big_mofo > 5) { - new_combat.big_mofo = 5; - } + } col = obj_controller.bat_tactical_column; @@ -610,9 +604,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if ((_unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) || (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) || (_unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role)) { if (_unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { new_combat.captains += 1; - if (new_combat.big_mofo > 5) { - new_combat.big_mofo = 5; - } + } if (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { new_combat.standard_bearers += 1; @@ -644,8 +636,6 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { col = obj_controller.bat_command_column; - new_combat.important_dudes += 1; - new_combat.big_mofo = 1; if (string_count("0", _unit.specials) > 0) { new_combat.chapter_master_psyker = 1; } else { @@ -654,25 +644,16 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } if (_unit.role() == "Forge Master") { col = obj_controller.bat_command_column; - new_combat.important_dudes += 1; } if (_unit.role() == "Master of Sanctity") { col = obj_controller.bat_command_column; - new_combat.important_dudes += 1; - if (new_combat.big_mofo > 2) { - new_combat.big_mofo = 2; - } + } if (_unit.role() == "Master of the Apothecarion") { col = obj_controller.bat_command_column; - new_combat.important_dudes += 1; } if (_unit.role() == "Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role)) { col = obj_controller.bat_command_column; - new_combat.important_dudes += 1; - if (new_combat.big_mofo > 3) { - new_combat.big_mofo = 3; - } } if (col == 0) { diff --git a/scripts/scr_roster/scr_roster.gml b/scripts/scr_roster/scr_roster.gml index d1e826debe..d69b3bc233 100644 --- a/scripts/scr_roster/scr_roster.gml +++ b/scripts/scr_roster/scr_roster.gml @@ -546,10 +546,8 @@ function add_unit_to_battle(unit, meeting, is_local) { if (_unit_role == _role[eROLE.SERGEANT]) { col = obj_controller.bat_tactical_column; //sergeants - new_combat.sgts++; } else if (_unit_role == _role[19]) { col = obj_controller.bat_veteran_column; - new_combat.vet_sgts++; } if (_unit_role == _role[12]) { //scouts @@ -557,41 +555,32 @@ function add_unit_to_battle(unit, meeting, is_local) { new_combat.scouts++; } else if (array_contains([_role[eROLE.TACTICAL], _role[eROLE.CHAPLAINASPIRANT], _role[eROLE.APOTHECARYASPIRANT],], _unit_role)) { col = obj_controller.bat_tactical_column; //tactical_marines - new_combat.tacticals++; } else if (_unit_role == _role[3]) { //veterans and veteran sergeants col = obj_controller.bat_veteran_column; - new_combat.veterans++; } else if (_unit_role == _role[9]) { //devastators col = obj_controller.bat_devastator_column; - new_combat.devastators++; } else if (_unit_role == _role[10]) { //assualt marines col = obj_controller.bat_assault_column; - new_combat.assaults++; //librarium roles } else if (unit.IsSpecialist(SPECIALISTS_LIBRARIANS, true)) { col = obj_controller.bat_librarian_column; //librarium - new_combat.librarians++; moov = 1; } else if (_unit_role == _role[16]) { //techmarines col = obj_controller.bat_techmarine_column; - new_combat.techmarines++; moov = 2; } else if (_unit_role == _role[2]) { //honour guard col = obj_controller.bat_honor_column; - new_combat.honors++; } else if (unit.IsSpecialist(SPECIALISTS_DREADNOUGHTS)) { col = obj_controller.bat_dreadnought_column; //dreadnoughts - new_combat.dreadnoughts++; } else if (_unit_role == obj_ini.player_role_data[eROLE.TERMINATOR].role) { //terminators col = obj_controller.bat_terminator_column; - new_combat.terminators++; } if (moov > 0) { @@ -613,17 +602,6 @@ function add_unit_to_battle(unit, meeting, is_local) { if ((_unit_role == _role[eROLE.APOTHECARY]) || (_unit_role == _role[eROLE.CHAPLAIN]) || unit.IsSpecialist(SPECIALISTS_TRAINEES)) { if (_unit_role == _role[eROLE.CHAPLAINASPIRANT]) { col = obj_controller.bat_tactical_column; - new_combat.tacticals++; - } - - if (_unit_role == _role[eROLE.APOTHECARY]) { - new_combat.apothecaries++; - } - if (_unit_role == _role[eROLE.CHAPLAIN]) { - new_combat.chaplains++; - if (new_combat.big_mofo > 5) { - new_combat.big_mofo = 5; - } } col = obj_controller.bat_tactical_column; @@ -638,18 +616,6 @@ function add_unit_to_battle(unit, meeting, is_local) { } if ((_unit_role == _role[eROLE.CAPTAIN]) || (_unit_role == _role[11]) || (_unit_role == _role[7])) { - if (_unit_role == _role[5]) { - new_combat.captains++; - if (new_combat.big_mofo > 5) { - new_combat.big_mofo = 5; - } - } - if (_unit_role == _role[11]) { - new_combat.standard_bearers++; - } - if (_unit_role == _role[7]) { - new_combat.champions++; - } if (company >= 2) { col = obj_controller.bat_tactical_column; } @@ -663,8 +629,6 @@ function add_unit_to_battle(unit, meeting, is_local) { if (_unit_role == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { col = obj_controller.bat_command_column; - new_combat.important_dudes++; - new_combat.big_mofo = 1; if (string_count("0", unit.specials) > 0) { new_combat.chapter_master_psyker = 1; } else { @@ -673,13 +637,6 @@ function add_unit_to_battle(unit, meeting, is_local) { } if (unit.IsSpecialist(SPECIALISTS_HEADS)) { col = obj_controller.bat_command_column; - new_combat.important_dudes++; - } - if (new_combat.big_mofo > 2) { - new_combat.big_mofo = 2; - } - if (new_combat.big_mofo > 3) { - new_combat.big_mofo = 3; } if (unit.squad != "none") { var squad = unit.get_squad(); @@ -724,6 +681,7 @@ function add_unit_to_battle(unit, meeting, is_local) { targ = instance_nearest(col * 10, 240, obj_pnunit); + obj_ncombat.player_unit_index.add_to_index([unit]); with (targ) { scr_add_unit_to_roster(unit, is_local); } diff --git a/scripts/scr_ship_battle/scr_ship_battle.gml b/scripts/scr_ship_battle/scr_ship_battle.gml deleted file mode 100644 index 7f10f4daf5..0000000000 --- a/scripts/scr_ship_battle/scr_ship_battle.gml +++ /dev/null @@ -1,207 +0,0 @@ -/// @desc Builds the player roster for a boarding battle aboard the target ship. -/// @param {Real} target_ship_id Index into obj_ini.ship of the ship the battle is fought over. -/// @param {Real} cooridor_width Second ship index whose occupants also count as present. -/// @returns {Undefined} -function scr_ship_battle(target_ship_id, cooridor_width) { - // determine occupants - // determine who is fighting - // set maximum attacks due to hallway? - // set battle special - - // if (argument2=true){ - var sofar = 0; - - for (var co = 0; co < array_length(obj_ini.TTRPG); co++) { - var _company_length = company_length(co); - - for (var v = 0; v < _company_length; v++) { - var okay = 0; - var _unit = fetch_unit([co, v]); - if (!is_struct(_unit)) { - continue; - } - if ((_unit.ship_location == target_ship_id) && _unit.hp()) { - okay = 1; - } - if ((_unit.ship_location == cooridor_width) && (cooridor_width == cooridor_width) && _unit.hp()) { - okay = 1; - } - - if ((string_count("spyrer", obj_ncombat.battle_special) > 0) && _unit.is_dreadnought()) { - okay = 0; - } - if (string_count("spyrer", obj_ncombat.battle_special) > 0) { - if ((okay == 1) && (sofar > 2)) { - okay = 0; - } - } - if (string_count("Aspirant", _unit.role()) > 0) { - okay = 0; - } - - if (okay == 0) { - obj_ncombat.fighting[co][v] = 0; - } - if (okay == 1) { - obj_ncombat.fighting[co][v] = 1; - sofar += 1; - - var col = 0, targ = 0; - - if (_unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { - col = obj_controller.bat_scout_column; - obj_ncombat.scouts += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { - col = obj_controller.bat_tactical_column; - obj_ncombat.tacticals += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { - col = obj_controller.bat_veteran_column; - obj_ncombat.veterans += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.DEVASTATOR].role) { - col = obj_controller.bat_devastator_column; - obj_ncombat.devastators += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.ASSAULT].role) { - col = obj_controller.bat_assault_column; - obj_ncombat.assaults += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { - col = obj_controller.bat_librarian_column; - obj_ncombat.librarians += 1; - } - if (_unit.role() == "Codiciery") { - col = obj_controller.bat_librarian_column; - obj_ncombat.librarians += 1; - } - if (_unit.role() == "Epistolary") { - col = obj_controller.bat_librarian_column; - obj_ncombat.librarians += 1; - } - if (_unit.role() == "Lexicanum") { - col = obj_controller.bat_librarian_column; - obj_ncombat.librarians += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { - col = obj_controller.bat_techmarine_column; - obj_ncombat.techmarines += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { - col = obj_controller.bat_honor_column; - obj_ncombat.honors += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { - col = obj_controller.bat_dreadnought_column; - obj_ncombat.dreadnoughts += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { - col = obj_controller.bat_terminator_column; - obj_ncombat.terminators += 1; - } - - if ((_unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) || (_unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role)) { - if (_unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) { - obj_ncombat.apothecaries += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { - obj_ncombat.chaplains += 1; - if (obj_ncombat.big_mofo > 5) { - obj_ncombat.big_mofo = 5; - } - } - - col = obj_controller.bat_tactical_column; - if (_unit.armour() == "Terminator Armour") { - col = obj_controller.bat_terminator_column; - } - if (_unit.armour() == "Tartaros Armour") { - col = obj_controller.bat_terminator_column; - } - if (co == 10) { - col = obj_controller.bat_scout_column; - } - } - - if ((_unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) || (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) || (_unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role)) { - if (_unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { - obj_ncombat.captains += 1; - if (obj_ncombat.big_mofo > 5) { - obj_ncombat.big_mofo = 5; - } - } - if (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { - obj_ncombat.standard_bearers += 1; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role) { - obj_ncombat.champions += 1; - } - - if (co == 1) { - col = obj_controller.bat_veteran_column; - if (_unit.armour() == "Terminator Armour") { - col = obj_controller.bat_terminator_column; - } - if (_unit.armour() == "Tartaros Armour") { - col = obj_controller.bat_terminator_column; - } - } - if (co >= 2) { - col = obj_controller.bat_tactical_column; - } - if (co == 10) { - col = obj_controller.bat_scout_column; - } - if (_unit.mobility_item() == "Jump Pack") { - col = obj_controller.bat_assault_column; - } - } - - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { - col = obj_controller.bat_command_column; - obj_ncombat.important_dudes += 1; - obj_ncombat.big_mofo = 1; - } - if (_unit.role() == "Forge Master") { - col = obj_controller.bat_command_column; - obj_ncombat.important_dudes += 1; - } - if (_unit.role() == "Master of Sanctity") { - col = obj_controller.bat_command_column; - obj_ncombat.important_dudes += 1; - if (obj_ncombat.big_mofo > 2) { - obj_ncombat.big_mofo = 2; - } - } - if (_unit.role() == "Master of the Apothecarion") { - col = obj_controller.bat_command_column; - obj_ncombat.important_dudes += 1; - } - if (_unit.role() == "Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role)) { - col = obj_controller.bat_command_column; - obj_ncombat.important_dudes += 1; - if (obj_ncombat.big_mofo > 3) { - obj_ncombat.big_mofo = 3; - } - } - - if (_unit.role() == "Death Company") { - // Ahahahahah - col = max(obj_controller.bat_assault_column, obj_controller.bat_command_column, obj_controller.bat_honor_column, obj_controller.bat_dreadnought_column, obj_controller.bat_veteran_column); - } - - if (col == 0) { - col = obj_controller.bat_hire_column; - } - - targ = instance_nearest(col * 10, 240, obj_pnunit); - with (targ) { - scr_add_unit_to_roster(_unit); - } - } - } - } - - // } -} diff --git a/scripts/scr_ship_battle/scr_ship_battle.yy b/scripts/scr_ship_battle/scr_ship_battle.yy deleted file mode 100644 index b48ea0e572..0000000000 --- a/scripts/scr_ship_battle/scr_ship_battle.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_ship_battle", - "isCompatibility":false, - "isDnD":false, - "name":"scr_ship_battle", - "parent":{ - "name":"Combat", - "path":"folders/Scripts/Combat.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file