From 4d40c61173a00b051cf3c99b8b1168563d3d27a3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 28 Jul 2026 22:35:24 +0100 Subject: [PATCH 01/82] remove god parrallel array --- objects/obj_controller/Alarm_5.gml | 19 +++++++------- objects/obj_controller/Mouse_50.gml | 6 ++--- objects/obj_ini/Create_0.gml | 26 +++++++++---------- scripts/scr_UnitGroup/scr_UnitGroup.gml | 2 +- .../scr_company_order/scr_company_order.gml | 14 ++++++++-- .../scr_controller_helpers.gml | 4 +-- scripts/scr_kill_unit/scr_kill_unit.gml | 1 - .../scr_marine_struct/scr_marine_struct.gml | 6 ++--- .../scr_move_unit_info/scr_move_unit_info.gml | 1 - scripts/scr_role_count/scr_role_count.gml | 2 +- .../scr_unit_quick_find_pane.gml | 2 +- 11 files changed, 45 insertions(+), 38 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 8d48d77664..6ee735f38c 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -289,22 +289,23 @@ try { } var p = 0; for (var c = 0; c < 11; c++) { - for (var e = 0; e < array_length(obj_ini.god[c]); e++) { - if (obj_ini.god[c][e] == 10) { - var unit = fetch_unit([c, e]); - if (!is_struct(unit)) { + for (var e = 0; e < array_length(obj_ini.TTRPG[c]); e++) { + var _unit = fetch_unt([c,e]); + if (_unit.god_status == 10) { + var _unit = fetch_unit([c, e]); + if (!is_struct(_unit)) { continue; } p += 1; penit_co[p] = c; penit_id[p] = e; penitorium += 1; - unit.alter_loyalty(-1); - if ((unit.corruption < 90) && (unit.corruption > 0)) { + _unit.alter_loyalty(-1); + if ((_unit.corruption < 90) && (_unit.corruption > 0)) { var heresy_old = 0, heresy_new = 0; - heresy_old = round((unit.corruption * unit.corruption) / 50) - 0.5; - heresy_new = (heresy_old * 50) / unit.corruption; - unit.corruption = max(0, heresy_new); + heresy_old = round((_unit.corruption * _unit.corruption) / 50) - 0.5; + heresy_new = (heresy_old * 50) / _unit.corruption; + _unit.corruption = max(0, heresy_new); } } } diff --git a/objects/obj_controller/Mouse_50.gml b/objects/obj_controller/Mouse_50.gml index e647319e1a..27d51eaff8 100644 --- a/objects/obj_controller/Mouse_50.gml +++ b/objects/obj_controller/Mouse_50.gml @@ -31,7 +31,7 @@ if ((menu == eMENU.RECLUSIAM) && (cooldown <= 0) && (penitorium > 0)) { if ((mouse_x >= xx + 1508) && (mouse_x < xx + 1567)) { cooldown = 20; var c = penit_co[qp], e = penit_id[qp]; - obj_ini.god[c][e] -= 10; + obj_ini.TTRPG[c][e].god_status -= 10; re = 1; } } @@ -44,8 +44,8 @@ if ((menu == eMENU.RECLUSIAM) && (cooldown <= 0) && (penitorium > 0)) { penitorium = 0; var p = 0; for (var c = 0; c < 11; c++) { - for (var e = 0; e < array_length(obj_ini.god[c]); e++) { - if (obj_ini.god[c][e] == 10) { + for (var e = 0; e < array_length(obj_ini.TTRPG[c]); e++) { + if (obj_ini.TTRPG[c][e].god_status == 10) { p += 1; penit_co[p] = c; penit_id[p] = e; diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 7eacd52cb0..00c13cca60 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -118,29 +118,29 @@ veh_acc = array_create_2d(_max_companies, _max_vehicles, ""); defaults_slot = 100; /// @type {Array>} -race = array_create_2d(11, 501, 0); +race = array_create(11, 501); /// @type {Array>} -name = array_create_2d(11, 501, ""); +name = array_create(11, []); /// @type {Array>} -role = array_create_2d(11, 501, ""); +role = array_create(11, []); /// @type {Array>} -wep1 = array_create_2d(11, 501, ""); +wep1 = array_create(11, []); /// @type {Array>} -spe = array_create_2d(11, 501, ""); +spe = array_create(11, []); /// @type {Array>} -wep2 = array_create_2d(11, 501, ""); +wep2 = array_create(11, []); /// @type {Array>} -armour = array_create_2d(11, 501, ""); +armour = array_create(11, []); /// @type {Array>} -gear = array_create_2d(11, 501, ""); +gear = array_create(11, []); /// @type {Array>} -mobi = array_create_2d(11, 501, ""); +mobi = array_create(11, []); /// @type {Array>} -age = array_create_2d(11, 501, 0); -/// @type {Array>} -god = array_create_2d(11, 501, 0); +age = array_create_2d(11, []); +/// @type {Array>} +god = array_create(11, []); /// @type {Array>} -TTRPG = array_create_2d(11, 501, undefined); +TTRPG = array_create(11, []); load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { role[defaults_slot][_role_id] = _role_name; diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index b1f0a062e0..38cd93048a 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -860,7 +860,7 @@ function stat_valuator(search_params, _unit) { function collect_by_religeon(religion, sub_cult = "", location = "") { var _units = [], _unit, count = 0, _add = false; for (var com = 0; com <= obj_ini.companies; com++) { - for (var i = 1; i < array_length(obj_ini.TTRPG[com]); i++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[com]); i++) { _add = false; _unit = fetch_unit([com, i]); if (!is_struct(_unit)) { diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index ba97992f45..3ced690014 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -112,9 +112,20 @@ function scr_company_order(company) { var _temps = []; for (var i = 0; i < array_length(_company_marines.units); i++) { var _unit = _company_marines.units[i]; - array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true), age: _unit.age(), spe: _unit.specials(), god: _unit.god_status()}); + array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true), age: _unit.age(), spe: _unit.specials(), god: _unit.god_status}); } + TTRPG[co] = array_create(_temps, 0); + race[co] = array_create(_temps, 0); + name[co] = array_create(_temps, 0); + role[co] = array_create(_temps, 0); + wep1[co] = array_create(_temps, 0); + wep2[co] = array_create(_temps, 0); + armour[co] = array_create(_temps, 0); + gear[co] = array_create(_temps, 0); + mobi[co] = array_create(_temps, 0); + age[co] = array_create(_temps, 0); + spe[co] = array_create(_temps, 0); for (var i = 0; i < array_length(_temps); i++) { var _unit = _temps[i]; var _struc = _unit.unit; @@ -129,7 +140,6 @@ function scr_company_order(company) { mobi[co][i] = _unit.mobi; age[co][i] = _unit.age; spe[co][i] = _unit.spe; - god[co][i] = _unit.god; if (_struc.marine_number != i) { if (TTRPG[_struc.company][_struc.marine_number].uid == _struc.uid) { TTRPG[_struc.company][_struc.marine_number] = new TTRPG_stats("chapter", _struc.company, _struc.marine_number, "blank"); diff --git a/scripts/scr_controller_helpers/scr_controller_helpers.gml b/scripts/scr_controller_helpers/scr_controller_helpers.gml index c78546e4b9..cd9d237906 100644 --- a/scripts/scr_controller_helpers/scr_controller_helpers.gml +++ b/scripts/scr_controller_helpers/scr_controller_helpers.gml @@ -236,8 +236,8 @@ function scr_toggle_reclu() { // Get list of jailed marines var p = 0; for (var c = 0; c < 11; c++) { - for (var e = 0; e < array_length(obj_ini.god[c]); e++) { - if (obj_ini.god[c][e] == 10) { + for (var e = 0; e < array_length(obj_ini.TTRPG[c]); e++) { + if (obj_ini.TTRPG[c][e].god_status == 10) { p += 1; penit_co[p] = c; penit_id[p] = e; diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 1c4377d38b..33b125b785 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -36,7 +36,6 @@ function scr_wipe_unit(company, unit_slot) { array_set(obj_ini.role[company], unit_slot, ""); array_set(obj_ini.armour[company], unit_slot, ""); array_set(obj_ini.gear[company], unit_slot, ""); - array_set(obj_ini.god[company], unit_slot, 0); array_set(obj_ini.age[company], unit_slot, 0); array_set(obj_ini.mobi[company], unit_slot, ""); array_set(obj_ini.TTRPG[company], unit_slot, undefined); diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 995346da20..ba54cc6f41 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -2004,12 +2004,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static in_jail = function() { - return god_status() >= 10; + return god_status >= 10; }; - static god_status = function() { - return obj_ini.god[company][marine_number]; - }; + god_status = 0; static forge_point_generation = unit_forge_point_generation; diff --git a/scripts/scr_move_unit_info/scr_move_unit_info.gml b/scripts/scr_move_unit_info/scr_move_unit_info.gml index 2889f1590b..d277ef3316 100644 --- a/scripts/scr_move_unit_info/scr_move_unit_info.gml +++ b/scripts/scr_move_unit_info/scr_move_unit_info.gml @@ -18,7 +18,6 @@ function scr_move_unit_info(start_company, end_company, start_slot, end_slot, ev obj_ini.wep2[end_company][end_slot] = obj_ini.wep2[start_company][start_slot]; obj_ini.gear[end_company][end_slot] = obj_ini.gear[start_company][start_slot]; obj_ini.armour[end_company][end_slot] = obj_ini.armour[start_company][start_slot]; - obj_ini.god[end_company][end_slot] = obj_ini.god[start_company][start_slot]; obj_ini.age[end_company][end_slot] = obj_ini.age[start_company][start_slot]; obj_ini.mobi[end_company][end_slot] = obj_ini.mobi[start_company][start_slot]; diff --git a/scripts/scr_role_count/scr_role_count.gml b/scripts/scr_role_count/scr_role_count.gml index 98ed503107..9e62e5f885 100644 --- a/scripts/scr_role_count/scr_role_count.gml +++ b/scripts/scr_role_count/scr_role_count.gml @@ -38,7 +38,7 @@ function scr_role_count(target_role, search_location = "", return_type = "count" if (!is_struct(unit) || unit.name() == "") { continue; } - if ((unit.role() == target_role) && (obj_ini.god[coom][i] < 10)) { + if ((unit.role() == target_role) && (obj_ini.TTRPG[coom][i].god_status < 10)) { count += 1; if (return_type == "units") { var _u = fetch_unit([coom, i]); diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index f051ff2dd9..7ad899655f 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -673,7 +673,7 @@ function jail_selection() { _unit = display_unit[f]; if (_unit.controllable()) { if (is_struct(display_unit[f]) && !_unit.in_jail()) { - obj_ini.god[_unit.company][_unit.marine_number] += 10; + display_unit[f].god_status += 10; ma_god[f] += 10; man_sel[f] = 0; } From b1de378952f4a463062bb116b13a02dc7405f507 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 28 Jul 2026 22:40:31 +0100 Subject: [PATCH 02/82] remove all age parallel arrays --- objects/obj_p_assra/Alarm_0.gml | 2 +- scripts/scr_add_man/scr_add_man.gml | 2 +- scripts/scr_after_combat/scr_after_combat.gml | 2 +- scripts/scr_company_order/scr_company_order.gml | 4 +--- .../scr_initialize_custom/scr_initialize_custom.gml | 5 +---- scripts/scr_kill_unit/scr_kill_unit.gml | 5 ++--- scripts/scr_marine_struct/scr_marine_struct.gml | 11 ++++------- scripts/scr_max_marine/scr_max_marine.gml | 4 ++-- scripts/scr_move_unit_info/scr_move_unit_info.gml | 1 - 9 files changed, 13 insertions(+), 23 deletions(-) diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index 3a30034ac1..fea9c80f59 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -18,7 +18,7 @@ for (o = 0; o < array_length(origin.board_co); o++) { if (apothecary_had > 0) { if (unit.base_group == "astartes") { - var age = obj_ini.age[co][i]; + var age = unit.age; if ((age <= ((obj_controller.millenium * 1000) + obj_controller.year) - 10) && (obj_ini.zygote == 0)) { seed_lost += 1; } diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index 925002aa1c..665b778c74 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -76,7 +76,7 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption } } - obj_ini.age[target_company][_company_slot] = (obj_controller.millenium * 1000) + obj_controller.year; + _unit.age = (obj_controller.millenium * 1000) + obj_controller.year; switch (spawn_name) { case "": diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index 2681c76db3..0b16e5fe91 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -301,7 +301,7 @@ function after_combat_recover_marine_gene_seed(unit) { } if (unit.base_group == "astartes") { - var _birthday = unit.age(); + var _birthday = unit.age; var _current_year = (obj_controller.millenium * 1000) + obj_controller.year; var _seed_harvestable = 0; var _seed_lost = 0; diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 3ced690014..f2a8115e1c 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -112,7 +112,7 @@ function scr_company_order(company) { var _temps = []; for (var i = 0; i < array_length(_company_marines.units); i++) { var _unit = _company_marines.units[i]; - array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true), age: _unit.age(), spe: _unit.specials(), god: _unit.god_status}); + array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true), age: _unit.age, spe: _unit.specials(), god: _unit.god_status}); } TTRPG[co] = array_create(_temps, 0); @@ -124,7 +124,6 @@ function scr_company_order(company) { armour[co] = array_create(_temps, 0); gear[co] = array_create(_temps, 0); mobi[co] = array_create(_temps, 0); - age[co] = array_create(_temps, 0); spe[co] = array_create(_temps, 0); for (var i = 0; i < array_length(_temps); i++) { var _unit = _temps[i]; @@ -138,7 +137,6 @@ function scr_company_order(company) { armour[co][i] = _unit.armour; gear[co][i] = _unit.gear; mobi[co][i] = _unit.mobi; - age[co][i] = _unit.age; spe[co][i] = _unit.spe; if (_struc.marine_number != i) { if (TTRPG[_struc.company][_struc.marine_number].uid == _struc.uid) { diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 9e2ff3f296..d8827d4e93 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1478,8 +1478,6 @@ function scr_initialize_custom() { armour[_idx] = array_create(_len, ""); gear[_idx] = array_create(_len, ""); mobi[_idx] = array_create(_len, ""); - age[_idx] = array_create(_len, _age_val); - god[_idx] = array_create(_len, 0); }; _init_marine_row(0, 500, _current_age); @@ -2013,9 +2011,8 @@ function scr_initialize_custom() { chaos[c][i] = 0; gear[c][i] = ""; mobi[c][i] = ""; - age[c][i] = ((millenium * 1000) + year) - 10; - god[c][i] = 0; TTRPG[c][i] = new TTRPG_stats("chapter", c, i, "blank"); + TTRPG[c][i].age = ((millenium * 1000) + year) - 10; } } diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 33b125b785..98f5718102 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -36,7 +36,6 @@ function scr_wipe_unit(company, unit_slot) { array_set(obj_ini.role[company], unit_slot, ""); array_set(obj_ini.armour[company], unit_slot, ""); array_set(obj_ini.gear[company], unit_slot, ""); - array_set(obj_ini.age[company], unit_slot, 0); array_set(obj_ini.mobi[company], unit_slot, ""); array_set(obj_ini.TTRPG[company], unit_slot, undefined); } @@ -54,10 +53,10 @@ function kill_and_recover(company, unit_slot, equipment = true, gene_seed_collec unit.alter_equipment(strip, false, true); } if (gene_seed_collect && unit.base_group == "astartes") { - if (unit.age() > 30 && !obj_ini.zygote && !obj_ini.doomed) { + if (unit.age > 30 && !obj_ini.zygote && !obj_ini.doomed) { obj_controller.gene_seed += 1; } - if (unit.age() > 50 && !obj_ini.doomed) { + if (unit.age > 50 && !obj_ini.doomed) { obj_controller.gene_seed += 1; } } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index ba54cc6f41..79fad569de 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -922,13 +922,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return true; }; - static age = function() { - var real_age = obj_ini.age[company][marine_number]; - return real_age; - }; // age + age = 0; static update_age = function(new_val) { - obj_ini.age[company][marine_number] = new_val; + age = new_val; }; //TODO build epithets in to marine profile @@ -2020,7 +2017,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static roll_age = scr_marine_spawn_age; static roll_experience = function() { - var _age_bonus = age(); + var _age_bonus = age; var _gauss_sd_mod = 14; var _exp = _age_bonus; @@ -2029,7 +2026,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static assign_reactionary_traits = function() { - var _age = age(); + var _age = age; var _exp = experience; var _total_score = _age + _exp; diff --git a/scripts/scr_max_marine/scr_max_marine.gml b/scripts/scr_max_marine/scr_max_marine.gml index 16c388d088..f9384239f3 100644 --- a/scripts/scr_max_marine/scr_max_marine.gml +++ b/scripts/scr_max_marine/scr_max_marine.gml @@ -30,8 +30,8 @@ function scr_max_marine(max_type) { man_i = i; } } else if (max_type == "age") { - if (obj_ini.age[c][i] < value) { - value = obj_ini.age[c][i]; + if (unit.age < value) { + value = unit.age; man_c = c; man_i = i; } diff --git a/scripts/scr_move_unit_info/scr_move_unit_info.gml b/scripts/scr_move_unit_info/scr_move_unit_info.gml index d277ef3316..b36145ab5c 100644 --- a/scripts/scr_move_unit_info/scr_move_unit_info.gml +++ b/scripts/scr_move_unit_info/scr_move_unit_info.gml @@ -18,7 +18,6 @@ function scr_move_unit_info(start_company, end_company, start_slot, end_slot, ev obj_ini.wep2[end_company][end_slot] = obj_ini.wep2[start_company][start_slot]; obj_ini.gear[end_company][end_slot] = obj_ini.gear[start_company][start_slot]; obj_ini.armour[end_company][end_slot] = obj_ini.armour[start_company][start_slot]; - obj_ini.age[end_company][end_slot] = obj_ini.age[start_company][start_slot]; obj_ini.mobi[end_company][end_slot] = obj_ini.mobi[start_company][start_slot]; var _temp_struct = fetch_unit([end_company, end_slot]); From 5d58dbadb80f4a859721db2c42279697b965218c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 28 Jul 2026 22:54:53 +0100 Subject: [PATCH 03/82] remove all spe parrallel arrays --- objects/obj_controller/Create_0.gml | 2 +- objects/obj_ini/Create_0.gml | 6 ------ scripts/scr_civil_roster/scr_civil_roster.gml | 6 +++--- scripts/scr_company_order/scr_company_order.gml | 4 +--- scripts/scr_dialogue/scr_dialogue.gml | 5 +++-- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 7 ++++--- .../scr_initialize_custom/scr_initialize_custom.gml | 8 +++----- scripts/scr_kill_unit/scr_kill_unit.gml | 1 - scripts/scr_marine_struct/scr_marine_struct.gml | 11 ++++------- scripts/scr_move_unit_info/scr_move_unit_info.gml | 1 - .../scr_player_combat_weapon_stacks.gml | 4 ++-- scripts/scr_random_event/scr_random_event.gml | 5 +++-- scripts/scr_roster/scr_roster.gml | 2 +- 13 files changed, 25 insertions(+), 37 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 40a74c51ad..26e6955303 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -591,7 +591,7 @@ if (instance_exists(obj_ini)) { penitent_end = millenium + year + obj_ini.penitent_end; } - if (string_count(obj_ini.spe[0][1], "$") > 0) { + if (string_count(obj_ini.TTRPG[0][0].specials, "$") > 0) { born_leader = 1; } } diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 00c13cca60..6c5180c0ef 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -126,8 +126,6 @@ role = array_create(11, []); /// @type {Array>} wep1 = array_create(11, []); /// @type {Array>} -spe = array_create(11, []); -/// @type {Array>} wep2 = array_create(11, []); /// @type {Array>} armour = array_create(11, []); @@ -135,10 +133,6 @@ armour = array_create(11, []); gear = array_create(11, []); /// @type {Array>} mobi = array_create(11, []); -/// @type {Array>} -age = array_create_2d(11, []); -/// @type {Array>} -god = array_create(11, []); /// @type {Array>} TTRPG = array_create(11, []); diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index b52723e985..0a9ca58810 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -366,7 +366,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.dudes_num[targ.men] = 1; targ.dudes_hp[targ.men] = unit.hp(); targ.dudes_exp[targ.men] = unit.experience; - targ.dudes_powers[targ.men] = deploying_unit.spe[cooh][va]; + targ.dudes_powers[targ.men] = unit.specials; targ.dudes_wep1[targ.men] = deploying_unit.wep1[cooh][va]; targ.dudes_wep2[targ.men] = deploying_unit.wep2[cooh][va]; targ.dudes_gear[targ.men] = deploying_unit.gear[cooh][va]; @@ -700,7 +700,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { col = obj_controller.bat_command_column; new_combat.important_dudes += 1; new_combat.big_mofo = 1; - if (string_count("0", deploying_unit.spe[cooh][va]) > 0) { + if (string_count("0", deploying_unit.specials) > 0) { new_combat.chapter_master_psyker = 1; } else { new_combat.chapter_master_psyker = 0; @@ -747,7 +747,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.marine_mobi[targ.men] = unit.mobility_item(); targ.marine_hp[targ.men] = unit.hp(); targ.marine_exp[targ.men] = unit.experience; - targ.marine_powers[targ.men] = deploying_unit.spe[cooh][va]; + targ.marine_powers[targ.men] = deploying_unit.specials; targ.marine_ranged[targ.men] = unit.ranged_attack(); targ.marine_ac[targ.men] = unit.armour_calc(); targ.marine_attack[targ.men] = unit.melee_attack(); diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index f2a8115e1c..dea3f34b1c 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -112,7 +112,7 @@ function scr_company_order(company) { var _temps = []; for (var i = 0; i < array_length(_company_marines.units); i++) { var _unit = _company_marines.units[i]; - array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true), age: _unit.age, spe: _unit.specials(), god: _unit.god_status}); + array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true)}); } TTRPG[co] = array_create(_temps, 0); @@ -124,7 +124,6 @@ function scr_company_order(company) { armour[co] = array_create(_temps, 0); gear[co] = array_create(_temps, 0); mobi[co] = array_create(_temps, 0); - spe[co] = array_create(_temps, 0); for (var i = 0; i < array_length(_temps); i++) { var _unit = _temps[i]; var _struc = _unit.unit; @@ -137,7 +136,6 @@ function scr_company_order(company) { armour[co][i] = _unit.armour; gear[co][i] = _unit.gear; mobi[co][i] = _unit.mobi; - spe[co][i] = _unit.spe; if (_struc.marine_number != i) { if (TTRPG[_struc.company][_struc.marine_number].uid == _struc.uid) { TTRPG[_struc.company][_struc.marine_number] = new TTRPG_stats("chapter", _struc.company, _struc.marine_number, "blank"); diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index e5614d98b1..181d329361 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -178,8 +178,9 @@ function scr_dialogue(diplo_keyphrase, data = {}) { // Option4 here if all the right conditions are met var born = false; - for (var i = 1; i <= 200; i++) { - if ((obj_ini.role[0][i] == obj_ini.role[100][eROLE.CHAPTERMASTER]) && (string_count("$", obj_ini.spe[0][i]) > 0)) { + for (var i = 0; i < array_length(obj_ini.TTRPG[0]); i++) { + var _unit = fetch_unit([o, i]); + if ((_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) && (string_count("$", _unit.specials) > 0)) { born = true; } } diff --git a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml index 93c7742ad8..f857c4609b 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -164,9 +164,10 @@ function scr_enemy_ai_d() { scr_event_log("red", $"Chief {obj_ini.role[100][17]} reports a disturbance in the warp. He claims it is like a shadow."); } if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop == 0) && yep) { - for (var q = 1; q <= 90; q++) { - if (obj_ini.role[0][q] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { - if (string_count("0", obj_ini.spe[0][q]) > 0) { + for (var q = 0; q < array_length(obj_ini.TTRPG[0]); q++) { + var _unit = fetch_unit([0, q]); + if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (string_count("0", _unit.special) > 0) { scr_popup("Shadow in the Warp", "You are distracted and bothered by a nagging sensation in the warp. It feels as though a shadow descends upon your sector.", "shadow", ""); scr_event_log("red", "You sense a disturbance in the warp. It feels something like a massive shadow."); } diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index d8827d4e93..89fb21e148 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1473,7 +1473,6 @@ function scr_initialize_custom() { name[_idx] = array_create(_len, ""); role[_idx] = array_create(_len, ""); wep1[_idx] = array_create(_len, ""); - spe[_idx] = array_create(_len, ""); wep2[_idx] = array_create(_len, ""); armour[_idx] = array_create(_len, ""); gear[_idx] = array_create(_len, ""); @@ -2005,7 +2004,6 @@ function scr_initialize_custom() { name[c][i] = ""; role[c][i] = ""; wep1[c][i] = ""; - spe[c][i] = ""; wep2[c][i] = ""; armour[c][i] = ""; chaos[c][i] = 0; @@ -2026,7 +2024,7 @@ function scr_initialize_custom() { chapter_master.add_bionics("none", "standard", false); } - spe[_company_i][_marine_i] = ""; + chapter_master.specials = ""; chapter_master.add_trait("lead_example"); //builds in which of the three chapter master types your CM is @@ -2034,12 +2032,12 @@ function scr_initialize_custom() { switch (obj_creation.chapter_master_specialty) { case 1: chapter_master.add_exp(550); - spe[_company_i][_marine_i] += "$"; + chapter_master.specials += "$"; chapter_master.add_trait("charismatic"); break; case 2: chapter_master.add_exp(650); - spe[_company_i][_marine_i] += "@"; + chapter_master.specials += "@"; chapter_master.add_trait("paragon"); break; case 3: diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 98f5718102..077f87a926 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -28,7 +28,6 @@ function scr_kill_unit(company, unit_slot) { } function scr_wipe_unit(company, unit_slot) { - array_set(obj_ini.spe[company], unit_slot, ""); array_set(obj_ini.race[company], unit_slot, 0); array_set(obj_ini.name[company], unit_slot, ""); array_set(obj_ini.wep1[company], unit_slot, ""); diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 79fad569de..68c770b364 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -938,7 +938,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } array_push(epithets, epithet); }; - static name = function() { return obj_ini.name[company][marine_number]; }; // get marine name @@ -1045,12 +1044,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return obj_ini.artifact[wep]; }; - static specials = function() { - return obj_ini.spe[company][marine_number]; - }; + specials = ""; static specials_array = function() { - var _specials_array = string_split(obj_ini.spe[company][marine_number], "|", true); + var _specials_array = string_split(specials, "|", true); return _specials_array; }; @@ -1067,7 +1064,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} var _powers_known_count = 0; var _discipline_powers_max = 0; var _powers_learned = 0; - var _abilities_string = specials(); + var _abilities_string = specials; var _discipline_prefix = get_discipline_data(obj_ini.psy_powers, "prefix"); var _discipline_powers = get_discipline_data(obj_ini.psy_powers, "powers"); @@ -1081,7 +1078,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (string_count(string(_power_index), _abilities_string) == 0) { _powers_known_count++; _powers_learned++; - obj_ini.spe[company][marine_number] += string(_discipline_prefix) + string(_power_index) + "|"; + specials += string(_discipline_prefix) + string(_power_index) + "|"; array_push(powers_known, _discipline_powers[_power_index]); } } diff --git a/scripts/scr_move_unit_info/scr_move_unit_info.gml b/scripts/scr_move_unit_info/scr_move_unit_info.gml index b36145ab5c..810e1bad12 100644 --- a/scripts/scr_move_unit_info/scr_move_unit_info.gml +++ b/scripts/scr_move_unit_info/scr_move_unit_info.gml @@ -10,7 +10,6 @@ function scr_move_unit_info(start_company, end_company, start_slot, end_slot, ev if (eval_squad) { unit.movement_after_math(end_company, end_slot); } - obj_ini.spe[end_company][end_slot] = obj_ini.spe[start_company][start_slot]; obj_ini.race[end_company][end_slot] = obj_ini.race[start_company][start_slot]; obj_ini.name[end_company][end_slot] = obj_ini.name[start_company][start_slot]; obj_ini.wep1[end_company][end_slot] = obj_ini.wep1[start_company][start_slot]; diff --git a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml index 076121d918..7f0be1ec55 100644 --- a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml +++ b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml @@ -380,9 +380,9 @@ function scr_add_unit_to_roster(unit, is_local = false, is_ally = false) { array_push(marine_hp, unit.hp()); array_push(marine_mobi, unit.mobility_item()); array_push(marine_exp, unit.experience); - array_push(marine_powers, unit.specials()); + array_push(marine_powers, unit.specials); array_push(marine_ranged, unit.ranged_attack()); - array_push(marine_powers, unit.specials()); + array_push(marine_powers, unit.specials); array_push(marine_ac, unit.armour_calc()); array_push(marine_attack, unit.melee_attack()); array_push(marine_local, is_local); diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 1600ebc599..e69132717a 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -707,8 +707,9 @@ function scr_random_event(execute_now) { var psyker_intolerant = scr_has_disadv("Psyker Intolerant"); var has_chief_psyker = scr_role_count("Chief " + string(obj_ini.role[100][17]), "") >= 1; var cm_is_psyker = false; - for (var i = 1; i < 100; i++) { - if (obj_ini.role[0][i] == obj_ini.role[100][eROLE.CHAPTERMASTER] && string_count("0", obj_ini.spe[0][i]) > 0) { + for (var i = 0; i < array_length(TTRPG[0]); i++) { + var _unit = fetch_unit([0 ,i]); + if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER] && string_count("0", _unit.special) > 0) { cm_is_psyker = true; break; } diff --git a/scripts/scr_roster/scr_roster.gml b/scripts/scr_roster/scr_roster.gml index 5762f4b9e5..b98f865448 100644 --- a/scripts/scr_roster/scr_roster.gml +++ b/scripts/scr_roster/scr_roster.gml @@ -663,7 +663,7 @@ function add_unit_to_battle(unit, meeting, is_local) { col = obj_controller.bat_command_column; new_combat.important_dudes++; new_combat.big_mofo = 1; - if (string_count("0", obj_ini.spe[cooh][va]) > 0) { + if (string_count("0", unit.specials) > 0) { new_combat.chapter_master_psyker = 1; } else { new_combat.chapter_master_psyker = 0; From 3f39895ff7c9e4ee4960b2505a956b504ca40fb1 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 28 Jul 2026 23:16:58 +0100 Subject: [PATCH 04/82] kill l array length --- scripts/scr_add_man/scr_add_man.gml | 200 +++++++++--------- .../scr_chapter_managent_events.gml | 4 +- .../scr_company_order/scr_company_order.gml | 25 +-- scripts/scr_company_view/scr_company_view.gml | 11 + .../scr_initialize_custom.gml | 2 + .../scr_unit_spawn_functions.gml | 11 +- 6 files changed, 128 insertions(+), 125 deletions(-) diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index 665b778c74..1f46916f2b 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -17,118 +17,116 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption _company_slot = find_company_open_slot(target_company); - if (_company_slot != -1) { - scr_wipe_unit(target_company, _company_slot); - var _unit = fetch_unit([target_company, _company_slot]); - if (other_gear == true) { - // TODO: Implement logic for Chapter Servitor, Neophyte, and Serf (Race 1, Scout/Astartes stats) - // TODO: Implement logic for Mercenary (Race 2, Human stats, Hellgun) - // TODO: Implement logic for Auxiliary Soldier (Race 2.5, Renegade stats) + scr_wipe_unit(target_company, _company_slot); + var _unit = fetch_unit([target_company, _company_slot]); + if (other_gear == true) { + // TODO: Implement logic for Chapter Servitor, Neophyte, and Serf (Race 1, Scout/Astartes stats) + // TODO: Implement logic for Mercenary (Race 2, Human stats, Hellgun) + // TODO: Implement logic for Auxiliary Soldier (Race 2.5, Renegade stats) - switch (man_role) { - case "Skitarii": - spawn_exp = 10; - obj_ini.race[target_company][_company_slot] = 3; - _unit = new TTRPG_stats("mechanicus", target_company, _company_slot, "skitarii"); - break; - case "Techpriest": - spawn_exp = 100; - obj_ini.race[target_company][_company_slot] = 3; - _unit = new TTRPG_stats("mechanicus", target_company, _company_slot, "tech_priest"); - break; - case "Crusader": - spawn_exp = 10; - obj_ini.race[target_company][_company_slot] = 4; - _unit = new TTRPG_stats("inquisition", target_company, _company_slot, "inquisition_crusader"); - break; - // TODO: Implement Sanctioned Psyker (Race 4, Psychic powers, Force Staff) - case "Sister of Battle": - spawn_exp = 20; - obj_ini.race[target_company][_company_slot] = 5; - _unit = new TTRPG_stats("adeptus_sororitas", target_company, _company_slot, "sister_of_battle"); - break; - case "Sister Hospitaler": - spawn_exp = 50; - obj_ini.race[target_company][_company_slot] = 5; - _unit = new TTRPG_stats("adeptus_sororitas", target_company, _company_slot, "sister_hospitaler"); - break; - // TODO: Implement Prioress (Race 5, Sororitas leader gear/stats) - case "Ranger": - spawn_exp = 180; - obj_ini.race[target_company][_company_slot] = 6; - _unit = new TTRPG_stats("Eldari", target_company, _company_slot, "eldar_ranger"); - break; - case "Ork Sniper": - spawn_exp = 20; - obj_ini.race[target_company][_company_slot] = eFACTION.ORK; - _unit = new TTRPG_stats("ork", target_company, _company_slot, "ork_sniper"); - break; - case "Flash Git": - spawn_exp = 40; - obj_ini.race[target_company][_company_slot] = eFACTION.ORK; - _unit = new TTRPG_stats("ork", target_company, _company_slot, "flash_git"); - break; - // TODO: Implement Warboss (Race 7) - // TODO: Implement Fire Warrior (Race 8, T'au gear/stats) - // TODO: Implement Chaos Cultist (Race 10, Autogun) - // TODO: Implement Chaos Champion (Race 11, CSM stats) - // TODO: Implement Chaos Spawn (Race 12, Possessed Claws) - } - } - - _unit.age = (obj_controller.millenium * 1000) + obj_controller.year; - - switch (spawn_name) { - case "": - case "imperial": - obj_ini.name[target_company][_company_slot] = global.name_generator.ChapterMemberNameGeneration(); + switch (man_role) { + case "Skitarii": + spawn_exp = 10; + obj_ini.race[target_company][_company_slot] = 3; + _unit = new TTRPG_stats("mechanicus", target_company, _company_slot, "skitarii"); break; - default: - obj_ini.name[target_company][_company_slot] = spawn_name; + case "Techpriest": + spawn_exp = 100; + obj_ini.race[target_company][_company_slot] = 3; + _unit = new TTRPG_stats("mechanicus", target_company, _company_slot, "tech_priest"); break; - } - switch (man_role) { + case "Crusader": + spawn_exp = 10; + obj_ini.race[target_company][_company_slot] = 4; + _unit = new TTRPG_stats("inquisition", target_company, _company_slot, "inquisition_crusader"); + break; + // TODO: Implement Sanctioned Psyker (Race 4, Psychic powers, Force Staff) + case "Sister of Battle": + spawn_exp = 20; + obj_ini.race[target_company][_company_slot] = 5; + _unit = new TTRPG_stats("adeptus_sororitas", target_company, _company_slot, "sister_of_battle"); + break; + case "Sister Hospitaler": + spawn_exp = 50; + obj_ini.race[target_company][_company_slot] = 5; + _unit = new TTRPG_stats("adeptus_sororitas", target_company, _company_slot, "sister_hospitaler"); + break; + // TODO: Implement Prioress (Race 5, Sororitas leader gear/stats) case "Ranger": - obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateMultiSyllable("eldar", 2); + spawn_exp = 180; + obj_ini.race[target_company][_company_slot] = 6; + _unit = new TTRPG_stats("Eldari", target_company, _company_slot, "eldar_ranger"); break; - case "Ork Sniper": - case "Flash Git": - obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateComposite("ork", false); + spawn_exp = 20; + obj_ini.race[target_company][_company_slot] = eFACTION.ORK; + _unit = new TTRPG_stats("ork", target_company, _company_slot, "ork_sniper"); break; - - case "Sister of Battle": - case "Sister Hospitaler": - obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateFromSet("imperial_female"); + case "Flash Git": + spawn_exp = 40; + obj_ini.race[target_company][_company_slot] = eFACTION.ORK; + _unit = new TTRPG_stats("ork", target_company, _company_slot, "flash_git"); break; + // TODO: Implement Warboss (Race 7) + // TODO: Implement Fire Warrior (Race 8, T'au gear/stats) + // TODO: Implement Chaos Cultist (Race 10, Autogun) + // TODO: Implement Chaos Champion (Race 11, CSM stats) + // TODO: Implement Chaos Spawn (Race 12, Possessed Claws) } + } - if (!array_contains(non_marine_roles, man_role)) { - obj_ini.race[target_company][_company_slot] = eFACTION.PLAYER; - if (man_role == obj_ini.role[100][12]) { - _gear = { - wep2: obj_ini.wep2[100][12], - wep1: obj_ini.wep1[100][12], - armour: obj_ini.armour[100][12], - gear: obj_ini.gear[100][12], - mobi: obj_ini.mobi[100][12], - }; - } + _unit.age = (obj_controller.millenium * 1000) + obj_controller.year; - _unit = new TTRPG_stats("chapter", target_company, _company_slot, "scout", other_data); - _unit.corruption = corruption; - _unit.roll_age(); - _unit.alter_equipment(_gear); - marines += 1; - } - obj_ini.TTRPG[target_company][_company_slot] = _unit; - _unit.add_exp(spawn_exp); - _unit.allocate_unit_to_fresh_spawn(home_spot); - _unit.update_role(man_role); - with (obj_ini) { - scr_company_order(target_company); + switch (spawn_name) { + case "": + case "imperial": + obj_ini.name[target_company][_company_slot] = global.name_generator.ChapterMemberNameGeneration(); + break; + default: + obj_ini.name[target_company][_company_slot] = spawn_name; + break; + } + switch (man_role) { + case "Ranger": + obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateMultiSyllable("eldar", 2); + break; + + case "Ork Sniper": + case "Flash Git": + obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateComposite("ork", false); + break; + + case "Sister of Battle": + case "Sister Hospitaler": + obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateFromSet("imperial_female"); + break; + } + + if (!array_contains(non_marine_roles, man_role)) { + obj_ini.race[target_company][_company_slot] = eFACTION.PLAYER; + if (man_role == obj_ini.role[100][12]) { + _gear = { + wep2: obj_ini.wep2[100][12], + wep1: obj_ini.wep1[100][12], + armour: obj_ini.armour[100][12], + gear: obj_ini.gear[100][12], + mobi: obj_ini.mobi[100][12], + }; } - _unit.update_health(_unit.max_health()); - return _unit; + + _unit = new TTRPG_stats("chapter", target_company, _company_slot, "scout", other_data); + _unit.corruption = corruption; + _unit.roll_age(); + _unit.alter_equipment(_gear); + marines += 1; + } + obj_ini.TTRPG[target_company][_company_slot] = _unit; + _unit.add_exp(spawn_exp); + _unit.allocate_unit_to_fresh_spawn(home_spot); + _unit.update_role(man_role); + with (obj_ini) { + scr_company_order(target_company); } + _unit.update_health(_unit.max_health()); + return _unit; } diff --git a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index 91f1fd6e78..52c6eb9782 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -272,8 +272,8 @@ function new_forge_master_chosen(pick) { } reset_popup_options(); if (pick.company > 0) { - for (var i = 1; i < 500; i++) { - if (obj_ini.name[0][i] == "") { + for (var i = 0; i < array_length(obj_ini.TTRPG[0]); i++) { + if (obj_ini.TTRPG[0][i].name() == "") { scr_move_unit_info(pick.company, 0, pick.marine_number, i); break; } diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index dea3f34b1c..0a70c3b5ad 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -115,15 +115,16 @@ function scr_company_order(company) { array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true)}); } - TTRPG[co] = array_create(_temps, 0); - race[co] = array_create(_temps, 0); - name[co] = array_create(_temps, 0); - role[co] = array_create(_temps, 0); - wep1[co] = array_create(_temps, 0); - wep2[co] = array_create(_temps, 0); - armour[co] = array_create(_temps, 0); - gear[co] = array_create(_temps, 0); - mobi[co] = array_create(_temps, 0); + var _new_length = array_length(_temps); + TTRPG[co] = array_create(_new_length, 0); + race[co] = array_create(_new_length, 0); + name[co] = array_create(_new_length, 0); + role[co] = array_create(_new_length, 0); + wep1[co] = array_create(_new_length, 0); + wep2[co] = array_create(_new_length, 0); + armour[co] = array_create(_new_length, 0); + gear[co] = array_create(_new_length, 0); + mobi[co] = array_create(_new_length, 0); for (var i = 0; i < array_length(_temps); i++) { var _unit = _temps[i]; var _struc = _unit.unit; @@ -136,12 +137,6 @@ function scr_company_order(company) { armour[co][i] = _unit.armour; gear[co][i] = _unit.gear; mobi[co][i] = _unit.mobi; - if (_struc.marine_number != i) { - if (TTRPG[_struc.company][_struc.marine_number].uid == _struc.uid) { - TTRPG[_struc.company][_struc.marine_number] = new TTRPG_stats("chapter", _struc.company, _struc.marine_number, "blank"); - scr_wipe_unit(_struc.company, _struc.marine_number); - } - } _struc.company = co; _struc.marine_number = i; if (_struc.squad != "none") { diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index ccbd7471df..84443fac6e 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -49,6 +49,17 @@ function find_company_open_slot(target_company) { break; } } + if (good == -1){ + array_push(race[target_company], ""); + array_push(name[target_company],""); + array_push(role[target_company],""); + array_push(wep1[target_company], ""); + array_push(wep2[target_company] , ""); + array_push(armour[target_company] , ""); + array_push(gear[target_company] , ""); + array_push(mobi[target_company] , ""); + array_push(TTRPG[target_company],undefined); + } return good; } diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 89fb21e148..b10f65ccc4 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -2997,7 +2997,9 @@ function scr_initialize_custom() { // ** sets up the starting squads** LOGGER.info("set up the starting squads"); obj_ini.squads = {}; + sort_all_companies(); game_start_squads(); + sort_all_companies(); } /// @description helper function to streamline code inside of scr_initialize_custom, should only be used as part of game setup and not during normal gameplay diff --git a/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml b/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml index 30181ec75f..3b39d32f9c 100644 --- a/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml +++ b/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml @@ -1,6 +1,5 @@ /// @self Struct.TTRPG_stats function scr_marine_spawn_age() { - var _age = 0; var _minimum_age = 0; var _maximum_age = 0; var _apply_gauss = false; @@ -130,15 +129,14 @@ function scr_marine_spawn_age() { if (_apply_gauss == true) { if (_maximum_age != 0) { _gauss_sd_mod = (_maximum_age - _minimum_age) / _gauss_sd_mod; - _age = gauss_positive(_minimum_age, _gauss_sd_mod); + age = round(gauss_positive(_minimum_age, _gauss_sd_mod)); } else { - _age = gauss_positive(_minimum_age, _minimum_age / _gauss_sd_mod); + age = round(gauss_positive(_minimum_age, _minimum_age / _gauss_sd_mod)); } } else { - _age = irandom_range(_minimum_age, _maximum_age); + age = irandom_range(_minimum_age, _maximum_age); } - update_age(round(_age)); } /// @self Struct.TTRPG_stats @@ -154,10 +152,9 @@ function scr_marine_spawn_armour() { } }; - var _age = age(); var _role = role(); var _exp = experience; - var _total_score = _age + _exp + (scr_has_adv("Crafters") ? 50 : 0); + var _total_score = age + _exp + (scr_has_adv("Crafters") ? 50 : 0); var _company = company; var _armour_weighted_lists = { From fee7b05aac5af5342e3a63e84762c6553369c9d1 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 28 Jul 2026 23:31:12 +0100 Subject: [PATCH 05/82] back to working --- scripts/scr_initialize_custom/scr_initialize_custom.gml | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index b10f65ccc4..b2ddcb4deb 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -2006,7 +2006,6 @@ function scr_initialize_custom() { wep1[c][i] = ""; wep2[c][i] = ""; armour[c][i] = ""; - chaos[c][i] = 0; gear[c][i] = ""; mobi[c][i] = ""; TTRPG[c][i] = new TTRPG_stats("chapter", c, i, "blank"); @@ -2997,9 +2996,7 @@ function scr_initialize_custom() { // ** sets up the starting squads** LOGGER.info("set up the starting squads"); obj_ini.squads = {}; - sort_all_companies(); game_start_squads(); - sort_all_companies(); } /// @description helper function to streamline code inside of scr_initialize_custom, should only be used as part of game setup and not during normal gameplay From a8aac37fed72c5407b34d31b56de00f5341d21b3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 28 Jul 2026 23:40:15 +0100 Subject: [PATCH 06/82] a few crashes --- objects/obj_controller/Alarm_5.gml | 3 +-- objects/obj_ini/Create_0.gml | 8 +++----- scripts/scr_count_forces/scr_count_forces.gml | 3 +-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 6ee735f38c..a2f8d1cf42 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -290,9 +290,8 @@ try { var p = 0; for (var c = 0; c < 11; c++) { for (var e = 0; e < array_length(obj_ini.TTRPG[c]); e++) { - var _unit = fetch_unt([c,e]); + var _unit = fetch_unit([c,e]); if (_unit.god_status == 10) { - var _unit = fetch_unit([c, e]); if (!is_struct(_unit)) { continue; } diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 6c5180c0ef..f040092a29 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -176,14 +176,12 @@ if (global.load == -1) { /// Called from save function to take all object variables and convert them to a json savable format and return it serialize = function() { var _marines = array_create(0); - for (var _coy = 0; _coy <= 10; _coy++) { - for (var _mar = 0; _mar <= 500; _mar++) { + for (var _coy = 0; _coy <= obj_ini.companies; _coy++) { + for (var _mar = 0; _mar < array_length(obj_ini.TTRPG[_coy]); _mar++) { if (name[_coy][_mar] != "") { var _marine_json = jsonify_marine_struct(_coy, _mar, false); array_push(_marines, _marine_json); - } else if (_mar > 0 && _mar <= 499 && name[_coy][_mar + 1] == "") { - break; - } + } } } diff --git a/scripts/scr_count_forces/scr_count_forces.gml b/scripts/scr_count_forces/scr_count_forces.gml index a1c6335a08..36e1cd6bab 100644 --- a/scripts/scr_count_forces/scr_count_forces.gml +++ b/scripts/scr_count_forces/scr_count_forces.gml @@ -6,7 +6,6 @@ function scr_count_forces(_unit_location, _target_location, _is_planet, _return_ var _marine_count = 0; var _vehicle_count = 0; var _max_companies = 11; - var _safety_limit = 500; for (var _company = 0; _company < _max_companies; _company++) { var _veh_race = obj_ini.veh_race[_company]; @@ -14,7 +13,7 @@ function scr_count_forces(_unit_location, _target_location, _is_planet, _return_ var _veh_wid = obj_ini.veh_wid[_company]; var _veh_len = array_length(_veh_race); - for (var i = 0; i < _safety_limit; i++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[_company]); i++) { var _unit = fetch_unit([_company, i]); var _marine_exists = is_struct(_unit) && _unit.name() != ""; var _vehicle_exists = i < _veh_len; From d604e1e4ae5652aac62334bb7a2ff667aef96ebd Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Tue, 28 Jul 2026 23:42:03 +0100 Subject: [PATCH 07/82] Update scripts/scr_company_view/scr_company_view.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_company_view/scr_company_view.gml | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index 84443fac6e..78edf41395 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -49,16 +49,18 @@ function find_company_open_slot(target_company) { break; } } - if (good == -1){ - array_push(race[target_company], ""); - array_push(name[target_company],""); - array_push(role[target_company],""); - array_push(wep1[target_company], ""); - array_push(wep2[target_company] , ""); - array_push(armour[target_company] , ""); - array_push(gear[target_company] , ""); - array_push(mobi[target_company] , ""); - array_push(TTRPG[target_company],undefined); + if (good == -1) { + good = array_length(obj_ini.name[target_company]); + array_push(obj_ini.race[target_company], 0); + array_push(obj_ini.name[target_company], ""); + array_push(obj_ini.role[target_company], ""); + array_push(obj_ini.wep1[target_company], ""); + array_push(obj_ini.wep2[target_company], ""); + array_push(obj_ini.armour[target_company], ""); + array_push(obj_ini.gear[target_company], ""); + array_push(obj_ini.mobi[target_company], ""); + array_push(obj_ini.TTRPG[target_company], undefined); + } } return good; } From 54397f5f0f16fc6f9cf8fa4a4c050830016c528e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 29 Jul 2026 00:03:53 +0100 Subject: [PATCH 08/82] fix ascension mechanic --- scripts/scr_kill_unit/scr_kill_unit.gml | 5 +++-- scripts/scr_marine_struct/scr_marine_struct.gml | 6 +----- .../scr_player_combat_weapon_stacks.gml | 1 - scripts/scr_unit_detail_text/scr_unit_detail_text.gml | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 077f87a926..c75e7e45ec 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -52,10 +52,11 @@ function kill_and_recover(company, unit_slot, equipment = true, gene_seed_collec unit.alter_equipment(strip, false, true); } if (gene_seed_collect && unit.base_group == "astartes") { - if (unit.age > 30 && !obj_ini.zygote && !obj_ini.doomed) { + + if (unit.marine_ascension > 30 && !obj_ini.zygote && !obj_ini.doomed) { obj_controller.gene_seed += 1; } - if (unit.age > 50 && !obj_ini.doomed) { + if (unit.marine_ascension > 100 && !obj_ini.doomed) { obj_controller.gene_seed += 1; } } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 68c770b364..40611d6ff2 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -256,7 +256,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} obj_controller.turn, ], ]; //marines_promotion and demotion history - marine_ascension = (obj_controller.millenium * 1000) + obj_controller.year; // on what day did this marine begin to exist + marine_ascension = obj_controller.turn; // on what day did this marine begin to exist } else { role_history = []; marine_ascension = 0; // on what turn did this marine begin to exist @@ -924,10 +924,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} age = 0; - static update_age = function(new_val) { - age = new_val; - }; - //TODO build epithets in to marine profile static add_epithet = function(epithet) { if (is_string(epithet)) { diff --git a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml index 7f0be1ec55..6c76291ae3 100644 --- a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml +++ b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml @@ -382,7 +382,6 @@ function scr_add_unit_to_roster(unit, is_local = false, is_ally = false) { array_push(marine_exp, unit.experience); array_push(marine_powers, unit.specials); array_push(marine_ranged, unit.ranged_attack()); - array_push(marine_powers, unit.specials); array_push(marine_ac, unit.armour_calc()); array_push(marine_attack, unit.melee_attack()); array_push(marine_local, is_local); diff --git a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml index 56e16356dc..be6766a06e 100644 --- a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml +++ b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml @@ -49,7 +49,7 @@ function scr_unit_detail_text() { if (ascension_date == "0") { ascension_date = "unknown"; } - unit_data_string += $"{round(age())} years old. Ascended to an Astartes in the {ascension_date} year."; + unit_data_string += $"{round(age} years old. Ascended to an Astartes in the {ascension_date} year."; if (struct_exists(spawn_data, "recruit_data")) { var recruit_data = spawn_data.recruit_data; unit_data_string += "\n"; From 3ee51c322a01c24d64611d9c6dc7ff9a471aeba1 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 29 Jul 2026 00:05:16 +0100 Subject: [PATCH 09/82] return good index --- scripts/scr_company_view/scr_company_view.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index 78edf41395..8ec175f944 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -60,7 +60,7 @@ function find_company_open_slot(target_company) { array_push(obj_ini.gear[target_company], ""); array_push(obj_ini.mobi[target_company], ""); array_push(obj_ini.TTRPG[target_company], undefined); - } + good = array_length(obj_ini.TTRPG) - 1; } return good; } From 3974216cdcf7225f74056d60821c37354458717f Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Wed, 29 Jul 2026 00:15:22 +0100 Subject: [PATCH 10/82] Update scripts/scr_unit_detail_text/scr_unit_detail_text.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_unit_detail_text/scr_unit_detail_text.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml index be6766a06e..4cb368df61 100644 --- a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml +++ b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml @@ -49,7 +49,7 @@ function scr_unit_detail_text() { if (ascension_date == "0") { ascension_date = "unknown"; } - unit_data_string += $"{round(age} years old. Ascended to an Astartes in the {ascension_date} year."; + unit_data_string += $"{round(age)} years old. Ascended to an Astartes in the {ascension_date} year."; if (struct_exists(spawn_data, "recruit_data")) { var recruit_data = spawn_data.recruit_data; unit_data_string += "\n"; From d2b80b57953d8ce46bb6a8baffe47568a15d5ade Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 29 Jul 2026 23:45:14 +0100 Subject: [PATCH 11/82] review points --- scripts/scr_add_man/scr_add_man.gml | 3 +- .../scr_chapter_managent_events.gml | 6 +- scripts/scr_check_equip/scr_check_equip.gml | 6 +- scripts/scr_civil_roster/scr_civil_roster.gml | 12 +- .../scr_company_order/scr_company_order.gml | 4 + scripts/scr_company_view/scr_company_view.gml | 2 +- scripts/scr_crusade/scr_crusade.gml | 11 +- scripts/scr_dialogue/scr_dialogue.gml | 2 +- .../scr_ship_occupants/scr_ship_occupants.gml | 133 +++++++----------- 9 files changed, 67 insertions(+), 112 deletions(-) diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index 1f46916f2b..859ba55bbb 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -13,9 +13,8 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption "Flash Git", ]; var _gear = {}; - var _company_slot = 0; - _company_slot = find_company_open_slot(target_company); + var _company_slot = find_company_open_slot(target_company); scr_wipe_unit(target_company, _company_slot); var _unit = fetch_unit([target_company, _company_slot]); diff --git a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index 52c6eb9782..80fc1bf338 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -273,10 +273,8 @@ function new_forge_master_chosen(pick) { reset_popup_options(); if (pick.company > 0) { for (var i = 0; i < array_length(obj_ini.TTRPG[0]); i++) { - if (obj_ini.TTRPG[0][i].name() == "") { - scr_move_unit_info(pick.company, 0, pick.marine_number, i); - break; - } + scr_move_unit_info(pick.company, 0, pick.marine_number, i); + break; } } } diff --git a/scripts/scr_check_equip/scr_check_equip.gml b/scripts/scr_check_equip/scr_check_equip.gml index af0134ae92..9c1091b9c7 100644 --- a/scripts/scr_check_equip/scr_check_equip.gml +++ b/scripts/scr_check_equip/scr_check_equip.gml @@ -9,10 +9,8 @@ function scr_check_equip(search_item, system, planet_or_ship_id, remove_item) { var man_c = 0, man_i = 0, have = 0, unit, marine_present; for (var c = 0; c <= 10; c++) { - for (var i = 1; i <= 500; i++) { - if (obj_ini.name[c][i] == "") { - continue; - } + for (var i = 0; i <= array_length(obj_ini.TTRPG[c]); i++) { + marine_present = false; if (!instance_exists(obj_ncombat)) { unit = fetch_unit([c, i]); diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index 0a9ca58810..87d15ea568 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -700,7 +700,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { col = obj_controller.bat_command_column; new_combat.important_dudes += 1; new_combat.big_mofo = 1; - if (string_count("0", deploying_unit.specials) > 0) { + if (string_count("0", unit.specials) > 0) { new_combat.chapter_master_psyker = 1; } else { new_combat.chapter_master_psyker = 0; @@ -740,14 +740,14 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.marine_co[targ.men] = unit.company; targ.marine_id[targ.men] = v; targ.marine_type[targ.men] = unit.role(); - targ.marine_wep1[targ.men] = deploying_unit.wep1[cooh][va]; - targ.marine_wep2[targ.men] = deploying_unit.wep2[cooh][va]; - targ.marine_armour[targ.men] = deploying_unit.armour[cooh][va]; - targ.marine_gear[targ.men] = deploying_unit.gear[cooh][va]; + targ.marine_wep1[targ.men] = unit.weapon_one(); + targ.marine_wep2[targ.men] = unit.weapon_two(); + targ.marine_armour[targ.men] = unit.armour(); + targ.marine_gear[targ.men] = unit.gear()); targ.marine_mobi[targ.men] = unit.mobility_item(); targ.marine_hp[targ.men] = unit.hp(); targ.marine_exp[targ.men] = unit.experience; - targ.marine_powers[targ.men] = deploying_unit.specials; + targ.marine_powers[targ.men] = unit.specials; targ.marine_ranged[targ.men] = unit.ranged_attack(); targ.marine_ac[targ.men] = unit.armour_calc(); targ.marine_attack[targ.men] = unit.melee_attack(); diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 0a70c3b5ad..b23a833bec 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -16,6 +16,10 @@ function sort_all_companies_to_map(map) { } } +function company_length(company){ + return obj_ini.TTRPG(company) +} + function scr_company_order(company) { try { // company : company number diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index 8ec175f944..f4c25b1e27 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -60,7 +60,7 @@ function find_company_open_slot(target_company) { array_push(obj_ini.gear[target_company], ""); array_push(obj_ini.mobi[target_company], ""); array_push(obj_ini.TTRPG[target_company], undefined); - good = array_length(obj_ini.TTRPG) - 1; + good = array_length(obj_ini.TTRPG[target_company]) - 1; } return good; } diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index e5a66eabdd..3b14febc0e 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -5,7 +5,6 @@ function scr_crusade() { var unit; var co = 0, i = 0, apoth = 0, death_determination = 0, death_determination_2 = 0, roll3 = 0, type = "", artifacts = 0, clean = 0; - good = 0; seed = 0; marines_lost = 0; var heroics_strings = []; @@ -58,18 +57,14 @@ function scr_crusade() { var death_data = death_sets[$ type]; - for (co = 0; co <= 10; co++) { + for (co = 0; co <= company_length(co); co++) { clean[co] = 0; } var total_ship_id = array_concat(capital_num, frigate_num, escort_num); - for (co = 0; co <= 10; co++) { - for (i = 0; i <= 500; i++) { - good = 0; + for (co = 0; co <= obj_ini.company_length(); co++) { + for (i = 0; i <= company_length(co)); i++) { dead = false; - if (obj_ini.name[co][i] == "") { - continue; - } unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index 181d329361..20f08f9646 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -179,7 +179,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { // Option4 here if all the right conditions are met var born = false; for (var i = 0; i < array_length(obj_ini.TTRPG[0]); i++) { - var _unit = fetch_unit([o, i]); + var _unit = fetch_unit([0, i]); if ((_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) && (string_count("$", _unit.specials) > 0)) { born = true; } diff --git a/scripts/scr_ship_occupants/scr_ship_occupants.gml b/scripts/scr_ship_occupants/scr_ship_occupants.gml index 81d2d6eba0..d12ddd2a81 100644 --- a/scripts/scr_ship_occupants/scr_ship_occupants.gml +++ b/scripts/scr_ship_occupants/scr_ship_occupants.gml @@ -1,99 +1,60 @@ function scr_ship_occupants(target_ship_id) { - var co, i, oc, ocn, ty, g, good, blur, unit; - co = -1; - i = -1; - ty = 0; - g = 0; - good = 0; - blur = ""; + var unit_list = []; - repeat (200) { - i += 1; - oc[i] = ""; - ocn[i] = 0; - } - - i = 0; - for (co = 0; co <= 10; co++) { - i = 0; - repeat (500) { - i += 1; - if (obj_ini.role[co][i] != "") { - unit = fetch_unit([co, i]); - if (!is_struct(unit)) { - continue; - } - if (unit.ship_location != target_ship_id) { - good = 0; - } - g = 0; - repeat (100) { - g += 1; - if (good == 0) { - if (oc[g] == unit.role()) { - good = 1; - ocn[g] += 1; - break; - } - } - } - if (good == 0) { - ty += 1; - oc[ty] = unit.role(); - ocn[ty] = 1; - good = 1; - } + // Crew + for (var co = 0; co < obj_ini.companies; co++) { + for (var i = 0; i <= company_length(co); i++) { + if (obj_ini.role[co][i] == "") { + continue; } - } - } - i = 0; - co = -1; - for (co = 0; co <= 10; co++) { - i = 0; - repeat (100) { - i += 1; - if ((obj_ini.veh_role[co][i] != "") && (obj_ini.veh_lid[co][i] == target_ship_id)) { - good = 0; - g = 0; - repeat (100) { - g += 1; - if (good == 0) { - if (oc[g] == obj_ini.veh_role[co][i]) { - good = 1; - ocn[g] += 1; - } - } - } - if (good == 0) { - ty += 1; - oc[ty] = obj_ini.veh_role[co][i]; - ocn[ty] = 1; - good = 1; - } + var unit = fetch_unit([co, i]); + if (!is_struct(unit)) { + continue; + } + if (unit.ship_location != target_ship_id) { + continue; } + array_push(unit_list, unit); } } + var occupant_index = new UnitIndex(unit_list); + var strings_array = occupant_index.create_plural_strings_array(); - i = 0; - good = 1; - repeat (100) { - i += 1; - if (good == 1) { - if (ocn[i] == 1) { - blur += string(ocn[i]) + "x " + string(oc[i]); - } - if (ocn[i] > 1) { - blur += string(ocn[i]) + "x " + string(oc[i]) + "s"; + // Vehicles (not compatible with UnitIndex - tally role strings directly) + var veh_index = {}; + var veh_keys = []; + for (var co = 0; co < obj_ini.companies; co++) { + for (var i = 0; i <= 100; i++) { + if (obj_ini.veh_role[co][i] == "" || obj_ini.veh_lid[co][i] != target_ship_id) { + continue; } - if (ocn[i + 1] > 0) { - blur += ", "; - } - if (ocn[i + 1] == 0) { - blur += "."; - good = 0; + var veh_role = obj_ini.veh_role[co][i]; + if (!struct_exists(veh_index, veh_role)) { + veh_index[$ veh_role] = 1; + array_push(veh_keys, veh_role); + } else { + veh_index[$ veh_role] += 1; } } } + for (var i = 0; i < array_length(veh_keys); i++) { + var _role = veh_keys[i]; + var _count = veh_index[$ _role]; + if (_count == 1) { + array_push(strings_array, {str1: _role, bold: true, italic: false}); + } else { + array_push(strings_array, string_plural_count(_role, _count, false)); + } + } + + // Build final string + var blur = ""; + var _total = array_length(strings_array); + for (var i = 0; i < _total; i++) { + var entry = strings_array[i]; + blur += is_struct(entry) ? entry.str1 : string(entry); + blur += (i < _total - 1) ? ", " : "."; + } return blur; -} +} \ No newline at end of file From 583b4e94e84fad25d5b99f50a9ae4f37da8010ce Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 29 Jul 2026 23:51:04 +0100 Subject: [PATCH 12/82] compile errors --- scripts/scr_civil_roster/scr_civil_roster.gml | 2 +- scripts/scr_crusade/scr_crusade.gml | 6 +- scripts/scr_max_marine/scr_max_marine.gml | 56 ++++++++----------- .../scr_unit_detail_text.gml | 2 +- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index 87d15ea568..46a74a0adb 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -743,7 +743,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.marine_wep1[targ.men] = unit.weapon_one(); targ.marine_wep2[targ.men] = unit.weapon_two(); targ.marine_armour[targ.men] = unit.armour(); - targ.marine_gear[targ.men] = unit.gear()); + targ.marine_gear[targ.men] = unit.gear(); targ.marine_mobi[targ.men] = unit.mobility_item(); targ.marine_hp[targ.men] = unit.hp(); targ.marine_exp[targ.men] = unit.experience; diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 3b14febc0e..7ad0281ed5 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -57,13 +57,13 @@ function scr_crusade() { var death_data = death_sets[$ type]; - for (co = 0; co <= company_length(co); co++) { + for (co = 0; co <= companies; co++) { clean[co] = 0; } var total_ship_id = array_concat(capital_num, frigate_num, escort_num); - for (co = 0; co <= obj_ini.company_length(); co++) { - for (i = 0; i <= company_length(co)); i++) { + for (co = 0; co <= obj_ini.companies; co++) { + for (i = 0; i < company_length(co); i++) { dead = false; unit = fetch_unit([co, i]); if (!is_struct(unit)) { diff --git a/scripts/scr_max_marine/scr_max_marine.gml b/scripts/scr_max_marine/scr_max_marine.gml index f9384239f3..9b29494b8f 100644 --- a/scripts/scr_max_marine/scr_max_marine.gml +++ b/scripts/scr_max_marine/scr_max_marine.gml @@ -3,44 +3,34 @@ function scr_max_marine(max_type) { // Returns the marine with the highest value - var man_c, man_i, c, i, value, unit; + var man_c, man_i, value, unit; man_c = 0; man_i = 0; - c = 0; - i = 0; value = 0; - i = -1; - c = -1; - repeat (11) { - c += 1; - i = 0; - repeat (305) { - i += 1; // man_c[i]=0;man_i[i]=0; - - if (obj_ini.name[c][i] != "") { - unit = fetch_unit([c, i]); - if (!is_struct(unit)) { - continue; + for (co = 0; co <= obj_ini.companies; co++) { + for (var i = 0; i < company_length(co); i++) { + unit = fetch_unit([c, i]); + if (!is_struct(unit)) { + continue; + } + if (max_type == "chaos") { + if (unit.corruption > value) { + value = unit.corruption; + man_c = c; + man_i = i; + } + } else if (max_type == "age") { + if (unit.age < value) { + value = unit.age; + man_c = c; + man_i = i; } - if (max_type == "chaos") { - if (unit.corruption > value) { - value = unit.corruption; - man_c = c; - man_i = i; - } - } else if (max_type == "age") { - if (unit.age < value) { - value = unit.age; - man_c = c; - man_i = i; - } - } else if (max_type == "exp") { - if (unit.experience > value) { - value = unit.experience; - man_c = c; - man_i = i; - } + } else if (max_type == "exp") { + if (unit.experience > value) { + value = unit.experience; + man_c = c; + man_i = i; } } } diff --git a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml index be6766a06e..4cb368df61 100644 --- a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml +++ b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml @@ -49,7 +49,7 @@ function scr_unit_detail_text() { if (ascension_date == "0") { ascension_date = "unknown"; } - unit_data_string += $"{round(age} years old. Ascended to an Astartes in the {ascension_date} year."; + unit_data_string += $"{round(age)} years old. Ascended to an Astartes in the {ascension_date} year."; if (struct_exists(spawn_data, "recruit_data")) { var recruit_data = spawn_data.recruit_data; unit_data_string += "\n"; From c77f242c103eed388cce67c3d3c71b649f901760 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 30 Jul 2026 13:36:23 +0100 Subject: [PATCH 13/82] variable name changes --- objects/obj_ini/Create_0.gml | 2 +- scripts/scr_add_man/scr_add_man.gml | 5 ++--- scripts/scr_company_order/scr_company_order.gml | 2 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 2 +- scripts/scr_random_event/scr_random_event.gml | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index f040092a29..346623cbc9 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -118,7 +118,7 @@ veh_acc = array_create_2d(_max_companies, _max_vehicles, ""); defaults_slot = 100; /// @type {Array>} -race = array_create(11, 501); +race = array_create(11, []); /// @type {Array>} name = array_create(11, []); /// @type {Array>} diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index 859ba55bbb..c6a1e3d242 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -73,9 +73,6 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption // TODO: Implement Chaos Spawn (Race 12, Possessed Claws) } } - - _unit.age = (obj_controller.millenium * 1000) + obj_controller.year; - switch (spawn_name) { case "": case "imperial": @@ -123,6 +120,8 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption _unit.add_exp(spawn_exp); _unit.allocate_unit_to_fresh_spawn(home_spot); _unit.update_role(man_role); + _unit.age = (obj_controller.millenium * 1000) + obj_controller.year; + with (obj_ini) { scr_company_order(target_company); } diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index b23a833bec..a23a6043d1 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -17,7 +17,7 @@ function sort_all_companies_to_map(map) { } function company_length(company){ - return obj_ini.TTRPG(company) + return obj_ini.TTRPG[company]; } function scr_company_order(company) { diff --git a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml index f857c4609b..d6880545f9 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -167,7 +167,7 @@ function scr_enemy_ai_d() { for (var q = 0; q < array_length(obj_ini.TTRPG[0]); q++) { var _unit = fetch_unit([0, q]); if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { - if (string_count("0", _unit.special) > 0) { + if (string_count("0", _unit.specials) > 0) { scr_popup("Shadow in the Warp", "You are distracted and bothered by a nagging sensation in the warp. It feels as though a shadow descends upon your sector.", "shadow", ""); scr_event_log("red", "You sense a disturbance in the warp. It feels something like a massive shadow."); } diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index e69132717a..df38fdefd1 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -709,7 +709,7 @@ function scr_random_event(execute_now) { var cm_is_psyker = false; for (var i = 0; i < array_length(TTRPG[0]); i++) { var _unit = fetch_unit([0 ,i]); - if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER] && string_count("0", _unit.special) > 0) { + if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER] && string_count("0", _unit.specials) > 0) { cm_is_psyker = true; break; } From 91a44073092d260ed17c2d4a99464112a9ac2782 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 30 Jul 2026 14:22:18 +0100 Subject: [PATCH 14/82] manage error --- .../scr_chapter_managent_events.gml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index 80fc1bf338..e390360f0b 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -272,10 +272,8 @@ function new_forge_master_chosen(pick) { } reset_popup_options(); if (pick.company > 0) { - for (var i = 0; i < array_length(obj_ini.TTRPG[0]); i++) { - scr_move_unit_info(pick.company, 0, pick.marine_number, i); - break; - } + var _company_slot = find_company_open_slot(0); + scr_move_unit_info(pick.company, 0, pick.marine_number, _company_slot); } } } From d67e24aa7e5a7407d313d25f4a9ea8bd8b69cfc5 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 30 Jul 2026 14:23:17 +0100 Subject: [PATCH 15/82] attempt reoval of all other parrllel arrays --- objects/obj_controller/Create_0.gml | 40 - objects/obj_creation/Create_0.gml | 46 +- objects/obj_creation_popup/Draw_0.gml | 51 +- scripts/scr_chapter_new/scr_chapter_new.gml | 15 +- .../scr_marine_struct/scr_marine_struct.gml | 6 +- .../scr_restart_variables.gml | 814 ------------------ scripts/scr_role_setup/scr_role_setup.gml | 12 + 7 files changed, 46 insertions(+), 938 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 26e6955303..61b7863fe9 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -107,22 +107,6 @@ var _arrays_count = 103; var _empty_array = []; LOGGER.info("Set Game Arrays and Statics"); -r_race = array_create_advanced(_arrays_count, _empty_array); -r_role = array_create_advanced(_arrays_count, _empty_array); -r_wep1 = array_create_advanced(_arrays_count, _empty_array); -r_wep2 = array_create_advanced(_arrays_count, _empty_array); -r_armour = array_create_advanced(_arrays_count, _empty_array); -r_gear = array_create_advanced(_arrays_count, _empty_array); -r_mobi = array_create_advanced(_arrays_count, _empty_array); - -var _empty_size = 21; -r_race[100] = array_create(_empty_size, 0); -r_role[100] = array_create(_empty_size, ""); -r_wep1[100] = array_create(_empty_size, ""); -r_wep2[100] = array_create(_empty_size, ""); -r_armour[100] = array_create(_empty_size, ""); -r_gear[100] = array_create(_empty_size, ""); -r_mobi[100] = array_create(_empty_size, ""); var _roles_data = {}; @@ -270,30 +254,6 @@ for (var k = 0, _kl = array_length(_role_keys); k < _kl; k++) { _max_id = max(_max_id, real(_role_keys[k])); } -for (var i = 101; i < 103; i++) { - var _target_size = _max_id + 1; - - r_role[i] = array_create(_target_size, ""); - r_wep1[i] = array_create(_target_size, ""); - r_wep2[i] = array_create(_target_size, ""); - r_armour[i] = array_create(_target_size, ""); - r_mobi[i] = array_create(_target_size, ""); - r_gear[i] = array_create(_target_size, ""); - - for (var j = 0, jl = array_length(_role_keys); j < jl; j++) { - var _key = _role_keys[j]; - var _id = real(_key); - var _data = _roles_data[$ _key]; - - r_role[i][_id] = _data.name; - r_wep1[i][_id] = _data.w1; - r_wep2[i][_id] = _data.w2; - r_armour[i][_id] = _data.arm; - r_mobi[i][_id] = _data.mob; - r_gear[i][_id] = _data.gear; - } -} - // ** Sets cheatcode values ** cheatcode = ""; cheatyface = 0; diff --git a/objects/obj_creation/Create_0.gml b/objects/obj_creation/Create_0.gml index d405e8e0be..b4aff6e0a2 100644 --- a/objects/obj_creation/Create_0.gml +++ b/objects/obj_creation/Create_0.gml @@ -537,26 +537,28 @@ chapter_trait_meta = []; setup_chapter_traits(); -race = []; -role = []; -wep1 = []; -wep2 = []; -armour = []; -gear = []; -mobi = []; -// Default Marine Loadouts -for (var slot = 99; slot <= 103; slot++) { - for (var i = 0; i <= 50; i++) { - race[slot][i] = 1; - role[slot][i] = ""; - wep1[slot][i] = ""; - wep2[slot][i] = ""; - armour[slot][i] = ""; - gear[slot][i] = ""; - mobi[slot][i] = ""; +function role_data_set(){ + return { + role : "", + wep1 : "", + wep2 : "", + armour : "", + mobi : "", + gear : "", + race : 1 } } +player_role_data = []; +default_role_data = []; + +// Default Marine Loadouts + +for (var i = 0; i <= 50; i++) { + player_role_data[i] = role_data_set(); + default_role_data[i] = role_data_set(); +} + defaults_slot = 100; @@ -568,15 +570,7 @@ defaults_slot = 100; /// @param {String} _armour /// @param {String} _mobi /// @param {String} _gear -load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { - role[defaults_slot][_role_id] = _role_name; - wep1[defaults_slot][_role_id] = _wep1; - wep2[defaults_slot][_role_id] = _wep2; - armour[defaults_slot][_role_id] = _armour; - mobi[defaults_slot][_role_id] = _mobi; - gear[defaults_slot][_role_id] = _gear; - race[defaults_slot][_role_id] = 1; -}; + load_default_gear(eROLE.CHAPTERMASTER, "Chapter Master", "Power Sword", "Bolter", "Artificer Armour", "", ""); load_default_gear(eROLE.HONOURGUARD, "Honour Guard", "Power Sword", "Bolter", "Artificer Armour", "", ""); diff --git a/objects/obj_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index b28c015ee4..bdeeb842f6 100644 --- a/objects/obj_creation_popup/Draw_0.gml +++ b/objects/obj_creation_popup/Draw_0.gml @@ -163,15 +163,8 @@ try { for (var i = 0; i < array_length(possible_custom_roles); i++) { var _role_pair = possible_custom_roles[i]; if (_role_pair[1] == _role_id) { - var c_role = { - name: obj_creation.role[100][_role_id], - wep1: obj_creation.wep1[100][_role_id], - wep2: obj_creation.wep2[100][_role_id], - gear: obj_creation.gear[100][_role_id], - mobi: obj_creation.mobi[100][_role_id], - armour: obj_creation.armour[100][_role_id], - }; - variable_struct_set(obj_creation.custom_roles, _role_pair[0], c_role); + var _p_role_data = obj_creation.player_role_data[_role_id]; + variable_struct_set(obj_creation.custom_roles, _role_pair[0], _p_role_data); break; } } @@ -234,23 +227,10 @@ try { if (mouse_button_clicked()) { var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; - switch (target_gear) { - case 0: - obj_creation.wep1[co][ide] = buh; - break; - case 1: - obj_creation.wep2[co][ide] = buh; - break; - case 2: - obj_creation.armour[co][ide] = buh; - break; - case 3: - obj_creation.gear[co][ide] = buh; - break; - case 4: - obj_creation.mobi[co][ide] = buh; - break; - } + var _player_data = obj_creation.player_role_data[ide]; + + _player_data[$ global.unit_equip_slots[target_gear]] = buh + } } } @@ -278,23 +258,8 @@ try { if (point_and_click(_button)) { var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; - switch (target_gear) { - case 0: - obj_creation.wep1[co][ide] = buh; - break; - case 1: - obj_creation.wep2[co][ide] = buh; - break; - case 2: - obj_creation.armour[co][ide] = buh; - break; - case 3: - obj_creation.gear[co][ide] = buh; - break; - case 4: - obj_creation.mobi[co][ide] = buh; - break; - } + var _player_data = obj_creation.player_role_data[ide]; + _player_data[$ global.unit_equip_slots[target_gear]] = buh } } tab = 1; diff --git a/scripts/scr_chapter_new/scr_chapter_new.gml b/scripts/scr_chapter_new/scr_chapter_new.gml index 38def22277..74bdf01a6e 100644 --- a/scripts/scr_chapter_new/scr_chapter_new.gml +++ b/scripts/scr_chapter_new/scr_chapter_new.gml @@ -210,19 +210,8 @@ function scr_chapter_new(chapter_identifier) { points = 100; maxpoints = 100; - - load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { - for (var i = 100; i <= 102; i++) { - role[i][_role_id] = _role_name; - wep1[i][_role_id] = _wep1; - wep2[i][_role_id] = _wep2; - armour[i][_role_id] = _armour; - mobi[i][_role_id] = _mobi; - gear[i][_role_id] = _gear; - race[i][_role_id] = 1; - } - }; - + player_role_data = []; + default_role_data = []; load_default_gear(eROLE.HONOURGUARD, "Honour Guard", "Power Sword", "Bolter", "Artificer Armour", "", ""); load_default_gear(eROLE.VETERAN, "Veteran", "Combiflamer", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); load_default_gear(eROLE.TERMINATOR, "Terminator", "Power Fist", "Storm Bolter", "Terminator Armour", "", ""); diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 40611d6ff2..f35bb49189 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -943,16 +943,18 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return new_name; }; + gear1 = ""; static gear = function(raw = false) { - var wep = obj_ini.gear[company][marine_number]; + var wep = gear1; if (is_string(wep) || raw) { return wep; } return obj_ini.artifact[wep]; }; + wep1 = ""; static weapon_one = function(raw = false) { - var wep = obj_ini.wep1[company][marine_number]; + var wep = wep1; if (is_string(wep) || raw) { return wep; } diff --git a/scripts/scr_restart_variables/scr_restart_variables.gml b/scripts/scr_restart_variables/scr_restart_variables.gml index b214d2b847..e69de29bb2 100644 --- a/scripts/scr_restart_variables/scr_restart_variables.gml +++ b/scripts/scr_restart_variables/scr_restart_variables.gml @@ -1,814 +0,0 @@ -// Restarts variables, ensuring loaded saves are properly initialized -function scr_restart_variables(saved_game) { - try { - if (saved_game == 1) { - with (obj_ini) { - // show_message(instance_number(obj_restart_vars)); - - obj_restart_vars.restart_name = obj_creation.chapter_name; - obj_restart_vars.restart_founding = global.founding; - - obj_restart_vars.restart_secret = global.founding_secret; - obj_restart_vars.restart_title[0] = ""; - - for (var i = 1; i < array_length(obj_restart_vars.restart_title); i++) { - obj_restart_vars.restart_title[i] = obj_ini.company_title[i]; - } - - obj_restart_vars.restart_icon = global.chapter_icon.name; - obj_restart_vars.restart_powers = psy_powers; - - for (var ad = 0; ad < 5; ad++) { - if (ad == 0) { - obj_restart_vars.restart_adv[ad] = ""; - obj_restart_vars.restart_dis[ad] = ""; - } - if (ad > 0) { - obj_restart_vars.restart_adv[ad] = adv[ad]; - obj_restart_vars.restart_dis[ad] = dis[ad]; - } - } - // show_message("A: "+string(obj_restart_vars.restart_dis[1])); - - obj_restart_vars.restart_recruiting_type = recruiting_type; - obj_restart_vars.restart_trial = 0; - obj_restart_vars.restart_recruiting_name = recruiting_name; - obj_restart_vars.restart_home_type = home_type; - obj_restart_vars.restart_home_name = home_name; - obj_restart_vars.restart_fleet_type = fleet_type; - obj_restart_vars.restart_flagship_name = obj_creation.flagship_name; - - obj_restart_vars.restart_recruiting_exists = obj_creation.recruiting_exists; - obj_restart_vars.restart_homeworld_exists = obj_creation.homeworld_exists; - obj_restart_vars.restart_homeworld_rule = obj_creation.homeworld_rule; - - obj_restart_vars.restart_battle_cry = obj_creation.battle_cry; - - obj_restart_vars.restart_main_color = obj_creation.main_color; - obj_restart_vars.restart_secondary_color = obj_creation.secondary_color; - obj_restart_vars.restart_trim_color = obj_creation.main_trim; - obj_restart_vars.restart_pauldron2_color = obj_creation.left_pauldron; - obj_restart_vars.restart_pauldron_color = obj_creation.right_pauldron; - obj_restart_vars.restart_lens_color = obj_creation.lens_color; - obj_restart_vars.restart_weapon_color = obj_creation.weapon_color; - obj_restart_vars.restart_col_special = obj_creation.col_special; - obj_restart_vars.restart_trim = obj_creation.trim; - obj_restart_vars.restart_skin_color = obj_creation.skin_color; - - obj_restart_vars.restart_hapothecary = obj_creation.hapothecary; - obj_restart_vars.restart_hchaplain = obj_creation.hchaplain; - obj_restart_vars.restart_clibrarian = obj_creation.clibrarian; - obj_restart_vars.restart_fmaster = obj_creation.fmaster; - obj_restart_vars.restart_recruiter = obj_creation.recruiter; - obj_restart_vars.restart_admiral = obj_creation.admiral; - - obj_restart_vars.restart_squad_distribution = obj_creation.squad_distribution; - obj_restart_vars.restart_load_to_ships = obj_creation.load_to_ships; - obj_restart_vars.restart_successors = obj_creation.successors; - - obj_restart_vars.restart_mutations = obj_creation.mutations; - obj_restart_vars.restart_preomnor = obj_creation.preomnor; - obj_restart_vars.restart_voice = obj_creation.voice; - obj_restart_vars.restart_doomed = obj_creation.doomed; - obj_restart_vars.restart_lyman = obj_creation.lyman; - obj_restart_vars.restart_omophagea = obj_creation.omophagea; - obj_restart_vars.restart_ossmodula = obj_creation.ossmodula; - obj_restart_vars.restart_membrane = obj_creation.membrane; - obj_restart_vars.restart_zygote = obj_creation.zygote; - obj_restart_vars.restart_betchers = obj_creation.betchers; - obj_restart_vars.restart_catalepsean = obj_creation.catalepsean; - obj_restart_vars.restart_secretions = obj_creation.secretions; - obj_restart_vars.restart_occulobe = obj_creation.occulobe; - obj_restart_vars.restart_mucranoid = obj_creation.mucranoid; - - obj_restart_vars.restart_master_name = obj_creation.chapter_master_name; - obj_restart_vars.restart_master_melee = obj_creation.chapter_master_melee; - obj_restart_vars.restart_master_ranged = obj_creation.chapter_master_ranged; - obj_restart_vars.restart_master_specialty = obj_creation.chapter_master_specialty; - - obj_restart_vars.restart_strength = obj_creation.strength; - obj_restart_vars.restart_cooperation = obj_creation.cooperation; - obj_restart_vars.restart_purity = obj_creation.purity; - obj_restart_vars.restart_stability = obj_creation.stability; - - // 100 is defaults, 101 is the allowable starting equipment - for (var i = 100; i < 103; i++) { - obj_restart_vars.r_race[i][2] = 1; - obj_restart_vars.r_role[i][2] = "Honour Guard"; - obj_restart_vars.r_wep1[i][2] = "Power Sword"; - obj_restart_vars.r_wep2[i][2] = "Bolter"; - obj_restart_vars.r_armour[i][2] = "Artificer Armour"; - obj_restart_vars.r_mobi[i][2] = ""; - obj_restart_vars.r_gear[i][2] = ""; - - obj_restart_vars.r_race[i][3] = 1; - obj_restart_vars.r_role[i][3] = "Veteran"; - obj_restart_vars.r_wep1[i][3] = "Chainsword"; - obj_restart_vars.r_wep2[i][3] = "Bolter"; - obj_restart_vars.r_armour[i][3] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_mobi[i][3] = ""; - obj_restart_vars.r_gear[i][3] = ""; - - obj_restart_vars.r_race[i][4] = 1; - obj_restart_vars.r_role[i][4] = "Terminator"; - obj_restart_vars.r_wep1[i][4] = "Power Fist"; - obj_restart_vars.r_wep2[i][4] = "Storm Bolter"; - obj_restart_vars.r_armour[i][4] = "Terminator Armour"; - obj_restart_vars.r_mobi[i][4] = ""; - obj_restart_vars.r_gear[i][4] = ""; - - obj_restart_vars.r_race[i][5] = 1; - obj_restart_vars.r_role[i][5] = "Captain"; - obj_restart_vars.r_wep1[i][5] = "Power Sword"; - obj_restart_vars.r_wep2[i][5] = "Bolt Pistol"; - obj_restart_vars.r_armour[i][5] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_mobi[i][5] = ""; - obj_restart_vars.r_gear[i][5] = "Iron Halo"; - - obj_restart_vars.r_race[i][6] = 1; - obj_restart_vars.r_role[i][6] = "Dreadnought"; - obj_restart_vars.r_wep1[i][6] = "Close Combat Weapon"; - obj_restart_vars.r_wep2[i][6] = "Twin Linked Lascannon"; - obj_restart_vars.r_armour[i][6] = "Dreadnought"; - obj_restart_vars.r_mobi[i][6] = ""; - obj_restart_vars.r_gear[i][6] = ""; - - obj_restart_vars.r_race[i][7] = 1; - obj_restart_vars.r_role[i][7] = "Champion"; - obj_restart_vars.r_wep1[i][7] = "Power Sword"; - obj_restart_vars.r_wep2[i][7] = "Bolt Pistol"; - obj_restart_vars.r_armour[i][7] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_mobi[i][7] = ""; - obj_restart_vars.r_gear[i][7] = "Combat Shield"; - - obj_restart_vars.r_race[i][8] = 1; - obj_restart_vars.r_role[i][8] = "Tactical Marine"; - obj_restart_vars.r_wep1[i][8] = "Bolter"; - obj_restart_vars.r_wep2[i][8] = "Combat Knife"; - obj_restart_vars.r_armour[i][8] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_mobi[i][8] = ""; - obj_restart_vars.r_gear[i][8] = ""; - - obj_restart_vars.r_race[i][9] = 1; - obj_restart_vars.r_role[i][9] = "Devastator Marine"; - obj_restart_vars.r_wep1[i][9] = ""; - obj_restart_vars.r_wep2[i][9] = "Combat Knife"; - obj_restart_vars.r_armour[i][9] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_mobi[i][9] = ""; - obj_restart_vars.r_gear[i][9] = ""; - - obj_restart_vars.r_race[i][10] = 1; - obj_restart_vars.r_role[i][10] = "Assault Marine"; - obj_restart_vars.r_wep1[i][10] = "Chainsword"; - obj_restart_vars.r_wep2[i][10] = "Bolt Pistol"; - obj_restart_vars.r_armour[i][10] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_mobi[i][10] = "Jump Pack"; - obj_restart_vars.r_gear[i][10] = ""; - - obj_restart_vars.r_role[i][11] = "Ancient"; - obj_restart_vars.r_wep1[i][11] = "Company Standard"; - obj_restart_vars.r_wep2[i][11] = "Power Sword"; - obj_restart_vars.r_armour[i][11] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_mobi[i][11] = ""; - obj_restart_vars.r_gear[i][11] = ""; - - obj_restart_vars.r_race[i][12] = 1; - obj_restart_vars.r_role[i][12] = "Scout"; - obj_restart_vars.r_wep1[i][12] = "Sniper Rifle"; - obj_restart_vars.r_wep2[i][12] = "Combat Knife"; - obj_restart_vars.r_armour[i][12] = "Scout Armour"; - obj_restart_vars.r_mobi[i][12] = ""; - obj_restart_vars.r_gear[i][12] = ""; - - obj_restart_vars.r_race[i][14] = 1; - obj_restart_vars.r_role[i][14] = "Chaplain"; - obj_restart_vars.r_wep1[i][14] = "Power Sword"; - obj_restart_vars.r_wep2[i][14] = "Bolt Pistol"; - obj_restart_vars.r_armour[i][14] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_gear[i][14] = "Rosarius"; - obj_restart_vars.r_mobi[i][14] = ""; - - obj_restart_vars.r_race[i][15] = 1; - obj_restart_vars.r_role[i][15] = "Apothecary"; - obj_restart_vars.r_wep1[i][15] = "Chainsword"; - obj_restart_vars.r_wep2[i][15] = "Bolt Pistol"; - obj_restart_vars.r_armour[i][15] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_gear[i][15] = "Narthecium"; - obj_restart_vars.r_mobi[i][15] = ""; - - obj_restart_vars.r_race[i][16] = 1; - obj_restart_vars.r_role[i][16] = "Techmarine"; - obj_restart_vars.r_wep1[i][16] = "Power Axe"; - obj_restart_vars.r_wep2[i][16] = "Storm Bolter"; - obj_restart_vars.r_armour[i][16] = "Artificer Armour"; - obj_restart_vars.r_gear[i][16] = ""; - obj_restart_vars.r_mobi[i][16] = "Servo-arm"; - - obj_restart_vars.r_race[i][17] = 1; - obj_restart_vars.r_role[i][17] = "Librarian"; - obj_restart_vars.r_wep1[i][17] = "Force Staff"; - obj_restart_vars.r_wep2[i][17] = "Bolt Pistol"; - obj_restart_vars.r_armour[i][17] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_gear[i][17] = "Psychic Hood"; - obj_restart_vars.r_mobi[i][17] = ""; - - obj_restart_vars.r_race[i][18] = 1; - obj_restart_vars.r_role[i][18] = "Sergeant"; - obj_restart_vars.r_wep1[i][18] = "Chainsword"; - obj_restart_vars.r_wep2[i][18] = "Storm Bolter"; - obj_restart_vars.r_armour[i][18] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_gear[i][18] = ""; - obj_restart_vars.r_mobi[i][18] = ""; - - obj_restart_vars.r_race[i][19] = 1; - obj_restart_vars.r_role[i][19] = "Veteran Sergeant"; - obj_restart_vars.r_wep1[i][19] = "Chainsword"; - obj_restart_vars.r_wep2[i][19] = "Storm Bolter"; - obj_restart_vars.r_armour[i][19] = STR_ANY_POWER_ARMOUR; - obj_restart_vars.r_gear[i][19] = ""; - obj_restart_vars.r_mobi[i][19] = ""; - } - - for (var i = 0; i < 21; i++) { - obj_restart_vars.r_race[100][i] = race[100][i]; - obj_restart_vars.r_role[100][i] = role[100][i]; - obj_restart_vars.r_wep1[100][i] = wep1[100][i]; - obj_restart_vars.r_wep2[100][i] = wep2[100][i]; - obj_restart_vars.r_armour[100][i] = armour[100][i]; - obj_restart_vars.r_gear[100][i] = gear[100][i]; - obj_restart_vars.r_mobi[100][i] = mobi[100][i]; - } - } - } - - if (saved_game == 2) { - obj_controller.restart_name = obj_restart_vars.restart_name; - obj_controller.restart_founding = obj_restart_vars.restart_founding; - - obj_controller.restart_secret = obj_restart_vars.restart_secret; - obj_controller.restart_title[0] = ""; - - for (var i = 1; i < array_length(obj_restart_vars.restart_title); i++) { - obj_controller.restart_title[i] = obj_restart_vars.restart_title[i]; - } - - obj_controller.restart_icon = obj_restart_vars.restart_icon; - obj_controller.restart_powers = obj_restart_vars.restart_powers; - - for (var ad = 0; ad < 5; ad++) { - if (ad == 0) { - obj_controller.restart_adv[ad] = ""; - obj_controller.restart_dis[ad] = ""; - } - if (ad > 0) { - obj_controller.restart_adv[ad] = obj_restart_vars.restart_adv[ad]; - obj_controller.restart_dis[ad] = obj_restart_vars.restart_dis[ad]; - } - } - // show_message("B: "+string(obj_controller.restart_dis[1])); - - obj_controller.restart_recruiting_type = obj_restart_vars.restart_recruiting_type; - obj_controller.restart_trial = obj_restart_vars.restart_trial; - obj_controller.restart_recruiting_name = obj_restart_vars.restart_recruiting_name; - obj_controller.restart_home_type = obj_restart_vars.restart_home_type; - obj_controller.restart_home_name = obj_restart_vars.restart_home_name; - obj_controller.restart_fleet_type = obj_restart_vars.restart_fleet_type; - obj_controller.restart_flagship_name = obj_restart_vars.restart_flagship_name; - - obj_controller.restart_recruiting_exists = obj_restart_vars.restart_recruiting_exists; - obj_controller.restart_homeworld_exists = obj_restart_vars.restart_homeworld_exists; - obj_controller.restart_homeworld_rule = obj_restart_vars.restart_homeworld_rule; - - obj_controller.restart_battle_cry = obj_restart_vars.restart_battle_cry; - - obj_controller.restart_main_color = obj_restart_vars.restart_main_color; - obj_controller.restart_secondary_color = obj_restart_vars.restart_secondary_color; - obj_controller.restart_trim_color = obj_restart_vars.restart_trim_color; - obj_controller.restart_pauldron2_color = obj_restart_vars.restart_pauldron2_color; - obj_controller.restart_pauldron_color = obj_restart_vars.restart_pauldron_color; - obj_controller.restart_lens_color = obj_restart_vars.restart_lens_color; - obj_controller.restart_weapon_color = obj_restart_vars.restart_weapon_color; - obj_controller.restart_col_special = obj_restart_vars.restart_col_special; - obj_controller.restart_trim = obj_restart_vars.restart_trim; - obj_controller.restart_skin_color = obj_restart_vars.restart_skin_color; - - obj_controller.restart_hapothecary = obj_restart_vars.restart_hapothecary; - obj_controller.restart_hchaplain = obj_restart_vars.restart_hchaplain; - obj_controller.restart_clibrarian = obj_restart_vars.restart_clibrarian; - obj_controller.restart_fmaster = obj_restart_vars.restart_fmaster; - obj_controller.restart_recruiter = obj_restart_vars.restart_recruiter; - obj_controller.restart_admiral = obj_restart_vars.restart_admiral; - - if (struct_exists(obj_restart_vars, "restart_squad_distribution")) { - obj_controller.restart_squad_distribution = obj_restart_vars.restart_squad_distribution; - } else if (struct_exists(obj_restart_vars, "restart_equal_specialists")) { - // migrate old saves - obj_controller.restart_squad_distribution = obj_restart_vars.restart_equal_specialists; - } else { - obj_controller.restart_squad_distribution = 0; - } - obj_controller.restart_load_to_ships = obj_restart_vars.restart_load_to_ships; - obj_controller.restart_successors = obj_restart_vars.restart_successors; - - obj_controller.restart_mutations = obj_restart_vars.restart_mutations; - obj_controller.restart_preomnor = obj_restart_vars.restart_preomnor; - obj_controller.restart_voice = obj_restart_vars.restart_voice; - obj_controller.restart_doomed = obj_restart_vars.restart_doomed; - obj_controller.restart_lyman = obj_restart_vars.restart_lyman; - obj_controller.restart_omophagea = obj_restart_vars.restart_omophagea; - obj_controller.restart_ossmodula = obj_restart_vars.restart_ossmodula; - obj_controller.restart_membrane = obj_restart_vars.restart_membrane; - obj_controller.restart_zygote = obj_restart_vars.restart_zygote; - obj_controller.restart_betchers = obj_restart_vars.restart_betchers; - obj_controller.restart_catalepsean = obj_restart_vars.restart_catalepsean; - obj_controller.restart_secretions = obj_restart_vars.restart_secretions; - obj_controller.restart_occulobe = obj_restart_vars.restart_occulobe; - obj_controller.restart_mucranoid = obj_restart_vars.restart_mucranoid; - - obj_controller.restart_master_name = obj_restart_vars.restart_master_name; - obj_controller.restart_master_melee = obj_restart_vars.restart_master_melee; - obj_controller.restart_master_ranged = obj_restart_vars.restart_master_ranged; - obj_controller.restart_master_specialty = obj_restart_vars.restart_master_specialty; - - obj_controller.restart_strength = obj_restart_vars.restart_strength; - obj_controller.restart_cooperation = obj_restart_vars.restart_cooperation; - obj_controller.restart_purity = obj_restart_vars.restart_purity; - obj_controller.restart_stability = obj_restart_vars.restart_stability; - - // 100 is defaults, 101 is the allowable starting equipment - for (var i = 100; i < 103; i++) { - obj_controller.r_race[i][2] = 1; - obj_controller.r_role[i][2] = "Honour Guard"; - obj_controller.r_wep1[i][2] = "Power Sword"; - obj_controller.r_wep2[i][2] = "Bolter"; - obj_controller.r_armour[i][2] = "Artificer Armour"; - obj_controller.r_mobi[i][2] = ""; - obj_controller.r_gear[i][2] = ""; - - obj_controller.r_race[i][3] = 1; - obj_controller.r_role[i][3] = "Veteran"; - obj_controller.r_wep1[i][3] = "Chainsword"; - obj_controller.r_wep2[i][3] = "Bolter"; - obj_controller.r_armour[i][3] = STR_ANY_POWER_ARMOUR; - obj_controller.r_mobi[i][3] = ""; - obj_controller.r_gear[i][3] = ""; - - obj_controller.r_race[i][4] = 1; - obj_controller.r_role[i][4] = "Terminator"; - obj_controller.r_wep1[i][4] = "Power Fist"; - obj_controller.r_wep2[i][4] = "Storm Bolter"; - obj_controller.r_armour[i][4] = "Terminator Armour"; - obj_controller.r_mobi[i][4] = ""; - obj_controller.r_gear[i][4] = ""; - - obj_controller.r_race[i][5] = 1; - obj_controller.r_role[i][5] = "Captain"; - obj_controller.r_wep1[i][5] = "Power Sword"; - obj_controller.r_wep2[i][5] = "Bolt Pistol"; - obj_controller.r_armour[i][5] = STR_ANY_POWER_ARMOUR; - obj_controller.r_mobi[i][5] = ""; - obj_controller.r_gear[i][5] = ""; - - obj_controller.r_race[i][6] = 1; - obj_controller.r_role[i][6] = "Dreadnought"; - obj_controller.r_wep1[i][6] = "Close Combat Weapon"; - obj_controller.r_wep2[i][6] = "Twin Linked Lascannon"; - obj_controller.r_armour[i][6] = "Dreadnought"; - obj_controller.r_mobi[i][6] = ""; - obj_controller.r_gear[i][6] = ""; - - obj_controller.r_race[i][7] = 1; - obj_controller.r_role[i][7] = "Champion"; - obj_controller.r_wep1[i][7] = "Power Sword"; - obj_controller.r_wep2[i][7] = "Bolt Pistol"; - obj_controller.r_armour[i][7] = STR_ANY_POWER_ARMOUR; - obj_controller.r_mobi[i][7] = ""; - obj_controller.r_gear[i][7] = "Combat Shield"; - - obj_controller.r_race[i][8] = 1; - obj_controller.r_role[i][8] = "Tactical Marine"; - obj_controller.r_wep1[i][8] = "Bolter"; - obj_controller.r_wep2[i][8] = "Combat Knife"; - obj_controller.r_armour[i][8] = STR_ANY_POWER_ARMOUR; - obj_controller.r_mobi[i][8] = ""; - obj_controller.r_gear[i][8] = ""; - - obj_controller.r_race[i][9] = 1; - obj_controller.r_role[i][9] = "Devastator Marine"; - obj_controller.r_wep1[i][9] = ""; - obj_controller.r_wep2[i][9] = "Combat Knife"; - obj_controller.r_armour[i][9] = STR_ANY_POWER_ARMOUR; - obj_controller.r_mobi[i][9] = ""; - obj_controller.r_gear[i][9] = ""; - - obj_controller.r_race[i][10] = 1; - obj_controller.r_role[i][10] = "Assault Marine"; - obj_controller.r_wep1[i][10] = "Chainsword"; - obj_controller.r_wep2[i][10] = "Bolt Pistol"; - obj_controller.r_armour[i][10] = STR_ANY_POWER_ARMOUR; - obj_controller.r_mobi[i][10] = "Jump Pack"; - obj_controller.r_gear[i][10] = ""; - - obj_controller.r_race[i][12] = 1; - obj_controller.r_role[i][12] = "Scout"; - obj_controller.r_wep1[i][12] = "Sniper Rifle"; - obj_controller.r_wep2[i][12] = "Combat Knife"; - obj_controller.r_armour[i][12] = "Scout Armour"; - obj_controller.r_mobi[i][12] = ""; - obj_controller.r_gear[i][12] = ""; - - obj_controller.r_race[i][14] = 1; - obj_controller.r_role[i][14] = "Chaplain"; - obj_controller.r_wep1[i][14] = "Power Sword"; - obj_controller.r_wep2[i][14] = "Bolt Pistol"; - obj_controller.r_armour[i][14] = STR_ANY_POWER_ARMOUR; - obj_controller.r_gear[i][14] = "Rosarius"; - obj_controller.r_mobi[i][14] = ""; - - obj_controller.r_race[i][15] = 1; - obj_controller.r_role[i][15] = "Apothecary"; - obj_controller.r_wep1[i][15] = "Chainsword"; - obj_controller.r_wep2[i][15] = "Bolt Pistol"; - obj_controller.r_armour[i][15] = STR_ANY_POWER_ARMOUR; - obj_controller.r_gear[i][15] = "Narthecium"; - obj_controller.r_mobi[i][15] = ""; - - obj_controller.r_race[i][16] = 1; - obj_controller.r_role[i][16] = "Techmarine"; - obj_controller.r_wep1[i][16] = "Power Axe"; - obj_controller.r_wep2[i][16] = "Storm Bolter"; - obj_controller.r_armour[i][16] = "Artificer Armour"; - obj_controller.r_gear[i][16] = ""; - obj_controller.r_mobi[i][16] = "Servo-arm"; - - obj_controller.r_race[i][17] = 1; - obj_controller.r_role[i][17] = "Librarian"; - obj_controller.r_wep1[i][17] = "Force Staff"; - obj_controller.r_wep2[i][17] = "Bolt Pistol"; - obj_controller.r_armour[i][17] = STR_ANY_POWER_ARMOUR; - obj_controller.r_gear[i][17] = "Psychic Hood"; - obj_controller.r_mobi[i][17] = ""; - - obj_controller.r_race[i][18] = 1; - obj_controller.r_role[i][18] = "Sergeant"; - obj_controller.r_wep1[i][18] = "Chainsword"; - obj_controller.r_wep2[i][18] = "Storm Bolter"; - obj_controller.r_armour[i][18] = STR_ANY_POWER_ARMOUR; - obj_controller.r_gear[i][18] = ""; - obj_controller.r_mobi[i][18] = ""; - - obj_controller.r_race[i][19] = 1; - obj_controller.r_role[i][19] = "Veteran Sergeant"; - obj_controller.r_wep1[i][19] = "Chainsword"; - obj_controller.r_wep2[i][19] = "Storm Bolter"; - obj_controller.r_armour[i][19] = STR_ANY_POWER_ARMOUR; - obj_controller.r_gear[i][19] = ""; - obj_controller.r_mobi[i][19] = ""; - } - - for (var i = 0; i < 21; i++) { - obj_controller.r_race[100][i] = obj_restart_vars.r_race[100][i]; - obj_controller.r_race[101][i] = obj_restart_vars.r_race[100][i]; - obj_controller.r_race[102][i] = obj_restart_vars.r_race[100][i]; - - obj_controller.r_role[100][i] = obj_restart_vars.r_role[100][i]; - obj_controller.r_wep1[100][i] = obj_restart_vars.r_wep1[100][i]; - obj_controller.r_wep2[100][i] = obj_restart_vars.r_wep2[100][i]; - obj_controller.r_armour[100][i] = obj_restart_vars.r_armour[100][i]; - obj_controller.r_gear[100][i] = obj_restart_vars.r_gear[100][i]; - obj_controller.r_mobi[100][i] = obj_restart_vars.r_mobi[100][i]; - } - } - - // Controller to restart vars - if (saved_game == 3) { - obj_restart_vars.restart_name = obj_controller.restart_name; - obj_restart_vars.restart_founding = obj_controller.restart_founding; - - obj_restart_vars.restart_secret = obj_controller.restart_secret; - obj_restart_vars.restart_title[0] = obj_controller.restart_title[0]; - - for (var i = 1; i < array_length(obj_restart_vars.restart_title); i++) { - obj_restart_vars.restart_title[i] = obj_controller.restart_title[i]; - } - - obj_restart_vars.restart_icon = obj_controller.restart_icon; - obj_restart_vars.restart_powers = obj_controller.restart_powers; - - for (var ad = 0; ad < 5; ad++) { - if (ad == 0) { - obj_restart_vars.restart_adv[ad] = ""; - obj_restart_vars.restart_dis[ad] = ""; - } - if (ad > 0) { - obj_restart_vars.restart_adv[ad] = obj_controller.restart_adv[ad]; - obj_restart_vars.restart_dis[ad] = obj_controller.restart_dis[ad]; - } - } - - // show_message("C: "+string(obj_restart_vars.restart_dis[1])); - - obj_restart_vars.restart_recruiting_type = obj_controller.restart_recruiting_type; - obj_restart_vars.restart_trial = obj_controller.restart_trial; - obj_restart_vars.restart_recruiting_name = obj_controller.restart_recruiting_name; - obj_restart_vars.restart_home_type = obj_controller.restart_home_type; // Good here - obj_restart_vars.restart_home_name = obj_controller.restart_home_name; - obj_restart_vars.restart_fleet_type = obj_controller.restart_fleet_type; - obj_restart_vars.restart_flagship_name = obj_controller.restart_flagship_name; - - obj_restart_vars.restart_recruiting_exists = obj_controller.restart_recruiting_exists; - obj_restart_vars.restart_homeworld_exists = obj_controller.restart_homeworld_exists; - obj_restart_vars.restart_homeworld_rule = obj_controller.restart_homeworld_rule; - - obj_restart_vars.restart_battle_cry = obj_controller.restart_battle_cry; - - obj_restart_vars.restart_main_color = obj_controller.restart_main_color; - obj_restart_vars.restart_secondary_color = obj_controller.restart_secondary_color; - obj_restart_vars.restart_trim_color = obj_controller.restart_trim_color; - obj_restart_vars.restart_pauldron2_color = obj_controller.restart_pauldron2_color; - obj_restart_vars.restart_pauldron_color = obj_controller.restart_pauldron_color; - obj_restart_vars.restart_lens_color = obj_controller.restart_lens_color; - obj_restart_vars.restart_weapon_color = obj_controller.restart_weapon_color; - obj_restart_vars.restart_col_special = obj_controller.restart_col_special; - obj_restart_vars.restart_trim = obj_controller.restart_trim; - obj_restart_vars.restart_skin_color = obj_controller.restart_skin_color; - - obj_restart_vars.restart_hapothecary = obj_controller.restart_hapothecary; - obj_restart_vars.restart_hchaplain = obj_controller.restart_hchaplain; - obj_restart_vars.restart_clibrarian = obj_controller.restart_clibrarian; - obj_restart_vars.restart_fmaster = obj_controller.restart_fmaster; - obj_restart_vars.restart_recruiter = obj_controller.restart_recruiter; - obj_restart_vars.restart_admiral = obj_controller.restart_admiral; - - obj_restart_vars.restart_squad_distribution = obj_controller.restart_squad_distribution; - obj_restart_vars.restart_load_to_ships = obj_controller.restart_load_to_ships; - obj_restart_vars.restart_successors = obj_controller.restart_successors; - - obj_restart_vars.restart_mutations = obj_controller.restart_mutations; - obj_restart_vars.restart_preomnor = obj_controller.restart_preomnor; - obj_restart_vars.restart_voice = obj_controller.restart_voice; - obj_restart_vars.restart_doomed = obj_controller.restart_doomed; - obj_restart_vars.restart_lyman = obj_controller.restart_lyman; - obj_restart_vars.restart_omophagea = obj_controller.restart_omophagea; - obj_restart_vars.restart_ossmodula = obj_controller.restart_ossmodula; - obj_restart_vars.restart_membrane = obj_controller.restart_membrane; - obj_restart_vars.restart_zygote = obj_controller.restart_zygote; - obj_restart_vars.restart_betchers = obj_controller.restart_betchers; - obj_restart_vars.restart_catalepsean = obj_controller.restart_catalepsean; - obj_restart_vars.restart_secretions = obj_controller.restart_secretions; - obj_restart_vars.restart_occulobe = obj_controller.restart_occulobe; - obj_restart_vars.restart_mucranoid = obj_controller.restart_mucranoid; - - obj_restart_vars.restart_master_name = obj_controller.restart_master_name; - obj_restart_vars.restart_master_melee = obj_controller.restart_master_melee; - obj_restart_vars.restart_master_ranged = obj_controller.restart_master_ranged; - obj_restart_vars.restart_master_specialty = obj_controller.restart_master_specialty; - - obj_restart_vars.restart_strength = obj_controller.restart_strength; - obj_restart_vars.restart_cooperation = obj_controller.restart_cooperation; - obj_restart_vars.restart_purity = obj_controller.restart_purity; - obj_restart_vars.restart_stability = obj_controller.restart_stability; - - for (var i = 0; i < 21; i++) { - obj_restart_vars.r_race[100][i] = obj_controller.r_race[100][i]; - obj_restart_vars.r_race[101][i] = obj_controller.r_race[100][i]; - obj_restart_vars.r_race[102][i] = obj_controller.r_race[100][i]; - - obj_restart_vars.r_role[100][i] = obj_controller.r_role[100][i]; - obj_restart_vars.r_wep1[100][i] = obj_controller.r_wep1[100][i]; - obj_restart_vars.r_wep2[100][i] = obj_controller.r_wep2[100][i]; - obj_restart_vars.r_armour[100][i] = obj_controller.r_armour[100][i]; - obj_restart_vars.r_gear[100][i] = obj_controller.r_gear[100][i]; - obj_restart_vars.r_mobi[100][i] = obj_controller.r_mobi[100][i]; - } - } - - if (saved_game == 4) {} - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } -} - -/// @self Asset.GMObject.obj_creation -function reset_creation_variables() { - points = 100; - maxpoints = 100; - custom = eCHAPTER_TYPE.PREMADE; - - hapothecary = global.name_generator.GenerateFromSet("space_marine"); - hchaplain = global.name_generator.GenerateFromSet("space_marine"); - clibrarian = global.name_generator.GenerateFromSet("space_marine"); - fmaster = global.name_generator.GenerateFromSet("space_marine"); - recruiter = global.name_generator.GenerateFromSet("space_marine"); - admiral = global.name_generator.GenerateFromSet("space_marine"); - - // First is for the correct slot, second is for default info - for (var i = 100; i < 103; i++) { - race[i][2] = 1; - role[i][2] = "Honour Guard"; - wep1[i][2] = "Power Sword"; - wep2[i][2] = "Bolter"; - armour[i][2] = "Artificer Armour"; - - race[i][3] = 1; - role[i][3] = "Veteran"; - wep1[i][3] = "Chainsword"; - wep2[i][3] = "Bolter"; - armour[i][3] = STR_ANY_POWER_ARMOUR; - - race[i][4] = 1; - role[i][4] = "Terminator"; - wep1[i][4] = "Power Fist"; - wep2[i][4] = "Storm Bolter"; - armour[i][4] = "Terminator Armour"; - - race[i][5] = 1; - role[i][5] = "Captain"; - wep1[i][5] = "Power Sword"; - wep2[i][5] = "Bolt Pistol"; - armour[i][5] = STR_ANY_POWER_ARMOUR; - gear[i][5] = "Iron Halo"; - - race[i][6] = 1; - role[i][6] = "Dreadnought"; - wep1[i][6] = "Close Combat Weapon"; - wep2[i][6] = "Twin Linked Lascannon"; - armour[i][6] = "Dreadnought"; - - race[i][8] = 1; - role[i][8] = "Tactical Marine"; - wep1[i][8] = "Bolter"; - wep2[i][8] = "Combat Knife"; - armour[i][8] = STR_ANY_POWER_ARMOUR; - - race[i][9] = 1; - role[i][9] = "Devastator Marine"; - wep1[i][9] = ""; - wep2[i][9] = "Combat Knife"; - armour[i][9] = STR_ANY_POWER_ARMOUR; - - race[i][10] = 1; - role[i][10] = "Assault Marine"; - wep1[i][10] = "Chainsword"; - wep2[i][10] = "Bolt Pistol"; - armour[i][10] = STR_ANY_POWER_ARMOUR; - mobi[i][10] = "Jump Pack"; - - race[i][11] = 1; - role[i][11] = "Ancient"; - wep1[i][11] = "Company Standard"; - wep2[i][11] = "Power Sword"; - armour[i][11] = STR_ANY_POWER_ARMOUR; - - race[i][12] = 1; - role[i][12] = "Scout"; - wep1[i][12] = "Sniper Rifle"; - wep2[i][12] = "Combat Knife"; - armour[i][12] = "Scout Armour"; - - race[i][14] = 1; - role[i][14] = "Chaplain"; - wep1[i][14] = "Power Sword"; - wep2[i][14] = "Bolt Pistol"; - armour[i][14] = STR_ANY_POWER_ARMOUR; - gear[i][14] = "Rosarius"; - - race[i][15] = 1; - role[i][15] = "Apothecary"; - wep1[i][15] = "Chainsword"; - wep2[i][15] = "Bolt Pistol"; - armour[i][15] = STR_ANY_POWER_ARMOUR; - gear[i][15] = "Narthecium"; - - race[i][16] = 1; - role[i][16] = "Techmarine"; - wep1[i][16] = "Power Axe"; - wep2[i][16] = "Storm Bolter"; - armour[i][16] = "Artificer Armour"; - gear[i][16] = ""; - mobi[i][16] = "Servo-arm"; - - race[i][17] = 1; - role[i][17] = "Librarian"; - wep1[i][17] = "Force Staff"; - wep2[i][17] = "Bolt Pistol"; - armour[i][17] = STR_ANY_POWER_ARMOUR; - gear[i][17] = "Psychic Hood"; - - race[i][18] = 1; - role[i][18] = "Sergeant"; - wep1[i][18] = "Chainsword"; - wep2[i][18] = "Storm Bolter"; - armour[i][18] = STR_ANY_POWER_ARMOUR; - gear[i][18] = ""; - - race[i][19] = 1; - role[i][19] = "Veteran Sergeant"; - wep1[i][19] = "Chainsword"; - wep2[i][19] = "Storm Bolter"; - armour[i][19] = STR_ANY_POWER_ARMOUR; - gear[i][19] = ""; - } - - points = 100; - selected_chapter = 999; - chapter = obj_restart_vars.restart_name; - founding = obj_restart_vars.restart_founding; - founding_secret = obj_restart_vars.restart_secret; - - company_title[0] = ""; - - for (var i = 1; i <= 11; i++) { - company_title[i] = obj_restart_vars.restart_title[i]; - } - - global.chapter_icon.name = obj_restart_vars.restart_icon; - discipline = obj_restart_vars.restart_powers; - - // show_message("D: "+string(dis[1])); - - // Need disposition here - - recruiting = obj_restart_vars.restart_recruiting_type; - aspirant_trial = obj_restart_vars.restart_trial; - recruiting_name = obj_restart_vars.restart_recruiting_name; - homeworld = obj_restart_vars.restart_home_type; - homeworld_name = obj_restart_vars.restart_home_name; - fleet_type = obj_restart_vars.restart_fleet_type; - flagship_name = obj_restart_vars.restart_flagship_name; - - recruiting_exists = obj_restart_vars.restart_recruiting_exists; - homeworld_exists = obj_restart_vars.restart_homeworld_exists; - homeworld_rule = obj_restart_vars.restart_homeworld_rule; - - battle_cry = obj_restart_vars.restart_battle_cry; - - main_color = obj_restart_vars.restart_main_color; - secondary_color = obj_restart_vars.restart_secondary_color; - main_trim = obj_restart_vars.restart_trim_color; - left_pauldron = obj_restart_vars.restart_pauldron2_color; - right_pauldron = obj_restart_vars.restart_pauldron_color; - lens_color = obj_restart_vars.restart_lens_color; - weapon_color = obj_restart_vars.restart_weapon_color; - col_special = obj_restart_vars.restart_col_special; - trim = obj_restart_vars.restart_trim; - skin_color = obj_restart_vars.restart_skin_color; - - hapothecary = obj_restart_vars.restart_hapothecary; - hchaplain = obj_restart_vars.restart_hchaplain; - clibrarian = obj_restart_vars.restart_clibrarian; - fmaster = obj_restart_vars.restart_fmaster; - recruiter = obj_restart_vars.restart_recruiter; - admiral = obj_restart_vars.restart_admiral; - - if (struct_exists(obj_restart_vars, "restart_squad_distribution")) { - squad_distribution = obj_restart_vars.restart_squad_distribution; - } else if (struct_exists(obj_restart_vars, "restart_equal_specialists")) { - // migrate old saves - squad_distribution = obj_restart_vars.restart_equal_specialists; - } else { - squad_distribution = 0; - } - load_to_ships = obj_restart_vars.restart_load_to_ships; - successors = obj_restart_vars.restart_successors; - - mutations = obj_restart_vars.restart_mutations; - preomnor = obj_restart_vars.restart_preomnor; - voice = obj_restart_vars.restart_voice; - doomed = obj_restart_vars.restart_doomed; - lyman = obj_restart_vars.restart_lyman; - omophagea = obj_restart_vars.restart_omophagea; - ossmodula = obj_restart_vars.restart_ossmodula; - membrane = obj_restart_vars.restart_membrane; - zygote = obj_restart_vars.restart_zygote; - betchers = obj_restart_vars.restart_betchers; - catalepsean = obj_restart_vars.restart_catalepsean; - secretions = obj_restart_vars.restart_secretions; - occulobe = obj_restart_vars.restart_occulobe; - mucranoid = obj_restart_vars.restart_mucranoid; - - chapter_master_name = obj_restart_vars.restart_master_name; - chapter_master_melee = obj_restart_vars.restart_master_melee; - chapter_master_ranged = obj_restart_vars.restart_master_ranged; - chapter_master_specialty = obj_restart_vars.restart_master_specialty; - - strength = obj_restart_vars.restart_strength; - cooperation = obj_restart_vars.restart_cooperation; - purity = obj_restart_vars.restart_purity; - stability = obj_restart_vars.restart_stability; - - for (var i = 0; i < 21; i++) { - race[100][i] = obj_restart_vars.r_race[100][i]; - - role[100][i] = obj_restart_vars.r_role[100][i]; - wep1[100][i] = obj_restart_vars.r_wep1[100][i]; - wep2[100][i] = obj_restart_vars.r_wep2[100][i]; - armour[100][i] = obj_restart_vars.r_armour[100][i]; - gear[100][i] = obj_restart_vars.r_gear[100][i]; - mobi[100][i] = obj_restart_vars.r_mobi[100][i]; - } - - custom = eCHAPTER_TYPE.RANDOM; - restarted = 1; - mutations_selected = mutations; -} diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index 1aae33d420..90e8856209 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -1,3 +1,15 @@ +load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { + default_role_data[_role_id] = { + role : _role_name, + wep1 : _wep1, + wep2 : _wep2, + armour : _armour, + mobi : _mobi, + gear : _gear, + race : 1 + }} +}; + /// @self Asset.GMObject.obj_creation function role_setup_objects() { specialist_distribution_box = new ToggleButton({ From ce3843b84e79806ff8a4e3a5c4d92873227d13ac Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 30 Jul 2026 19:55:41 +0100 Subject: [PATCH 16/82] refactor specialist traiining and moving slots --- objects/obj_ini/Create_0.gml | 2 + .../scr_initialize_custom.gml | 52 +-- .../scr_manage_task_selector.gml | 55 +-- .../scr_marine_struct/scr_marine_struct.gml | 22 +- .../scr_move_unit_info/scr_move_unit_info.gml | 6 - .../scr_specialist_training.gml | 429 ++++++++---------- scripts/scr_ui_settings/scr_ui_settings.gml | 11 +- .../scr_unit_equip_functions.gml | 25 +- 8 files changed, 261 insertions(+), 341 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 346623cbc9..35825a8a70 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -16,6 +16,8 @@ commands = 0; heh1 = 0; heh2 = 0; +player_role_data = []; +default_role_data = []; companies = 10; progenitor = ePROGENITOR.NONE; diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index b2ddcb4deb..b1941f14f0 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -828,6 +828,9 @@ function scr_initialize_custom() { occulobe = obj_creation.occulobe; mucranoid = obj_creation.mucranoid; + player_role_data = obj_creation.player_role_data; + default_role_data = obj_creation.default_role_data; + chapter_data = new ChapterGameData(); adv = []; @@ -1593,14 +1596,7 @@ function scr_initialize_custom() { eROLE.VETERANSERGEANT, ], ]; - var possible_custom_attributes = [ - "name", - "wep1", - "wep2", - "mobi", - "gear", - "armour", - ]; + var possible_custom_attributes = global.unit_equip_slots; /** * check whether the json structure exists to populate custom role names and * attributes then set them using the map above @@ -1614,26 +1610,7 @@ function scr_initialize_custom() { var attribute = possible_custom_attributes[a]; if (struct_exists(c_roles[$ c_rolename], attribute)) { var value = c_roles[$ c_rolename][$ attribute]; - switch (attribute) { - case "name": - role[defaults_slot][c_roleid] = value; - break; - case "wep1": - wep1[defaults_slot][c_roleid] = value; - break; - case "wep2": - wep2[defaults_slot][c_roleid] = value; - break; - case "armour": - armour[defaults_slot][c_roleid] = value; - break; - case "gear": - gear[defaults_slot][c_roleid] = value; - break; - case "mobi": - mobi[defaults_slot][c_roleid] = value; - break; - } + player_role_data[c_roleid][$ attribute] = value; } } } @@ -1769,18 +1746,19 @@ function scr_initialize_custom() { "{squad_name}": _squad_name, }, ]; - var _roles_player = obj_ini.role[100]; - var _default_player = obj_ini.role[101]; + + var _roles_player = player_role_data; + var _default_player = default_role_data; for (var i = 1; i < 20; i++) { - if (_roles_player[i] == "") { + if (_roles_player[i].role == "") { continue; } - if (_default_player[i] == "") { + if (_default_player[i].role == "") { continue; } var _set = {}; - variable_struct_set(_set, _default_player[i], _roles_player[i]); + variable_struct_set(_set, _default_player[i].role, _roles_player[i].role); array_push(_swaps, _set); } @@ -1788,13 +1766,13 @@ function scr_initialize_custom() { for (var i = 1; i < 20; i++) { var _set = {}; var _key = $"wep1[{i}]"; - var _val = obj_ini.wep1[100][i]; + var _val = _roles_player[i].wep1; variable_struct_set(_set, _key, _val); array_push(_swaps, _set); _set = {}; _key = $"wep2[{i}]"; - _val = obj_ini.wep2[100][i]; + _val = _roles_player[i].wep2; variable_struct_set(_set, _key, _val); array_push(_swaps, _set); } @@ -1824,11 +1802,11 @@ function scr_initialize_custom() { squad_types.assault_squad.loadout = { "required": { "wep1": [ - wep1[100][10], + _default_player[10].wep1, 5, ], "wep2": [ - wep2[100][10], + _default_player[10].wep2, 5, ], }, diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index 8b7a4ed636..7fd998d0f7 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -74,15 +74,8 @@ function task_selector_man_manage() { case "captain_promote": _unit.update_role(obj_ini.role[100][eROLE.CAPTAIN]); _unit.squad = "none"; - var _start_company = _unit.company; - var _end_company = selection_data.target_company; - var _endslot = find_company_open_slot(_end_company); - scr_move_unit_info(_start_company, _end_company, _unit.marine_number, _endslot); - with (obj_ini) { - scr_company_order(_start_company); - scr_company_order(_end_company); - } - managing = _end_company; + _unit.move_to_company(selection_data.target_company); + managing = selection_data.target_company; update_general_manage_view(); exit; case "champion_promote": @@ -108,54 +101,26 @@ function task_selector_man_manage() { exit; case "chaplain_promote": _unit.squad = "none"; - _start_company = _unit.company; - _end_company = selection_data.target_company; - var endslot = find_company_open_slot(_end_company); - scr_move_unit_info(_start_company, _end_company, _unit.marine_number, endslot); - with (obj_ini) { - scr_company_order(_start_company); - scr_company_order(_end_company); - } - managing = _end_company; + _unit.move_to_company(selection_data.target_company); + managing = selection_data.target_company; update_general_manage_view(); exit; case "apothecary_promote": _unit.squad = "none"; - _start_company = _unit.company; - _end_company = selection_data.target_company; - endslot = find_company_open_slot(_end_company); - scr_move_unit_info(_start_company, _end_company, _unit.marine_number, endslot); - with (obj_ini) { - scr_company_order(_start_company); - scr_company_order(_end_company); - } - managing = _end_company; + _unit.move_to_company(selection_data.target_company); + managing = selection_data.target_company; update_general_manage_view(); exit; case "tech_marine_promote": _unit.squad = "none"; - _start_company = _unit.company; - _end_company = selection_data.target_company; - endslot = find_company_open_slot(_end_company); - scr_move_unit_info(_start_company, _end_company, _unit.marine_number, endslot); - with (obj_ini) { - scr_company_order(_start_company); - scr_company_order(_end_company); - } - managing = _end_company; + _unit.move_to_company(selection_data.target_company); + managing = selection_data.target_company; update_general_manage_view(); exit; case "librarian_promote": _unit.squad = "none"; - _start_company = _unit.company; - _end_company = selection_data.target_company; - endslot = find_company_open_slot(_end_company); - scr_move_unit_info(_start_company, _end_company, _unit.marine_number, endslot); - with (obj_ini) { - scr_company_order(_start_company); - scr_company_order(_end_company); - } - managing = _end_company; + _unit.move_to_company(selection_data.target_company); + managing = selection_data.target_company; update_general_manage_view(); exit; case "hunt_beast": diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index f35bb49189..cff449014c 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -402,16 +402,34 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static handle_stat_growth = unit_stat_growth; + static move_to_company(new_company){ + var _slot = find_company_open_slot(new_company); + var _old_loc = [company, marine_number]; + obj_ini.TTRPG[new_company][_slot] = self; + company = new_company; + marine_number = _slot; + movement_after_math(); + var _old_company_length = array_length(obj_ini.TTRP[_old_loc[0]]); + for (var i = _old_loc[1] + 1; i < _old_company_length ; i++){ + var _unit = fetch_unit[_old_loc[0] , i]; + _unit.movement_after_math(_old_loc[0] ,i -1 ); + _unit.marine_number = i -1; + } + array_delete(obj_ini.TTRP[_old_loc[0]] , _old_loc[1] , 1); + } + + armour1 = ""; static armour = function(raw = false) { - var wep = obj_ini.armour[company][marine_number]; + var wep = armour1; if (is_string(wep) || raw) { return wep; } return obj_ini.artifact[wep]; }; + current_role = ""; static role = function() { - return obj_ini.role[company][marine_number]; + return current_role; }; static squad_role = function() { diff --git a/scripts/scr_move_unit_info/scr_move_unit_info.gml b/scripts/scr_move_unit_info/scr_move_unit_info.gml index 810e1bad12..ce4be1388b 100644 --- a/scripts/scr_move_unit_info/scr_move_unit_info.gml +++ b/scripts/scr_move_unit_info/scr_move_unit_info.gml @@ -10,14 +10,8 @@ function scr_move_unit_info(start_company, end_company, start_slot, end_slot, ev if (eval_squad) { unit.movement_after_math(end_company, end_slot); } - obj_ini.race[end_company][end_slot] = obj_ini.race[start_company][start_slot]; obj_ini.name[end_company][end_slot] = obj_ini.name[start_company][start_slot]; - obj_ini.wep1[end_company][end_slot] = obj_ini.wep1[start_company][start_slot]; obj_ini.role[end_company][end_slot] = obj_ini.role[start_company][start_slot]; - obj_ini.wep2[end_company][end_slot] = obj_ini.wep2[start_company][start_slot]; - obj_ini.gear[end_company][end_slot] = obj_ini.gear[start_company][start_slot]; - obj_ini.armour[end_company][end_slot] = obj_ini.armour[start_company][start_slot]; - obj_ini.mobi[end_company][end_slot] = obj_ini.mobi[start_company][start_slot]; var _temp_struct = fetch_unit([end_company, end_slot]); diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index fa6175ac82..72d7558723 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -126,80 +126,63 @@ function apothecary_training() { var training_points_values = global.apothecary_training_tiers; apothecary_recruit_points += training_points_values[training_apothecary]; - var novice_type = string("{0} Aspirant", obj_ini.role[100][15]); + var _apoth_role = player_role_data[eROLE.APOTHECARY]; + + var novice_type = string("{0} Aspirant", obj_ini._apoth_role.role); if (training_apothecary > 0) { recruit_count = scr_role_count(novice_type, ""); if (apothecary_recruit_points >= 48) { if (recruit_count > 0) { var random_marine = scr_random_marine(novice_type, 0); - if (random_marine != "none") { - /// @type {Struct.TTRPG_stats} - var unit = fetch_unit(random_marine); - if (!is_struct(unit) || unit.name() == "") { - return; - } - - apothecary_recruit_points -= 48; - scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); - unit.update_role(obj_ini.role[100][15]); - unit.role_tag = [ - 0, - 0, - 0, - 0, - ]; - unit.add_exp(10); + if (random_marine == "none") { + return; + } + /// @type {Struct.TTRPG_stats} + var unit = fetch_unit(random_marine); + if (!is_struct(unit) || unit.name() == "") { + return; + } - var _warn = ""; - if (unit.update_weapon_one(obj_ini.wep1[100][15]) == "no_items") { - _warn += $", {obj_ini.wep1[100][15]}"; - } - if (unit.update_weapon_two(obj_ini.wep2[100][15]) == "no_items") { - _warn += $", {obj_ini.wep2[100][15]}"; - } - if (unit.update_gear(obj_ini.gear[100][15]) == "no_items") { - _warn += $", {obj_ini.gear[100][15]}"; - } + apothecary_recruit_points -= 48; + scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); + unit.update_role(_apoth_role.role); + unit.role_tag = [ + 0, + 0, + 0, + 0, + ]; + unit.add_exp(10); + + var _warn = ""; + var _outcome = unit.alter_equipment(_apoth_role, true, true); + + if (!_outcome.success) { + scr_alert("red", "recruitment", $"{_outcome.description}!", 0, 0); + } - if (_warn != "") { - _warn += "."; - scr_alert("red", "recruitment", "Not enough equipment: " + string(_warn), 0, 0); - } - with (obj_ini) { - scr_company_order(0); - } - } } else { apothecary_recruit_points = 0; } } else if ((apothecary_recruit_points >= 4) && (recruit_count == 0)) { var random_marine = spec_data_set(eROLE_TAG.Apothecary); - if (random_marine != "none") { - var marine_position = random_marine[1]; - var marine_company = random_marine[0]; - // This gets the last open slot for company 0 - var open_slot = find_company_open_slot(0); - if (open_slot != -1) { - scr_move_unit_info(marine_company, 0, marine_position, open_slot); - var unit = fetch_unit([0, open_slot]); - if (!is_struct(unit) || unit.name() == "") { - return; - } - unit.update_role(novice_type); - unit.update_gear(""); - unit.update_mobility_item(""); - scr_alert("green", "recruitment", unit.name_role() + " begins training.", 0, 0); - with (obj_ini) { - scr_company_order(marine_company); - scr_company_order(0); - } - } - } else { - training_apothecary = 0; - scr_alert("red", "recruitment", $"No marines available for {obj_ini.role[100][eROLE.APOTHECARY]} training", 0, 0); + if (random_marine == "none") { + return; } + var _unit = fetch_unit(random_marine); + // This gets the last open slot for company 0 + _unit.move_to_company(0); + + unit.update_role(novice_type); + unit.update_gear(""); + unit.update_mobility_item(""); + scr_alert("green", "recruitment", unit.name_role() + " begins training.", 0, 0); + + } else { + training_apothecary = 0; + scr_alert("red", "recruitment", $"No marines available for {obj_ini.role[100][eROLE.APOTHECARY]} training", 0, 0); } } } @@ -219,66 +202,53 @@ function chaplain_training() { if (chaplain_points >= 48) { if (recruit_count > 0) { var random_marine = scr_random_marine(novice_type, 0); - if (random_marine != "none") { - var unit = fetch_unit(random_marine); - if (!is_struct(unit) || unit.name() == "") { - return; - } - scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); - chaplain_points -= 48; - unit.update_role(obj_ini.role[100][14]); - unit.role_tag = [ - 0, - 0, - 0, - 0, - ]; - unit.add_exp(10); - chaplain_aspirant = 0; - var _warn = ""; - if (unit.update_weapon_one(obj_ini.wep1[100][14]) == "no_items") { - _warn += $", {obj_ini.wep1[100][14]}"; - } - if (unit.update_weapon_two(obj_ini.wep2[100][14]) == "no_items") { - _warn += $", {obj_ini.wep2[100][14]}"; - } - if (unit.update_gear(obj_ini.gear[100][14]) == "no_items") { - _warn += $", {obj_ini.gear[100][14]}"; - } - - if (_warn != "") { - _warn += "."; - scr_alert("red", "recruitment", "Not enough equipment: " + string(_warn), 0, 0); - } - with (obj_ini) { - scr_company_order(0); - } + if (random_marine == "none") { + return; + } + var _chap_role = obj_ini.player_role_data[eROLE.CHAPLAIN]; + var unit = fetch_unit(random_marine); + + scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); + chaplain_points -= 48; + unit.update_role(_chap_role.role); + unit.role_tag = [ + 0, + 0, + 0, + 0, + ]; + unit.add_exp(10); + chaplain_aspirant = 0; + var _warn = ""; + var _outcome = unit.alter_equipment(_tech_role, true, true); + + if (!_outcome.success) { + scr_alert("red", "recruitment", $"{_outcome.description}!", 0, 0); } + } else { chaplain_points = 0; } } else if ((chaplain_points >= 4) && (recruit_count == 0)) { var random_marine = spec_data_set(eROLE_TAG.Chaplain); if (random_marine != "none") { - var marine_position = random_marine[1]; - var marine_company = random_marine[0]; - var open_slot = find_company_open_slot(0); - if (open_slot != -1) { - scr_move_unit_info(marine_company, 0, marine_position, open_slot); - var unit = fetch_unit([0, open_slot]); - if (!is_struct(unit) || unit.name() == "") { - return; - } - chaplain_aspirant = 1; - unit.update_role(novice_type); - unit.update_gear(""); - unit.update_mobility_item(""); - scr_alert("green", "recruitment", unit.name_role() + " begins training.", 0, 0); - with (obj_ini) { - scr_company_order(marine_company); - scr_company_order(0); - } + var _unit = fetch_unit(random_marine); + if (!is_struct(_unit)){ + return; } + + _unit.move_to_company(0); + + chaplain_aspirant = 1; + unit.update_role(novice_type); + unit.update_gear(""); + unit.update_mobility_item(""); + scr_alert("green", "recruitment", $"{unit.name_role()} begins training.", 0, 0); + with (obj_ini) { + scr_company_order(marine_company); + scr_company_order(0); + } + } else { training_chaplain = 0; scr_alert("red", "recruitment", $"No remaining {obj_ini.role[100][eROLE.CHAPLAIN]} applicant marines for training", 0, 0); @@ -303,26 +273,23 @@ function librarian_training() { if (psyker_points >= goal) { if (recruit_count > 0) { var random_marine = scr_random_marine(novice_type, 0, {"stat": [["psionic", 2, "more"]]}); - if (random_marine != "none") { - var unit = fetch_unit(random_marine); - if (!is_struct(unit) || unit.name() == "") { - return; - } - psyker_points -= goal; - psyker_aspirant = 0; - - scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); - unit.update_role("Lexicanum"); - unit.role_tag = [ - 0, - 0, - 0, - 0, - ]; - with (obj_ini) { - scr_company_order(0); - } + if (random_marine == "none") { + return; } + var unit = fetch_unit(random_marine); + + psyker_points -= goal; + psyker_aspirant = 0; + + scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); + unit.update_role("Lexicanum"); + unit.role_tag = [ + 0, + 0, + 0, + 0, + ]; + } else { psyker_points = 0; } @@ -333,27 +300,19 @@ function librarian_training() { scr_alert("red", "recruitment", "No remaining warp sensitive marines for training", 0, 0); } else if (random_marine != "none") { // This gets the last open slot for company 0 - var marine_position = random_marine[1]; - var marine_company = random_marine[0]; - var open_slot = find_company_open_slot(0); - if (open_slot != -1) { - scr_move_unit_info(marine_company, 0, marine_position, open_slot); - var unit = fetch_unit([0, open_slot]); - if (!is_struct(unit) || unit.name() == "") { - return; - } - unit.update_role(novice_type); - unit.update_powers(); - psyker_aspirant = 1; - - unit.update_gear(""); - unit.update_mobility_item(""); - scr_alert("green", "recruitment", unit.name_role() + " begins training.", 0, 0); - with (obj_ini) { - scr_company_order(marine_company); - scr_company_order(0); - } - } + var _unit = fetch_unit(random_marine); + _unit.move_to_company(0); + + unit.update_role(novice_type); + unit.update_powers(); + psyker_aspirant = 1; + + uit.alter_equipment({ + gear : "", + mobi : "" + }) + unit.update_mobility_item(""); + scr_alert("green", "recruitment", unit.name_role() + " begins training.", 0, 0); } } } @@ -372,8 +331,11 @@ function techmarine_training() { 10, 14, ]; + + var _tech_role = obj_ini.player_role_data[eROLE.TECHMARINE]; + tech_points += training_points_values[training_techmarine]; - var novice_type = string("{0} Aspirant", obj_ini.role[100][16]); + var novice_type = string("{0} Aspirant", _tech_role.role); if (training_techmarine > 0) { recruit_count = scr_role_count(novice_type, ""); var _threshold = 252; @@ -385,66 +347,56 @@ function techmarine_training() { if (tech_points >= _threshold) { if (recruit_count > 0) { var random_marine = scr_random_marine(novice_type, 0); - if (random_marine != "none") { - var unit = fetch_unit(random_marine); - if (!is_struct(unit) || unit.name() == "") { + if (random_marine == "none") { return; - } - tech_points -= _threshold; + } + var unit = fetch_unit(random_marine); + if (!is_struct(unit) || unit.name() == "") { + return; + } + tech_points -= _threshold; + + unit.update_role(_tech_role.role); + unit.role_tag = [ + 0, + 0, + 0, + 0, + ]; + unit.add_exp(30); + + unit.religion = "cult_mechanicus"; + if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { + unit.add_trait("mars_trained"); + unit.alter_equipment(_tech_role, false, true); + scr_alert("green", "recruitment", $"{unit.name()} returns from Mars, a {unit.role()}.", 0, 0); + } else { + unit.add_trait("chapter_trained_tech"); + scr_alert("green", "recruitment", $"{unit.name_role()} has finished training.", 0, 0); - unit.update_role(obj_ini.role[100][16]); - unit.role_tag = [ - 0, - 0, - 0, - 0, - ]; - unit.add_exp(30); - - unit.religion = "cult_mechanicus"; - if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { - unit.add_trait("mars_trained"); - unit.update_weapon_one(obj_ini.wep1[100][eROLE.TECHMARINE], false); - unit.update_weapon_two(obj_ini.wep2[100][eROLE.TECHMARINE], false); - unit.update_mobility_item(obj_ini.mobi[100][eROLE.TECHMARINE], false); - scr_alert("green", "recruitment", $"{unit.name()} returns from Mars, a {unit.role()}.", 0, 0); - } else { - unit.add_trait("chapter_trained_tech"); - scr_alert("green", "recruitment", $"{unit.name_role()} has finished training.", 0, 0); - - var _warn = ""; - if (unit.update_weapon_one(obj_ini.wep1[100][eROLE.TECHMARINE]) == "no_items") { - _warn += $", {obj_ini.wep1[100][eROLE.TECHMARINE]}"; - } - if (unit.update_weapon_two(obj_ini.wep2[100][eROLE.TECHMARINE]) == "no_items") { - _warn += $", {obj_ini.wep2[100][eROLE.TECHMARINE]}"; - } - if (unit.update_gear(obj_ini.gear[100][eROLE.TECHMARINE]) == "no_items") { - _warn += $", {obj_ini.gear[100][eROLE.TECHMARINE]}"; - } - - if (_warn != "") { - scr_alert("red", "recruitment", $"Not enough equipment: {_warn}!", 0, 0); - } - } + var _outcome = unit.alter_equipment(_tech_role, true, true); - if (unit.location_string == "Terra") { - unit.allocate_unit_to_fresh_spawn("default"); + if (!_outcome.success) { + scr_alert("red", "recruitment", $"{_outcome.description}!", 0, 0); } + } - var extra_bio = 0; - if (global.chapter_name != "Iron Hands" || !unit.has_trait("flesh_is_weak")) { - extra_bio = unit.bionics < 4 ? choose(1, 2, 3) : 1; - } else { - extra_bio = choose(4, 5, 6); - } - repeat (extra_bio) { - unit.add_bionics(); - } - // 135 ; probably also want to increase the p_player by 1 just because - with (obj_ini) { - scr_company_order(0); - } + if (unit.location_string == "Terra") { + unit.allocate_unit_to_fresh_spawn("default"); + } + + var extra_bio = 0; + if (global.chapter_name != "Iron Hands" || !unit.has_trait("flesh_is_weak")) { + extra_bio = unit.bionics < 4 ? choose(1, 2, 3) : 1; + } else { + extra_bio = choose(4, 5, 6); + } + repeat (extra_bio) { + unit.add_bionics(); + } + // 135 ; probably also want to increase the p_player by 1 just because + with (obj_ini) { + scr_company_order(0); } } else { tech_points = 0; @@ -452,45 +404,40 @@ function techmarine_training() { } else if ((tech_points >= 4) && (recruit_count == 0)) { var random_marine = spec_data_set(eROLE_TAG.Techmarine); if (random_marine != "none") { - var marine_position = random_marine[1]; - var marine_company = random_marine[0]; - // This gets the last open slot for company 0 - var open_slot = find_company_open_slot(0); - if (open_slot != -1) { - scr_move_unit_info(marine_company, 0, marine_position, open_slot); - var unit = fetch_unit([0, open_slot]); - if (!is_struct(unit) || unit.name() == "") { - return; - } - unit.update_role(novice_type); - // Remove from ship - if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { - if (unit.ship_location > -1) { - var man_size = unit.get_unit_size(); - obj_ini.ship_carrying[unit.ship_location] -= man_size; - } - unit.location_string = "Terra"; - unit.planet_location = 4; - unit.ship_location = -1; - } - unit.update_weapon_one(""); - unit.update_weapon_two(""); - unit.update_gear(""); - unit.update_mobility_item(""); - if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { - scr_alert("green", "recruitment", $"{unit.name_role()} journeys to Mars.", 0, 0); - } else { - scr_alert("green", "recruitment", $"{unit.name_role()} begins training.", 0, 0); - } - with (obj_ini) { - scr_company_order(marine_company); - scr_company_order(0); + var _unit = fetch_unit(random_marine); + if (!is_struct(unit)){ + return; + } + _unit.move_to_company(0); + unit.update_role(novice_type); + + // Remove from ship + if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { + if (unit.ship_location > -1) { + var man_size = unit.get_unit_size(); + obj_ini.ship_carrying[unit.ship_location] -= man_size; } + unit.location_string = "Terra"; + unit.planet_location = 4; + unit.ship_location = -1; + } + unit.alter_equipment({ + wep1 : "", + wep2 : "", + armour : "", + gear : "", + mobi : "" + }); + + if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { + scr_alert("green", "recruitment", $"{unit.name_role()} journeys to Mars.", 0, 0); + } else { + scr_alert("green", "recruitment", $"{unit.name_role()} begins training.", 0, 0); } } else { training_techmarine = 0; - scr_alert("red", "recruitment", $"No marines with sufficient technology aptitude for {obj_ini.role[100][eROLE.TECHMARINE]} training", 0, 0); + scr_alert("red", "recruitment", $"No marines with sufficient technology aptitude for {_tech_role.role} training", 0, 0); } } } diff --git a/scripts/scr_ui_settings/scr_ui_settings.gml b/scripts/scr_ui_settings/scr_ui_settings.gml index f26f87d193..c805e88897 100644 --- a/scripts/scr_ui_settings/scr_ui_settings.gml +++ b/scripts/scr_ui_settings/scr_ui_settings.gml @@ -626,11 +626,12 @@ function setup_role_settings_buttons() { role_settings_ui = {}; var _button_x = 830; var _settings = obj_controller.settings; + var _role_data = obj_ini.player_role_data[_settings]; role_settings_ui.main_weapon_button = new UnitButtonObject({ style: "pixel", x1: _button_x, y1: 185, - label: $"Main Weapon: {obj_ini.wep1[100][_settings]}", + label: $"Main Weapon: {_role_data.wep1}", set_width: true, w: 250, active: true, @@ -641,7 +642,7 @@ function setup_role_settings_buttons() { style: "pixel", x1: _button_x, y1: role_settings_ui.main_weapon_button.y2, - label: $"Secondary Weapon: {obj_ini.wep2[100][_settings]}", + label: $"Secondary Weapon: {_role_data.wep2}", set_width: true, w: 250, active: true, @@ -652,7 +653,7 @@ function setup_role_settings_buttons() { style: "pixel", x1: _button_x, y1: role_settings_ui.secondary_weapon_button.y2, - label: $"Armour: {obj_ini.armour[100][_settings]}", + label: $"Armour: {_role_data.armour_role_data}", set_width: true, w: 250, active: true, @@ -663,7 +664,7 @@ function setup_role_settings_buttons() { style: "pixel", x1: _button_x, y1: role_settings_ui.armour_button.y2, - label: $"Special Item: {obj_ini.gear[100][_settings]}", + label: $"Special Item: {_role_data.gear}", set_width: true, w: 250, active: true, @@ -674,7 +675,7 @@ function setup_role_settings_buttons() { style: "pixel", x1: _button_x, y1: role_settings_ui.gear_button.y2, - label: $"Mobility Item: {obj_ini.mobi[100][_settings]}", + label: $"Mobility Item: {_role_data.mobi}", set_width: true, w: 250, active: true, diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 44ec618490..4787ba5d8a 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -443,29 +443,44 @@ function scr_update_unit_mobility_item(new_mobility_item, from_armoury = true, t /// @self Struct.TTRPG_stats function alter_unit_equipment(update_equipment, from_armoury = true, to_armoury = true, quality = "any") { + var _outcome_desc = ""; + static no_equip = "Not enough equipment:"; + var _missing_items = ""; + var _success = true; if (is_array(update_equipment)) { update_equipment = convert_equipment_array_into_struct(update_equipment); } var equip_areas = struct_get_names(update_equipment); for (var i = 0; i < array_length(equip_areas); i++) { + var _item = update_equipment[$ equip_areas[i]]; switch (equip_areas[i]) { case "wep1": - update_weapon_one(update_equipment[$ equip_areas[i]], from_armoury, to_armoury, quality); + var _outcome = update_weapon_one(_item, from_armoury, to_armoury, quality); break; case "wep2": - update_weapon_two(update_equipment[$ equip_areas[i]], from_armoury, to_armoury, quality); + var _outcome = update_weapon_two(_item, from_armoury, to_armoury, quality); break; case "mobi": - update_mobility_item(update_equipment[$ equip_areas[i]], from_armoury, to_armoury, quality); + var _outcome = update_mobility_item(_item, from_armoury, to_armoury, quality); break; case "armour": - update_armour(update_equipment[$ equip_areas[i]], from_armoury, to_armoury, quality); + var _outcome = update_armour(_item, from_armoury, to_armoury, quality); break; case "gear": - update_gear(update_equipment[$ equip_areas[i]], from_armoury, to_armoury, quality); + var _outcome = update_gear(_item, from_armoury, to_armoury, quality); break; } + if (_outcome == "no_items"){ + _missing_items += $"{_missing_items == "" ? "" : ","} {_item}"; + _success = false; + } + } + + if (_missing_items != ""){ + _outcome_desc += no_equip + _missing_items; } + var _final_outcome = {success : _final_outcome,description :_outcome_desc}; + } /// @self Struct.TTRPG_stats From 86b14c35065b02c534d1c2217af341ef28a0e153 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 12:57:26 +0100 Subject: [PATCH 17/82] change marine transfer ethodology --- .../scr_chapter_managent_events.gml | 3 +- .../scr_marine_struct/scr_marine_struct.gml | 4 +-- .../scr_move_unit_info/scr_move_unit_info.gml | 35 ------------------- scripts/scr_promote/scr_promote.gml | 17 ++------- .../scr_transfer_marines.gml | 7 ++-- 5 files changed, 8 insertions(+), 58 deletions(-) diff --git a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index e390360f0b..400b8acd8e 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -272,8 +272,7 @@ function new_forge_master_chosen(pick) { } reset_popup_options(); if (pick.company > 0) { - var _company_slot = find_company_open_slot(0); - scr_move_unit_info(pick.company, 0, pick.marine_number, _company_slot); + pick.move_to_company(0); } } } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index cff449014c..62ba8fa5ad 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -405,14 +405,14 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static move_to_company(new_company){ var _slot = find_company_open_slot(new_company); var _old_loc = [company, marine_number]; + movement_after_math(new_company , _slot); obj_ini.TTRPG[new_company][_slot] = self; company = new_company; marine_number = _slot; - movement_after_math(); var _old_company_length = array_length(obj_ini.TTRP[_old_loc[0]]); for (var i = _old_loc[1] + 1; i < _old_company_length ; i++){ var _unit = fetch_unit[_old_loc[0] , i]; - _unit.movement_after_math(_old_loc[0] ,i -1 ); + _unit.movement_after_math(_old_loc[0] ,i -1, false); _unit.marine_number = i -1; } array_delete(obj_ini.TTRP[_old_loc[0]] , _old_loc[1] , 1); diff --git a/scripts/scr_move_unit_info/scr_move_unit_info.gml b/scripts/scr_move_unit_info/scr_move_unit_info.gml index ce4be1388b..e69de29bb2 100644 --- a/scripts/scr_move_unit_info/scr_move_unit_info.gml +++ b/scripts/scr_move_unit_info/scr_move_unit_info.gml @@ -1,35 +0,0 @@ -function scr_move_unit_info(start_company, end_company, start_slot, end_slot, eval_squad = true) { - //eval_squad : determine whether movement of units between companies should decide to check their squad coherency or not, defaults to true - - //this makes sure coherency of the unit's squad and the squads logging of the unit location are kept up to date - var unit = fetch_unit([start_company, start_slot]); - if (!is_struct(unit)) { - exit; - } - - if (eval_squad) { - unit.movement_after_math(end_company, end_slot); - } - obj_ini.name[end_company][end_slot] = obj_ini.name[start_company][start_slot]; - obj_ini.role[end_company][end_slot] = obj_ini.role[start_company][start_slot]; - - var _temp_struct = fetch_unit([end_company, end_slot]); - - obj_ini.TTRPG[end_company][end_slot] = obj_ini.TTRPG[start_company][start_slot]; - - obj_ini.TTRPG[start_company][start_slot] = _temp_struct; - if (is_struct(_temp_struct)) { - _temp_struct.company = start_company; - _temp_struct.marine_number = start_slot; - } - - _temp_struct = fetch_unit([end_company, end_slot]); - if (is_struct(_temp_struct)) { - _temp_struct.company = end_company; - _temp_struct.marine_number = end_slot; - } else { - obj_ini.TTRPG[end_company][end_slot] = new TTRPG_stats("chapter", end_company, end_slot, "blank"); - } - - scr_wipe_unit(start_company, start_slot); -} diff --git a/scripts/scr_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index f193b203d9..ef3a2badbd 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -86,20 +86,13 @@ function setup_promotion_popup() { //move squad if (moveable) { var mem; + squad.company = target_comp; for (mem = 0; mem < array_length(move_members); mem++) { var mem_unit = fetch_unit(move_members[mem]); if (!is_struct(mem_unit)) { continue; } - if (mem_unit.company != target_comp) { - scr_move_unit_info(mem_unit.company, target_comp, mem_unit.marine_number, mahreens, false); - squad.members[mem][0] = target_comp; - squad.members[mem][1] = mahreens; - } - mem_unit = fetch_unit([target_comp, mahreens]); - if (!is_struct(mem_unit)) { - continue; - } + mem_unit.move_to_company(target_comp); mem_unit.squad = move_squad; if (!mem_unit.IsSpecialist(SPECIALISTS_SQUAD_LEADERS)) { mem_unit.update_role(role_name[target_role]); @@ -121,11 +114,7 @@ function setup_promotion_popup() { //move individual if (!moveable) { if (unit.company != target_comp) { - scr_move_unit_info(unit.company, target_comp, unit.marine_number, mahreens); - unit = fetch_unit([target_comp, mahreens]); - if (!is_struct(unit)) { - continue; - } + unit.move_to_company(target_comp); } unit.update_role(role_name[target_role]); unit.alter_equipment({"wep1": req_wep1, "wep2": req_wep2, "mobi": req_mobi, "armour": req_armour, "gear": req_gear}); diff --git a/scripts/scr_transfer_marines/scr_transfer_marines.gml b/scripts/scr_transfer_marines/scr_transfer_marines.gml index 9494051a26..c85589b434 100644 --- a/scripts/scr_transfer_marines/scr_transfer_marines.gml +++ b/scripts/scr_transfer_marines/scr_transfer_marines.gml @@ -66,11 +66,8 @@ function transfer_marines() { if (!is_struct(member_unit)) { continue; } + unit.move_to_company(target_comp, false); scr_move_unit_info(member_unit.company, target_comp, member_unit.marine_number, mahreens, false); - var _unit = fetch_unit([target_comp, mahreens]); - if (!is_struct(_unit)) { - continue; - } _unit.squad = move_squad; squad.members[mem][0] = target_comp; squad.members[mem][1] = mahreens; @@ -83,7 +80,7 @@ function transfer_marines() { } //move individual if (!moveable) { - scr_move_unit_info(unit.company, target_comp, unit.marine_number, mahreens, true); + unit.move_to_company(target_comp) mahreens++; } var check = 0; From eb262c704ca7d682fffe8f0235e6e38845df504f Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 15:19:22 +0100 Subject: [PATCH 18/82] remove race parallel array --- datafiles/data/unit_stats.json | 4 +- objects/obj_creation/Create_0.gml | 19 +-- objects/obj_creation/Draw_0.gml | 12 +- objects/obj_en_fleet/Alarm_1.gml | 6 +- objects/obj_ini/Create_0.gml | 17 +-- objects/obj_p_assra/Alarm_0.gml | 22 +-- scripts/globals/globals.gml | 10 ++ scripts/scr_add_man/scr_add_man.gml | 2 +- scripts/scr_chapter_new/scr_chapter_new.gml | 18 +-- .../scr_company_order/scr_company_order.gml | 19 +-- scripts/scr_creation/scr_creation.gml | 12 +- .../scr_ini_ship_cleanup.gml | 2 +- .../scr_initialize_custom.gml | 138 +++++------------ scripts/scr_kill_unit/scr_kill_unit.gml | 8 - .../scr_marine_struct/scr_marine_struct.gml | 36 +++-- .../scr_popup_functions.gml | 22 +-- scripts/scr_powers/scr_powers.gml | 2 +- scripts/scr_role_setup/scr_role_setup.gml | 88 ++++++++--- .../scr_transfer_marines.gml | 140 +++++++++--------- scripts/scr_ui_settings/scr_ui_settings.gml | 25 +--- 20 files changed, 259 insertions(+), 343 deletions(-) diff --git a/datafiles/data/unit_stats.json b/datafiles/data/unit_stats.json index a8ad115cf7..7f91ed5da8 100644 --- a/datafiles/data/unit_stats.json +++ b/datafiles/data/unit_stats.json @@ -108,7 +108,7 @@ 45, 4 ], - "base_group": "skitarii", + "base_group": "eldar", "charisma": [ 20, 2 @@ -152,7 +152,7 @@ "wisdom": [ 50, 3 - ] + ], }, "flash_git": { "ballistic_skill": [ diff --git a/objects/obj_creation/Create_0.gml b/objects/obj_creation/Create_0.gml index b4aff6e0a2..1ce03984ae 100644 --- a/objects/obj_creation/Create_0.gml +++ b/objects/obj_creation/Create_0.gml @@ -572,24 +572,7 @@ defaults_slot = 100; /// @param {String} _gear -load_default_gear(eROLE.CHAPTERMASTER, "Chapter Master", "Power Sword", "Bolter", "Artificer Armour", "", ""); -load_default_gear(eROLE.HONOURGUARD, "Honour Guard", "Power Sword", "Bolter", "Artificer Armour", "", ""); -load_default_gear(eROLE.VETERAN, "Veteran", "Combiflamer", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); -load_default_gear(eROLE.TERMINATOR, "Terminator", "Power Fist", "Storm Bolter", "Terminator Armour", "", ""); -load_default_gear(eROLE.CAPTAIN, "Captain", "Power Sword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Iron Halo"); -load_default_gear(eROLE.DREADNOUGHT, "Dreadnought", "Dreadnought Lightning Claw", "Lascannon", "Dreadnought", "", ""); -load_default_gear(eROLE.CHAMPION, "Champion", "Power Sword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Combat Shield"); -load_default_gear(eROLE.TACTICAL, "Tactical", "Bolter", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); -load_default_gear(eROLE.DEVASTATOR, "Devastator", "", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); -load_default_gear(eROLE.ASSAULT, "Assault", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "Jump Pack", ""); -load_default_gear(eROLE.ANCIENT, "Ancient", "Company Standard", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); -load_default_gear(eROLE.SCOUT, "Scout", "Bolter", "Combat Knife", "Scout Armour", "", ""); -load_default_gear(eROLE.CHAPLAIN, "Chaplain", "Crozius Arcanum", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Rosarius"); -load_default_gear(eROLE.APOTHECARY, "Apothecary", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Narthecium"); -load_default_gear(eROLE.TECHMARINE, "Techmarine", "Power Axe", "Bolt Pistol", "Artificer Armour", "Servo-arm", ""); -load_default_gear(eROLE.LIBRARIAN, "Librarian", "Force Staff", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Psychic Hood"); -load_default_gear(eROLE.SERGEANT, "Sergeant", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); -load_default_gear(eROLE.VETERANSERGEANT, "Veteran Sergeant", "Chainsword", "Plasma Pistol", STR_ANY_POWER_ARMOUR, "", ""); +setup_default_gears(); col = []; col_r = []; diff --git a/objects/obj_creation/Draw_0.gml b/objects/obj_creation/Draw_0.gml index ede7ea23c0..bec0443f8b 100644 --- a/objects/obj_creation/Draw_0.gml +++ b/objects/obj_creation/Draw_0.gml @@ -574,8 +574,11 @@ try { // draw_text_transformed(444,505,"Select Speciality",0.6,0.6,0); draw_set_halign(fa_center); - var psy_intolerance = scr_has_disadv("Psyker Intolerant"); - if ((chapter_master_specialty == 3) && ((race[100][17] == 0) || psy_intolerance)) { + if (scr_has_disadv("Psyker Intolerant")){ + player_role_data[eROLE.LIBRARIAN].available_to_player = false; + } + var _lib_role = player_role_data[eROLE.LIBRARIAN]; + if ((chapter_master_specialty == 3) && !_lib_role.available_to_player ) { chapter_master_speciality = choose(1, 2); } x6 = 474; @@ -600,11 +603,10 @@ try { "The impossible is nothing to you; despite being a Psyker you have slowly risen to lead a Chapter. Chapter Master gains every Power within the chosen Discipline.", ], ]; - repeat (3) { - h += 1; + for (var h=1;h<=3;h++) { var cur_leader_type = leader_types[h]; draw_set_alpha(1); - var nope = (h == 3) && ((race[100][17] == 0) || psy_intolerance); + var nope = (h == 3) && !player_role_data[eROLE.LIBRARIAN].available_to_player; if (nope) { draw_set_alpha(0.5); } diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index d0b0e42e2b..1a4baed103 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -170,13 +170,13 @@ try { continue; } if ((_unit.location_string == cur_star.name) && (_unit.planet_location > 0)) { - if ((_unit.role() == "Ork Sniper") && (obj_ini.race[ca][ia] != 1)) { + if (_unit.role() == "Ork Sniper") { tem1_base = 3; } - if ((_unit.role() == "Flash Git") && (obj_ini.race[ca][ia] != 1)) { + if (_unit.role() == "Flash Git") { tem1_base = 3; } - if ((_unit.role() == "Ranger") && (obj_ini.race[ca][ia] != 1)) { + if (_unit.role() == "Ranger") { tem1_base = 3; } if (_unit.equipped_artifact_tag("daemon")) { diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 35825a8a70..e51df5f3b8 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -138,16 +138,6 @@ mobi = array_create(11, []); /// @type {Array>} TTRPG = array_create(11, []); -load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { - role[defaults_slot][_role_id] = _role_name; - wep1[defaults_slot][_role_id] = _wep1; - wep2[defaults_slot][_role_id] = _wep2; - armour[defaults_slot][_role_id] = _armour; - mobi[defaults_slot][_role_id] = _mobi; - gear[defaults_slot][_role_id] = _gear; - race[defaults_slot][_role_id] = 1; -}; - check_number = 0; year_fraction = 0; year = 0; @@ -180,10 +170,8 @@ serialize = function() { var _marines = array_create(0); for (var _coy = 0; _coy <= obj_ini.companies; _coy++) { for (var _mar = 0; _mar < array_length(obj_ini.TTRPG[_coy]); _mar++) { - if (name[_coy][_mar] != "") { - var _marine_json = jsonify_marine_struct(_coy, _mar, false); - array_push(_marines, _marine_json); - } + var _marine_json = jsonify_marine_struct(_coy, _mar, false); + array_push(_marines, _marine_json); } } @@ -221,7 +209,6 @@ serialize = function() { "temp", "serialize", "deserialize", - "load_default_gear", "role_spawn_buffs", "TTRPG", "squads", diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index fea9c80f59..2c8abcd699 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -1,24 +1,24 @@ -var co = 0, i = 0, o = 0, unit; +var co = 0, i = 0, o = 0, _unit; for (o = 0; o < array_length(origin.board_co); o++) { co = origin.board_co[o]; i = origin.board_id[o]; - unit = fetch_unit([co, i]); - if (!is_struct(unit)) { + _unit = fetch__unit([co, i]); + if (!is_struct(_unit)) { continue; } - if ((unit.hp() <= -15) && (obj_ini.race[co][i] == 1) && (unit.name() != "")) { + if ((_unit.hp() <= -15) && (_unnit.base_group != "astartes") { var seed_lost = 0; if (apothecary <= 0) { - if (unit.IsSpecialist(SPECIALISTS_STANDARD)) { + if (_unit.IsSpecialist(SPECIALISTS_STANDARD)) { obj_fleet.fallen_command += 1; } else { obj_fleet.fallen += 1; } if (apothecary_had > 0) { - if (unit.base_group == "astartes") { - var age = unit.age; + if (_unit.base_group == "astartes") { + var age = _unit.age; if ((age <= ((obj_controller.millenium * 1000) + obj_controller.year) - 10) && (obj_ini.zygote == 0)) { seed_lost += 1; } @@ -29,23 +29,23 @@ for (o = 0; o < array_length(origin.board_co); o++) { } // obj_fleet.marines_lost+=1; - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { obj_controller.alarm[7] = 1; if (global.defeat <= 1) { global.defeat = 1; } } - if (unit.weapon_one() == "Company Standard" || unit.weapon_two() == "Company Standard") { + if (_unit.weapon_one() == "Company Standard" || _unit.weapon_two() == "Company Standard") { scr_loyalty("Lost Standard", "+"); } - scr_kill_unit(co, i); + scr_kill__unit(co, i); if (obj_fleet.capital + obj_fleet.frigate + obj_fleet.escort > 0) { obj_controller.gene_seed += seed_lost; } } else if (apothecary > 0) { - unit.add_or_sub_health(irandom_range(9, 14)); + _unit.add_or_sub_health(irandom_range(9, 14)); apothecary -= 0.5; } } diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 32ad24fb19..507fd01116 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -131,6 +131,16 @@ global.unit_equip_slots = [ "all", ]; +global.role_data_keys = [ + "wep1", + "wep2", + "armour", + "gear", + "mobi", + "role", + "available_to_player" +] + // Human-readable labels for equipment slots. global.unit_equip_slots_display = [ "First Weapon", diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index c6a1e3d242..9faaeb66ab 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -26,8 +26,8 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption switch (man_role) { case "Skitarii": spawn_exp = 10; - obj_ini.race[target_company][_company_slot] = 3; _unit = new TTRPG_stats("mechanicus", target_company, _company_slot, "skitarii"); + _unit.unit_race = 3 break; case "Techpriest": spawn_exp = 100; diff --git a/scripts/scr_chapter_new/scr_chapter_new.gml b/scripts/scr_chapter_new/scr_chapter_new.gml index 74bdf01a6e..a1a1f8c1c9 100644 --- a/scripts/scr_chapter_new/scr_chapter_new.gml +++ b/scripts/scr_chapter_new/scr_chapter_new.gml @@ -212,23 +212,7 @@ function scr_chapter_new(chapter_identifier) { maxpoints = 100; player_role_data = []; default_role_data = []; - load_default_gear(eROLE.HONOURGUARD, "Honour Guard", "Power Sword", "Bolter", "Artificer Armour", "", ""); - load_default_gear(eROLE.VETERAN, "Veteran", "Combiflamer", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.TERMINATOR, "Terminator", "Power Fist", "Storm Bolter", "Terminator Armour", "", ""); - load_default_gear(eROLE.CAPTAIN, "Captain", "Power Sword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Iron Halo"); - load_default_gear(eROLE.DREADNOUGHT, "Dreadnought", "Dreadnought Lightning Claw", "Twin Linked Lascannon", "Dreadnought", "", ""); - load_default_gear(eROLE.CHAMPION, "Champion", "Power Sword", STR_ANY_POWER_ARMOUR, STR_ANY_POWER_ARMOUR, "", "Combat Shield"); - load_default_gear(eROLE.TACTICAL, "Tactical", "Bolter", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.DEVASTATOR, "Devastator", "", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.ASSAULT, "Assault", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "Jump Pack", ""); - load_default_gear(eROLE.ANCIENT, "Ancient", "Company Standard", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.SCOUT, "Scout", "Bolter", "Combat Knife", "Scout Armour", "", ""); - load_default_gear(eROLE.CHAPLAIN, "Chaplain", "Crozius Arcanum", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Rosarius"); - load_default_gear(eROLE.APOTHECARY, "Apothecary", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Narthecium"); - load_default_gear(eROLE.TECHMARINE, "Techmarine", "Power Axe", "Bolt Pistol", "Artificer Armour", "Servo-arm", ""); - load_default_gear(eROLE.LIBRARIAN, "Librarian", "Force Staff", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Psychic Hood"); - load_default_gear(eROLE.SERGEANT, "Sergeant", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.VETERANSERGEANT, "Veteran Sergeant", "Chainsword", "Plasma Pistol", STR_ANY_POWER_ARMOUR, "", ""); + setup_default_gears(); for (var c = 0; c < array_length(all_chapters); c++) { if (chapter_identifier == all_chapters[c].name && all_chapters[c].json == true) { diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index a23a6043d1..4d448235bb 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -116,32 +116,15 @@ function scr_company_order(company) { var _temps = []; for (var i = 0; i < array_length(_company_marines.units); i++) { var _unit = _company_marines.units[i]; - array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true)}); + array_push(_temps, {unit: _unit); } var _new_length = array_length(_temps); TTRPG[co] = array_create(_new_length, 0); - race[co] = array_create(_new_length, 0); - name[co] = array_create(_new_length, 0); - role[co] = array_create(_new_length, 0); - wep1[co] = array_create(_new_length, 0); - wep2[co] = array_create(_new_length, 0); - armour[co] = array_create(_new_length, 0); - gear[co] = array_create(_new_length, 0); - mobi[co] = array_create(_new_length, 0); for (var i = 0; i < array_length(_temps); i++) { var _unit = _temps[i]; var _struc = _unit.unit; TTRPG[co][i] = _struc; - race[co][i] = _unit.race; - name[co][i] = _unit.name; - role[co][i] = _unit.role; - wep1[co][i] = _unit.wep1; - wep2[co][i] = _unit.wep2; - armour[co][i] = _unit.armour; - gear[co][i] = _unit.gear; - mobi[co][i] = _unit.mobi; - _struc.company = co; _struc.marine_number = i; if (_struc.squad != "none") { var _squad = _struc.get_squad(); diff --git a/scripts/scr_creation/scr_creation.gml b/scripts/scr_creation/scr_creation.gml index a5002329ec..4d037a88e1 100644 --- a/scripts/scr_creation/scr_creation.gml +++ b/scripts/scr_creation/scr_creation.gml @@ -67,7 +67,8 @@ function update_creation_roles_radio(start_role = 1) { var _role_data = []; for (var i = start_role; i <= 19; i++) { - if (race[100][i] != 0 && role[100][i] != "") { + var _role_data = player_role_data[i]; + if (_role_data.available_to_player && _role_data.role != "") { array_push(_role_data, {str1: role[100][i], font: fnt_40k_14b, role_id: i}); } } @@ -184,18 +185,15 @@ function scr_creation(slide_num) { if (name_bad == 0) { change_slide = true; goto_slide = 3; - race[100][17] = 1; + player_role_data[eROLE.LIBRARIAN].available_to_player = true; } } if (slide_num == eCREATION_SLIDES.CHAPTERTRAITS && custom == eCHAPTER_TYPE.PREMADE) { change_slide = true; goto_slide = 3; - race[100][eROLE.CHAPLAIN] = 1; - race[100][eROLE.LIBRARIAN] = 1; - if (chapter_name == "Iron Hands" || chapter_name == "Space Wolves") { - race[100][eROLE.CHAPLAIN] = 0; - } + player_role_data[eROLE.LIBRARIAN].available_to_player = true; + player_role_data[eROLE.CHAPLAIN].available_to_player = chapter_name != "Iron Hands" && chapter_name != "Space Wolves"; } if (slide_num == eCREATION_SLIDES.CHAPTERHOME) { diff --git a/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml b/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml index 5b2065f5df..356da81c25 100644 --- a/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml +++ b/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml @@ -4,7 +4,7 @@ function scr_kill_ship(index) { var _units_on_ship = []; var _unit; for (var co = 0; co <= companies; co++) { - for (var i = 0; i < array_length(name[co]); i++) { + for (var i = 0; i < array_length(TTRPG[co]); i++) { _unit = fetch_unit([co, i]); if (!is_struct(_unit)) { continue; diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index b1941f14f0..e5ba16eff2 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1469,23 +1469,6 @@ function scr_initialize_custom() { var _current_age = ((millenium * 1000) + year) - 10; - /// @self Asset.GMObject.obj_ini - var _init_marine_row = function(_idx, _count, _age_val) { - var _len = _count + 1; - race[_idx] = array_create(_len, 1); - name[_idx] = array_create(_len, ""); - role[_idx] = array_create(_len, ""); - wep1[_idx] = array_create(_len, ""); - wep2[_idx] = array_create(_len, ""); - armour[_idx] = array_create(_len, ""); - gear[_idx] = array_create(_len, ""); - mobi[_idx] = array_create(_len, ""); - }; - - _init_marine_row(0, 500, _current_age); - _init_marine_row(100, 100, _current_age); - _init_marine_row(102, 100, _current_age); - TTRPG[0] = array_create(501); for (var i = 0; i <= 500; i++) { TTRPG[0][i] = new TTRPG_stats("chapter", 0, i, "blank"); @@ -1498,28 +1481,8 @@ function scr_initialize_custom() { _hi_qual_armour = STR_ANY_POWER_ARMOUR; } - load_default_gear(eROLE.CHAPTERMASTER, "Chapter Master", "Power Sword", "Bolt Pistol", _hi_qual_armour, "", "Iron Halo"); - load_default_gear(eROLE.HONOURGUARD, "Honour Guard", "Power Sword", "Bolter", _hi_qual_armour, "", ""); - load_default_gear(eROLE.VETERAN, "Veteran", "Combiflamer", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.TERMINATOR, "Terminator", "Power Fist", "Storm Bolter", "Terminator Armour", "", ""); - load_default_gear(eROLE.CAPTAIN, "Captain", "Power Sword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Iron Halo"); - load_default_gear(eROLE.DREADNOUGHT, "Dreadnought", "Close Combat Weapon", "Lascannon", "Dreadnought", "", ""); - load_default_gear(eROLE.CHAMPION, "Champion", "Power Sword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Combat Shield"); - load_default_gear(eROLE.TACTICAL, "Tactical", "Bolter", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.DEVASTATOR, "Devastator", "", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.ASSAULT, "Assault", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "Jump Pack", ""); - load_default_gear(eROLE.ANCIENT, "Ancient", "Company Standard", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.SCOUT, "Scout", "Bolter", "Combat Knife", "Scout Armour", "", ""); - load_default_gear(eROLE.CHAPLAIN, "Chaplain", "Crozius Arcanum", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Rosarius"); - load_default_gear(eROLE.APOTHECARY, "Apothecary", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Narthecium"); - load_default_gear(eROLE.TECHMARINE, "Techmarine", "Omnissian Axe", "Bolt Pistol", _hi_qual_armour, "Servo-arm", ""); - load_default_gear(eROLE.LIBRARIAN, "Librarian", "Force Staff", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Psychic Hood"); - load_default_gear(eROLE.SERGEANT, "Sergeant", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); - load_default_gear(eROLE.VETERANSERGEANT, "Veteran Sergeant", "Chainsword", "Plasma Pistol", STR_ANY_POWER_ARMOUR, "", ""); - obj_ini.role[101] = obj_ini.role[100]; - if (scr_has_disadv("Psyker Intolerant")) { - race[defaults_slot][eROLE.LIBRARIAN] = 0; - } + setup_default_gears(); + if (variable_instance_exists(obj_creation, "custom_roles")) { var c_roles = obj_creation.custom_roles; var possible_custom_roles = [ @@ -1749,7 +1712,7 @@ function scr_initialize_custom() { var _roles_player = player_role_data; var _default_player = default_role_data; - for (var i = 1; i < 20; i++) { + for (var i = 0; i < 20; i++) { if (_roles_player[i].role == "") { continue; } @@ -1978,14 +1941,6 @@ function scr_initialize_custom() { #region Chapter HQ for (var c = 0; c < 11; c++) { for (var i = 0; i < 501; i++) { - race[c][i] = 1; - name[c][i] = ""; - role[c][i] = ""; - wep1[c][i] = ""; - wep2[c][i] = ""; - armour[c][i] = ""; - gear[c][i] = ""; - mobi[c][i] = ""; TTRPG[c][i] = new TTRPG_stats("chapter", c, i, "blank"); TTRPG[c][i].age = ((millenium * 1000) + year) - 10; } @@ -1993,10 +1948,10 @@ function scr_initialize_custom() { // Chapter Master // This needs work - name[_company_i][_marine_i] = obj_creation.chapter_master_name; var cm_equip = load_chapter_master_equipment(); var chapter_master = add_unit_to_company("chapter_master", _company_i, _marine_i, roles.chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); + _forge_master.set_name(obj_creation.chapter_master_name); repeat (cm_equip.bionics) { chapter_master.add_bionics("none", "standard", false); } @@ -2036,8 +1991,9 @@ function scr_initialize_custom() { commands = 1; // Forge Master - name[_company_i][_marine_i] = obj_creation.fmaster; + var _forge_master = add_unit_to_company("marine", _company_i, _marine_i, "Forge Master", eROLE.TECHMARINE, "Infernus Pistol", "Omnissian Axe", "default", "Servo-harness", _hq_armour); + _forge_master.set_name(obj_creation.fmaster); if (_forge_master.technology < 40) { _forge_master.technology = 40; } @@ -2058,8 +2014,8 @@ function scr_initialize_custom() { // Master of Sanctity (Chaplain) if (chaplains > 0) { - name[_company_i][_marine_i] = high_chaplain_name; var _hchap = add_unit_to_company("marine", _company_i, _marine_i, "Master of Sanctity", eROLE.CHAPLAIN, "default", "Plasma Pistol", "default", "default", _hq_armour); + _hchap.set_name(obj_creation.high_chaplain_name); _hchap.edit_corruption(-100); if (_hchap.piety < 45) { _hchap.piety = 45; @@ -2070,16 +2026,16 @@ function scr_initialize_custom() { } // Maser of the Apothecarion (Apothecary) - name[_company_i][_marine_i] = obj_creation.hapothecary; var _hapoth = add_unit_to_company("marine", _company_i, _marine_i, "Master of the Apothecarion", eROLE.APOTHECARY, "default", "Plasma Pistol", "default", "default", _hq_armour); + _hapoth.set_name(obj_creation.hapothecary); _hapoth.edit_corruption(0); _marine_i += 1; commands += 1; // Chief Librarian if (!scr_has_disadv("Psyker Intolerant")) { - name[_company_i][_marine_i] = obj_creation.clibrarian; var _clibrarian = add_unit_to_company("marine", _company_i, _marine_i, string("Chief {0}", roles.librarian), eROLE.LIBRARIAN, "default", "Plasma Pistol", "default", "default", _hq_armour); + _clibrarian.set_name(obj_creation.clibrarian); _clibrarian.edit_corruption(0); _clibrarian.psionic = choose(11, 12); _clibrarian.update_powers(); @@ -2548,38 +2504,41 @@ function scr_initialize_custom() { // SPECIALISTS case "captains": + var _cap_gen_name = global.name_generator.ChapterMemberNameGeneration() switch (_coy.coy) { case 1: - name[_coy.coy][_marine_i] = honor_captain_name != "" ? honor_captain_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = honor_captain_name != "" ? honor_captain_name : _cap_gen_name; break; case 2: - name[_coy.coy][_marine_i] = watch_master_name != "" ? watch_master_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = watch_master_name != "" ? watch_master_name : _cap_gen_name; break; case 3: - name[_coy.coy][_marine_i] = arsenal_master_name != "" ? arsenal_master_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = arsenal_master_name != "" ? arsenal_master_name : _cap_gen_name; break; case 4: - name[_coy.coy][_marine_i] = lord_admiral_name != "" ? lord_admiral_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = lord_admiral_name != "" ? lord_admiral_name : _cap_gen_name; break; case 5: - name[_coy.coy][_marine_i] = march_master_name != "" ? march_master_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = march_master_name != "" ? march_master_name : _cap_gen_name; break; case 6: - name[_coy.coy][_marine_i] = rites_master_name != "" ? rites_master_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = rites_master_name != "" ? rites_master_name : _cap_gen_name; break; case 7: - name[_coy.coy][_marine_i] = chief_victualler_name != "" ? chief_victualler_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = chief_victualler_name != "" ? chief_victualler_name : _cap_gen_name; break; case 8: - name[_coy.coy][_marine_i] = lord_executioner_name != "" ? lord_executioner_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = lord_executioner_name != "" ? lord_executioner_name : _cap_gen_name; break; case 9: - name[_coy.coy][_marine_i] = relic_master_name != "" ? relic_master_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = relic_master_name != "" ? relic_master_name : _cap_gen_name; break; case 10: - name[_coy.coy][_marine_i] = recruiter_name != "" ? recruiter_name : global.name_generator.ChapterMemberNameGeneration(); + var _new_name = recruiter_name != "" ? recruiter_name : _cap_gen_name; break; } + var _unit = fetch_unit([_coy.coy ,_marine_i]); + _unit.set_name(_new_name); commands++; _rolename = roles.captain; _erole = eROLE.CAPTAIN; @@ -2846,8 +2805,9 @@ function scr_initialize_custom() { scr_add_item("Chainsword", 20); scr_add_item("Bolt Pistol", 5); scr_add_item("Heavy Weapons Pack", 10); - scr_add_item(wep1[defaults_slot][eROLE.SCOUT], 20); - scr_add_item(wep2[defaults_slot][eROLE.SCOUT], 20); + var _scout_data = player_role_data[eROLE.SCOUT]; + scr_add_item(_scout_data.wep1, 20); + scr_add_item(_scout_data.wep2, 20); scr_add_item("Scout Armour", 20); scr_add_item("MK8 Errant", 1); @@ -3009,49 +2969,19 @@ function add_veh_to_company(name, company, slot, wep1, wep2, wep3, upgrade, acce function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 = "default", wep2 = "default", gear = "default", mobi = "default", armour = "default") { obj_ini.TTRPG[company][slot] = new TTRPG_stats("chapter", company, slot, ttrpg_name); var spawn_unit = fetch_unit([company, slot]); - obj_ini.race[company][slot] = 1; + spawn_unit.update_role(role_name) + spawn_unit.unit_race = 1; spawn_unit.location_string = obj_ini.home_name; - obj_ini.role[company][slot] = role_name; + spawn_unit.update_role(role_name) - if (obj_ini.name[company][slot] == "") { - obj_ini.name[company][slot] = global.name_generator.ChapterMemberNameGeneration(); + if (spawn_unit.name() == "") { + spawn_unit.set_name(global.name_generator.ChapterMemberNameGeneration()) } - if (wep1 != "") { - if (wep1 == "default") { - spawn_unit.update_weapon_one(obj_ini.wep1[obj_ini.defaults_slot][role_id], false, false); - } else { - spawn_unit.update_weapon_one(wep1, false, false); - } - } - if (wep2 != "") { - if (wep2 == "default") { - spawn_unit.update_weapon_two(obj_ini.wep2[obj_ini.defaults_slot][role_id], false, false); - } else { - spawn_unit.update_weapon_two(wep2, false, false); - } - } - if (armour != "") { - if (armour == "default") { - spawn_unit.update_armour(obj_ini.armour[obj_ini.defaults_slot][role_id], false, false); - } else { - spawn_unit.update_armour(armour, false, false); - } - } - if (gear != "") { - if (gear == "default") { - spawn_unit.update_gear(obj_ini.gear[obj_ini.defaults_slot][role_id], false, false); - } else { - spawn_unit.update_gear(gear, false, false); - } - } - if (mobi != "") { - if (mobi == "default") { - spawn_unit.update_mobility_item(obj_ini.mobi[obj_ini.defaults_slot][role_id], false, false); - } else { - spawn_unit.update_mobility_item(mobi, false, false); - } - } + spawn_unit.set_default_equipment(false,false); + + update_role_data_wth_defaults(); + if (ttrpg_name == "marine" || ttrpg_name == "scout") { spawn_unit.marine_assembling(); } else { diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index c75e7e45ec..fdca563ca2 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -28,14 +28,6 @@ function scr_kill_unit(company, unit_slot) { } function scr_wipe_unit(company, unit_slot) { - array_set(obj_ini.race[company], unit_slot, 0); - array_set(obj_ini.name[company], unit_slot, ""); - array_set(obj_ini.wep1[company], unit_slot, ""); - array_set(obj_ini.wep2[company], unit_slot, ""); - array_set(obj_ini.role[company], unit_slot, ""); - array_set(obj_ini.armour[company], unit_slot, ""); - array_set(obj_ini.gear[company], unit_slot, ""); - array_set(obj_ini.mobi[company], unit_slot, ""); array_set(obj_ini.TTRPG[company], unit_slot, undefined); } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 62ba8fa5ad..323a36e1aa 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -149,6 +149,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} unit_health = 0; bionics = 0; size = 0; + unit_race = 1; // Progression experience = 0; @@ -189,7 +190,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} //takes dict and plumbs dict values into unit struct if (array_contains(variable_struct_get_names(global.base_stats), class)) { - load_json_data(global.base_stats[$ class]); + move_data_to_current_scope(global.base_stats[$ class] , true); } var stats = [ @@ -227,7 +228,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } if (struct_exists(self, "start_gear")) { - if (base_group != "marine") { + if (base_group != "astartes") { alter_equipment(start_gear, false, false); } else { alter_equipment(start_gear, true, true); @@ -428,6 +429,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; current_role = ""; + static role = function() { return current_role; }; @@ -806,7 +808,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static race = function() { - return obj_ini.race[company][marine_number]; + return unit_race; }; static alter_loyalty = function(alt_val) { @@ -952,10 +954,15 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } array_push(epithets, epithet); }; - static name = function() { + unit_name = ""; + static name = function(update) { return obj_ini.name[company][marine_number]; }; // get marine name + static set_name = function(val){ + unit_name = val; + } + static set_name = function(new_name) { obj_ini.name[company][marine_number] = new_name; return new_name; @@ -2052,17 +2059,24 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } }; - static set_default_equipment = function(from_armoury = true, to_armoury = true, quality = "any") { - var role_match = -1; + static get_role_data = function(){ for (var i = 0; i < 24; i++) { - if (obj_ini.role[100][i] == role()) { - role_match = i; - break; + var _role_data == obj_ini.player_role_data[i]; + if (_role_data.role == role()) { + return _role_data; } } - if (role_match != -1) { - alter_equipment({"wep1": obj_ini.wep1[100][role_match], "wep2": obj_ini.wep2[100][role_match], "mobi": obj_ini.mobi[100][role_match], "armour": obj_ini.armour[100][role_match], "gear": obj_ini.gear[100][role_match]}, from_armoury, to_armoury, quality); + return undefined; + } + + static set_default_equipment = function(from_armoury = true, to_armoury = true, quality = "any") { + var role_match = -1; + var _data = get_role_data() + if (is_undefined(_data)){ + return "no_role_found"; } + + alter_equipment(_data, from_armoury, to_armoury, quality); }; static equipped_artifacts = function() { diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index 8cca473cbf..ee58b5d1d6 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -321,31 +321,33 @@ function calculate_equipment_needs() { req_wep2_num = units; } else { for (var i = 2; i < 20; i++) { - if (obj_ini.role[100][i] == rall) { - req_armour = obj_ini.armour[100][i]; + var _role = obj_ini.player_role_data; + if (_role.role == rall) { + req_armour = _role.armour; req_armour_num = units; - req_wep1 = obj_ini.wep1[100][i]; + req_wep1 = _role.wep1; req_wep1_num = units; - req_wep2 = obj_ini.wep2[100][i]; + req_wep2 = _role.wep2; req_wep2_num = units; - req_mobi = obj_ini.mobi[100][i]; + req_mobi = _role.mobi; req_mobi_num = units; - req_gear = obj_ini.gear[100][i]; + req_gear = _role.gear; req_gear_num = units; break; } } } - if (rall == obj_ini.role[100][6]) { + var _dread_role = obj_ini.player_role_data[eROLE.DREADNOUGHT]; + if (rall == _dread_role.role) { req_armour = "Dreadnought"; req_armour_num = units; - req_wep1 = obj_ini.wep1[100][6]; + req_wep1 = _dread_role.wep1; req_wep1_num = units; - req_wep2 = obj_ini.wep2[100][6]; + req_wep2 = _dread_role.wep2; req_wep2_num = units; } - if (rall == $"Venerable {obj_ini.role[100][6]}") { + if (rall == $"Venerable {_dread_role.role}") { req_armour = ""; req_armour_num = 0; req_wep1 = ""; diff --git a/scripts/scr_powers/scr_powers.gml b/scripts/scr_powers/scr_powers.gml index ebd8f94b50..41b6c4761e 100644 --- a/scripts/scr_powers/scr_powers.gml +++ b/scripts/scr_powers/scr_powers.gml @@ -521,7 +521,7 @@ function power_conditions_check(conditions_array) { /// @self Asset.GMObject.obj_creation function player_select_powers() { - if (race[100][17] != 0) { + if (player_role_data[eROLE.LIBRARIAN].available_to_player) { var _starting_powers = global.psy_disciplines_starting; var _discipline_index = array_get_index(_starting_powers, discipline); if (_discipline_index == -1) { diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index 90e8856209..f28b818342 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -1,14 +1,58 @@ -load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { - default_role_data[_role_id] = { - role : _role_name, - wep1 : _wep1, - wep2 : _wep2, - armour : _armour, - mobi : _mobi, - gear : _gear, - race : 1 - }} -}; + + +function setup_default_gears = function(){ + load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { + default_role_data[_role_id] = { + role : _role_name, + wep1 : _wep1, + wep2 : _wep2, + armour : _armour, + mobi : _mobi, + gear : _gear, + available_to_player : 1 + }} + }; + load_default_gear(eROLE.HONOURGUARD, "Honour Guard", "Power Sword", "Bolter", "Artificer Armour", "", ""); + load_default_gear(eROLE.VETERAN, "Veteran", "Combiflamer", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); + load_default_gear(eROLE.TERMINATOR, "Terminator", "Power Fist", "Storm Bolter", "Terminator Armour", "", ""); + load_default_gear(eROLE.CAPTAIN, "Captain", "Power Sword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Iron Halo"); + load_default_gear(eROLE.DREADNOUGHT, "Dreadnought", "Dreadnought Lightning Claw", "Twin Linked Lascannon", "Dreadnought", "", ""); + load_default_gear(eROLE.CHAMPION, "Champion", "Power Sword", STR_ANY_POWER_ARMOUR, STR_ANY_POWER_ARMOUR, "", "Combat Shield"); + load_default_gear(eROLE.TACTICAL, "Tactical", "Bolter", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); + load_default_gear(eROLE.DEVASTATOR, "Devastator", "", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); + load_default_gear(eROLE.ASSAULT, "Assault", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "Jump Pack", ""); + load_default_gear(eROLE.ANCIENT, "Ancient", "Company Standard", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); + load_default_gear(eROLE.SCOUT, "Scout", "Bolter", "Combat Knife", "Scout Armour", "", ""); + load_default_gear(eROLE.CHAPLAIN, "Chaplain", "Crozius Arcanum", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Rosarius"); + load_default_gear(eROLE.APOTHECARY, "Apothecary", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Narthecium"); + load_default_gear(eROLE.TECHMARINE, "Techmarine", "Power Axe", "Bolt Pistol", "Artificer Armour", "Servo-arm", ""); + load_default_gear(eROLE.LIBRARIAN, "Librarian", "Force Staff", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Psychic Hood"); + load_default_gear(eROLE.SERGEANT, "Sergeant", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); + load_default_gear(eROLE.VETERANSERGEANT, "Veteran Sergeant", "Chainsword", "Plasma Pistol", STR_ANY_POWER_ARMOUR, "", ""); +} + +function update_role_data_wth_defaults(){ + for (var i = 0; i < array_length(player_role_data); i++) { + var _role_data = player_role_data[i]; + var _default_data = default_role_data[i]; + var _keys = global.role_data_keys; + for (var k=0;k= 1) && (target_comp <= 10)) { - obj_ini.veh_race[target_comp][vehi] = obj_ini.veh_race[veh_data[0]][veh_data[1]]; - obj_ini.veh_loc[target_comp][vehi] = obj_ini.veh_loc[veh_data[0]][veh_data[1]]; - obj_ini.veh_role[target_comp][vehi] = obj_ini.veh_role[veh_data[0]][veh_data[1]]; - obj_ini.veh_wep1[target_comp][vehi] = obj_ini.veh_wep1[veh_data[0]][veh_data[1]]; - obj_ini.veh_wep2[target_comp][vehi] = obj_ini.veh_wep2[veh_data[0]][veh_data[1]]; - obj_ini.veh_wep3[target_comp][vehi] = obj_ini.veh_wep3[veh_data[0]][veh_data[1]]; - obj_ini.veh_upgrade[target_comp][vehi] = obj_ini.veh_upgrade[veh_data[0]][veh_data[1]]; - obj_ini.veh_acc[target_comp][vehi] = obj_ini.veh_acc[veh_data[0]][veh_data[1]]; - obj_ini.veh_hp[target_comp][vehi] = obj_ini.veh_hp[veh_data[0]][veh_data[1]]; - obj_ini.veh_chaos[target_comp][vehi] = obj_ini.veh_chaos[veh_data[0]][veh_data[1]]; - obj_ini.veh_lid[target_comp][vehi] = obj_ini.veh_lid[veh_data[0]][veh_data[1]]; - obj_ini.veh_wid[target_comp][vehi] = obj_ini.veh_wid[veh_data[0]][veh_data[1]]; - - destroy_vehicle(veh_data[0], veh_data[1]); - - vehi++; + } + //move squad + if (moveable) { + for (var mem = 0; mem < array_length(move_members); mem++) { + obj_controller.man_sel[array_index + mem] = 0; + var member_unit = fetch_unit(move_members[mem]); + if (!is_struct(member_unit)) { + continue; + } + unit.move_to_company(target_comp, false); + scr_move_unit_info(member_unit.company, target_comp, member_unit.marine_number, mahreens, false); + _unit.squad = move_squad; + squad.members[mem][0] = _unit.company; + squad.members[mem][1] = _unit.marine_number; } + squad.base_company = target_comp; + } + } else { + moveable = false; + } + //move individual + if (!moveable) { + unit.move_to_company(target_comp) + } + } + + // The MAHREENS and TARGET/FROM seems to check out + for (var w = 0; w < array_length(obj_controller.display_unit); w++) { + if (!obj_controller.man_sel[w]) { + continue; + } + if (obj_controller.man[w] == "man" && is_struct(obj_controller.display_unit[w])) { + transfer_unit(w); + } else if (obj_controller.man[w] == "vehicle" && is_array(obj_controller.display_unit[w])) { + // This seems to execute the correct number of times + var veh_data = obj_controller.display_unit[w]; + // Check if the target company is within the allowed range + if ((target_comp >= 1) && (target_comp <= 10)) { + obj_ini.veh_race[target_comp][vehi] = obj_ini.veh_race[veh_data[0]][veh_data[1]]; + obj_ini.veh_loc[target_comp][vehi] = obj_ini.veh_loc[veh_data[0]][veh_data[1]]; + obj_ini.veh_role[target_comp][vehi] = obj_ini.veh_role[veh_data[0]][veh_data[1]]; + obj_ini.veh_wep1[target_comp][vehi] = obj_ini.veh_wep1[veh_data[0]][veh_data[1]]; + obj_ini.veh_wep2[target_comp][vehi] = obj_ini.veh_wep2[veh_data[0]][veh_data[1]]; + obj_ini.veh_wep3[target_comp][vehi] = obj_ini.veh_wep3[veh_data[0]][veh_data[1]]; + obj_ini.veh_upgrade[target_comp][vehi] = obj_ini.veh_upgrade[veh_data[0]][veh_data[1]]; + obj_ini.veh_acc[target_comp][vehi] = obj_ini.veh_acc[veh_data[0]][veh_data[1]]; + obj_ini.veh_hp[target_comp][vehi] = obj_ini.veh_hp[veh_data[0]][veh_data[1]]; + obj_ini.veh_chaos[target_comp][vehi] = obj_ini.veh_chaos[veh_data[0]][veh_data[1]]; + obj_ini.veh_lid[target_comp][vehi] = obj_ini.veh_lid[veh_data[0]][veh_data[1]]; + obj_ini.veh_wid[target_comp][vehi] = obj_ini.veh_wid[veh_data[0]][veh_data[1]]; + + destroy_vehicle(veh_data[0], veh_data[1]); + + vehi++; } } } diff --git a/scripts/scr_ui_settings/scr_ui_settings.gml b/scripts/scr_ui_settings/scr_ui_settings.gml index c805e88897..a66973f953 100644 --- a/scripts/scr_ui_settings/scr_ui_settings.gml +++ b/scripts/scr_ui_settings/scr_ui_settings.gml @@ -861,6 +861,8 @@ function scr_draw_mass_equip_gui() { var column_width = 146; var column_gap = 3; + var _role = player_role_data[role]; + for (var h = 0; h < array_length(item_name); h++) { if (h > 0 && h % items_per_column == 0) { x3 += column_width; @@ -883,29 +885,8 @@ function scr_draw_mass_equip_gui() { if (mouse_button_clicked()) { var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; + _role[$ global.unit_equip_slots[tab]] = buh; - switch (tab) { - // slots - case 0: - obj_ini.wep1[100][role] = buh; - break; - case 1: - obj_ini.wep2[100][role] = buh; - break; - case 2: - obj_ini.armour[100][role] = buh; - // No bikes or jump packs for Terminators - if (array_contains(global.list_terminator_armour, buh) || buh == STR_ANY_TERMINATOR_ARMOUR) { - obj_ini.mobi[100][role] = ""; - } - break; - case 3: - obj_ini.gear[100][role] = buh; - break; - case 4: - obj_ini.mobi[100][role] = buh; - break; - } tab = -1; refresh = true; with (obj_controller) { From 92019a343f60b8e8b2146f3202c167c9373f9b79 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 16:05:44 +0100 Subject: [PATCH 19/82] remove legacy scripts --- scripts/scr_UnitGroup/scr_UnitGroup.gml | 8 ++++ scripts/scr_add_man/scr_add_man.gml | 9 ----- scripts/scr_after_combat/scr_after_combat.gml | 1 - .../scr_bionics_count/scr_bionics_count.gml | 40 ------------------- scripts/scr_company_view/scr_company_view.gml | 14 ++----- scripts/scr_event_dudes/scr_event_dudes.gml | 9 ++--- .../scr_inquisition_inspection.gml | 25 ++++-------- scripts/scr_kill_unit/scr_kill_unit.gml | 2 +- scripts/scr_marine_count/scr_marine_count.gml | 39 ------------------ .../scr_mechanicus_missions.gml | 5 ++- .../scr_mission_functions.gml | 2 +- scripts/scr_ui_settings/scr_ui_settings.gml | 2 +- 12 files changed, 28 insertions(+), 128 deletions(-) diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 38cd93048a..0c347631f4 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -41,6 +41,14 @@ function UnitGroup(units) constructor { return false; }; + static tally_attr = function(attrib){ + var _tally = 0; + for (var i = 0; i < array_length(units); i++) { + _tally += units[i][$ attrib]; + } + return _tally + } + static get_from = function(search_conditions = {}, as_UnitGroup = true, remove_from = false) { var _wanted = []; var conditions = new SearchConditions(search_conditions); diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index 9faaeb66ab..e3e6618b7a 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -27,43 +27,35 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption case "Skitarii": spawn_exp = 10; _unit = new TTRPG_stats("mechanicus", target_company, _company_slot, "skitarii"); - _unit.unit_race = 3 break; case "Techpriest": spawn_exp = 100; - obj_ini.race[target_company][_company_slot] = 3; _unit = new TTRPG_stats("mechanicus", target_company, _company_slot, "tech_priest"); break; case "Crusader": spawn_exp = 10; - obj_ini.race[target_company][_company_slot] = 4; _unit = new TTRPG_stats("inquisition", target_company, _company_slot, "inquisition_crusader"); break; // TODO: Implement Sanctioned Psyker (Race 4, Psychic powers, Force Staff) case "Sister of Battle": spawn_exp = 20; - obj_ini.race[target_company][_company_slot] = 5; _unit = new TTRPG_stats("adeptus_sororitas", target_company, _company_slot, "sister_of_battle"); break; case "Sister Hospitaler": spawn_exp = 50; - obj_ini.race[target_company][_company_slot] = 5; _unit = new TTRPG_stats("adeptus_sororitas", target_company, _company_slot, "sister_hospitaler"); break; // TODO: Implement Prioress (Race 5, Sororitas leader gear/stats) case "Ranger": spawn_exp = 180; - obj_ini.race[target_company][_company_slot] = 6; _unit = new TTRPG_stats("Eldari", target_company, _company_slot, "eldar_ranger"); break; case "Ork Sniper": spawn_exp = 20; - obj_ini.race[target_company][_company_slot] = eFACTION.ORK; _unit = new TTRPG_stats("ork", target_company, _company_slot, "ork_sniper"); break; case "Flash Git": spawn_exp = 40; - obj_ini.race[target_company][_company_slot] = eFACTION.ORK; _unit = new TTRPG_stats("ork", target_company, _company_slot, "flash_git"); break; // TODO: Implement Warboss (Race 7) @@ -99,7 +91,6 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption } if (!array_contains(non_marine_roles, man_role)) { - obj_ini.race[target_company][_company_slot] = eFACTION.PLAYER; if (man_role == obj_ini.role[100][12]) { _gear = { wep2: obj_ini.wep2[100][12], diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index 0b16e5fe91..d777686458 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -367,7 +367,6 @@ function after_combat_dead_marine_equipment_recovered(unit) { if (obj_ncombat.dropping && obj_ncombat.defeat) { _specific_item_chance = 9999; } - //if (obj_ini.race[marine_co[i], marine_id[i]]!=1) then _specific_item_chance=9999; var _specific_type_recovery = basic_recover_chance + _item.recovery_chance; diff --git a/scripts/scr_bionics_count/scr_bionics_count.gml b/scripts/scr_bionics_count/scr_bionics_count.gml index 61776799dc..e69de29bb2 100644 --- a/scripts/scr_bionics_count/scr_bionics_count.gml +++ b/scripts/scr_bionics_count/scr_bionics_count.gml @@ -1,40 +0,0 @@ -function scr_bionics_count(argument0, argument1, argument2, argument3) { - // argument0: "star" or "ship" or "all" - // argument1: name or all - // argument2: planet number - // argument3: "total" or "number" - total or number of marines WITH bionics - - var com, i, count, coom; - count = 0; - i = 0; - com = 0; - coom = -999; - - repeat (11) { - i = 0; - repeat (300) { - i += 1; - var _unit = fetch_unit([com, i]); - if (!is_struct(_unit)) { - continue; - } - if (argument0 == "star") { - if ((obj_ini.race[com][i] == 1) && (_unit.location_string == argument1) && (_unit.planet_location == argument2)) { - if (argument3 == "total") { - count += _unit.bionics; - } - if ((argument3 == "number") && (_unit.bionics > 0)) { - count += 1; - } - } - } - } - com += 1; - } - - return count; - - // temp[36]=scr_role_count("Chaplain","field"); - // temp[37]=scr_role_count("Chaplain","home"); - // temp[37]=scr_role_count("Chaplain",""); -} diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index f4c25b1e27..fb9ea42241 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -43,22 +43,14 @@ function reset_manage_arrays() { function find_company_open_slot(target_company) { var good = -1; - for (var i = 0; i < array_length(obj_ini.name[target_company]); i++) { - if ((obj_ini.name[target_company][i] == "") || (obj_ini.role[target_company][i] == "")) { + var _company_length = array_length(obj_ini.name[target_company]); + for (var i = 0; i < _company_length; i++) { + if (is_undefined(obj_ini.TTRPG[target_company]) { good = i; break; } } if (good == -1) { - good = array_length(obj_ini.name[target_company]); - array_push(obj_ini.race[target_company], 0); - array_push(obj_ini.name[target_company], ""); - array_push(obj_ini.role[target_company], ""); - array_push(obj_ini.wep1[target_company], ""); - array_push(obj_ini.wep2[target_company], ""); - array_push(obj_ini.armour[target_company], ""); - array_push(obj_ini.gear[target_company], ""); - array_push(obj_ini.mobi[target_company], ""); array_push(obj_ini.TTRPG[target_company], undefined); good = array_length(obj_ini.TTRPG[target_company]) - 1; } diff --git a/scripts/scr_event_dudes/scr_event_dudes.gml b/scripts/scr_event_dudes/scr_event_dudes.gml index a82c2e2a78..5ae6972cb1 100644 --- a/scripts/scr_event_dudes/scr_event_dudes.gml +++ b/scripts/scr_event_dudes/scr_event_dudes.gml @@ -59,13 +59,9 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { } if ((is_planet == 0) && (unit.ship_location == location_id)) { - if ((obj_ini.race[coh][ide] == 1) || (obj_ini.race[coh][ide] == 5)) { adding = true; - } } else if ((is_planet == 1) && (unit.location_string == system_name) && (unit.planet_location == location_id)) { - if ((obj_ini.race[coh][ide] == 1) || (obj_ini.race[coh][ide] == 5)) { adding = true; - } } if (obj_ini.role[coh][ide] == obj_ini.role[100][6]) { @@ -123,9 +119,10 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { if (obj_controller.trim == 3) { obj_event.avatar_image[obj_event.avatars] = 2; } - if (obj_ini.race[coh][ide] == 5) { + /*if (obj_ini.race[coh][ide] == 5) { obj_event.avatar_image[obj_event.avatars] = 3; - } + }*/ + //replace with check agaiinsst role or base_group obj_event.avatar_co[obj_event.avatars] = coh; obj_event.avatar_id[obj_event.avatars] = ide; } diff --git a/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml b/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml index 50018d362f..df458c20f0 100644 --- a/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml +++ b/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml @@ -106,28 +106,17 @@ function inquisitor_inspection_structure() constructor { var _units_to_check = _units_override == undefined ? units : _units_override; for (var i = 0; i < array_length(_units_to_check); i++) { - var unit = _units_to_check[i]; - if (unit == undefined) { - continue; - } - if (unit.name() == "") { + var _unit = _units_to_check[i]; + if (_unit == undefined) { continue; } // Xenos merc checks: ork base_group or Rangers of non-Imperial race - if (unit.base_group == "ork") { - add_xenos_mercs(unit.role()); - } else if (unit.role() == "Ranger") { - // example race check - adapt as needed - var ca = unit.company_index != undefined ? unit.company_index : 0; - var ia = unit.instance_index != undefined ? unit.instance_index : 0; - if (obj_ini.race[ca][ia] != 1) { - add_xenos_mercs(unit.role()); - } - } - + if (_unit.base_group == "ork" || _unit.base_group == "eldar") { + add_xenos_mercs(_unit.role()); + } // Check equipped artifacts - var artis = unit.equipped_artifacts(); + var artis = _unit.equipped_artifacts(); for (var art = 0; art < array_length(artis); art++) { var artifact_index = artis[art]; if (artifact_index == undefined) { @@ -578,7 +567,7 @@ function inquisition_inspection_loyalty(inspection_type) { _inspect_results.finds.heresy += player_inspection_fleet.hurssy; } - var unit; + var _unit; if (player_inspection_fleet.hurssy > 0) { hurr += player_inspection_fleet.hurssy; } diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index fdca563ca2..d3ca4fc6aa 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -52,7 +52,7 @@ function kill_and_recover(company, unit_slot, equipment = true, gene_seed_collec obj_controller.gene_seed += 1; } } - if (obj_ini.race[company][unit_slot] == 1) { + if (obj_ini.base_group == "astartes") { if (is_specialist(obj_ini.role[company][unit_slot])) { obj_controller.command -= 1; } else { diff --git a/scripts/scr_marine_count/scr_marine_count.gml b/scripts/scr_marine_count/scr_marine_count.gml index 091d55b4d6..e69de29bb2 100644 --- a/scripts/scr_marine_count/scr_marine_count.gml +++ b/scripts/scr_marine_count/scr_marine_count.gml @@ -1,39 +0,0 @@ -function scr_marine_count(argument0, argument1, argument2) { - // argument0: star object - // argument1: planet number - // argument2: stop check at - - var com, ide, check, sca, unit; - com = -1; - ide = 0; - check = 0; - sca = 9999; - if (argument2 > 0) { - sca = argument2; - } - - repeat (11) { - if (check < sca) { - com += 1; - ide = 0; - repeat (300) { - if (obj_ini.name[com][ide] == "") { - continue; - } - unit = fetch_unit([com, ide]); - if (!is_struct(unit)) { - ide += 1; - continue; - } - if (check < sca) { - ide += 1; - if ((unit.role() != "") && (obj_ini.race[com][ide] <= 5) && (unit.location_string == argument0.name) && (unit.planet_location == argument1)) { - check += 1; - } - } - } - } - } - - return check; -} diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index ebd77afd93..a1c2443afa 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -16,7 +16,10 @@ function mechanicus_missions_end_turn(planet) { var bionics_planet_slot = has_problem_planet_with_time(planet, "mech_bionics"); if (bionics_planet_slot > -1) { var check1 = scr_bionics_count("star", name, planet, "number"); - if (check1 >= 10) { + var _pdata = get_planet_data(planet); + var _units = _pdata.collect_planet_group(); + var _bionics = _units.tally_attr("bionics"); + if (_bionics >= 10) { var _prob_data = p_problem_other_data[planet][bionics_planet_slot]; var percent_complete = increment_mission_completion(_prob_data); scr_alert("", $"mission", $"Mechanicus Mission on {planet_numeral_name(planet, id)} is {floor(percent_complete)}% complete.", 0, 0); diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 56f4aae9e1..30f1bedfdd 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -225,7 +225,7 @@ function problem_end_turn_checks() { for (var co = 0; co <= obj_ini.companies; co++) { me = 0; for (me = 0; me < array_length(obj_ini.role[co]); me++) { - if ((obj_ini.race[co][me] == 1) && (obj_ini.role[co][me] != "")) { + if (obj_ini.base_group == "astartes") { _unit = fetch_unit([co, me]); if (!is_struct(_unit)) { continue; diff --git a/scripts/scr_ui_settings/scr_ui_settings.gml b/scripts/scr_ui_settings/scr_ui_settings.gml index a66973f953..86a42c69c3 100644 --- a/scripts/scr_ui_settings/scr_ui_settings.gml +++ b/scripts/scr_ui_settings/scr_ui_settings.gml @@ -74,7 +74,7 @@ function setup_ui_chapter_settings() { for (var i = 0; i < array_length(_role_order); i++) { var _role_id = _role_order[i]; - var _active = obj_ini.race[100][_role_id] != 0; + var _active = obj_ini.player_role_data[_role_id].available_to_player; var _button = new UnitButtonObject({ style: "pixel", x1: _but_x, From f90c484f7a3d350ce1728452cf9b2283e46cede4 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 16:22:52 +0100 Subject: [PATCH 20/82] most roles updated to new system --- objects/obj_controller/Alarm_5.gml | 7 +- objects/obj_controller/Alarm_6.gml | 34 +++--- objects/obj_controller/Mouse_50.gml | 2 +- objects/obj_controller/Step_0.gml | 2 +- objects/obj_dropdown_sel/Step_0.gml | 2 +- objects/obj_enunit/Alarm_0.gml | 2 +- objects/obj_enunit/Alarm_1.gml | 10 +- objects/obj_ncombat/Alarm_1.gml | 16 +-- objects/obj_ncombat/Alarm_7.gml | 8 +- objects/obj_p_assra/Alarm_0.gml | 2 +- objects/obj_p_ship/Alarm_0.gml | 2 +- objects/obj_pnunit/Alarm_3.gml | 2 +- objects/obj_popup/Create_0.gml | 24 ++-- scripts/is_specialist/is_specialist.gml | 8 +- scripts/scr_UnitGroup/scr_UnitGroup.gml | 2 +- scripts/scr_add_artifact/scr_add_artifact.gml | 2 +- scripts/scr_add_man/scr_add_man.gml | 2 +- scripts/scr_after_combat/scr_after_combat.gml | 6 +- .../scr_chapter_random/scr_chapter_random.gml | 2 +- scripts/scr_civil_roster/scr_civil_roster.gml | 6 +- scripts/scr_company_view/scr_company_view.gml | 12 +- scripts/scr_crusade/scr_crusade.gml | 4 +- .../scr_destroy_planet/scr_destroy_planet.gml | 4 +- scripts/scr_dialogue/scr_dialogue.gml | 4 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 2 +- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 8 +- scripts/scr_event_dudes/scr_event_dudes.gml | 4 +- scripts/scr_event_gossip/scr_event_gossip.gml | 6 +- scripts/scr_flavor/scr_flavor.gml | 8 +- scripts/scr_flavor2/scr_flavor2.gml | 4 +- scripts/scr_income/scr_income.gml | 2 +- .../scr_initialize_custom.gml | 2 +- scripts/scr_kill_unit/scr_kill_unit.gml | 2 +- .../scr_manage_task_selector.gml | 6 +- .../scr_marine_struct/scr_marine_struct.gml | 16 +-- scripts/scr_master_loc/scr_master_loc.gml | 2 +- .../scr_mechanicus_missions.gml | 2 +- .../scr_mission_functions.gml | 2 +- scripts/scr_perils_table/scr_perils_table.gml | 2 +- .../scr_player_combat_weapon_stacks.gml | 2 +- .../scr_player_fleet_combat_functions.gml | 2 +- scripts/scr_promote/scr_promote.gml | 6 +- scripts/scr_random_event/scr_random_event.gml | 4 +- .../scr_random_marine/scr_random_marine.gml | 2 +- scripts/scr_roster/scr_roster.gml | 4 +- scripts/scr_ship_battle/scr_ship_battle.gml | 20 ++-- scripts/scr_special_view/scr_special_view.gml | 8 +- .../scr_specialist_training.gml | 8 +- scripts/scr_squads/scr_squads.gml | 6 +- scripts/scr_ui_advisors/scr_ui_advisors.gml | 2 +- .../scr_unit_detail_text.gml | 4 +- .../scr_unit_equip_functions.gml | 2 +- scripts/scr_unit_size/scr_unit_size.gml | 2 +- .../scr_unit_spawn_functions.gml | 110 +++++++++--------- 54 files changed, 210 insertions(+), 205 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index a2f8d1cf42..a82cb43bc3 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -82,11 +82,12 @@ try { if (recruit_name[i] == "") { continue; } + var _recruit_role = obj_ini.player_role_data[eROLE.SCOUT] if (recruit_distance[i] <= 0) { recruit_training[i] -= 1; } if (recruit_training[i] <= 0) { - scr_add_man(obj_ini.role[100][12], 10, recruit_exp[i], recruit_name[i], recruit_corruption[i], false, "default", recruit_data[i]); + scr_add_man(_recruit_role.role, 10, recruit_exp[i], recruit_name[i], recruit_corruption[i], false, "default", recruit_data[i]); if (recruit_first == "") { recruit_first = recruit_name[i]; } @@ -106,9 +107,9 @@ try { scr_company_order(10); } if (recruits_finished == 1) { - scr_alert("green", "recruitment", $"{obj_ini.role[100][12]} {recruit_first} has joined X Company.", 0, 0); + scr_alert("green", "recruitment", $"{_recruit_role.role} {recruit_first} has joined X Company.", 0, 0); } else if (recruits_finished > 1) { - scr_alert("green", "recruitment", $"{recruits_finished}x {obj_ini.role[100][12]} have joined X Company.", 0, 0); + scr_alert("green", "recruitment", $"{recruits_finished}x {_recruit_role.role} have joined X Company.", 0, 0); } recruits = total_recruits; diff --git a/objects/obj_controller/Alarm_6.gml b/objects/obj_controller/Alarm_6.gml index 1c8b3d7a04..98e9d90cc5 100644 --- a/objects/obj_controller/Alarm_6.gml +++ b/objects/obj_controller/Alarm_6.gml @@ -32,7 +32,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { // sets up count for the marines if (man[f] == "man") { manz += 1; - if (unit.role() == obj_ini.role[100][5]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { cap += 1; } else if (unit.role() == obj_ini.role[100][15]) { apo += 1; @@ -42,9 +42,9 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { lib += 1; } else if (unit.role() == obj_ini.role[100][16]) { tech += 1; - } else if (unit.role() == obj_ini.role[100][6]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { drea += 1; - } else if (unit.role() == $"Venerable {obj_ini.role[100][6]}") { + } else if (unit.role() == $"Venerable {obj_ini.player_role_data[eROLE.DREADNOUGHT].role}") { vdrea += 1; } else if (unit.role() == obj_ini.role[100][11]) { bear += 1; @@ -54,23 +54,23 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { assa += 1; } else if (unit.role() == obj_ini.role[100][9]) { dev += 1; - } else if (unit.role() == obj_ini.role[100][12]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { sco += 1; - } else if (unit.role() == obj_ini.role[100][2]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { hon += 1; - } else if (unit.role() == obj_ini.role[100][3]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { ve += 1; - } else if (unit.role() == obj_ini.role[100][4]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { ter += 1; } else if (unit.role() == obj_ini.role[100][18]) { sgt++; - } else if (unit.role() == obj_ini.role[100][19]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.VETERANSERGEANT].role) { vet_sgt++; } else if (unit.role() == "Codiciery") { codi += 1; } else if (unit.role() == "Lexicanum") { lexi += 1; - } else if (unit.role() == obj_ini.role[100][eROLE.ANCIENT]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { champ += 1; } } @@ -100,7 +100,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes = ""; // Infantry text if (cap > 0) { - selecting_dudes += string(cap) + " " + string(obj_ini.role[100][5]); + selecting_dudes += string(cap) + " " + string(obj_ini.player_role_data[eROLE.CAPTAIN].role); if (cap > 1) { selecting_dudes += "s"; } @@ -114,7 +114,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (champ > 0) { - selecting_dudes += $"{champ} {obj_ini.role[100][eROLE.ANCIENT]}"; + selecting_dudes += $"{champ} {obj_ini.player_role_data[eROLE.ANCIENT].role}"; if (chap > 1) { selecting_dudes += "s"; } @@ -156,7 +156,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (hon > 0) { - selecting_dudes += string(hon) + " " + string(obj_ini.role[100][2]); + selecting_dudes += string(hon) + " " + string(obj_ini.player_role_data[eROLE.HONOURGUARD].role); if (hon > 1) { selecting_dudes += "s"; } @@ -177,7 +177,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (ve > 0) { - selecting_dudes += string(ve) + " " + string(obj_ini.role[100][3]); + selecting_dudes += string(ve) + " " + string(obj_ini.player_role_data[eROLE.VETERAN].role); if (ve > 1) { selecting_dudes += "s"; } @@ -198,21 +198,21 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (assa > 0) { - selecting_dudes += string(assa) + " " + string(obj_ini.role[100][eROLE.ASSAULT]); + selecting_dudes += string(assa) + " " + string(obj_ini.player_role_data[eROLE.ASSAULT].role); if (sgt > 1) { selecting_dudes += "s"; } selecting_dudes += ", "; } if (sco > 0) { - selecting_dudes += string(sco) + " " + string(obj_ini.role[100][12]); + selecting_dudes += string(sco) + " " + string(obj_ini.player_role_data[eROLE.SCOUT].role); if (sco > 1) { selecting_dudes += "s"; } selecting_dudes += ", "; } if (drea > 0) { - selecting_dudes += string(drea) + " " + string(obj_ini.role[100][6]); + selecting_dudes += string(drea) + " " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role); if (drea > 1) { selecting_dudes += "s"; } @@ -226,7 +226,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (vet_sgt > 0) { - selecting_dudes += string(vet_sgt) + " " + string(obj_ini.role[100][19]); + selecting_dudes += string(vet_sgt) + " " + string(obj_ini.player_role_data[eROLE.VETERANSERGEANT].role); if (vet_sgt > 1) { selecting_dudes += "s"; } diff --git a/objects/obj_controller/Mouse_50.gml b/objects/obj_controller/Mouse_50.gml index 27d51eaff8..521059fcc9 100644 --- a/objects/obj_controller/Mouse_50.gml +++ b/objects/obj_controller/Mouse_50.gml @@ -15,7 +15,7 @@ if ((menu == eMENU.RECLUSIAM) && (cooldown <= 0) && (penitorium > 0)) { cooldown = 20; var c = penit_co[qp], e = penit_id[qp]; - if (obj_ini.role[c][e] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (obj_ini.role[c][e] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { alarm[7] = 5; global.defeat = 3; } diff --git a/objects/obj_controller/Step_0.gml b/objects/obj_controller/Step_0.gml index 53588fe41a..1d2117202a 100644 --- a/objects/obj_controller/Step_0.gml +++ b/objects/obj_controller/Step_0.gml @@ -490,7 +490,7 @@ try { } if (menu == eMENU.DEFAULT && !instances_exist_any([obj_ncombat, obj_fleet_controller])) { - if (!array_contains(obj_ini.role[0], obj_ini.role[100][eROLE.CHAPTERMASTER]) && (alarm[7] == -1)) { + if (!array_contains(obj_ini.role[0], obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) && (alarm[7] == -1)) { alarm[7] = 15; } } diff --git a/objects/obj_dropdown_sel/Step_0.gml b/objects/obj_dropdown_sel/Step_0.gml index 357a042f45..f24f8f4c8c 100644 --- a/objects/obj_dropdown_sel/Step_0.gml +++ b/objects/obj_dropdown_sel/Step_0.gml @@ -129,7 +129,7 @@ if ((target == "event_loc") && (determined_planets == 0)) { if (!is_struct(_unit)) { continue; } - if ((_unit.role() != obj_ini.role[100][6]) && (_unit.role() != "Venerable " + string(obj_ini.role[100][6])) && (_unit.planet_location > 0)) { + if ((_unit.role() != obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (_unit.role() != "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) && (_unit.planet_location > 0)) { var stahp = 0; var first_open = 0; diff --git a/objects/obj_enunit/Alarm_0.gml b/objects/obj_enunit/Alarm_0.gml index f6fc34e44c..e23df448ee 100644 --- a/objects/obj_enunit/Alarm_0.gml +++ b/objects/obj_enunit/Alarm_0.gml @@ -71,7 +71,7 @@ if (!engaged) { var cm_block = noone; with (obj_pnunit) { for (var u = 0; u < array_length(unit_struct); u++) { - if (marine_type[u] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (marine_type[u] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { cm_present = true; cm_index = u; cm_block = id; diff --git a/objects/obj_enunit/Alarm_1.gml b/objects/obj_enunit/Alarm_1.gml index b46eb0e465..c7963912e7 100644 --- a/objects/obj_enunit/Alarm_1.gml +++ b/objects/obj_enunit/Alarm_1.gml @@ -206,7 +206,7 @@ if (obj_ncombat.enemy == eFACTION.PLAYER) { // marine_casting[g] = false; if (((dudes[g] != "") && (dudes_num[g] > 0)) && (dudes_hp[g] > 0)) { - if ((dudes[g] == obj_ini.role[100][6]) || (dudes[g] == "Venerable " + obj_ini.role[100][6]) && (dudes_hp[g] > 0)) { + if ((dudes[g] == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) || (dudes[g] == "Venerable " + obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (dudes_hp[g] > 0)) { dreads += 1; } if (dudes_mobi[g] == "Bike") { @@ -232,10 +232,10 @@ if (obj_ncombat.enemy == eFACTION.PLAYER) { if ((dudes[j] == "") && (open == 0)) { open = j; // Determine if vehicle here - if (dudes[j] == "Venerable " + string(obj_ini.role[100][6])) { + if (dudes[j] == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { dudes_vehicle[j] = 1; } - if (dudes[j] == obj_ini.role[100][6]) { + if (dudes[j] == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { dudes_vehicle[j] = 1; } } @@ -243,7 +243,7 @@ if (obj_ncombat.enemy == eFACTION.PLAYER) { if ((dudes_wep1[g] != "") && (marine_casting[g] == false)) { // Do not add weapons to the roster while casting - if (dudes[g] != obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (dudes[g] != obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { scr_en_weapon(string(dudes_wep1[g]), false, 1, dudes[g], g); } @@ -258,7 +258,7 @@ if (obj_ncombat.enemy == eFACTION.PLAYER) { } } if ((dudes_wep2[g] != "") && (marine_casting[g] == false)) { - if (dudes[g] != obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (dudes[g] != obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { scr_en_weapon(string(dudes_wep2[g]), false, 1, dudes[g], g); } diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index c2a3b31708..18a626a542 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -175,10 +175,10 @@ if ((tacticals > 0) && (veterans == 0)) { } if ((tacticals == 0) && (veterans > 0)) { if (veterans == 1) { - p2 = string(veterans) + " " + string(obj_ini.role[100][3]) + ", "; + p2 = string(veterans) + " " + string(obj_ini.player_role_data[eROLE.VETERAN].role) + ", "; } if (veterans > 1) { - p2 = string(veterans) + " " + string(obj_ini.role[100][3]) + "s, "; + p2 = string(veterans) + " " + string(obj_ini.player_role_data[eROLE.VETERAN].role) + "s, "; } } @@ -253,19 +253,19 @@ if ((temp < 200) && (sgts > 0)) { } if ((temp < 200) && (vet_sgts > 0)) { if (techmarines == 1) { - p2 += string(techmarines) + " " + string(obj_ini.role[100][19]) + ", "; + p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.VETERANSERGEANT].role) + ", "; } if (techmarines > 1) { - p2 += string(techmarines) + " " + string(obj_ini.role[100][19]) + ", "; + p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.VETERANSERGEANT].role) + ", "; } } if (scouts > 0) { if (scouts == 1) { - p2 += string(scouts) + " " + string(obj_ini.role[100][12]) + ", "; + p2 += string(scouts) + " " + string(obj_ini.player_role_data[eROLE.SCOUT].role) + ", "; } if (scouts > 1) { - p2 += string(scouts) + " " + string(obj_ini.role[100][12]) + "s, "; + p2 += string(scouts) + " " + string(obj_ini.player_role_data[eROLE.SCOUT].role) + "s, "; } } @@ -310,10 +310,10 @@ if ((standard_bearers > 1) && (!dropping)) { if (dreadnoughts + predators + land_raiders > 3) { p6 = " Forming up the armoured division is "; if (dreadnoughts == 1) { - p6 += string(dreadnoughts) + " " + string(obj_ini.role[100][6]) + ", "; + p6 += string(dreadnoughts) + " " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role) + ", "; } if (dreadnoughts > 1) { - p6 += string(dreadnoughts) + " " + string(obj_ini.role[100][6]) + "s, "; + p6 += string(dreadnoughts) + " " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role) + "s, "; } if (rhinos == 1) { diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 94a61fd19a..2d9e778b2a 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -54,7 +54,7 @@ try { instance_create(x, y, obj_temp_meeting); var master_present = 0; - var master_index = array_get_index(obj_ini.role[0], obj_ini.role[100][eROLE.CHAPTERMASTER]); + var master_index = array_get_index(obj_ini.role[0], obj_ini.player_role_data[eROLE.CHAPTERMASTER].role); var _fetched_chaos = fetch_unit([0, master_index]); if (!is_struct(_fetched_chaos)) { LOGGER.error($"fetch_unit guardrail triggered for chapter master [0, {master_index}] in cs_meeting post-battle"); @@ -72,10 +72,10 @@ try { if (_unit.planet_location == floor(chaos_meeting)) { good += 1; } - if ((obj_ini.role[co][i] != obj_ini.role[100][6]) && (obj_ini.role[co][i] != "Venerable " + string(obj_ini.role[100][6]))) { + if ((obj_ini.role[co][i] != obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (obj_ini.role[co][i] != "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role))) { good += 1; } - if ((string_count("Dread", obj_ini.armour[co][i]) == 0) || (obj_ini.role[co][i] == obj_ini.role[100][eROLE.CHAPTERMASTER])) { + if ((string_count("Dread", obj_ini.armour[co][i]) == 0) || (obj_ini.role[co][i] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role)) { good += 1; } @@ -85,7 +85,7 @@ try { obj_temp_meeting.present[otm] = 1; obj_temp_meeting.co[otm] = co; obj_temp_meeting.ide[otm] = i; - if (obj_ini.role[co][i] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (obj_ini.role[co][i] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { master_present = 1; } } diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index 2c8abcd699..f3ba4f9562 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -29,7 +29,7 @@ for (o = 0; o < array_length(origin.board_co); o++) { } // obj_fleet.marines_lost+=1; - if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { obj_controller.alarm[7] = 1; if (global.defeat <= 1) { global.defeat = 1; diff --git a/objects/obj_p_ship/Alarm_0.gml b/objects/obj_p_ship/Alarm_0.gml index 39392fdeee..bc2191ebac 100644 --- a/objects/obj_p_ship/Alarm_0.gml +++ b/objects/obj_p_ship/Alarm_0.gml @@ -205,7 +205,7 @@ for (var co = 0; co <= obj_ini.companies; co++) { // Loc 1: in transit // Loc >1: (instance_id), on enemy vessel if (co == 0 && master_present == 0 && i < 100) { - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER] && unit.ship_location == ship_id) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role && unit.ship_location == ship_id) { master_present = 1; obj_fleet.control = true; } diff --git a/objects/obj_pnunit/Alarm_3.gml b/objects/obj_pnunit/Alarm_3.gml index 8525839838..ef9d8c70c9 100644 --- a/objects/obj_pnunit/Alarm_3.gml +++ b/objects/obj_pnunit/Alarm_3.gml @@ -37,7 +37,7 @@ try { _r_roll -= 350; } - if ((marine_dead[raar] == 0) && (marine_type[raar] != "Death Company") && (marine_type[raar] != obj_ini.role[100][eROLE.CHAPTERMASTER]) && (_r_roll <= 4)) { + if ((marine_dead[raar] == 0) && (marine_type[raar] != "Death Company") && (marine_type[raar] != obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) && (_r_roll <= 4)) { r_lost += 1; marine_type[raar] = "Death Company"; obj_ncombat.red_thirst += 1; diff --git a/objects/obj_popup/Create_0.gml b/objects/obj_popup/Create_0.gml index eedec39c70..6eb1d48c3a 100644 --- a/objects/obj_popup/Create_0.gml +++ b/objects/obj_popup/Create_0.gml @@ -139,9 +139,9 @@ get_unit_promotion_options = function() { role_name[1] = obj_ini.role[100][15]; role_exp[1] = 5; spec = 1; - } else if (unit_role == obj_ini.role[100][6]) { + } else if (unit_role == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { //venerable dreadnought - role_name[1] = "Venerable " + string(obj_ini.role[100][6]); + role_name[1] = "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role); role_exp[1] = 400; spec = 0; } else if (unit_role == obj_ini.role[100][14] && global.chapter_name != "Space Wolves" && global.chapter_name != "Iron Hands") { @@ -162,10 +162,10 @@ get_unit_promotion_options = function() { } if (target_comp > 0 && target_comp <= 10 && spec == 0) { if (units == 1) { - if (scr_role_count(obj_ini.role[100][5], "1") == 0) { + if (scr_role_count(obj_ini.player_role_data[eROLE.CAPTAIN].role, "1") == 0) { //captain i += 1; - role_name[i] = obj_ini.role[100][5]; + role_name[i] = obj_ini.player_role_data[eROLE.CAPTAIN].role; role_exp[i] = 80; //all captains are equalish } if (scr_role_count(obj_ini.role[100][11], "1") == 0) { @@ -181,7 +181,7 @@ get_unit_promotion_options = function() { role_exp[i] = company_promote_data[target_comp].exp + 10; //may as well have this liniked to weapon skill } i += 1; - role_name[i] = obj_ini.role[100][6]; //dreadnought + role_name[i] = obj_ini.player_role_data[eROLE.DREADNOUGHT].role; //dreadnought role_exp[i] = 200; } @@ -215,13 +215,13 @@ get_unit_promotion_options = function() { if (target_comp == 1) { i += 1; - role_name[i] = obj_ini.role[100][4]; //terminators + role_name[i] = obj_ini.player_role_data[eROLE.TERMINATOR].role; //terminators role_exp[i] = 100; } if (target_comp == 10) { i += 1; - role_name[i] = obj_ini.role[100][12]; //scouts + role_name[i] = obj_ini.player_role_data[eROLE.SCOUT].role; //scouts role_exp[i] = company_promote_data[target_comp].exp; if (obj_controller.command_set[2] == 0) { role_exp[i] = 0; @@ -230,7 +230,7 @@ get_unit_promotion_options = function() { if (target_comp == 1) { i += 1; - role_name[i] = obj_ini.role[100][3]; //veterans + role_name[i] = obj_ini.player_role_data[eROLE.VETERAN].role; //veterans role_exp[i] = 100; } } else { @@ -247,21 +247,21 @@ get_unit_promotion_options = function() { role_exp[i] = 0; i += 1; - role_name[i] = obj_ini.role[100][4]; //terminators + role_name[i] = obj_ini.player_role_data[eROLE.TERMINATOR].role; //terminators role_exp[i] = 100; i += 1; - role_name[i] = obj_ini.role[100][12]; //scouts + role_name[i] = obj_ini.player_role_data[eROLE.SCOUT].role; //scouts role_exp[i] = 0; i += 1; - role_name[i] = obj_ini.role[100][3]; //veterans + role_name[i] = obj_ini.player_role_data[eROLE.VETERAN].role; //veterans role_exp[i] = 0; } } if ((target_comp == 0 || target_comp > 10) && (spec == 0)) { i += 1; - role_name[i] = obj_ini.role[100][2]; //honor guard + role_name[i] = obj_ini.player_role_data[eROLE.HONOURGUARD].role; //honor guard role_exp[i] = 140; if (obj_controller.command_set[2] == 0) { role_exp[i] = 0; diff --git a/scripts/is_specialist/is_specialist.gml b/scripts/is_specialist/is_specialist.gml index 3fea1b170c..c0343c322e 100644 --- a/scripts/is_specialist/is_specialist.gml +++ b/scripts/is_specialist/is_specialist.gml @@ -17,7 +17,11 @@ /// @description Retrieves the active roles from the game, either from the obj_creation or obj_ini object. /// @returns {Array} function active_roles() { - var _roles = instance_exists(obj_creation) ? obj_creation.role[100] : obj_ini.role[100]; + var _obj = instance_exists(obj_creation) ? obj_creation.player_role_data: obj_ini.player_role_data; + var _roles = []; + for (var i = 0; i < array_length(_obj); i++){ + array_push(_roles, struct_exists(_obj[i], "role") ? _obj[i].role : ""); + } return _roles; } @@ -155,7 +159,7 @@ function role_groups(group, include_trainee = false, include_heads = true) { "Master of Sanctity", $"Chief {_roles[eROLE.LIBRARIAN]}", "Forge Master", - string(obj_ini.role[100][eROLE.CHAPTERMASTER]), + string(obj_ini.player_role_data[eROLE.CHAPTERMASTER].role), "Master of the Apothecarion", ]; break; diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 0c347631f4..59f9feb99d 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -284,7 +284,7 @@ function UnitGroup(units) constructor { //if a new sergeant is needed find the marine with the highest experience in the squad //(which if everything works right should be a marine with the old_guard, seasoned, or ancient trait) - /*and ((squad_fulfilment[$ obj_ini.role[100][8]] > 4)or (squad_fulfilment[$ obj_ini.role[100][10]] > 4) or (squad_fulfilment[$ obj_ini.role[100][9]] > 4)or (squad_fulfilment[$ obj_ini.role[100][3]] > 4) )*/ + /*and ((squad_fulfilment[$ obj_ini.role[100][8]] > 4)or (squad_fulfilment[$ obj_ini.role[100][10]] > 4) or (squad_fulfilment[$ obj_ini.role[100][9]] > 4)or (squad_fulfilment[$ obj_ini.player_role_data[eROLE.VETERAN].role] > 4) )*/ var _members = squad.get_members(true); var _exp_unit = 0; diff --git a/scripts/scr_add_artifact/scr_add_artifact.gml b/scripts/scr_add_artifact/scr_add_artifact.gml index 54ae78eabb..e2be0e5777 100644 --- a/scripts/scr_add_artifact/scr_add_artifact.gml +++ b/scripts/scr_add_artifact/scr_add_artifact.gml @@ -625,7 +625,7 @@ function ArtifactStruct(Index) constructor { var _dwarn = false; if (has_tag("daemonic") || has_tag("chaos")) { unit.corruption += irandom(10 + 2); - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { _dwarn = true; } } diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index e3e6618b7a..fbe795ae88 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -91,7 +91,7 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption } if (!array_contains(non_marine_roles, man_role)) { - if (man_role == obj_ini.role[100][12]) { + if (man_role == obj_ini.player_role_data[eROLE.SCOUT].role) { _gear = { wep2: obj_ini.wep2[100][12], wep1: obj_ini.wep1[100][12], diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index d777686458..9a4543b7d6 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -8,7 +8,7 @@ function add_marines_to_recovery() { var _role_priority_bonus = 0; var _chief_librarian = $"Chief {_roles[eROLE.LIBRARIAN]}"; switch (_unit.role()) { - case obj_ini.role[100][eROLE.CHAPTERMASTER]: + case obj_ini.player_role_data[eROLE.CHAPTERMASTER].role: _role_priority_bonus = 720; break; case "Forge Master": @@ -277,7 +277,7 @@ function after_combat_recover_marine_gene_seed(unit) { var recent = true; if (is_specialist(unit.role, SPECIALISTS_TRAINEES)) { recent = false; - } else if (array_contains([string("Venerable {0}", obj_ini.role[100][6]), "Codiciery", "Lexicanum"], unit.role())) { + } else if (array_contains([string("Venerable {0}", obj_ini.player_role_data[eROLE.DREADNOUGHT].role), "Codiciery", "Lexicanum"], unit.role())) { recent = false; } if (recent == true) { @@ -291,7 +291,7 @@ function after_combat_recover_marine_gene_seed(unit) { // show_message("ded; increase final deaths"); if (obj_controller.blood_debt == 1) { - if (unit.role() == obj_ini.role[100][eROLE.SCOUT]) { + if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { obj_controller.penitent_current += 2; } else { obj_controller.penitent_current += 4; diff --git a/scripts/scr_chapter_random/scr_chapter_random.gml b/scripts/scr_chapter_random/scr_chapter_random.gml index 1db09d07be..3fbd460187 100644 --- a/scripts/scr_chapter_random/scr_chapter_random.gml +++ b/scripts/scr_chapter_random/scr_chapter_random.gml @@ -952,7 +952,7 @@ function scr_chapter_random(custom_or_random) { if (ran2 == 93) { phrase2 = "Wizards"; col_second = "Purple"; - role[100][eROLE.LIBRARIAN] = "Wizard"; + player_role_data[eROLE.LIBRARIAN].role = "Wizard"; chapter_master_specialty = 3; } if (ran2 == 94) { diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index 46a74a0adb..15375fbe96 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -140,12 +140,12 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { new_combat.fighting[cooh][va] = 1; } if (new_combat.battle_special == "cs_meeting_battle7") { - if (unit.role() != obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (unit.role() != obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { new_combat.fighting[cooh][va] = -5; } } - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { new_combat.fighting[cooh][va] = 1; } if (new_combat.fighting[cooh][va] == 1) { @@ -696,7 +696,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + 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; diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index fb9ea42241..36cb7825cd 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -255,16 +255,16 @@ function other_manage_data() { if (is_specialist(_squad_type, SPECIALISTS_HEADS)) { n = 1; } - if ((_squad_type == obj_ini.role[100][6]) && (_squad_type != ma_role[v]) && (_squad_type != "Venerable " + string(ma_role[v]))) { + if ((_squad_type == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (_squad_type != ma_role[v]) && (_squad_type != "Venerable " + string(ma_role[v]))) { n = 2; } - if ((_squad_type == obj_ini.role[100][6]) && (ma_role[v] == obj_ini.role[100][6])) { + if ((_squad_type == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (ma_role[v] == obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { n = 0; } - if ((_squad_type == obj_ini.role[100][6]) && (ma_role[v] == "Venerable " + string(obj_ini.role[100][6]))) { + if ((_squad_type == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (ma_role[v] == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role))) { n = 0; } - if ((_squad_type == "Venerable " + string(obj_ini.role[100][6])) && (ma_role[v] == obj_ini.role[100][6])) { + if ((_squad_type == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) && (ma_role[v] == obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { n = 0; } if (_squad_loc[0] == eLOCATION_TYPES.SHIP) { @@ -318,11 +318,11 @@ function other_manage_data() { _squad_loc = _unit_loc; } - if ((ma_role[v] == obj_ini.role[100][3]) || (ma_role[v] == obj_ini.role[100][4])) { + if ((ma_role[v] == obj_ini.player_role_data[eROLE.VETERAN].role) || (ma_role[v] == obj_ini.player_role_data[eROLE.TERMINATOR].role)) { if ((_unit.company == 1) && (ma_exp[v] >= 140)) { ma_promote[v] = 1; } - } else if ((_unit.role() == obj_ini.role[100][6]) && (ma_exp[v] >= 400)) { + } else if ((_unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (ma_exp[v] >= 400)) { ma_promote[v] = 1; } else if ((_unit.role() == obj_ini.role[100][15]) || (ma_role[v] == obj_ini.role[100][14])) { ma_promote[v] = 1; diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 7ad0281ed5..882b5e4308 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -90,7 +90,7 @@ function scr_crusade() { var _dead = false; if (death_determination > death_data[0] || death_determination_2 > death_data[1]) { _dead = true; - if (unit.role() == obj_ini.role[100][5]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { if (irandom(20) < unit.luck) { _dead = false; } else { @@ -104,7 +104,7 @@ function scr_crusade() { array_push(heroics_strings, heroic_death); } } - } else if (unit.role() == obj_ini.role[100][11] || unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + } else if (unit.role() == obj_ini.role[100][11] || unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { _dead = false; } } diff --git a/scripts/scr_destroy_planet/scr_destroy_planet.gml b/scripts/scr_destroy_planet/scr_destroy_planet.gml index 2acc46780f..233e41c796 100644 --- a/scripts/scr_destroy_planet/scr_destroy_planet.gml +++ b/scripts/scr_destroy_planet/scr_destroy_planet.gml @@ -47,14 +47,14 @@ function scr_destroy_planet(destruction_method) { continue; } if ((unit.location_string == you.name) && (unit.planet_location == baid)) { - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { obj_controller.alarm[7] = 15; if (global.defeat <= 1) { global.defeat = 1; } } - if (obj_ini.race[cah][ed] == 1) { + if (unit.base_group == "astartes") { var comm = unit.IsSpecialist(, true); if (comm == false) { diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index 20f08f9646..5df76dc77a 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -180,7 +180,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { var born = false; for (var i = 0; i < array_length(obj_ini.TTRPG[0]); i++) { var _unit = fetch_unit([0, i]); - if ((_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) && (string_count("$", _unit.specials) > 0)) { + if ((_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) && (string_count("$", _unit.specials) > 0)) { born = true; } } @@ -347,7 +347,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { var born = false; for (var ii = 1; ii < 200; ii++) { - if (obj_ini.role[0][ii] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (obj_ini.role[0][ii] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { var _unit = fetch_unit([0, ii]); if (is_struct(_unit)) { _unit.corruption += floor(random_range(30, 50)); diff --git a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml index d6880545f9..a9d9002bea 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -166,7 +166,7 @@ function scr_enemy_ai_d() { if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop == 0) && yep) { for (var q = 0; q < array_length(obj_ini.TTRPG[0]); q++) { var _unit = fetch_unit([0, q]); - if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { if (string_count("0", _unit.specials) > 0) { scr_popup("Shadow in the Warp", "You are distracted and bothered by a nagging sensation in the warp. It feels as though a shadow descends upon your sector.", "shadow", ""); scr_event_log("red", "You sense a disturbance in the warp. It feels something like a massive shadow."); diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index 7135623a6f..932851cc26 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -750,17 +750,17 @@ function scr_enemy_ai_e() { } var _is_unit_real_and_here = _unit.role() != "" && _unit.location_string == name; var _is_this_a_chaos_meeting = _unit.planet_location == floor(chaos_meeting); - var _unit_does_not_have_dreadnought_role = _unit.role() != obj_ini.role[100][6]; - var _unit_is_not_venerable = _unit.role() != "Venerable " + string(obj_ini.role[100][6]); + var _unit_does_not_have_dreadnought_role = _unit.role() != obj_ini.player_role_data[eROLE.DREADNOUGHT].role; + var _unit_is_not_venerable = _unit.role() != "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role); var _unit_does_not_have_dreadnought_armour = string_count("Dread", obj_ini.armour[co][i]) == 0; - var _is_chapter_master = _unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]; + var _is_chapter_master = _unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role; if (_is_unit_real_and_here && _is_this_a_chaos_meeting && _unit_does_not_have_dreadnought_role && _unit_is_not_venerable && (_unit_does_not_have_dreadnought_armour || _is_chapter_master)) { _meeting.dudes += 1; otm = _meeting.dudes; _meeting.present[otm] = 1; _meeting.co[otm] = co; _meeting.ide[otm] = i; - if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { master_present = true; } } diff --git a/scripts/scr_event_dudes/scr_event_dudes.gml b/scripts/scr_event_dudes/scr_event_dudes.gml index 5ae6972cb1..0ffd1523ca 100644 --- a/scripts/scr_event_dudes/scr_event_dudes.gml +++ b/scripts/scr_event_dudes/scr_event_dudes.gml @@ -64,10 +64,10 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { adding = true; } - if (obj_ini.role[coh][ide] == obj_ini.role[100][6]) { + if (obj_ini.role[coh][ide] == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { adding = false; } - if (obj_ini.role[coh][ide] == "Venerable " + string(obj_ini.role[100][6])) { + if (obj_ini.role[coh][ide] == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { adding = false; } if (string_count("Dread", obj_ini.armour[coh][ide]) > 0) { diff --git a/scripts/scr_event_gossip/scr_event_gossip.gml b/scripts/scr_event_gossip/scr_event_gossip.gml index 0f28932384..8502eb230f 100644 --- a/scripts/scr_event_gossip/scr_event_gossip.gml +++ b/scripts/scr_event_gossip/scr_event_gossip.gml @@ -502,7 +502,7 @@ function scr_event_gossip(argument0) { if ((blah == "captain_promote") && (cn.recent_number[gossip_recent[that]] == attend_co[argument0])) { rando = choose(1, 2); - words += "gives a cheer to " + string(cn.recent_keyword[gossip_recent[that]]) + ", for his promotion to " + string(obj_ini.role[100][5]) + "."; + words += "gives a cheer to " + string(cn.recent_keyword[gossip_recent[that]]) + ", for his promotion to " + string(obj_ini.player_role_data[eROLE.CAPTAIN].role) + "."; if (rando == 1) { words += " May he lead the company to glory!"; } @@ -512,7 +512,7 @@ function scr_event_gossip(argument0) { } if ((blah == "terminator_promote") && (cn.recent_number[gossip_recent[that]] == attend_co[argument0])) { rando = choose(1, 2); - words += "gives a cheer to " + string(cn.recent_keyword[gossip_recent[that]]) + ", for his promotion to " + string(obj_ini.role[100][4]) + "."; + words += "gives a cheer to " + string(cn.recent_keyword[gossip_recent[that]]) + ", for his promotion to " + string(obj_ini.player_role_data[eROLE.TERMINATOR].role) + "."; if (rando == 1) { words += " Let the enemies of man die at his feet!"; } @@ -522,7 +522,7 @@ function scr_event_gossip(argument0) { } if ((blah == "honor_promote") && (cn.recent_number[gossip_recent[that]] == attend_co[argument0])) { rando = choose(1, 2); - words += "gives a cheer to " + string(cn.recent_keyword[gossip_recent[that]]) + ", for his promotion to " + string(obj_ini.role[100][2]) + "."; + words += "gives a cheer to " + string(cn.recent_keyword[gossip_recent[that]]) + ", for his promotion to " + string(obj_ini.player_role_data[eROLE.HONOURGUARD].role) + "."; if (rando >= 1) { words += " Let the enemies of man die at his feet!"; } diff --git a/scripts/scr_flavor/scr_flavor.gml b/scripts/scr_flavor/scr_flavor.gml index 270928b9a8..dd6e558d13 100644 --- a/scripts/scr_flavor/scr_flavor.gml +++ b/scripts/scr_flavor/scr_flavor.gml @@ -535,16 +535,16 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot } else if (weapon_name == "Close Combat Weapon") { flavoured = true; if ((number_of_shots == 1) && (casulties == 0)) { - attack_message = $"{target_name} is struck by " + string(obj_ini.role[100][6]) + " but survives."; + attack_message = $"{target_name} is struck by " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role) + " but survives."; } if ((number_of_shots == 1) && (casulties == 1)) { - attack_message = $"{target_name} is struck down by " + string(obj_ini.role[100][6]) + "."; + attack_message = $"{target_name} is struck down by " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role) + "."; } if ((number_of_shots > 1) && (casulties == 0)) { - attack_message = $"{number_of_shots} {string(obj_ini.role[100][6])}s wrench and smash at {target_name} but fail to destroy it."; + attack_message = $"{number_of_shots} {string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)}s wrench and smash at {target_name} but fail to destroy it."; } if ((number_of_shots > 1) && (casulties > 1)) { - attack_message = $"{number_of_shots} {string(obj_ini.role[100][6])}s stomp, wrench, and smash {casulties} {target_name} into paste."; + attack_message = $"{number_of_shots} {string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)}s stomp, wrench, and smash {casulties} {target_name} into paste."; } } else if (weapon_name == "Chainsword") { flavoured = true; diff --git a/scripts/scr_flavor2/scr_flavor2.gml b/scripts/scr_flavor2/scr_flavor2.gml index 7c728003f5..ae22caee89 100644 --- a/scripts/scr_flavor2/scr_flavor2.gml +++ b/scripts/scr_flavor2/scr_flavor2.gml @@ -415,7 +415,7 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo units_lost = lost_num[role_index]; if (unit_role != "" && units_lost > 0) { mes_color = eMSG_COLOR.RED; - special = is_specialist(unit_role, SPECIALISTS_HEADS) || unit_role == obj_ini.role[100][eROLE.CHAPTERMASTER] || unit_role == "Venerable " + string(obj_ini.role[100][eROLE.DREADNOUGHT]) || unit_role == obj_ini.role[100][eROLE.CAPTAIN] || obj_ncombat.player_max <= 6; + special = is_specialist(unit_role, SPECIALISTS_HEADS) || unit_role == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role || unit_role == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role) || unit_role == obj_ini.player_role_data[eROLE.CAPTAIN].role || obj_ncombat.player_max <= 6; if (!special) { plural = units_lost > 1 ? "s" : ""; @@ -432,7 +432,7 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo if (him != -1) { // found a valid unit obj_ncombat.dead_jims += 1; - if (marine_type[him] == obj_ini.role[100][5]) { + if (marine_type[him] == obj_ini.player_role_data[eROLE.CAPTAIN].role) { obj_ncombat.dead_jim[obj_ncombat.dead_jims] = $"A {marine_type[him]} has been lost!"; } else { obj_ncombat.dead_jim[obj_ncombat.dead_jims] = $"{unit_struct[him].name_role()} has been lost!"; diff --git a/scripts/scr_income/scr_income.gml b/scripts/scr_income/scr_income.gml index a002431e6e..04e94f4c59 100644 --- a/scripts/scr_income/scr_income.gml +++ b/scripts/scr_income/scr_income.gml @@ -28,7 +28,7 @@ function scr_income() { income_training = 0; if (faction_status[eFACTION.MECHANICUS] != "War") { - var _chapter_tech_count = scr_role_count(obj_ini.role[100][eROLE.TECHMARINE], ""); + var _chapter_tech_count = scr_role_count(obj_ini.player_role_data[eROLE.TECHMARINE].role, ""); if (_chapter_tech_count >= ((disposition[3] / 2) + 5)) { training_techmarine = 0; } diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index e5ba16eff2..5393ffe683 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -3004,7 +3004,7 @@ function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 spawn_unit.add_trait("favoured_by_the_warp"); } - if (role_name == obj_ini.role[100][eROLE.LIBRARIAN]) { + if (role_name == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { spawn_unit.psionic = irandom_range(8, 10); } else if (role_name == "Codiciery") { spawn_unit.psionic = irandom_range(5, 7); diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index d3ca4fc6aa..822540b8fa 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -5,7 +5,7 @@ function scr_kill_unit(company, unit_slot) { array_push(obj_ini.previous_forge_masters, obj_ini.name[company][unit_slot]); } - if (obj_ini.role[company][unit_slot] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (obj_ini.role[company][unit_slot] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { tek = "c"; alarm[7] = 5; global.defeat = 1; diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index 7fd998d0f7..778451e150 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -72,14 +72,14 @@ function task_selector_man_manage() { }; break; case "captain_promote": - _unit.update_role(obj_ini.role[100][eROLE.CAPTAIN]); + _unit.update_role(obj_ini.player_role_data[eROLE.CAPTAIN].role); _unit.squad = "none"; _unit.move_to_company(selection_data.target_company); managing = selection_data.target_company; update_general_manage_view(); exit; case "champion_promote": - _unit.update_role(obj_ini.role[100][eROLE.CHAMPION]); + _unit.update_role(obj_ini.player_role_data[eROLE.CHAMPION].role); _unit.squad = "none"; with (obj_ini) { @@ -90,7 +90,7 @@ function task_selector_man_manage() { update_general_manage_view(); exit; case "ancient_promote": - _unit.update_role(obj_ini.role[100][eROLE.ANCIENT]); + _unit.update_role(obj_ini.player_role_data[eROLE.ANCIENT].role); _unit.squad = "none"; with (obj_ini) { diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 323a36e1aa..57aac6aba6 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -355,7 +355,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } var _cloak_chance = 5; - if (role() == obj_ini.role[100][eROLE.CHAPLAIN]) { + if (role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { _cloak_chance += 25; } else if (IsSpecialist(SPECIALISTS_LIBRARIANS)) { _cloak_chance += 75; @@ -457,7 +457,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return "no change"; } if (base_group == "astartes") { - if (role() == obj_ini.role[100][12] && new_role != obj_ini.role[100][12]) { + if (role() == obj_ini.player_role_data[eROLE.SCOUT].role && new_role != obj_ini.player_role_data[eROLE.SCOUT].role) { if (!get_body_data("black_carapace", "torso")) { alter_body("torso", "black_carapace", true); stat_boosts({strength: 4, constitution: 4, dexterity: 4}); //will decide on if these are needed @@ -480,7 +480,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (instance_exists(obj_controller)) { array_push(role_history, [role(), obj_controller.turn]); } - if (new_role == obj_ini.role[100][5]) { + if (new_role == obj_ini.player_role_data[eROLE.CAPTAIN].role) { if (company == 2) { obj_ini.watch_master_name = name(); } @@ -509,11 +509,11 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} obj_ini.recruiter_name = name(); } scr_recent("captain_promote", name(), company); - } else if (new_role == obj_ini.role[100][4]) { + } else if (new_role == obj_ini.player_role_data[eROLE.TERMINATOR].role) { scr_recent("terminator_promote", name(), company); - } else if (new_role == obj_ini.role[100][2]) { + } else if (new_role == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { scr_recent("honor_promote", name(), company); - } else if (new_role == obj_ini.role[100][6]) { + } else if (new_role == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { var dread_weapons = [ "Close Combat Weapon", "Force Staff", @@ -600,7 +600,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } else if (array_contains(global.list_terminator_armour, arm)) { sz += 1; } - if (unit_role == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (unit_role == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { sz++; } size = sz; @@ -1174,7 +1174,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (role() == "Lexicanum" && psionic >= 5 && experience > 50) { update_role("Codiciery"); } else if (role() == "Codiciery" && psionic >= 8 && experience > 100) { - update_role(obj_ini.role[100][eROLE.LIBRARIAN]); + update_role(obj_ini.player_role_data[eROLE.LIBRARIAN].role); } }; diff --git a/scripts/scr_master_loc/scr_master_loc.gml b/scripts/scr_master_loc/scr_master_loc.gml index fee148dc62..b17f2fa6c6 100644 --- a/scripts/scr_master_loc/scr_master_loc.gml +++ b/scripts/scr_master_loc/scr_master_loc.gml @@ -24,7 +24,7 @@ function scr_master_loc() { if (!is_struct(unit)) { continue; } - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { if ((unit.planet_location > 0) && (unit.ship_location < 0)) { lick = $"{unit.location_string}." + string(unit.planet_location); } diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index a1c2443afa..02b90b03f6 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -386,7 +386,7 @@ function mechanicus_mars_mission_target_time_elapsed(planet) { if (!is_struct(_unit) || _unit.name() == "") { continue; } - if (_unit.role() == obj_ini.role[100][eROLE.TECHMARINE]) { + if (_unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { // Case 1: on planet if ((_unit.location_string == name) && (_unit.planet_location == planet)) { p_player[planet] -= _unit.get_unit_size(); diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 30f1bedfdd..dee30c62a4 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -470,7 +470,7 @@ function protect_raiders_suppress_information() { title = "Captains Disgruntled"; options1 = "continue"; pathway = ""; - var _caps = scr_role_count(obj_ini.roles[100][eROLE.CAPTAIN]); + var _caps = scr_role_count(obj_ini.player_role_data[eROLE.CAPTAIN].role); var _worst = -1; var _worst_hit = -1; for (var i = 0; i < array_length(_caps); i++) { diff --git a/scripts/scr_perils_table/scr_perils_table.gml b/scripts/scr_perils_table/scr_perils_table.gml index 4f3a3a1b79..b048ca8343 100644 --- a/scripts/scr_perils_table/scr_perils_table.gml +++ b/scripts/scr_perils_table/scr_perils_table.gml @@ -203,7 +203,7 @@ function scr_perils_table(perils_strength, unit, psy_discipline, power_name, uni function(perils_strength, unit, psy_discipline, power_name, unit_id) { var flavour_text2 = choose("There is a snap, and pop, and he disappears entirely.", "He explodes into a cloud of gore, splattering guts and ceramite across the battlefield."); - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { flavour_text2 = "There is a snap, and pop, and he disappears entirely. Reappearing minutes later, barely alive and stunned."; unit.update_health(10); marine_casting_cooldown[unit_id] = 999; diff --git a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml index 6c76291ae3..5ec298ee87 100644 --- a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml +++ b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml @@ -193,7 +193,7 @@ function scr_player_combat_weapon_stacks() { add_second_profiles_to_stack(armour_item); } - if (unit.IsSpecialist(SPECIALISTS_LIBRARIANS, true) || (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER] && obj_ncombat.chapter_master_psyker == 1)) { + if (unit.IsSpecialist(SPECIALISTS_LIBRARIANS, true) || (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role && obj_ncombat.chapter_master_psyker == 1)) { if (marine_casting_cooldown[g] == 0) { if (array_length(unit.powers_known) > 0) { if (marine_casting[g] == true) { diff --git a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml index 57bda0a7ca..4ece26f009 100644 --- a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml +++ b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml @@ -366,7 +366,7 @@ function setup_player_combat_ship() { // Loc 1: in transit // Loc >1: (instance_id), on enemy vessel if (co == 0 && master_present == 0 && i < 100) { - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER] && unit.ship_location == ship_id) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role && unit.ship_location == ship_id) { master_present = 1; obj_fleet.control = true; } diff --git a/scripts/scr_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index ef3a2badbd..d5f3c98a4a 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -50,9 +50,9 @@ function setup_promotion_popup() { variable_struct_set(role_squad_equivilances, obj_ini.role[100][8], "tactical_squad"); variable_struct_set(role_squad_equivilances, obj_ini.role[100][9], "devastator_squad"); variable_struct_set(role_squad_equivilances, obj_ini.role[100][10], "assault_squad"); - variable_struct_set(role_squad_equivilances, obj_ini.role[100][12], "scout_squad"); - variable_struct_set(role_squad_equivilances, obj_ini.role[100][3], "veteran_squad"); - variable_struct_set(role_squad_equivilances, obj_ini.role[100][4], "terminator_squad"); + variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.SCOUT].role, "scout_squad"); + variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.VETERAN].role, "veteran_squad"); + variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.TERMINATOR].role, "terminator_squad"); for (var i = 0; i < array_length(obj_controller.display_unit) && mahreens < 500; i++) { if ((obj_controller.man[i] == "man") && (obj_controller.man_sel[i] == 1) && (obj_controller.ma_exp[i] >= min_exp)) { diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index df38fdefd1..fe1ffdaf43 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -265,7 +265,7 @@ function scr_random_event(execute_now) { } } else if (chosen_event == eEVENT.PROMOTION) { LOGGER.info("RE: Promotion"); - var marine_and_company = scr_random_marine([obj_ini.role[100][8], obj_ini.role[100][12], obj_ini.role[100][9], obj_ini.role[100][10]], 0); + var marine_and_company = scr_random_marine([obj_ini.role[100][8], obj_ini.player_role_data[eROLE.SCOUT].role, obj_ini.role[100][9], obj_ini.role[100][10]], 0); if (marine_and_company == "none") { LOGGER.error("RE: Promotion, couldn't pick a space marine"); exit; @@ -709,7 +709,7 @@ function scr_random_event(execute_now) { var cm_is_psyker = false; for (var i = 0; i < array_length(TTRPG[0]); i++) { var _unit = fetch_unit([0 ,i]); - if (_unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER] && string_count("0", _unit.specials) > 0) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role && string_count("0", _unit.specials) > 0) { cm_is_psyker = true; break; } diff --git a/scripts/scr_random_marine/scr_random_marine.gml b/scripts/scr_random_marine/scr_random_marine.gml index 85c8f38df7..b0e846a523 100644 --- a/scripts/scr_random_marine/scr_random_marine.gml +++ b/scripts/scr_random_marine/scr_random_marine.gml @@ -57,7 +57,7 @@ function scr_random_marine(role, exp_req, search_params = {}) { //check correct search param roles var unit_role = unit.role(); - if (unit_role == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (unit_role == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { array_delete(marine_list, list_place, 1); comp_size--; continue; diff --git a/scripts/scr_roster/scr_roster.gml b/scripts/scr_roster/scr_roster.gml index b98f865448..c517afb9c6 100644 --- a/scripts/scr_roster/scr_roster.gml +++ b/scripts/scr_roster/scr_roster.gml @@ -588,7 +588,7 @@ function add_unit_to_battle(unit, meeting, is_local) { } else if (unit.IsSpecialist(SPECIALISTS_DREADNOUGHTS)) { col = obj_controller.bat_dreadnought_column; //dreadnoughts new_combat.dreadnoughts++; - } else if (_unit_role == obj_ini.role[100][4]) { + } else if (_unit_role == obj_ini.player_role_data[eROLE.TERMINATOR].role) { //terminators col = obj_controller.bat_terminator_column; new_combat.terminators++; @@ -659,7 +659,7 @@ function add_unit_to_battle(unit, meeting, is_local) { } } - if (_unit_role == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + 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; diff --git a/scripts/scr_ship_battle/scr_ship_battle.gml b/scripts/scr_ship_battle/scr_ship_battle.gml index 3426bb0844..0536bdd400 100644 --- a/scripts/scr_ship_battle/scr_ship_battle.gml +++ b/scripts/scr_ship_battle/scr_ship_battle.gml @@ -41,7 +41,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { okay = 1; } - if ((string_count("spyrer", obj_ncombat.battle_special) > 0) && ((obj_ini.role[co][v] == obj_ini.role[100][6]) || (unit.role() == "Venerable " + string(obj_ini.role[100][6])))) { + if ((string_count("spyrer", obj_ncombat.battle_special) > 0) && ((obj_ini.role[co][v] == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) || (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)))) { okay = 0; } if (string_count("spyrer", obj_ncombat.battle_special) > 0) { @@ -62,7 +62,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { var col = 0, targ = 0; - if (unit.role() == obj_ini.role[100][12]) { + if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { col = obj_controller.bat_scout_column; obj_ncombat.scouts += 1; } @@ -70,7 +70,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { col = obj_controller.bat_tactical_column; obj_ncombat.tacticals += 1; } - if (unit.role() == obj_ini.role[100][3]) { + if (unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { col = obj_controller.bat_veteran_column; obj_ncombat.veterans += 1; } @@ -102,19 +102,19 @@ function scr_ship_battle(target_ship_id, cooridor_width) { col = obj_controller.bat_techmarine_column; obj_ncombat.techmarines += 1; } - if (unit.role() == obj_ini.role[100][2]) { + 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.role[100][6]) { + if (unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { col = obj_controller.bat_dreadnought_column; obj_ncombat.dreadnoughts += 1; } - if (unit.role() == "Venerable " + string(obj_ini.role[100][6])) { + if (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { col = obj_controller.bat_dreadnought_column; obj_ncombat.dreadnoughts += 1; } - if (unit.role() == obj_ini.role[100][4]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { col = obj_controller.bat_terminator_column; obj_ncombat.terminators += 1; } @@ -142,8 +142,8 @@ function scr_ship_battle(target_ship_id, cooridor_width) { } } - if ((unit.role() == obj_ini.role[100][5]) || (unit.role() == obj_ini.role[100][11]) || (unit.role() == obj_ini.role[100][7])) { - if (unit.role() == obj_ini.role[100][5]) { + if ((unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) || (unit.role() == obj_ini.role[100][11]) || (unit.role() == obj_ini.role[100][7])) { + 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; @@ -176,7 +176,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { } } - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + 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; diff --git a/scripts/scr_special_view/scr_special_view.gml b/scripts/scr_special_view/scr_special_view.gml index 34a590e8e5..24b24260ea 100644 --- a/scripts/scr_special_view/scr_special_view.gml +++ b/scripts/scr_special_view/scr_special_view.gml @@ -180,7 +180,7 @@ function scr_special_view(command_group) { if (squad_typ == ma_role[i]) { n = 0; } - if ((squad_typ == obj_ini.role[100][eROLE.LIBRARIAN]) && (ma_role[i] == "Codiciery")) { + if ((squad_typ == obj_ini.player_role_data[eROLE.LIBRARIAN].role) && (ma_role[i] == "Codiciery")) { n = 1; } if ((squad_typ == "Codiciery") && (ma_role[i] == "Lexicanum")) { @@ -190,13 +190,13 @@ function scr_special_view(command_group) { if (squad_typ == "Master of Sanctity") { n = 1; } - if (squad_typ == "Chief " + string(obj_ini.role[100][eROLE.LIBRARIAN])) { + if (squad_typ == "Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role)) { n = 1; } if (squad_typ == "Forge Master") { n = 1; } - if (squad_typ == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (squad_typ == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { n = 1; } if (squad_typ == "Master of the Apothecarion") { @@ -209,7 +209,7 @@ function scr_special_view(command_group) { if ((ma_wid[i] + (ma_lid[i] / 100)) != squad_loc) { n = 1; } - if (squad_typ == obj_ini.role[100][6]) { + if (squad_typ == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { n = 2; } diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index 72d7558723..ea347b335c 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -68,7 +68,7 @@ function specialistfunct(specialist, req_exp) { break; } - if (role() == obj_ini.role[100][12]) { + if (role() == obj_ini.player_role_data[eROLE.SCOUT].role) { colors[0] = c_fuchsia; } @@ -77,7 +77,7 @@ function specialistfunct(specialist, req_exp) { } if (experience >= req_exp) { - if (!(role() == obj_ini.role[100][12])) { + if (!(role() == obj_ini.player_role_data[eROLE.SCOUT].role)) { spec_tip = tips_list[1]; } else { spec_tip = tips_list[2]; @@ -182,7 +182,7 @@ function apothecary_training() { } else { training_apothecary = 0; - scr_alert("red", "recruitment", $"No marines available for {obj_ini.role[100][eROLE.APOTHECARY]} training", 0, 0); + scr_alert("red", "recruitment", $"No marines available for {obj_ini.player_role_data[eROLE.APOTHECARY].role} training", 0, 0); } } } @@ -251,7 +251,7 @@ function chaplain_training() { } else { training_chaplain = 0; - scr_alert("red", "recruitment", $"No remaining {obj_ini.role[100][eROLE.CHAPLAIN]} applicant marines for training", 0, 0); + scr_alert("red", "recruitment", $"No remaining {obj_ini.player_role_data[eROLE.CHAPLAIN].role} applicant marines for training", 0, 0); } } } diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index a7b7f3708e..e4c50f0984 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -333,7 +333,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { if (exp_unit.name() != "") { var new_role; if (veteran == true) { - new_role = obj_ini.role[100][19]; + new_role = obj_ini.player_role_data[eROLE.VETERANSERGEANT].role; } else { new_role = obj_ini.role[100][18]; } @@ -418,7 +418,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { required[$ _wanted_unit_role] = _min_role_allowed - _squad_role_current; } } - var _sarge = obj_ini.role[100][eROLE.SERGEANT]; + var _sarge = obj_ini.player_role_data[eROLE.SERGEANT].role; if (struct_exists(required, _sarge)) { if (required[$ _sarge] > 0) { new_sergeant(); @@ -426,7 +426,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { } } //find a new veteran sergeant - var _vet_sarge = obj_ini.role[100][eROLE.VETERANSERGEANT]; + var _vet_sarge = obj_ini.player_role_data[eROLE.VETERANSERGEANT].role; if (struct_exists(required, _vet_sarge)) { if (required[$ _vet_sarge] > 0) { new_sergeant(true); diff --git a/scripts/scr_ui_advisors/scr_ui_advisors.gml b/scripts/scr_ui_advisors/scr_ui_advisors.gml index 0f5a467fb6..cfbdcae0f2 100644 --- a/scripts/scr_ui_advisors/scr_ui_advisors.gml +++ b/scripts/scr_ui_advisors/scr_ui_advisors.gml @@ -746,7 +746,7 @@ function scr_ui_advisors() { draw_rectangle(xx + 217, yy + 380, xx + 617, yy + 411, 1); draw_set_font(fnt_large); - draw_text_transformed(xx + 410, yy + 29, obj_ini.role[100][eROLE.CHAPTERMASTER], 0.5, 0.5, 0); + draw_text_transformed(xx + 410, yy + 29, obj_ini.player_role_data[eROLE.CHAPTERMASTER].role, 0.5, 0.5, 0); draw_set_font(fnt_fancy); draw_text_transformed(xx + 410, yy + 40, string_hash_to_newline(string(obj_ini.master_name)), 1.5, 1.5, 0); diff --git a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml index 4cb368df61..c2ed807208 100644 --- a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml +++ b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml @@ -2,7 +2,7 @@ function scr_unit_detail_text() { var unit_data_string = ""; var is_astartes = false; - var is_superior = array_contains([obj_ini.role[100][18], obj_ini.role[100][19]], role()); + var is_superior = array_contains([obj_ini.role[100][18], obj_ini.player_role_data[eROLE.VETERANSERGEANT].role], role()); var unit_name = name(); var unit_role = role(); var body_augmentations = { @@ -78,7 +78,7 @@ function scr_unit_detail_text() { // Psyker text unit_data_string += $"Has an Assignment rating of {_psionic_assignment} ({psionic}) "; - var is_lib = array_contains(["Lexicanum", "Codiciery", obj_ini.role[100][17]], role()) || role() == obj_ini.role[100][eROLE.CHAPTERMASTER]; + var is_lib = array_contains(["Lexicanum", "Codiciery", obj_ini.role[100][17]], role()) || role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role; if (psionic < -6) { unit_data_string += ", so inert in the Warp as to actually exhibit negative psychic influence upon others."; } else if (psionic < 0) { diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 4787ba5d8a..195fba1968 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -120,7 +120,7 @@ function scr_update_unit_armour(new_armour, from_armoury = true, to_armoury = tr if (new_arm_data.has_tag("dreadnought")) { is_boarder = false; remove_from_squad(); - update_role(obj_ini.role[100][eROLE.DREADNOUGHT]); + update_role(obj_ini.player_role_data[eROLE.DREADNOUGHT].role); update_gear(""); update_mobility_item(""); } diff --git a/scripts/scr_unit_size/scr_unit_size.gml b/scripts/scr_unit_size/scr_unit_size.gml index 4386d9a6c5..3810c93a78 100644 --- a/scripts/scr_unit_size/scr_unit_size.gml +++ b/scripts/scr_unit_size/scr_unit_size.gml @@ -28,7 +28,7 @@ function scr_unit_size(armour, role, other_factors, mobility = false) { var vehicle_size_map = get_vehicle_size_map(); - if (role == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (role == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { _size++; } else if (struct_exists(vehicle_size_map, role)) { _size = vehicle_size_map[$ role]; diff --git a/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml b/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml index 3b39d32f9c..dc3eaebec3 100644 --- a/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml +++ b/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml @@ -37,10 +37,10 @@ function scr_marine_spawn_age() { break; } - var _venerable_dred = string_concat("Venerable ", obj_ini.role[100][eROLE.DREADNOUGHT]); + var _venerable_dred = string_concat("Venerable ", obj_ini.player_role_data[eROLE.DREADNOUGHT].role); switch (role()) { - case obj_ini.role[100][eROLE.DREADNOUGHT]: + case obj_ini.player_role_data[eROLE.DREADNOUGHT].role: _minimum_age = 400; _maximum_age = 600; _apply_gauss = true; @@ -51,7 +51,7 @@ function scr_marine_spawn_age() { _apply_gauss = true; break; // HQ only - case obj_ini.role[100][eROLE.CHAPTERMASTER]: + case obj_ini.player_role_data[eROLE.CHAPTERMASTER].role: _minimum_age = 250; _maximum_age = 350; _apply_gauss = true; @@ -60,16 +60,16 @@ function scr_marine_spawn_age() { case "Forge Master": case "Master of Sanctity": case "Master of the Apothecarion": - case obj_ini.role[100][eROLE.HONOURGUARD]: + case obj_ini.player_role_data[eROLE.HONOURGUARD].role: _minimum_age = 200; _maximum_age = 300; _apply_gauss = true; break; // Command Squads and HQ - case obj_ini.role[100][eROLE.CHAPLAIN]: - case obj_ini.role[100][eROLE.APOTHECARY]: - case obj_ini.role[100][eROLE.TECHMARINE]: - case obj_ini.role[100][eROLE.LIBRARIAN]: + case obj_ini.player_role_data[eROLE.CHAPLAIN].role: + case obj_ini.player_role_data[eROLE.APOTHECARY].role: + case obj_ini.player_role_data[eROLE.TECHMARINE].role: + case obj_ini.player_role_data[eROLE.LIBRARIAN].role: _minimum_age += 80; _maximum_age += 150; _apply_gauss = true; @@ -83,43 +83,43 @@ function scr_marine_spawn_age() { _maximum_age = 40; break; // 1st company only - case obj_ini.role[100][eROLE.VETERAN]: + case obj_ini.player_role_data[eROLE.VETERAN].role: _minimum_age = 100; _maximum_age = 140; break; - case obj_ini.role[100][eROLE.TERMINATOR]: + case obj_ini.player_role_data[eROLE.TERMINATOR].role: _minimum_age = 120; _maximum_age = 160; break; - case obj_ini.role[100][eROLE.VETERANSERGEANT]: + case obj_ini.player_role_data[eROLE.VETERANSERGEANT].role: _minimum_age = 160; _maximum_age = 180; break; // Command Squads - case obj_ini.role[100][eROLE.ANCIENT]: + case obj_ini.player_role_data[eROLE.ANCIENT].role: _minimum_age += 100; _maximum_age += 110; break; - case obj_ini.role[100][eROLE.CAPTAIN]: + case obj_ini.player_role_data[eROLE.CAPTAIN].role: _minimum_age += 80; _maximum_age += 90; break; - case obj_ini.role[100][eROLE.CHAMPION]: + case obj_ini.player_role_data[eROLE.CHAMPION].role: _minimum_age += 50; _maximum_age += 60; break; // Company marines - case obj_ini.role[100][eROLE.SERGEANT]: + case obj_ini.player_role_data[eROLE.SERGEANT].role: _minimum_age += 30; _maximum_age += 40; break; - case obj_ini.role[100][eROLE.TACTICAL]: - case obj_ini.role[100][eROLE.DEVASTATOR]: - case obj_ini.role[100][eROLE.ASSAULT]: + case obj_ini.player_role_data[eROLE.TACTICAL].role: + case obj_ini.player_role_data[eROLE.DEVASTATOR].role: + case obj_ini.player_role_data[eROLE.ASSAULT].role: _minimum_age += 20; _maximum_age += 30; break; - case obj_ini.role[100][eROLE.SCOUT]: + case obj_ini.player_role_data[eROLE.SCOUT].role: default: _minimum_age = 18; _maximum_age = 25; @@ -255,13 +255,13 @@ function scr_marine_spawn_armour() { }; var _terminator_roles_array = [ - obj_ini.role[100][eROLE.CAPTAIN], - obj_ini.role[100][eROLE.CHAMPION], - obj_ini.role[100][eROLE.ANCIENT], - obj_ini.role[100][eROLE.CHAPLAIN], - obj_ini.role[100][eROLE.APOTHECARY], - obj_ini.role[100][eROLE.LIBRARIAN], - obj_ini.role[100][eROLE.TECHMARINE], + obj_ini.player_role_data[eROLE.CAPTAIN].role, + obj_ini.player_role_data[eROLE.CHAMPION].role, + obj_ini.player_role_data[eROLE.ANCIENT].role, + obj_ini.player_role_data[eROLE.CHAPLAIN].role, + obj_ini.player_role_data[eROLE.APOTHECARY].role, + obj_ini.player_role_data[eROLE.LIBRARIAN].role, + obj_ini.player_role_data[eROLE.TECHMARINE].role, ]; // terminator/tartaros should be decided in scr_initialize_custom @@ -270,31 +270,31 @@ function scr_marine_spawn_armour() { } else { switch (_role) { // HQ - // case obj_ini.role[100][eROLE.CHAPTERMASTER]: + // case obj_ini.player_role_data[eROLE.CHAPTERMASTER].role: // case "Chief Librarian": // case "Forge Master": // case "Master of Sanctity": // case "Master of the Apothecarion": - // case obj_ini.role[100][eROLE.HONOURGUARD]: + // case obj_ini.player_role_data[eROLE.HONOURGUARD].role: case "Codiciery": case "Lexicanum": // 1st company only - case obj_ini.role[100][eROLE.VETERAN]: - case obj_ini.role[100][eROLE.VETERANSERGEANT]: + case obj_ini.player_role_data[eROLE.VETERAN].role: + case obj_ini.player_role_data[eROLE.VETERANSERGEANT].role: // Command Squads - case obj_ini.role[100][eROLE.CAPTAIN]: - case obj_ini.role[100][eROLE.CHAMPION]: - case obj_ini.role[100][eROLE.ANCIENT]: + case obj_ini.player_role_data[eROLE.CAPTAIN].role: + case obj_ini.player_role_data[eROLE.CHAMPION].role: + case obj_ini.player_role_data[eROLE.ANCIENT].role: // Command Squads and HQ - case obj_ini.role[100][eROLE.CHAPLAIN]: - case obj_ini.role[100][eROLE.APOTHECARY]: - case obj_ini.role[100][eROLE.LIBRARIAN]: + case obj_ini.player_role_data[eROLE.CHAPLAIN].role: + case obj_ini.player_role_data[eROLE.APOTHECARY].role: + case obj_ini.player_role_data[eROLE.LIBRARIAN].role: // Company marines - // case obj_ini.role[100][eROLE.SCOUT]: - case obj_ini.role[100][eROLE.TACTICAL]: - case obj_ini.role[100][eROLE.DEVASTATOR]: - case obj_ini.role[100][eROLE.ASSAULT]: - case obj_ini.role[100][eROLE.SERGEANT]: + // case obj_ini.player_role_data[eROLE.SCOUT].role: + case obj_ini.player_role_data[eROLE.TACTICAL].role: + case obj_ini.player_role_data[eROLE.DEVASTATOR].role: + case obj_ini.player_role_data[eROLE.ASSAULT].role: + case obj_ini.player_role_data[eROLE.SERGEANT].role: if (scr_has_adv("Ancient Armoury")) { update_armour(choose_weighted(_armour_weighted_lists.ancient_armour), false, false); } else if (_total_score > 280) { @@ -307,7 +307,7 @@ function scr_marine_spawn_armour() { update_armour(choose_weighted(_armour_weighted_lists.normal_armour), false, false); } break; - case obj_ini.role[100][eROLE.TECHMARINE]: + case obj_ini.player_role_data[eROLE.TECHMARINE].role: if (_total_score > 280) { update_armour("Artificer Armour", false, false); } else if (scr_has_adv("Ancient Armoury")) { @@ -320,7 +320,7 @@ function scr_marine_spawn_armour() { update_armour(choose_weighted(_armour_weighted_lists.normal_armour), false, false); } break; - case obj_ini.role[100][eROLE.TERMINATOR]: + case obj_ini.player_role_data[eROLE.TERMINATOR].role: _terminator_armour_roll(_total_score); break; } @@ -342,7 +342,7 @@ function scr_marine_game_spawn_constructions() { bionic_count = choose(2, 3, 4, 5); } switch (role()) { - case obj_ini.role[100][eROLE.CAPTAIN]: //captain + case obj_ini.player_role_data[eROLE.CAPTAIN].role: //captain if (old_guard >= 80 || company == 1) { bionic_count = choose(0, 0, 1, 2, 3); } else { @@ -367,7 +367,7 @@ function scr_marine_game_spawn_constructions() { } } break; - case obj_ini.role[100][eROLE.APOTHECARY]: //apothecary + case obj_ini.player_role_data[eROLE.APOTHECARY].role: //apothecary if (company > 0) { if (old_guard >= 80 || company == 1) { bionic_count = choose(0, 0, 1, 2, 3); @@ -381,7 +381,7 @@ function scr_marine_game_spawn_constructions() { intelligence = 40; } break; - case obj_ini.role[100][eROLE.ANCIENT]: // Ancient + case obj_ini.player_role_data[eROLE.ANCIENT].role: // Ancient if (old_guard >= 50 || company == 1) { bionic_count = choose(0, 0, 1, 2, 3); } else { @@ -394,12 +394,12 @@ function scr_marine_game_spawn_constructions() { } } break; - case obj_ini.role[100][eROLE.TACTICAL]: //tacticals + case obj_ini.player_role_data[eROLE.TACTICAL].role: //tacticals break; - case obj_ini.role[100][eROLE.DEVASTATOR]: //devastators + case obj_ini.player_role_data[eROLE.DEVASTATOR].role: //devastators break; - case obj_ini.role[100][eROLE.TERMINATOR]: - case obj_ini.role[100][eROLE.VETERAN]: //veterans + case obj_ini.player_role_data[eROLE.TERMINATOR].role: + case obj_ini.player_role_data[eROLE.VETERAN].role: //veterans if (_chap_name == "Ultramarines" || scr_has_adv("Enemy: Tyranids")) { if (choose(true, false)) { add_trait("tyrannic_vet"); @@ -408,7 +408,7 @@ function scr_marine_game_spawn_constructions() { } break; - case obj_ini.role[100][eROLE.TECHMARINE]: //techmarines + case obj_ini.player_role_data[eROLE.TECHMARINE].role: //techmarines if ((old_guard >= 90 && company > 0 && company < 6) || company == 1) { bionic_count = choose(1, 2, 3, 4, 5); } else if (company > 0 && company < 6) { @@ -458,10 +458,10 @@ function scr_marine_game_spawn_constructions() { } religion = "cult_mechanicus"; break; - case obj_ini.role[100][eROLE.SCOUT]: //scouts + case obj_ini.player_role_data[eROLE.SCOUT].role: //scouts bionic_count = choose(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); break; - case obj_ini.role[100][eROLE.CHAPLAIN]: //chaplain + case obj_ini.player_role_data[eROLE.CHAPLAIN].role: //chaplain if (company > 0) { if (old_guard >= 80 || company == 1) { bionic_count = choose(0, 0, 1, 2, 3); @@ -482,7 +482,7 @@ function scr_marine_game_spawn_constructions() { break; case "Lexicanum": break; - case obj_ini.role[100][eROLE.LIBRARIAN]: + case obj_ini.player_role_data[eROLE.LIBRARIAN].role: if ((old_guard >= 90 && company > 0 && company < 6) || company == 1) { bionic_count = choose(0, 0, 1, 2, 3); } else if (company > 0 && company < 6) { @@ -491,7 +491,7 @@ function scr_marine_game_spawn_constructions() { bionic_count = choose(0, 0, 0, 0, 1); } break; - case obj_ini.role[100][eROLE.CHAMPION]: + case obj_ini.player_role_data[eROLE.CHAMPION].role: if (old_guard >= 80 || company == 1) { bionic_count = choose(0, 0, 1, 2, 3); } else { From 605c8af25e22e1f45bc9a1de85a6b87053843e76 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 17:11:54 +0100 Subject: [PATCH 21/82] more static array conversioni --- objects/obj_controller/Alarm_5.gml | 4 +- objects/obj_controller/Alarm_6.gml | 34 +++++----- objects/obj_ncombat/Alarm_1.gml | 36 +++++------ objects/obj_popup/Create_0.gml | 36 +++++------ scripts/Armamentarium/Armamentarium.gml | 6 +- scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- scripts/scr_UnitGroup/scr_UnitGroup.gml | 2 +- scripts/scr_add_man/scr_add_man.gml | 10 +-- scripts/scr_apothecarium/scr_apothecarium.gml | 18 +++--- .../scr_chapter_managent_events.gml | 2 +- scripts/scr_company_view/scr_company_view.gml | 4 +- .../scr_controller_helpers.gml | 10 +-- scripts/scr_crusade/scr_crusade.gml | 6 +- .../scr_culture_visuals.gml | 2 +- .../scr_diplomacy_helpers.gml | 2 +- .../scr_draw_planet_features.gml | 2 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 6 +- scripts/scr_event_code/scr_event_code.gml | 14 ++--- .../scr_initialize_custom.gml | 62 +++++++++---------- scripts/scr_librarium/scr_librarium.gml | 4 +- .../scr_marine_struct/scr_marine_struct.gml | 2 +- .../scr_mechanicus_missions.gml | 16 ++--- .../scr_mission_reward/scr_mission_reward.gml | 10 +-- .../scr_planetary_feature.gml | 6 +- .../scr_popup_functions.gml | 4 +- .../scr_post_battle_events.gml | 2 +- scripts/scr_promote/scr_promote.gml | 6 +- scripts/scr_random_event/scr_random_event.gml | 6 +- scripts/scr_role_setup/scr_role_setup.gml | 2 +- scripts/scr_roster/scr_roster.gml | 4 +- scripts/scr_ruins_reward/scr_ruins_reward.gml | 2 +- scripts/scr_ship_battle/scr_ship_battle.gml | 24 +++---- scripts/scr_special_view/scr_special_view.gml | 8 +-- .../scr_specialist_point_handler.gml | 2 +- .../scr_specialist_training.gml | 22 +++---- scripts/scr_squads/scr_squads.gml | 2 +- scripts/scr_ui_advisors/scr_ui_advisors.gml | 18 +++--- .../scr_unit_detail_text.gml | 4 +- 38 files changed, 201 insertions(+), 201 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index a82cb43bc3..6daf5855e6 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -475,12 +475,12 @@ try { scr_loyalty("Xeno Associate", "+"); } - var loyalty_counter = scr_role_count(obj_ini.role[100][15], ""); + var loyalty_counter = scr_role_count(obj_ini.player_role_data[eROLE.APOTHECARY].role, ""); if (loyalty_counter == 0) { scr_loyalty("Lack of Apothecary", "+"); } - loyalty_counter = scr_role_count(obj_ini.role[100][14], ""); + loyalty_counter = scr_role_count(obj_ini.player_role_data[eROLE.CHAPLAIN].role, ""); if (loyalty_counter == 0) { scr_loyalty("Undevout", "+"); } diff --git a/objects/obj_controller/Alarm_6.gml b/objects/obj_controller/Alarm_6.gml index 98e9d90cc5..fdfb119493 100644 --- a/objects/obj_controller/Alarm_6.gml +++ b/objects/obj_controller/Alarm_6.gml @@ -34,25 +34,25 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { manz += 1; if (unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { cap += 1; - } else if (unit.role() == obj_ini.role[100][15]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) { apo += 1; - } else if (unit.role() == obj_ini.role[100][14]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { chap += 1; - } else if (unit.role() == obj_ini.role[100][17]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { lib += 1; - } else if (unit.role() == obj_ini.role[100][16]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { tech += 1; } else if (unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { drea += 1; } else if (unit.role() == $"Venerable {obj_ini.player_role_data[eROLE.DREADNOUGHT].role}") { vdrea += 1; - } else if (unit.role() == obj_ini.role[100][11]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { bear += 1; - } else if (unit.role() == obj_ini.role[100][8]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { tct += 1; - } else if (unit.role() == obj_ini.role[100][10]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.ASSAULT].role) { assa += 1; - } else if (unit.role() == obj_ini.role[100][9]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.DEVASTATOR].role) { dev += 1; } else if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { sco += 1; @@ -62,7 +62,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { ve += 1; } else if (unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { ter += 1; - } else if (unit.role() == obj_ini.role[100][18]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.SERGEANT].role) { sgt++; } else if (unit.role() == obj_ini.player_role_data[eROLE.VETERANSERGEANT].role) { vet_sgt++; @@ -107,7 +107,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (chap > 0) { - selecting_dudes += string(chap) + " " + string(obj_ini.role[100][14]); + selecting_dudes += string(chap) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role); if (chap > 1) { selecting_dudes += "s"; } @@ -121,14 +121,14 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (apo > 0) { - selecting_dudes += string(apo) + " " + string(obj_ini.role[100][15]); + selecting_dudes += string(apo) + " " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role); if (apo > 1) { selecting_dudes += "s"; } selecting_dudes += ", "; } if (lib > 0) { - selecting_dudes += string(lib) + " " + string(obj_ini.role[100][17]); + selecting_dudes += string(lib) + " " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role); if (lib > 1) { selecting_dudes += "s"; } @@ -149,7 +149,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (bear > 0) { - selecting_dudes += string(bear) + " " + string(obj_ini.role[100][11]); + selecting_dudes += string(bear) + " " + string(obj_ini.player_role_data[eROLE.ANCIENT].role); if (bear > 1) { selecting_dudes += "s"; } @@ -163,7 +163,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (tech > 0) { - selecting_dudes += string(tech) + " " + string(obj_ini.role[100][16]); + selecting_dudes += string(tech) + " " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role); if (tech > 1) { selecting_dudes += "s"; } @@ -184,14 +184,14 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (tct > 0) { - selecting_dudes += string(tct) + " " + string(obj_ini.role[100][8]); + selecting_dudes += string(tct) + " " + string(obj_ini.player_role_data[eROLE.TACTICAL].role); if (tct > 1) { selecting_dudes += "s"; } selecting_dudes += ", "; } if (dev > 0) { - selecting_dudes += string(dev) + " " + string(obj_ini.role[100][9]); + selecting_dudes += string(dev) + " " + string(obj_ini.player_role_data[eROLE.DEVASTATOR].role); if (dev > 1) { selecting_dudes += "s"; } @@ -219,7 +219,7 @@ if ((menu == eMENU.MANAGE) && (managing > 0)) { selecting_dudes += ", "; } if (sgt > 0) { - selecting_dudes += string(sgt) + " " + string(obj_ini.role[100][18]); + selecting_dudes += string(sgt) + " " + string(obj_ini.player_role_data[eROLE.SERGEANT].role); if (sgt > 1) { selecting_dudes += "s"; } diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index 18a626a542..56bfaf50c5 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -163,14 +163,14 @@ if (string_count("_attack", battle_special) > 0) { } if ((tacticals > 0) && (veterans > 0)) { - p2 = string(tacticals + veterans) + " " + string(obj_ini.role[100][8]) + "s, "; + 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.role[100][8]) + ", "; + p2 = string(tacticals) + " " + string(obj_ini.player_role_data[eROLE.TACTICAL].role) + ", "; } if (tacticals > 1) { - p2 = string(tacticals) + " " + string(obj_ini.role[100][8]) + "s, "; + p2 = string(tacticals) + " " + string(obj_ini.player_role_data[eROLE.TACTICAL].role) + "s, "; } } if ((tacticals == 0) && (veterans > 0)) { @@ -184,18 +184,18 @@ if ((tacticals == 0) && (veterans > 0)) { if (assaults > 0) { if (assaults == 1) { - p2 += string(assaults) + " " + string(obj_ini.role[100][10]) + ", "; + p2 += string(assaults) + " " + string(obj_ini.player_role_data[eROLE.ASSAULT].role) + ", "; } if (assaults > 1) { - p2 += string(assaults) + " " + string(obj_ini.role[100][10]) + "s, "; + 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.role[100][9]) + ", "; + p2 += string(devastators) + " " + string(obj_ini.player_role_data[eROLE.DEVASTATOR].role) + ", "; } if (devastators > 1) { - p2 += string(devastators) + " " + string(obj_ini.role[100][9]) + "s, "; + p2 += string(devastators) + " " + string(obj_ini.player_role_data[eROLE.DEVASTATOR].role) + "s, "; } } @@ -210,45 +210,45 @@ if ((temp < 200) && (terminators > 0)) { if ((temp < 200) && (chaplains > 0)) { if (chaplains == 1) { - p2 += string(chaplains) + " " + string(obj_ini.role[100][14]) + ", "; + p2 += string(chaplains) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + ", "; } if (chaplains > 1) { - p2 += string(chaplains) + " " + string(obj_ini.role[100][14]) + ", "; + p2 += string(chaplains) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + ", "; } } if ((temp < 200) && (apothecaries > 0)) { if (apothecaries == 1) { - p2 += string(apothecaries) + " " + string(obj_ini.role[100][15]) + ", "; + p2 += string(apothecaries) + " " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ", "; } if (apothecaries > 1) { - p2 += string(apothecaries) + " " + string(obj_ini.role[100][15]) + ", "; + p2 += string(apothecaries) + " " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ", "; } } if ((temp < 200) && (librarians > 0)) { if (librarians == 1) { - p2 += string(librarians) + " " + string(obj_ini.role[100][17]) + ", "; + p2 += string(librarians) + " " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + ", "; } if (librarians > 1) { - p2 += string(librarians) + " " + string(obj_ini.role[100][17]) + ", "; + p2 += string(librarians) + " " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + ", "; } } if ((temp < 200) && (techmarines > 0)) { if (techmarines == 1) { - p2 += string(techmarines) + " " + string(obj_ini.role[100][16]) + ", "; + p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + ", "; } if (techmarines > 1) { - p2 += string(techmarines) + " " + string(obj_ini.role[100][16]) + ", "; + 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.role[100][18]) + ", "; + p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.SERGEANT].role) + ", "; } if (techmarines > 1) { - p2 += string(techmarines) + " " + string(obj_ini.role[100][18]) + ", "; + p2 += string(techmarines) + " " + string(obj_ini.player_role_data[eROLE.SERGEANT].role) + ", "; } } if ((temp < 200) && (vet_sgts > 0)) { @@ -607,7 +607,7 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && !dropp p1 = "The Master of Sanctity "; } if (big_mofo == 3) { - p1 = "Chief " + string(obj_ini.role[100][17]) + " "; + p1 = "Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " "; } if (big_mofo == 5) { p1 = "A Captain "; diff --git a/objects/obj_popup/Create_0.gml b/objects/obj_popup/Create_0.gml index 6eb1d48c3a..e5c57e89ad 100644 --- a/objects/obj_popup/Create_0.gml +++ b/objects/obj_popup/Create_0.gml @@ -129,14 +129,14 @@ get_unit_promotion_options = function() { array_set_value(role_exp, 0); var i = 0; // this area does the required exp for roles per company - if (unit_role == obj_ini.role[100][16]) { + if (unit_role == obj_ini.player_role_data[eROLE.TECHMARINE].role) { //techmarine - role_name[1] = obj_ini.role[100][16]; + role_name[1] = obj_ini.player_role_data[eROLE.TECHMARINE].role; role_exp[1] = 5; spec = 1; - } else if (unit_role == obj_ini.role[100][15]) { + } else if (unit_role == obj_ini.player_role_data[eROLE.APOTHECARY].role) { //apothecary - role_name[1] = obj_ini.role[100][15]; + role_name[1] = obj_ini.player_role_data[eROLE.APOTHECARY].role; role_exp[1] = 5; spec = 1; } else if (unit_role == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { @@ -144,19 +144,19 @@ get_unit_promotion_options = function() { role_name[1] = "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role); role_exp[1] = 400; spec = 0; - } else if (unit_role == obj_ini.role[100][14] && global.chapter_name != "Space Wolves" && global.chapter_name != "Iron Hands") { + } else if (unit_role == obj_ini.player_role_data[eROLE.CHAPLAIN].role && global.chapter_name != "Space Wolves" && global.chapter_name != "Iron Hands") { //chaplain - role_name[1] = obj_ini.role[100][14]; + role_name[1] = obj_ini.player_role_data[eROLE.CHAPLAIN].role; role_exp[1] = 5; spec = 1; } else if (unit_role == "Lexicanum") { - role_name[1] = obj_ini.role[100][17]; + role_name[1] = obj_ini.player_role_data[eROLE.LIBRARIAN].role; role_exp[1] = 125; spec = 1; role_name[2] = "Codiciery"; role_exp[2] = 80; } else if (unit_role == "Codiciery" && target_comp == 0) { - role_name[1] = obj_ini.role[100][17]; + role_name[1] = obj_ini.player_role_data[eROLE.LIBRARIAN].role; role_exp[1] = 125; spec = 1; } @@ -168,16 +168,16 @@ get_unit_promotion_options = function() { role_name[i] = obj_ini.player_role_data[eROLE.CAPTAIN].role; role_exp[i] = 80; //all captains are equalish } - if (scr_role_count(obj_ini.role[100][11], "1") == 0) { + if (scr_role_count(obj_ini.player_role_data[eROLE.ANCIENT].role, "1") == 0) { //company ancient i += 1; - role_name[i] = obj_ini.role[100][11]; + role_name[i] = obj_ini.player_role_data[eROLE.ANCIENT].role; role_exp[i] = company_promote_data[target_comp].exp + 10; } - if (scr_role_count(obj_ini.role[100][7], "1") == 0) { + if (scr_role_count(obj_ini.player_role_data[eROLE.CHAMPION].role, "1") == 0) { //company champ i += 1; - role_name[i] = obj_ini.role[100][7]; + role_name[i] = obj_ini.player_role_data[eROLE.CHAMPION].role; role_exp[i] = company_promote_data[target_comp].exp + 10; //may as well have this liniked to weapon skill } i += 1; @@ -188,7 +188,7 @@ get_unit_promotion_options = function() { if (obj_controller.command_set[2] == 1) { if (array_contains([2, 3, 4, 5, 6, 7], target_comp)) { i += 1; - role_name[i] = obj_ini.role[100][8]; //tacts + role_name[i] = obj_ini.player_role_data[eROLE.TACTICAL].role; //tacts role_exp[i] = company_promote_data[target_comp].exp; if (obj_controller.command_set[2] == 0) { role_exp[i] = 0; @@ -197,7 +197,7 @@ get_unit_promotion_options = function() { if (array_contains([2, 3, 4, 5, 8], target_comp)) { i += 1; - role_name[i] = obj_ini.role[100][10]; //assualts + role_name[i] = obj_ini.player_role_data[eROLE.ASSAULT].role; //assualts role_exp[i] = company_promote_data[target_comp].exp; if (obj_controller.command_set[2] == 0) { role_exp[i] = 0; @@ -206,7 +206,7 @@ get_unit_promotion_options = function() { if (array_contains([2, 3, 4, 5, 9], target_comp)) { i += 1; - role_name[i] = obj_ini.role[100][9]; //devs + role_name[i] = obj_ini.player_role_data[eROLE.DEVASTATOR].role; //devs role_exp[i] = company_promote_data[target_comp].exp; if (obj_controller.command_set[2] == 0) { role_exp[i] = 0; @@ -235,15 +235,15 @@ get_unit_promotion_options = function() { } } else { i += 1; - role_name[i] = obj_ini.role[100][8]; //tacts + role_name[i] = obj_ini.player_role_data[eROLE.TACTICAL].role; //tacts role_exp[i] = 0; i += 1; - role_name[i] = obj_ini.role[100][10]; //assualts + role_name[i] = obj_ini.player_role_data[eROLE.ASSAULT].role; //assualts role_exp[i] = 0; i += 1; - role_name[i] = obj_ini.role[100][9]; //devs + role_name[i] = obj_ini.player_role_data[eROLE.DEVASTATOR].role; //devs role_exp[i] = 0; i += 1; diff --git a/scripts/Armamentarium/Armamentarium.gml b/scripts/Armamentarium/Armamentarium.gml index fefa1964ef..5e3708b92e 100644 --- a/scripts/Armamentarium/Armamentarium.gml +++ b/scripts/Armamentarium/Armamentarium.gml @@ -736,7 +736,7 @@ function Armamentarium(_controller) constructor { /// @desc Updates the counts of tech-capable personnel. static _refresh_personnel_counts = function() { - var _role_name = obj_ini.role[100][16]; + var _role_name = obj_ini.player_role_data[eROLE.TECHMARINE].role; count_techmarines = scr_role_count(_role_name, ""); count_aspirants = scr_role_count($"{_role_name} Aspirant", ""); count_total = count_techmarines + count_aspirants; @@ -825,7 +825,7 @@ function Armamentarium(_controller) constructor { /// @desc Save CPU time during Draw. static _update_advisor_report = function() { - var _role_tech = obj_ini.role[100][16]; + var _role_tech = obj_ini.player_role_data[eROLE.TECHMARINE].role; var _dispo_mech = controller.disposition[3]; var _max_techs = round(_dispo_mech / 2) + 5; var _diff = _max_techs - count_total; @@ -1155,7 +1155,7 @@ function Armamentarium(_controller) constructor { controller.specialist_point_handler.draw_forge_queue(359, 132); - var _role_name = obj_ini.role[100][16]; + var _role_name = obj_ini.player_role_data[eROLE.TECHMARINE].role; var _master_craft = controller.master_craft_chance; var _forge_count = controller.player_forge_data.player_forges; diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 93ef230662..43edd8acc1 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -901,7 +901,7 @@ function PlanetData(_planet, _system) constructor { var _slaughter = new_player_ship("Gloriana", system.name, "Slaughtersong"); var flit = create_player_fleet(system.x, system.y, [_slaughter]); - scr_popup($"Ancient Ship Restored", $"The ancient ship within the ruins of {locy} has been fully repaired. It is determined to be a Gloriana Class vessel and is bristling with golden age weaponry and armour. Your {string(obj_ini.role[100][16])}s are excited; the Slaughtersong is ready for it's maiden voyage, at your command.", "", ""); + scr_popup($"Ancient Ship Restored", $"The ancient ship within the ruins of {locy} has been fully repaired. It is determined to be a Gloriana Class vessel and is bristling with golden age weaponry and armour. Your {string(obj_ini.player_role_data[eROLE.TECHMARINE].role)}s are excited; the Slaughtersong is ready for it's maiden voyage, at your command.", "", ""); } } } catch (_exception) { diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 59f9feb99d..1ae4c48a78 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -284,7 +284,7 @@ function UnitGroup(units) constructor { //if a new sergeant is needed find the marine with the highest experience in the squad //(which if everything works right should be a marine with the old_guard, seasoned, or ancient trait) - /*and ((squad_fulfilment[$ obj_ini.role[100][8]] > 4)or (squad_fulfilment[$ obj_ini.role[100][10]] > 4) or (squad_fulfilment[$ obj_ini.role[100][9]] > 4)or (squad_fulfilment[$ obj_ini.player_role_data[eROLE.VETERAN].role] > 4) )*/ + /*and ((squad_fulfilment[$ obj_ini.player_role_data[eROLE.TACTICAL].role] > 4)or (squad_fulfilment[$ obj_ini.player_role_data[eROLE.ASSAULT].role] > 4) or (squad_fulfilment[$ obj_ini.player_role_data[eROLE.DEVASTATOR].role] > 4)or (squad_fulfilment[$ obj_ini.player_role_data[eROLE.VETERAN].role] > 4) )*/ var _members = squad.get_members(true); var _exp_unit = 0; diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index fbe795ae88..6bf2ea7de3 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -93,11 +93,11 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption if (!array_contains(non_marine_roles, man_role)) { if (man_role == obj_ini.player_role_data[eROLE.SCOUT].role) { _gear = { - wep2: obj_ini.wep2[100][12], - wep1: obj_ini.wep1[100][12], - armour: obj_ini.armour[100][12], - gear: obj_ini.gear[100][12], - mobi: obj_ini.mobi[100][12], + wep2: obj_ini.player_role_data[eROLE.SCOUT].wep2, + wep1: obj_ini.player_role_data[eROLE.SCOUT].wep1, + armour: obj_ini.player_role_data[eROLE.SCOUT].armour, + gear: obj_ini.player_role_data[eROLE.SCOUT].gear, + mobi: obj_ini.player_role_data[eROLE.SCOUT].mobi, }; } diff --git a/scripts/scr_apothecarium/scr_apothecarium.gml b/scripts/scr_apothecarium/scr_apothecarium.gml index d46e4d8bad..c6861e1023 100644 --- a/scripts/scr_apothecarium/scr_apothecarium.gml +++ b/scripts/scr_apothecarium/scr_apothecarium.gml @@ -45,7 +45,7 @@ function scr_apothecarium() { var xx = camera_get_view_x(view_camera[0]); var yy = camera_get_view_y(view_camera[0]); var eta = 0; - var _apoth_screen_text = "Milord, I come with a report. Our Chapter currently boasts " + string(obj_controller.temp[36]) + " " + string(obj_ini.role[100][15]) + " working on a variety of things, from field-duty to research to administrative duties. "; + var _apoth_screen_text = "Milord, I come with a report. Our Chapter currently boasts " + string(obj_controller.temp[36]) + " " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " working on a variety of things, from field-duty to research to administrative duties. "; draw_sprite(spr_rock_bg, 0, xx, yy); @@ -87,15 +87,15 @@ function scr_apothecarium() { } if (obj_controller.training_apothecary == 0) { - _apoth_screen_text += "Our Brothers are currently not assigned to train further " + string(obj_ini.role[100][15]) + "; no more can be trained until Apothcarium funds are increased."; + _apoth_screen_text += "Our Brothers are currently not assigned to train further " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + "; no more can be trained until Apothcarium funds are increased."; } if (obj_controller.training_apothecary > 0) { - _apoth_screen_text += "Our Brothers assigned to the training of future " + string(obj_ini.role[100][15]) + "s have taken up a "; + _apoth_screen_text += "Our Brothers assigned to the training of future " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + "s have taken up a "; if (obj_controller.training_apothecary >= 1 && obj_controller.training_apothecary <= 6) { var _recruit_rates = global.recruitment_rates; _apoth_screen_text += _recruit_rates[obj_controller.training_apothecary]; } - _apoth_screen_text += " pace and expect to graduate an additional " + string(obj_ini.role[100][15]) + " in "; + _apoth_screen_text += " pace and expect to graduate an additional " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " in "; var training_points_values = global.apothecary_training_tiers; eta = floor((47 - obj_controller.apothecary_recruit_points) / training_points_values[obj_controller.training_apothecary]) + 1; _apoth_screen_text += string(eta) + " months."; @@ -105,10 +105,10 @@ function scr_apothecarium() { _apoth_screen_text += "##My lord, our stocks of gene-seed are empty. It would be best to have some come mechanicus tithe.##Further training of Neophytes is halted until our stocks replenish."; } if ((obj_controller.gene_seed > 0) && (obj_controller.gene_seed <= 10)) { - _apoth_screen_text += "##My Brother " + string(obj_ini.role[100][15]) + "s assigned to the gene-vault have informed me that our stocks are nearly gone. They only number " + string(obj_controller.gene_seed) + "; this includes those recently recovered from our fallen comerades-in-arms."; + _apoth_screen_text += "##My Brother " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + "s assigned to the gene-vault have informed me that our stocks are nearly gone. They only number " + string(obj_controller.gene_seed) + "; this includes those recently recovered from our fallen comerades-in-arms."; } if (obj_controller.gene_seed > 10) { - _apoth_screen_text += "##My Brother " + string(obj_ini.role[100][15]) + "s assigned to the gene-vault have informed me that our stocks of gene-seed currently number " + string(obj_controller.gene_seed) + ". This includes those recently recovered from our fallen comerades-in-arms."; + _apoth_screen_text += "##My Brother " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + "s assigned to the gene-vault have informed me that our stocks of gene-seed currently number " + string(obj_controller.gene_seed) + ". This includes those recently recovered from our fallen comerades-in-arms."; } if (obj_controller.gene_seed > 0) { _apoth_screen_text += "##The stocks are stable and show no sign of mutation."; @@ -116,13 +116,13 @@ function scr_apothecarium() { if (obj_controller.menu_adept == 1) { var _recruit_pace = global.recruitment_pace_descriptions; - _apoth_screen_text = "Your Chapter contains " + string(obj_controller.temp[36]) + " " + string(obj_ini.role[100][15]) + ".##"; - _apoth_screen_text += "Training of further " + string(obj_ini.role[100][15]) + "s"; + _apoth_screen_text = "Your Chapter contains " + string(obj_controller.temp[36]) + " " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ".##"; + _apoth_screen_text += "Training of further " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + "s"; if (obj_controller.training_apothecary >= 0 && obj_controller.training_apothecary <= 6) { _apoth_screen_text += _recruit_pace[obj_controller.training_apothecary]; } if (obj_controller.training_apothecary > 0) { - _apoth_screen_text += " The next " + string(obj_ini.role[100][15]) + " is expected in " + string(eta) + " months."; + _apoth_screen_text += " The next " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " is expected in " + string(eta) + " months."; } _apoth_screen_text += "##You have " + string(obj_controller.gene_seed) + " gene-seed stocked."; } diff --git a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index 400b8acd8e..8e3aedcdf2 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -133,7 +133,7 @@ function setup_new_forge_master_popup(techs) { }; for (var i = array_length(techs) - 1; i >= 0; i--) { - if (techs[i].role() != obj_ini.role[100][16]) { + if (techs[i].role() != obj_ini.player_role_data[eROLE.TECHMARINE].role) { array_delete(techs, i, 1); } } diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index 36cb7825cd..4bb98f1171 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -324,9 +324,9 @@ function other_manage_data() { } } else if ((_unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (ma_exp[v] >= 400)) { ma_promote[v] = 1; - } else if ((_unit.role() == obj_ini.role[100][15]) || (ma_role[v] == obj_ini.role[100][14])) { + } else if ((_unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) || (ma_role[v] == obj_ini.player_role_data[eROLE.CHAPLAIN].role)) { ma_promote[v] = 1; - } else if (_unit.role() == obj_ini.role[100][16]) { + } else if (_unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { ma_promote[v] = 1; } diff --git a/scripts/scr_controller_helpers/scr_controller_helpers.gml b/scripts/scr_controller_helpers/scr_controller_helpers.gml index cd9d237906..ccc393063e 100644 --- a/scripts/scr_controller_helpers/scr_controller_helpers.gml +++ b/scripts/scr_controller_helpers/scr_controller_helpers.gml @@ -211,7 +211,7 @@ function scr_toggle_apothecarion() { if (menu != eMENU.APOTHECARION) { menu = eMENU.APOTHECARION; - temp[36] = scr_role_count(obj_ini.role[100][15], ""); + temp[36] = scr_role_count(obj_ini.player_role_data[eROLE.APOTHECARY].role, ""); } } }); @@ -229,8 +229,8 @@ function scr_toggle_reclu() { if (menu != eMENU.RECLUSIAM) { menu = eMENU.RECLUSIAM; - temp[36] = string(scr_role_count(obj_ini.role[100][14], "field")); - temp[37] = string(scr_role_count(obj_ini.role[100][14], "home")); + temp[36] = string(scr_role_count(obj_ini.player_role_data[eROLE.CHAPLAIN].role, "field")); + temp[37] = string(scr_role_count(obj_ini.player_role_data[eROLE.CHAPLAIN].role, "home")); penitorium = 0; // Get list of jailed marines @@ -258,7 +258,7 @@ function scr_toggle_lib() { var yy = camera_get_view_y(view_camera[0]); menu_adept = 0; hide_banner = 1; - if (scr_role_count("Chief " + string(obj_ini.role[100][17]), "0") == 0) { + if (scr_role_count("Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role), "0") == 0) { menu_adept = 1; } if (menu != eMENU.LIBRARIUM) { @@ -267,7 +267,7 @@ function scr_toggle_lib() { if ((artifacts > 0) && (menu_artifact == 0)) { menu_artifact = 1; } - temp[36] = scr_role_count(obj_ini.role[100][17], ""); + temp[36] = scr_role_count(obj_ini.player_role_data[eROLE.LIBRARIAN].role, ""); temp[37] = scr_role_count("Codiciery", ""); temp[38] = scr_role_count("Lexicanum", ""); artifact_equip = new ShutterButton(); diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 882b5e4308..0157951de5 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -104,7 +104,7 @@ function scr_crusade() { array_push(heroics_strings, heroic_death); } } - } else if (unit.role() == obj_ini.role[100][11] || unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role || unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { _dead = false; } } @@ -182,10 +182,10 @@ function scr_crusade() { if (obj_ini.doomed == 0) { if ((apoth > 0) && (seed > 0)) { - tixt += " The " + string(apoth) + " surviving " + string(obj_ini.role[100][15]) + " were able to recover " + string(seed) + " Gene-Seed."; + tixt += " The " + string(apoth) + " surviving " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " were able to recover " + string(seed) + " Gene-Seed."; } if ((apoth == 0) && (seed > 0)) { - tixt += " You had no able-bodied " + string(obj_ini.role[100][15]) + ", or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(seed) + " of your Gene-Seed."; + tixt += " You had no able-bodied " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ", or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(seed) + " of your Gene-Seed."; } } if (obj_ini.doomed == 1) { diff --git a/scripts/scr_culture_visuals/scr_culture_visuals.gml b/scripts/scr_culture_visuals/scr_culture_visuals.gml index 45f604a40a..25a74819a7 100644 --- a/scripts/scr_culture_visuals/scr_culture_visuals.gml +++ b/scripts/scr_culture_visuals/scr_culture_visuals.gml @@ -2211,7 +2211,7 @@ function DummyMarine() constructor { if (obj_creation.livery_selection_options.current_selection == 2) { return role[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; } else { - return role[100][eROLE.TACTICAL]; + return player_role_data[eROLE.TACTICAL].role; } } }; diff --git a/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml b/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml index cf80eacfdb..a4cbc1f01b 100644 --- a/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml +++ b/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml @@ -289,7 +289,7 @@ function scr_emmisary_diplomacy_routes() { scr_diplomacy_hit(1,, function() { cooldown = 8000; diplomacy_pathway = "sacrifice_champ"; - var champ = scr_random_marine(obj_ini.role[100][7], 0); + var champ = scr_random_marine(obj_ini.player_role_data[eROLE.CHAMPION].role, 0); if (champ != "none") { var chapter_master = fetch_unit([0, 1]); chapter_master.add_trait("blood_for_blood"); diff --git a/scripts/scr_draw_planet_features/scr_draw_planet_features.gml b/scripts/scr_draw_planet_features/scr_draw_planet_features.gml index df5033ce78..91eaedfffb 100644 --- a/scripts/scr_draw_planet_features/scr_draw_planet_features.gml +++ b/scripts/scr_draw_planet_features/scr_draw_planet_features.gml @@ -134,7 +134,7 @@ function FeatureSelected(_feature, _system, _planet) constructor { case eP_FEATURES.STC_FRAGMENT: generic = true; title = "STC Fragment"; - body = $"Unload a {obj_ini.role[100][16]} and whatever entourage you deem necessary to recover the STC Fragment"; + body = $"Unload a {obj_ini.player_role_data[eROLE.TECHMARINE].role} and whatever entourage you deem necessary to recover the STC Fragment"; break; case eP_FEATURES.GENE_STEALER_CULT: generic = true; diff --git a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml index a9d9002bea..74caa6583f 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -156,12 +156,12 @@ function scr_enemy_ai_d() { } if (has_problem_planet_and_time(i, "Hive Fleet", 3) > -1) { - var woop = scr_role_count("Chief " + string(obj_ini.role[100][17]), ""); + var woop = scr_role_count("Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role), ""); var yep = !scr_has_disadv("Psyker Intolerant"); if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop != 0) && yep) { - scr_popup("Shadow in the Warp", $"Chief {obj_ini.role[100][17]} " + string(obj_ini.name[0][5]) + " reports a disturbance in the warp. He claims it is like a shadow.", "shadow", ""); - scr_event_log("red", $"Chief {obj_ini.role[100][17]} reports a disturbance in the warp. He claims it is like a shadow."); + scr_popup("Shadow in the Warp", $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role} " + string(obj_ini.name[0][5]) + " reports a disturbance in the warp. He claims it is like a shadow.", "shadow", ""); + scr_event_log("red", $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role} reports a disturbance in the warp. He claims it is like a shadow."); } if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop == 0) && yep) { for (var q = 0; q < array_length(obj_ini.TTRPG[0]); q++) { diff --git a/scripts/scr_event_code/scr_event_code.gml b/scripts/scr_event_code/scr_event_code.gml index 8431bf7d98..6c8cd5fb63 100644 --- a/scripts/scr_event_code/scr_event_code.gml +++ b/scripts/scr_event_code/scr_event_code.gml @@ -167,24 +167,24 @@ function event_end_turn_action() { LOGGER.warning($"comp: {comp}, marine_num: {marine_num}"); - var killy = 0, tixt = $"{obj_ini.role[100][16]} {marine_name} has finished his work- "; + var killy = 0, tixt = $"{obj_ini.player_role_data[eROLE.TECHMARINE].role} {marine_name} has finished his work- "; if (item == "Icon") { tixt += $"it is a {global.chapter_name} Icon wrought in metal, finely decorated. Pride for his chapter seems to have overtaken him. There are no corrections to be made and the item is placed where many may view it."; } if (item == "Statue") { - tixt += "it is a small, finely crafted statue wrought in metal. The " + string(obj_ini.role[100][16]) + " is scolded for the waste of material, but none daresay the quality of the piece."; + tixt += "it is a small, finely crafted statue wrought in metal. The " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " is scolded for the waste of material, but none daresay the quality of the piece."; } if (item == "Bike") { scr_add_item("Bike", 1); - tixt += "it is a finely crafted Bike, conforming mostly to STC standards. The other " + string(obj_ini.role[100][16]) + " are surprised at the rapid pace of his work."; + tixt += "it is a finely crafted Bike, conforming mostly to STC standards. The other " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " are surprised at the rapid pace of his work."; } if (item == "Rhino") { scr_add_vehicle("Rhino", 0, {}, "Storm Bolter", "Storm Bolter", "", "Artificer Hull", "Dozer Blades"); - tixt += "it is a finely crafted Rhino, conforming to STC standards. The other " + string(obj_ini.role[100][16]) + " are surprised at the rapid pace of his work."; + tixt += "it is a finely crafted Rhino, conforming to STC standards. The other " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " are surprised at the rapid pace of his work."; } if (item == "Artifact") { - scr_event_log("", string(obj_ini.role[100][16]) + " " + string(marine_name) + " constructs an Artifact."); + scr_event_log("", string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " " + string(marine_name) + " constructs an Artifact."); var _last_artifact = scr_add_artifact("random_nodemon", "", 0); tixt += $"some form of divine inspiration has seemed to have taken hold of him. An artifact {obj_ini.artifact[_last_artifact]} has been crafted."; @@ -194,7 +194,7 @@ function event_end_turn_action() { tixt += "some form of horrendous statue. A weird amalgram of limbs and tentacles, the sheer atrocity of it is made worse by the tiny, baby-like form, the once natural shape of a human child twisted nearly beyond recognition."; } else if (item == "robot") { _unit.edit_corruption(choose(2, 4, 6, 8, 10)); - tixt += $"some form of small, box-like robot. It seems to teeter around haphazardly, nearly falling over with each step. {_unit.name()} maintains that it has no AI, though the other " + string(obj_ini.role[100][16]) + " express skepticism."; + tixt += $"some form of small, box-like robot. It seems to teeter around haphazardly, nearly falling over with each step. {_unit.name()} maintains that it has no AI, though the other " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " express skepticism."; _unit.add_trait("tech_heretic"); } else if (item == "demon") { _unit.edit_corruption(choose(8, 12, 16, 20)); @@ -203,7 +203,7 @@ function event_end_turn_action() { } else if (item == "fusion") { //TODO if tech heretic chosen don't kill the dude // _unit.corruption+=choose(70); - tixt += $"some kind of ill-mannered ascension. One of your battle-brothers enters the armamentarium to find {marine_name} fused to a vehicle, his flesh twisted and submerged into the frame. Mechendrites and weapons fire upon the marine without warning, a windy scream eminating from the abomination. It takes several battle-brothers to take out what was once a " + string(obj_ini.role[100][16]) + "."; + tixt += $"some kind of ill-mannered ascension. One of your battle-brothers enters the armamentarium to find {marine_name} fused to a vehicle, his flesh twisted and submerged into the frame. Mechendrites and weapons fire upon the marine without warning, a windy scream eminating from the abomination. It takes several battle-brothers to take out what was once a " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + "."; // This is causing the problem diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 5393ffe683..63555af795 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1581,24 +1581,24 @@ function scr_initialize_custom() { } var roles = { - chapter_master: role[defaults_slot][eROLE.CHAPTERMASTER], - honour_guard: role[defaults_slot][eROLE.HONOURGUARD], - veteran: role[defaults_slot][eROLE.VETERAN], - terminator: role[defaults_slot][eROLE.TERMINATOR], - captain: role[defaults_slot][eROLE.CAPTAIN], - dreadnought: role[defaults_slot][eROLE.DREADNOUGHT], - champion: role[defaults_slot][eROLE.CHAMPION], - tactical: role[defaults_slot][eROLE.TACTICAL], - devastator: role[defaults_slot][eROLE.DEVASTATOR], - assault: role[defaults_slot][eROLE.ASSAULT], - ancient: role[defaults_slot][eROLE.ANCIENT], - scout: role[defaults_slot][eROLE.SCOUT], - chaplain: role[defaults_slot][eROLE.CHAPLAIN], - apothecary: role[defaults_slot][eROLE.APOTHECARY], - techmarine: role[defaults_slot][eROLE.TECHMARINE], - librarian: role[defaults_slot][eROLE.LIBRARIAN], - sergeant: role[defaults_slot][eROLE.SERGEANT], - veteran_sergeant: role[defaults_slot][eROLE.VETERANSERGEANT], + chapter_master: player_role_data[eROLE.CHAPTERMASTER].role, + honour_guard: player_role_data[eROLE.HONOURGUARD].role, + veteran: player_role_data[eROLE.VETERAN].role, + terminator: player_role_data[eROLE.TERMINATOR].role, + captain: player_role_data[eROLE.CAPTAIN].role, + dreadnought: player_role_data[eROLE.DREADNOUGHT].role, + champion: player_role_data[eROLE.CHAMPION].role, + tactical: player_role_data[eROLE.TACTICAL].role, + devastator: player_role_data[eROLE.DEVASTATOR].role, + assault: player_role_data[eROLE.ASSAULT].role, + ancient: player_role_data[eROLE.ANCIENT].role, + scout: player_role_data[eROLE.SCOUT].role, + chaplain: player_role_data[eROLE.CHAPLAIN].role, + apothecary: player_role_data[eROLE.APOTHECARY].role, + techmarine: player_role_data[eROLE.TECHMARINE].role, + librarian: player_role_data[eROLE.LIBRARIAN].role, + sergeant: player_role_data[eROLE.SERGEANT].role, + veteran_sergeant: player_role_data[eROLE.VETERANSERGEANT].role, }; #endregion @@ -1839,7 +1839,7 @@ function scr_initialize_custom() { "min": 4, "loadout": { //tactical breacher marine - "required": {"wep1": [wep1[100][8], 7], "wep2": ["Boarding Shield", "max"], "armour": ["MK3 Iron Armour", "max"], "gear": ["Plasma Bomb", "max"], "mobi": ["", "max"]}, + "required": {"wep1": [player_role_data[eROLE.TACTICAL].wep1, 7], "wep2": ["Boarding Shield", "max"], "armour": ["MK3 Iron Armour", "max"], "gear": ["Plasma Bomb", "max"], "mobi": ["", "max"]}, "option": {"wep1": [[["Flamer", "Flamer", "Flamer", "Grav-Gun", "Meltagun", "Lascutter"], 2]]}, }, "role": $"Breacher", @@ -2465,7 +2465,7 @@ function scr_initialize_custom() { case "devastators": _rolename = roles.devastator; _erole = eROLE.DEVASTATOR; - if (wep1[defaults_slot][eROLE.DEVASTATOR] == "Heavy Ranged") { + if (player_role_data[eROLE.DEVASTATOR].wep1 == "Heavy Ranged") { _wep1 = choose("Multi-Melta", "Lascannon", "Missile Launcher", "Heavy Bolter"); } break; @@ -2562,7 +2562,7 @@ function scr_initialize_custom() { } if (_coy.coy == 1 && _coy.terminators > 0) { _armour = scr_has_adv("Crafters") ? "Tartaros" : "Terminator Armour"; - _wep2 = wep2[defaults_slot][eROLE.TERMINATOR]; + _wep2 = player_role_data[eROLE.TERMINATOR].wep2; } break; case "apothecaries": @@ -2574,8 +2574,8 @@ function scr_initialize_custom() { } if (_coy.coy == 1 && _coy.terminators > 0) { _armour = scr_has_adv("Crafters") ? "Tartaros" : "Terminator Armour"; - _wep1 = wep1[defaults_slot][eROLE.TERMINATOR]; - _wep2 = wep2[defaults_slot][eROLE.TERMINATOR]; + _wep1 = player_role_data[eROLE.TERMINATOR].wep1; + _wep2 = player_role_data[eROLE.TERMINATOR].wep2; } break; case "techmarines": @@ -2585,7 +2585,7 @@ function scr_initialize_custom() { if (_coy.coy == 1) { if (_coy.terminators > 0) { _armour = scr_has_adv("Crafters") ? "Tartaros" : "Terminator Armour"; - _wep2 = wep2[defaults_slot][eROLE.TERMINATOR]; + _wep2 = player_role_data[eROLE.TERMINATOR].wep2; } if (!_is_terminator(_armour)) { if (scr_has_disadv("Poor Equipment")) { @@ -2605,7 +2605,7 @@ function scr_initialize_custom() { } if (_coy.coy == 1 && _coy.terminators > 0) { _armour = scr_has_adv("Crafters") ? "Tartaros" : "Terminator Armour"; - _wep2 = wep2[defaults_slot][eROLE.TERMINATOR]; + _wep2 = player_role_data[eROLE.TERMINATOR].wep2; } break; case "champions": @@ -2614,7 +2614,7 @@ function scr_initialize_custom() { if (_coy.coy == 1 && _coy.terminators > 0) { _armour = scr_has_adv("Crafters") ? "Tartaros" : "Terminator Armour"; _wep1 = "Thunder Hammer"; - _wep2 = wep2[defaults_slot][eROLE.TERMINATOR]; + _wep2 = player_role_data[eROLE.TERMINATOR].wep2; if (global.chapter_name == "Dark Angels") { _wep1 = "Heavy Thunder Hammer"; _wep2 = ""; @@ -2626,7 +2626,7 @@ function scr_initialize_custom() { _erole = eROLE.ANCIENT; if (_coy.coy == 1 && _coy.terminators > 0) { _armour = scr_has_adv("Crafters") ? "Tartaros" : "Terminator Armour"; - _wep2 = wep2[defaults_slot][eROLE.TERMINATOR]; + _wep2 = player_role_data[eROLE.TERMINATOR].wep2; } break; @@ -2830,8 +2830,8 @@ function scr_initialize_custom() { if (scr_has_disadv("Sieged")) { scr_add_item("Narthecium", 4); - scr_add_item(wep1[defaults_slot][eROLE.APOTHECARY], 4); - scr_add_item(wep2[defaults_slot][eROLE.APOTHECARY], 4); + scr_add_item(player_role_data[eROLE.APOTHECARY].wep1, 4); + scr_add_item(player_role_data[eROLE.APOTHECARY].wep2, 4); scr_add_item("Psychic Hood", 4); scr_add_item("Crozius Arcanum", 4); scr_add_item("Servo-arm", 4); @@ -3009,7 +3009,7 @@ function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 } else if (role_name == "Codiciery") { spawn_unit.psionic = irandom_range(5, 7); if (roll_dice_unit(spawn_unit, 1, 6, "high") < 4) { - spawn_unit.update_gear(obj_ini.gear[obj_ini.defaults_slot][eROLE.TACTICAL], false, false); + spawn_unit.update_gear(obj_ini.player_role_data[eROLE.TACTICAL].gear, false, false); } if (roll_dice_unit(spawn_unit, 1, 6, "high") < 4) { spawn_unit.update_weapon_one(choose("Force Axe", "Force Sword"), false, false); @@ -3017,7 +3017,7 @@ function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 } else if (role_name == "Lexicanum") { spawn_unit.psionic = irandom_range(2, 4); spawn_unit.update_weapon_one(choose("Force Axe", "Force Sword"), false, false); - spawn_unit.update_gear(obj_ini.gear[obj_ini.defaults_slot][eROLE.TACTICAL], false, false); + spawn_unit.update_gear(obj_ini.player_role_data[eROLE.TACTICAL].gear, false, false); } spawn_unit.update_powers(); } diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index 6d29161710..940f75964e 100644 --- a/scripts/scr_librarium/scr_librarium.gml +++ b/scripts/scr_librarium/scr_librarium.gml @@ -186,7 +186,7 @@ function scr_librarium() { draw_set_color(c_gray); draw_set_font(fnt_40k_30b); draw_text_transformed(xx + 352, yy + 66, "Librarium", 1, 1, 0); - draw_text_transformed(xx + 352, yy + 100, string_hash_to_newline("Chief " + string(obj_ini.role[100][17]) + " " + string(obj_ini.name[0][4])), 0.6, 0.6, 0); + draw_text_transformed(xx + 352, yy + 100, string_hash_to_newline("Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " " + string(obj_ini.name[0][4])), 0.6, 0.6, 0); draw_set_font(fnt_40k_14); } if (menu_adept == 1) { @@ -221,7 +221,7 @@ function scr_librarium() { draw_text_ext(xx + 352, yy + 130, string_hash_to_newline($"Chapter Master {obj_ini.name[0][0]}, greetings.#I assume you've come for the report? The Chapter currently possesses {temp[36]} Epistolaries, {temp[37]} Codiceries, and {temp[38]} Lexicanum. We are working to identify additional warp-sensitive brothers before they cause harm, and the training is {blurp}.##We could likely speed up the identification and application of appropriate training, but we would need more resources...I don't suppose we can spare some?##Our Chapter has {artif}"), -1, 536); } if (menu_adept == 1) { - draw_text_ext(xx + 352, yy + 130, string_hash_to_newline($"Your Chapter contains {temp[36]} {obj_ini.role[100][17]}s, {temp[37]} Codiceries, and {temp[38]} Lexicanum.##Training of more {obj_ini.role[100][17]}s is {blurp}.##Your chapter has {artif}"), -1, 536); + draw_text_ext(xx + 352, yy + 130, string_hash_to_newline($"Your Chapter contains {temp[36]} {obj_ini.player_role_data[eROLE.LIBRARIAN].role}s, {temp[37]} Codiceries, and {temp[38]} Lexicanum.##Training of more {obj_ini.player_role_data[eROLE.LIBRARIAN].role}s is {blurp}.##Your chapter has {artif}"), -1, 536); } draw_set_color(#5F730D); diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 57aac6aba6..9efb5200ef 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -1048,7 +1048,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} qual_string = "no_items"; } if (new_weapon == "Company Standard") { - if (role() != obj_ini.role[100][11]) { + if (role() != obj_ini.player_role_data[eROLE.ANCIENT].role) { viable = false; qual_string = "wrong_role"; } diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 02b90b03f6..084e0d83f0 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -149,7 +149,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { if (array_length(_forge_stars)) { array_push(mechanicus_missions, "mech_bionics"); - if (scr_role_count(obj_ini.role[100][16], "") >= 6) { + if (scr_role_count(obj_ini.player_role_data[eROLE.TECHMARINE].role, "") >= 6) { array_push(mechanicus_missions, "mech_raider"); } } @@ -191,7 +191,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { }; var _name = star.name; if (chosen_mission == "mech_raider") { - text = $"The Adeptus Mechanicus are trusting you with a special mission. They wish for you to bring a Land Raider and six {obj_ini.role[100][16]} to a Forge World in {_name} for testing and training, for a duration of 24 months. You have four years to complete this. Can your chapter handle this mission?"; + text = $"The Adeptus Mechanicus are trusting you with a special mission. They wish for you to bring a Land Raider and six {obj_ini.player_role_data[eROLE.TECHMARINE].role} to a Forge World in {_name} for testing and training, for a duration of 24 months. You have four years to complete this. Can your chapter handle this mission?"; _mission_data.options = [ { str1: "Accept", @@ -217,7 +217,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { ]; _evented = true; } else { - text = $"The local Adeptus Mechanicus are preparing to embark on a voyage to Mars, to delve into the catacombs in search of lost technology. Due to your close relations they have made the offer to take some of your {obj_ini.role[100][16]}s with them for both their unique abilities to function as both scientific helpers and as helpers (high Weapon Skill and Technology is reccomended). Can your chapter handle this mission?"; + text = $"The local Adeptus Mechanicus are preparing to embark on a voyage to Mars, to delve into the catacombs in search of lost technology. Due to your close relations they have made the offer to take some of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s with them for both their unique abilities to function as both scientific helpers and as helpers (high Weapon Skill and Technology is reccomended). Can your chapter handle this mission?"; _mission_data.options = [ { str1: "Accept", @@ -311,8 +311,8 @@ function accept_mechanicus_land_raider_mission() { var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, _star.x, _star.y, _nearest_fleet, false); _planet.add_problem("mech_raider", _mission_time, {completion: 0, required_months: 24}); - text = $"The Adeptus Mechanicus await your forces at {_mission_loc}. They are expecting six {obj_ini.role[100][16]}s and a Land Raider."; - scr_event_log("", $"Mechanicus Mission Accepted: Six of your {obj_ini.role[100][16]}s and a Land Raider are to be stationed at {_mission_loc} for {_mission_time} months.", _star.name); + text = $"The Adeptus Mechanicus await your forces at {_mission_loc}. They are expecting six {obj_ini.player_role_data[eROLE.TECHMARINE].role}s and a Land Raider."; + scr_event_log("", $"Mechanicus Mission Accepted: Six of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s and a Land Raider are to be stationed at {_mission_loc} for {_mission_time} months.", _star.name); with (_star) { new_star_event_marker("green"); } @@ -360,8 +360,8 @@ function accept_mechanicus_mars_mission() { _planet.add_problem("mech_bionics", _mission_time, {completion: 0, required_months: 24}); _planet.add_problem("mech_mars", _mission_time); - text = $"The Adeptus Mechanicus await your {obj_ini.role[100][16]}s at {_mission_loc}. They are willing to hold on the voyage for up to {_mission_time} months."; - scr_event_log("", $"Mechanicus Mission Accepted: {obj_ini.role[100][16]}s are expected at {_mission_loc} within 30 months, for the voyage to Mars.", _star.name); + text = $"The Adeptus Mechanicus await your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s at {_mission_loc}. They are willing to hold on the voyage for up to {_mission_time} months."; + scr_event_log("", $"Mechanicus Mission Accepted: {obj_ini.player_role_data[eROLE.TECHMARINE].role}s are expected at {_mission_loc} within 30 months, for the voyage to Mars.", _star.name); with (_star) { new_star_event_marker("green"); } @@ -424,7 +424,7 @@ function mechanicus_mars_mission_target_time_elapsed(planet) { if (techs_taken >= 5) { obj_controller.disposition[3] += max(techs_taken, 4); } - var _text = $"Mechanicus Ship departs for the Mars catacombs. Onboard are {techs_taken} of your {obj_ini.role[100][16]}s."; + var _text = $"Mechanicus Ship departs for the Mars catacombs. Onboard are {techs_taken} of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s."; scr_alert("", "mission", _text, 0, 0); scr_event_log("green", _text); var flit = create_enemy_fleet(x, y, eFACTION.MECHANICUS); diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml index be982d132e..a5b4d73b43 100644 --- a/scripts/scr_mission_reward/scr_mission_reward.gml +++ b/scripts/scr_mission_reward/scr_mission_reward.gml @@ -69,7 +69,7 @@ function scr_mission_reward(mission, star, planet) { } } - var tixt = $"The journey into the Mars Catacombs was a success. Your {techs_alive} remaining {obj_ini.role[100][16]}s were useful to the Mechanicus force and return with a bounty. They await retrieval at {star.name} {scr_roman(planet)}.\n"; + var tixt = $"The journey into the Mars Catacombs was a success. Your {techs_alive} remaining {obj_ini.player_role_data[eROLE.TECHMARINE].role}s were useful to the Mechanicus force and return with a bounty. They await retrieval at {star.name} {scr_roman(planet)}.\n"; tixt += $"\n{found_requisition} Requisition from salvage"; if (found_artifact > 0) { tixt += $"\n{string_plural("Unidentified Artifacts", found_artifact)} recovered"; @@ -83,7 +83,7 @@ function scr_mission_reward(mission, star, planet) { } scr_popup("Mechanicus Mission Completed", tixt, "mechanicus", ""); - tixt = "Mechanicus Mission Completed: {techs_alive}/{techs_alive+techs_lost} of your {obj_ini.role[100][16]}s return with "; + tixt = "Mechanicus Mission Completed: {techs_alive}/{techs_alive+techs_lost} of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s return with "; tixt += string(found_requisition) + " Requisition, "; if (found_artifact > 0) { tixt += $"\n{found_artifact} : {string_plural("Unidentified Artifacts", found_artifact)} recovered"; @@ -114,7 +114,7 @@ function scr_mission_reward(mission, star, planet) { } if (result == "New") { - scr_popup("Mechanicus Mission Completed", $"Your {obj_ini.role[100][16]} have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 300 Requisition has been given to your Chapter and relations are better than before.", "mechanicus", ""); + scr_popup("Mechanicus Mission Completed", $"Your {obj_ini.player_role_data[eROLE.TECHMARINE].role} have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 300 Requisition has been given to your Chapter and relations are better than before.", "mechanicus", ""); obj_controller.requisition += 300; obj_controller.disposition[3] += 2; var onceh = 0; @@ -146,7 +146,7 @@ function scr_mission_reward(mission, star, planet) { } } if (result == "Land Raider") { - scr_popup("Mechanicus Mission Completed", "Your " + string(obj_ini.role[100][16]) + " have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. A new Land Raider has been provided in return.", "mechanicus", ""); + scr_popup("Mechanicus Mission Completed", "Your " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. A new Land Raider has been provided in return.", "mechanicus", ""); var onceh = 0; obj_controller.disposition[3] += 1; for (var com = 0; com <= 10; com++) { @@ -163,7 +163,7 @@ function scr_mission_reward(mission, star, planet) { } } if (result == "Requisition") { - scr_popup("Mechanicus Mission Completed", "Your " + string(obj_ini.role[100][16]) + " have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 600 Requisition has been given to your Chapter as compensation.", "mechanicus", ""); + scr_popup("Mechanicus Mission Completed", "Your " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 600 Requisition has been given to your Chapter as compensation.", "mechanicus", ""); obj_controller.requisition += 600; obj_controller.disposition[3] += 1; } diff --git a/scripts/scr_planetary_feature/scr_planetary_feature.gml b/scripts/scr_planetary_feature/scr_planetary_feature.gml index a14bc78edd..572a4d9046 100644 --- a/scripts/scr_planetary_feature/scr_planetary_feature.gml +++ b/scripts/scr_planetary_feature/scr_planetary_feature.gml @@ -580,14 +580,14 @@ function discover_stc_fragment_popup(techies, mechanicus_reps) { if (techies > 0) { array_push(options, {str1: "Swiftly take the STC Fragment.", choice_func: remove_stc_from_planet}); if (mechanicus_reps == 0) { - pop.text = $"{_text}; what it might contain is unknown. Your {obj_ini.role[100][16]}s wish to reclaim, identify, and put it to use immediately. What is thy will?"; + pop.text = $"{_text}; what it might contain is unknown. Your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s wish to reclaim, identify, and put it to use immediately. What is thy will?"; } else { - pop.text = $"{_text}. Your {obj_ini.role[100][16]}s wish to reclaim, identify, and put it to use immediately, and the Tech Priests wish to send it to the closest forge world. What is thy will?"; + pop.text = $"{_text}. Your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s wish to reclaim, identify, and put it to use immediately, and the Tech Priests wish to send it to the closest forge world. What is thy will?"; } } else if (mechanicus_reps > 0) { pop.text = $"{_text}; what it might contain is unknown. The present Tech Priests wish to send it to Mars, and refuse to take the device off-world otherwise."; } else { - pop.text = $"{_text}; what it might contain is unknown. The ground team has no {obj_ini.role[100][16]}s or Tech Priests, so you have no choice but to leave it be or notify the Mechanicus about its location."; + pop.text = $"{_text}; what it might contain is unknown. The ground team has no {obj_ini.player_role_data[eROLE.TECHMARINE].role}s or Tech Priests, so you have no choice but to leave it be or notify the Mechanicus about its location."; } array_push(options, {str1: "Send it to the Adeptus Mechanicuss.", choice_func: send_stc_to_adeptus_mech}); diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index ee58b5d1d6..5fbf836ec5 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -303,7 +303,7 @@ function calculate_equipment_needs() { req_wep2_num = 0; req_mobi = ""; req_mobi_num = 0; - req_gear = obj_ini.gear[100][17]; + req_gear = obj_ini.player_role_data[eROLE.LIBRARIAN].gear; req_gear_num = units; } else if (rall == "Lexicanum") { req_armour = ""; @@ -314,7 +314,7 @@ function calculate_equipment_needs() { req_wep2_num = 0; req_mobi = ""; req_mobi_num = 0; - } else if (rall == obj_ini.role[100][11]) { + } else if (rall == obj_ini.player_role_data[eROLE.ANCIENT].role) { req_armour = STR_ANY_POWER_ARMOUR; req_armour_num = units; req_wep2 = "Company Standard"; diff --git a/scripts/scr_post_battle_events/scr_post_battle_events.gml b/scripts/scr_post_battle_events/scr_post_battle_events.gml index 555650580a..6dc58c72ee 100644 --- a/scripts/scr_post_battle_events/scr_post_battle_events.gml +++ b/scripts/scr_post_battle_events/scr_post_battle_events.gml @@ -88,7 +88,7 @@ function hunt_fallen_battle_aftermath() { var tixt = "The Fallen on " + battle_object[current_battle].name; tixt += scr_roman(battle_world[current_battle]); scr_event_log("", $"Mission Succesful: {tixt} have been captured or purged."); - tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.role[100][14]}s posthaste, in order to account for their sins. "; + tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; var _tex_options = [ "Suffering is the beginning to penance.", "Their screams shall be the harbringer of their contrition.", diff --git a/scripts/scr_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index d5f3c98a4a..c941e7830c 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -47,9 +47,9 @@ function setup_promotion_popup() { // Gets the number of marines in the target company var unit, squad_mover, moveable; var role_squad_equivilances = {}; //this is the only way to set variables as keys in gml - variable_struct_set(role_squad_equivilances, obj_ini.role[100][8], "tactical_squad"); - variable_struct_set(role_squad_equivilances, obj_ini.role[100][9], "devastator_squad"); - variable_struct_set(role_squad_equivilances, obj_ini.role[100][10], "assault_squad"); + variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.TACTICAL].role, "tactical_squad"); + variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.DEVASTATOR].role, "devastator_squad"); + variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.ASSAULT].role, "assault_squad"); variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.SCOUT].role, "scout_squad"); variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.VETERAN].role, "veteran_squad"); variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.TERMINATOR].role, "terminator_squad"); diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index fe1ffdaf43..39e3af72d7 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -265,7 +265,7 @@ function scr_random_event(execute_now) { } } else if (chosen_event == eEVENT.PROMOTION) { LOGGER.info("RE: Promotion"); - var marine_and_company = scr_random_marine([obj_ini.role[100][8], obj_ini.player_role_data[eROLE.SCOUT].role, obj_ini.role[100][9], obj_ini.role[100][10]], 0); + var marine_and_company = scr_random_marine([obj_ini.player_role_data[eROLE.TACTICAL].role, obj_ini.player_role_data[eROLE.SCOUT].role, obj_ini.player_role_data[eROLE.DEVASTATOR].role, obj_ini.player_role_data[eROLE.ASSAULT].role], 0); if (marine_and_company == "none") { LOGGER.error("RE: Promotion, couldn't pick a space marine"); exit; @@ -705,7 +705,7 @@ function scr_random_event(execute_now) { add_event({e_id: "chaos_invasion", duration: 1}); var psyker_intolerant = scr_has_disadv("Psyker Intolerant"); - var has_chief_psyker = scr_role_count("Chief " + string(obj_ini.role[100][17]), "") >= 1; + var has_chief_psyker = scr_role_count("Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role), "") >= 1; var cm_is_psyker = false; for (var i = 0; i < array_length(TTRPG[0]); i++) { var _unit = fetch_unit([0 ,i]); @@ -716,7 +716,7 @@ function scr_random_event(execute_now) { } if ((!psyker_intolerant) && has_chief_psyker) { - scr_popup("The Maw of the Warp Yawns Wide", "Chief " + string(obj_ini.role[100][17]) + " " + string(obj_ini.name[0][5]) + " reports that the barrier between the realm of man and the Immaterium feels thin and tested.", "Warp", ""); + scr_popup("The Maw of the Warp Yawns Wide", "Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " " + string(obj_ini.name[0][5]) + " reports that the barrier between the realm of man and the Immaterium feels thin and tested.", "Warp", ""); } else if ((psyker_intolerant || !has_chief_psyker) && cm_is_psyker) { scr_popup("The Maw of the Warp Yawns Wide", "The barrier between the realm of man and the Immaterium feels thin and tested to you. Dark forces are afoot.", "Warp", ""); } diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index f28b818342..46f3cc1d33 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -62,7 +62,7 @@ function role_setup_objects() { style: "box", x1: 500, y1: 250, - tooltip: $"Specialist Distribution\nCheck if you wish for your Companies to be uniform and each contain {role[100][10]}s and {role[100][9]}s.", + tooltip: $"Specialist Distribution\nCheck if you wish for your Companies to be uniform and each contain {player_role_data[eROLE.ASSAULT].role}s and {player_role_data[eROLE.DEVASTATOR].role}s.", active: (squad_distribution == 1 || squad_distribution == 3), clicked_check_default: true, }); diff --git a/scripts/scr_roster/scr_roster.gml b/scripts/scr_roster/scr_roster.gml index c517afb9c6..dd07b674ab 100644 --- a/scripts/scr_roster/scr_roster.gml +++ b/scripts/scr_roster/scr_roster.gml @@ -544,7 +544,7 @@ function add_unit_to_battle(unit, meeting, is_local) { new_combat.player_starting_dudes++; } - if (_unit_role == obj_ini.role[100][18]) { + if (_unit_role == obj_ini.player_role_data[eROLE.SERGEANT].role) { col = obj_controller.bat_tactical_column; //sergeants new_combat.sgts++; } else if (_unit_role == _role[19]) { @@ -555,7 +555,7 @@ function add_unit_to_battle(unit, meeting, is_local) { //scouts col = obj_controller.bat_scout_column; new_combat.scouts++; - } else if (array_contains([obj_ini.role[100][8], $"{_role[15]} Aspirant", $"{_role[14]} Aspirant"], _unit_role)) { + } else if (array_contains([obj_ini.player_role_data[eROLE.TACTICAL].role, $"{_role[15]} Aspirant", $"{_role[14]} Aspirant"], _unit_role)) { col = obj_controller.bat_tactical_column; //tactical_marines new_combat.tacticals++; } else if (_unit_role == _role[3]) { diff --git a/scripts/scr_ruins_reward/scr_ruins_reward.gml b/scripts/scr_ruins_reward/scr_ruins_reward.gml index 1f8871c97a..03526be82e 100644 --- a/scripts/scr_ruins_reward/scr_ruins_reward.gml +++ b/scripts/scr_ruins_reward/scr_ruins_reward.gml @@ -206,7 +206,7 @@ function scr_ruins_reward(_star_system, _pid_idx, _ruins) { case eLOOT_TYPE.STARSHIP: _popup.image = "ruins_ship"; _popup.title = "Ancient Ruins: Starship"; - _popup.text = $"The ground beneath one of your battle brothers crumbles, and he falls a great height. The other marines go down in pursuit. Within a great chamber they find the remains of an ancient starship. Though derelict, it is possible to land {obj_ini.role[100][16]}s to repair the ship. 10,000 Requisition will be needed to make it operational."; + _popup.text = $"The ground beneath one of your battle brothers crumbles, and he falls a great height. The other marines go down in pursuit. Within a great chamber they find the remains of an ancient starship. Though derelict, it is possible to land {obj_ini.player_role_data[eROLE.TECHMARINE].role}s to repair the ship. 10,000 Requisition will be needed to make it operational."; _ruins.find_starship(); scr_event_log("", $"Ancient Starship discovered on {_planet_name}.", _star_system.name); break; diff --git a/scripts/scr_ship_battle/scr_ship_battle.gml b/scripts/scr_ship_battle/scr_ship_battle.gml index 0536bdd400..2a184dc78b 100644 --- a/scripts/scr_ship_battle/scr_ship_battle.gml +++ b/scripts/scr_ship_battle/scr_ship_battle.gml @@ -66,7 +66,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { col = obj_controller.bat_scout_column; obj_ncombat.scouts += 1; } - if (unit.role() == obj_ini.role[100][8]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { col = obj_controller.bat_tactical_column; obj_ncombat.tacticals += 1; } @@ -74,15 +74,15 @@ function scr_ship_battle(target_ship_id, cooridor_width) { col = obj_controller.bat_veteran_column; obj_ncombat.veterans += 1; } - if (unit.role() == obj_ini.role[100][9]) { + 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.role[100][10]) { + 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.role[100][17]) { + if (unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { col = obj_controller.bat_librarian_column; obj_ncombat.librarians += 1; } @@ -98,7 +98,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { col = obj_controller.bat_librarian_column; obj_ncombat.librarians += 1; } - if (unit.role() == obj_ini.role[100][16]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { col = obj_controller.bat_techmarine_column; obj_ncombat.techmarines += 1; } @@ -119,11 +119,11 @@ function scr_ship_battle(target_ship_id, cooridor_width) { obj_ncombat.terminators += 1; } - if ((unit.role() == obj_ini.role[100][15]) || (unit.role() == obj_ini.role[100][14])) { - if (unit.role() == obj_ini.role[100][15]) { + 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.role[100][14]) { + 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; @@ -142,17 +142,17 @@ function scr_ship_battle(target_ship_id, cooridor_width) { } } - if ((unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) || (unit.role() == obj_ini.role[100][11]) || (unit.role() == obj_ini.role[100][7])) { + 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.role[100][11]) { + if (unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { obj_ncombat.standard_bearers += 1; } - if (unit.role() == obj_ini.role[100][7]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role) { obj_ncombat.champions += 1; } @@ -196,7 +196,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { col = obj_controller.bat_command_column; obj_ncombat.important_dudes += 1; } - if (unit.role() == "Chief " + string(obj_ini.role[100][17])) { + 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) { diff --git a/scripts/scr_special_view/scr_special_view.gml b/scripts/scr_special_view/scr_special_view.gml index 24b24260ea..e58e10b777 100644 --- a/scripts/scr_special_view/scr_special_view.gml +++ b/scripts/scr_special_view/scr_special_view.gml @@ -159,16 +159,16 @@ function scr_special_view(command_group) { // Squads if (squads > 0) { var n = 1; - if (squad_typ == obj_ini.role[100][15]) { + if (squad_typ == obj_ini.player_role_data[eROLE.APOTHECARY].role) { n = 0; } - if (squad_typ == obj_ini.role[100][14]) { + if (squad_typ == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { n = 0; } - if (squad_typ == obj_ini.role[100][17]) { + if (squad_typ == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { n = 0; } - if (squad_typ == obj_ini.role[100][16]) { + if (squad_typ == obj_ini.player_role_data[eROLE.TECHMARINE].role) { n = 0; } if (squad_typ == "Codiciery") { diff --git a/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml b/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml index 69b687b91e..98b67b5f3c 100644 --- a/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml +++ b/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml @@ -129,7 +129,7 @@ function SpecialistPointHandler() constructor { new_tech_heretic_spawn(); if (forge_master == -1) { - var _tech_units = scr_role_count(obj_ini.role[100][16], "", "units"); + var _tech_units = scr_role_count(obj_ini.player_role_data[eROLE.TECHMARINE].role, "", "units"); var _count = array_length(_tech_units); if (_count > 1) { setup_new_forge_master_popup(techs); diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index ea347b335c..c71423c484 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -3,14 +3,14 @@ /// @param {Real} req_exp function specialistfunct(specialist, req_exp) { var spec_tips = [ - string("{0} Potential", obj_ini.role[100][16]), - string("{0} Potential", obj_ini.role[100][15]), - string("{0} Potential", obj_ini.role[100][14]), - string("{0} Potential", obj_ini.role[100][17]), - string("{0} Applicant", obj_ini.role[100][16]), - string("{0} Applicant", obj_ini.role[100][15]), - string("{0} Applicant", obj_ini.role[100][14]), - string("{0} Applicant", obj_ini.role[100][17]), + string("{0} Potential", obj_ini.player_role_data[eROLE.TECHMARINE].role), + string("{0} Potential", obj_ini.player_role_data[eROLE.APOTHECARY].role), + string("{0} Potential", obj_ini.player_role_data[eROLE.CHAPLAIN].role), + string("{0} Potential", obj_ini.player_role_data[eROLE.LIBRARIAN].role), + string("{0} Applicant", obj_ini.player_role_data[eROLE.TECHMARINE].role), + string("{0} Applicant", obj_ini.player_role_data[eROLE.APOTHECARY].role), + string("{0} Applicant", obj_ini.player_role_data[eROLE.CHAPLAIN].role), + string("{0} Applicant", obj_ini.player_role_data[eROLE.LIBRARIAN].role), string("Promote to Marine"), ]; @@ -111,7 +111,7 @@ function spec_data_set(specialist) { var random_marine = scr_random_marine( // TODO LOW SEARCH_OPTIONAL // Make this function handle optional search_params - [obj_ini.role[100][8], obj_ini.role[100][18], obj_ini.role[100][10], obj_ini.role[100][9]], + [obj_ini.player_role_data[eROLE.TACTICAL].role, obj_ini.player_role_data[eROLE.SERGEANT].role, obj_ini.player_role_data[eROLE.ASSAULT].role, obj_ini.player_role_data[eROLE.DEVASTATOR].role], _data.min_exp, _search, ); @@ -195,7 +195,7 @@ function chaplain_training() { var training_points_values = global.chaplain_training_tiers; if ((global.chapter_name != "Space Wolves") && (global.chapter_name != "Iron Hands")) { chaplain_points += training_points_values[training_chaplain]; - var novice_type = string("{0} Aspirant", obj_ini.role[100][14]); + var novice_type = string("{0} Aspirant", obj_ini.player_role_data[eROLE.CHAPLAIN].role); if (training_chaplain > 0) { recruit_count = scr_role_count(novice_type, ""); @@ -266,7 +266,7 @@ function librarian_training() { psyker_points += training_points_values[training_psyker]; var goal = 48; - var novice_type = string("{0} Aspirant", obj_ini.role[100][17]); + var novice_type = string("{0} Aspirant", obj_ini.player_role_data[eROLE.LIBRARIAN].role); if (training_psyker > 0) { recruit_count = scr_role_count(novice_type, ""); diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index e4c50f0984..fc3e646c91 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -335,7 +335,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { if (veteran == true) { new_role = obj_ini.player_role_data[eROLE.VETERANSERGEANT].role; } else { - new_role = obj_ini.role[100][18]; + new_role = obj_ini.player_role_data[eROLE.SERGEANT].role; } exp_unit.update_role(new_role); if (irandom(1) == 0) { diff --git a/scripts/scr_ui_advisors/scr_ui_advisors.gml b/scripts/scr_ui_advisors/scr_ui_advisors.gml index cfbdcae0f2..111957b902 100644 --- a/scripts/scr_ui_advisors/scr_ui_advisors.gml +++ b/scripts/scr_ui_advisors/scr_ui_advisors.gml @@ -76,13 +76,13 @@ function scr_ui_advisors() { draw_set_alpha(1); draw_set_color(c_gray); if (temp[36] != "0") { - blurp = $"Sir! You requested a report? Currently, we have deployed {temp[36]} {obj_ini.role[100][14]}s to watch over the health of our Battle-Brothers in the field. We have an additional " + string(temp[37]) + " " + string(obj_ini.role[100][14]) + "s who await only your order to carry the word to the troops."; + blurp = $"Sir! You requested a report? Currently, we have deployed {temp[36]} {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s to watch over the health of our Battle-Brothers in the field. We have an additional " + string(temp[37]) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + "s who await only your order to carry the word to the troops."; } if (temp[36] == "0") { blurp = "Sir! You requested a report? Currently, we have {temp[37]} {obj_ini.role[100, 14]}s who await only your order to carry the word to the troops."; } if ((global.chapter_name != "Space Wolves") && (global.chapter_name != "Iron Hands")) { - blurp += "##Currently, we are training additional " + string(obj_ini.role[100][14]) + " at a "; + blurp += "##Currently, we are training additional " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " at a "; var _recruit_rates = global.recruitment_rates; blurp += _recruit_rates[training_chaplain]; if (training_chaplain > 0 && training_chaplain <= 6) { @@ -136,15 +136,15 @@ function scr_ui_advisors() { draw_set_color(c_gray); if (menu_adept == 1) { - blurp = "Your Chapter contains " + string(temp[36]) + " " + string(obj_ini.role[100][14]) + "s.##"; + blurp = "Your Chapter contains " + string(temp[36]) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + "s.##"; if ((global.chapter_name != "Space Wolves") && (global.chapter_name != "Iron Hands")) { - blurp += "Training of further " + string(obj_ini.role[100][14]) + "s"; + blurp += "Training of further " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + "s"; if (training_chaplain >= 0 && training_chaplain <= 6) { var _recruit_pace = global.recruitment_pace_descriptions; blurp += _recruit_pace[training_chaplain]; } if (training_chaplain > 0) { - blurp += " The next " + string(obj_ini.role[100][14]) + " is expected in " + string(eta) + " months."; + blurp += " The next " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " is expected in " + string(eta) + " months."; } } } @@ -165,7 +165,7 @@ function scr_ui_advisors() { if (menu_adept == 0) { if (fest_scheduled == 0) { if ((global.chapter_name != "Space Wolves") && (global.chapter_name != "Iron Hands")) { - blurp2 = "As our bolters are charged with death for the Emperor's enemies, our thoughts are charged with his wisdom. As our bodies are armoured with Adamantium, our souls are protected with our loyalty- loyalty to Him, and loyalty to our brothers. The bonds of this brotherhood are worth revering, even if a lull in duty invites doubt and heresy. Should you wish to schedule a rousing event, or challenge, I will make it so. Under the careful watch of our " + string(obj_ini.role[100][14]) + "s, our brothers' spirits may be lifted."; + blurp2 = "As our bolters are charged with death for the Emperor's enemies, our thoughts are charged with his wisdom. As our bodies are armoured with Adamantium, our souls are protected with our loyalty- loyalty to Him, and loyalty to our brothers. The bonds of this brotherhood are worth revering, even if a lull in duty invites doubt and heresy. Should you wish to schedule a rousing event, or challenge, I will make it so. Under the careful watch of our " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + "s, our brothers' spirits may be lifted."; } if (global.chapter_name == "Space Wolves") { blurp2 = ""; @@ -281,13 +281,13 @@ function scr_ui_advisors() { } if (fest_type == "Chapter Relic") { if (fest_feature1 == 1) { - blurp2 += " Our " + string(obj_ini.role[100][16]) + "s aim to create a weapon."; + blurp2 += " Our " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + "s aim to create a weapon."; } if (fest_feature2 == 1) { - blurp2 += " Our " + string(obj_ini.role[100][16]) + "s aim to create a suit of armour."; + blurp2 += " Our " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + "s aim to create a suit of armour."; } if (fest_feature3 == 1) { - blurp2 += " Our " + string(obj_ini.role[100][16]) + "s aim to hone and strengthen an already existing relic."; + blurp2 += " Our " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + "s aim to hone and strengthen an already existing relic."; } } if (fest_type == "Imperial Mass") { diff --git a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml index c2ed807208..9c40f84771 100644 --- a/scripts/scr_unit_detail_text/scr_unit_detail_text.gml +++ b/scripts/scr_unit_detail_text/scr_unit_detail_text.gml @@ -2,7 +2,7 @@ function scr_unit_detail_text() { var unit_data_string = ""; var is_astartes = false; - var is_superior = array_contains([obj_ini.role[100][18], obj_ini.player_role_data[eROLE.VETERANSERGEANT].role], role()); + var is_superior = array_contains([obj_ini.player_role_data[eROLE.SERGEANT].role, obj_ini.player_role_data[eROLE.VETERANSERGEANT].role], role()); var unit_name = name(); var unit_role = role(); var body_augmentations = { @@ -78,7 +78,7 @@ function scr_unit_detail_text() { // Psyker text unit_data_string += $"Has an Assignment rating of {_psionic_assignment} ({psionic}) "; - var is_lib = array_contains(["Lexicanum", "Codiciery", obj_ini.role[100][17]], role()) || role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role; + var is_lib = array_contains(["Lexicanum", "Codiciery", obj_ini.player_role_data[eROLE.LIBRARIAN].role], role()) || role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role; if (psionic < -6) { unit_data_string += ", so inert in the Warp as to actually exhibit negative psychic influence upon others."; } else if (psionic < 0) { From a38c09754cb9cece4d1d259ac51524ccb7b3a5c6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 18:32:29 +0100 Subject: [PATCH 22/82] few final tweaks --- objects/obj_controller/Alarm_5.gml | 32 +++++++++++---------- scripts/scr_check_equip/scr_check_equip.gml | 4 +-- scripts/scr_max_marine/scr_max_marine.gml | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index a2f8d1cf42..e4e1d947bd 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -291,21 +291,23 @@ try { for (var c = 0; c < 11; c++) { for (var e = 0; e < array_length(obj_ini.TTRPG[c]); e++) { var _unit = fetch_unit([c,e]); - if (_unit.god_status == 10) { - if (!is_struct(_unit)) { - continue; - } - p += 1; - penit_co[p] = c; - penit_id[p] = e; - penitorium += 1; - _unit.alter_loyalty(-1); - if ((_unit.corruption < 90) && (_unit.corruption > 0)) { - var heresy_old = 0, heresy_new = 0; - heresy_old = round((_unit.corruption * _unit.corruption) / 50) - 0.5; - heresy_new = (heresy_old * 50) / _unit.corruption; - _unit.corruption = max(0, heresy_new); - } + if (!is_struct(_unit)) { + continue; + } + if (_unit.god_status != 10) { + continue; + } + + p += 1; + penit_co[p] = c; + penit_id[p] = e; + penitorium += 1; + _unit.alter_loyalty(-1); + if ((_unit.corruption < 90) && (_unit.corruption > 0)) { + var heresy_old = 0, heresy_new = 0; + heresy_old = round((_unit.corruption * _unit.corruption) / 50) - 0.5; + heresy_new = (heresy_old * 50) / _unit.corruption; + _unit.corruption = max(0, heresy_new); } } } diff --git a/scripts/scr_check_equip/scr_check_equip.gml b/scripts/scr_check_equip/scr_check_equip.gml index 9c1091b9c7..0e01036562 100644 --- a/scripts/scr_check_equip/scr_check_equip.gml +++ b/scripts/scr_check_equip/scr_check_equip.gml @@ -8,8 +8,8 @@ function scr_check_equip(search_item, system, planet_or_ship_id, remove_item) { var man_c = 0, man_i = 0, have = 0, unit, marine_present; - for (var c = 0; c <= 10; c++) { - for (var i = 0; i <= array_length(obj_ini.TTRPG[c]); i++) { + for (var c = 0; c <= obj_ini.companies; c++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[c]); i++) { marine_present = false; if (!instance_exists(obj_ncombat)) { diff --git a/scripts/scr_max_marine/scr_max_marine.gml b/scripts/scr_max_marine/scr_max_marine.gml index 9b29494b8f..656bc6d013 100644 --- a/scripts/scr_max_marine/scr_max_marine.gml +++ b/scripts/scr_max_marine/scr_max_marine.gml @@ -10,7 +10,7 @@ function scr_max_marine(max_type) { for (co = 0; co <= obj_ini.companies; co++) { for (var i = 0; i < company_length(co); i++) { - unit = fetch_unit([c, i]); + unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; } From 6fe07e3701268c3d9b247db4218cfe14b0aece07 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 18:56:23 +0100 Subject: [PATCH 23/82] anpther array length catch --- scripts/scr_ship_occupants/scr_ship_occupants.gml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/scr_ship_occupants/scr_ship_occupants.gml b/scripts/scr_ship_occupants/scr_ship_occupants.gml index d12ddd2a81..d6a51cd335 100644 --- a/scripts/scr_ship_occupants/scr_ship_occupants.gml +++ b/scripts/scr_ship_occupants/scr_ship_occupants.gml @@ -3,7 +3,8 @@ function scr_ship_occupants(target_ship_id) { // Crew for (var co = 0; co < obj_ini.companies; co++) { - for (var i = 0; i <= company_length(co); i++) { + var _co_length = company_length(co); + for (var i = 0; i < _co_length; i++) { if (obj_ini.role[co][i] == "") { continue; } From 77455270078b0836ec9dae55419a590018b488e9 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 19:01:16 +0100 Subject: [PATCH 24/82] even more role conversion --- scripts/scr_civil_roster/scr_civil_roster.gml | 163 +++++++++--------- .../scr_ship_occupants/scr_ship_occupants.gml | 3 - 2 files changed, 81 insertions(+), 85 deletions(-) diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index 15375fbe96..32f4d829ef 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -9,7 +9,6 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { //-------------------------------------------------------------------------------------------------------------------- // Global objects used. //-------------------------------------------------------------------------------------------------------------------- - var deploying_unit = obj_ini; var new_combat = obj_ncombat; //???=obj_drop_select; //???=obj_controller @@ -163,32 +162,32 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ = 0; moov = 0; - if (unit.role() == deploying_unit.role[100][12]) { + if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { col = 22 - obj_controller.bat_scout_column; new_combat.en_scouts += 1; } - if (unit.role() == deploying_unit.role[100][8]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { col = 22 - obj_controller.bat_tactical_column; new_combat.en_tacticals += 1; } - if (unit.role() == deploying_unit.role[100][3]) { + if (unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { col = 22 - obj_controller.bat_veteran_column; new_combat.en_veterans += 1; } - if (unit.role() == deploying_unit.role[100][9]) { + if (unit.role() == obj_ini.player_role_data[eROLE.DEVASTATOR].role) { col = 22 - obj_controller.bat_devastator_column; new_combat.en_devastators += 1; } - if (unit.role() == deploying_unit.role[100][10]) { + if (unit.role() == obj_ini.player_role_data[eROLE.ASSAULT].role) { col = 22 - obj_controller.bat_assault_column; new_combat.en_assaults += 1; } - if (unit.role() == deploying_unit.role[100][17]) { + if (unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { col = 22 - obj_controller.bat_librarian_column; new_combat.en_librarians += 1; moov = 1; } - if (unit.role() == string(deploying_unit.role[100][17]) + " Aspirant") { + if (unit.role() == string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " Aspirant") { col = 22 - obj_controller.bat_librarian_column; new_combat.en_librarians += 1; moov = 1; @@ -209,25 +208,25 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { new_combat.en_librarians += 1; moov = 1; } - if (unit.role() == deploying_unit.role[100][16]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { col = 22 - obj_controller.bat_techmarine_column; new_combat.en_techmarines += 1; moov = 2; } - if (unit.role() == deploying_unit.role[100][2]) { + if (unit.role() == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { col = 22 - obj_controller.bat_honor_column; new_combat.en_honors += 1; } - if (unit.role() == deploying_unit.role[100][6]) { + if (unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { col = 22 - obj_controller.bat_dreadnought_column; new_combat.en_dreadnoughts += 1; } - if (unit.role() == "Venerable " + string(deploying_unit.role[100][6])) { + if (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { col = 22 - obj_controller.bat_dreadnought_column; new_combat.en_dreadnoughts += 1; } - if (unit.role() == deploying_unit.role[100][4]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { col = 22 - obj_controller.bat_terminator_column; new_combat.en_terminators += 1; } @@ -240,26 +239,26 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (co == 10) { col = 22 - obj_controller.bat_scout_column; } - if (deploying_unit.mobi[cooh][va] == "Jump Pack") { + if (obj_ini.mobi[cooh][va] == "Jump Pack") { col = 22 - obj_controller.bat_assault_column; } } } - if ((unit.role() == deploying_unit.role[100][15]) || (unit.role() == deploying_unit.role[100][14]) || (string_count("Aspirant", unit.role()) > 0)) { - if (unit.role() == string(deploying_unit.role[100][15]) + " Aspirant") { + if ((unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) || (unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) || (string_count("Aspirant", unit.role()) > 0)) { + if (unit.role() == string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " Aspirant") { col = 22 - obj_controller.bat_tactical_column; new_combat.en_tacticals += 1; } - if (unit.role() == string(deploying_unit.role[100][14]) + " Aspirant") { + if (unit.role() == string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " Aspirant") { col = 22 - obj_controller.bat_tactical_column; new_combat.en_tacticals += 1; } - if (unit.role() == deploying_unit.role[100][15]) { + if (unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) { new_combat.en_apothecaries += 1; } - if (unit.role() == deploying_unit.role[100][14]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { new_combat.en_chaplains += 1; if (new_combat.en_big_mofo > 5) { new_combat.en_big_mofo = 5; @@ -280,17 +279,17 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if ((unit.role() == deploying_unit.role[100][5]) || (unit.role() == deploying_unit.role[100][11]) || (unit.role() == deploying_unit.role[100][7])) { - if (unit.role() == deploying_unit.role[100][5]) { + 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.en_captains += 1; if (new_combat.en_big_mofo > 5) { new_combat.en_big_mofo = 5; } } - if (unit.role() == deploying_unit.role[100][11]) { + if (unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { new_combat.en_standard_bearers += 1; } - if (unit.role() == deploying_unit.role[100][7]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role) { new_combat.champions += 1; } @@ -310,7 +309,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (co == 10) { col = 22 - obj_controller.bat_scout_column; } - if (deploying_unit.mobi[cooh][va] == "Jump Pack") { + if (obj_ini.mobi[cooh][va] == "Jump Pack") { col = 22 - obj_controller.bat_assault_column; } } @@ -330,7 +329,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { col = 22 - obj_controller.bat_command_column; new_combat.en_important_dudes += 1; } - if (unit.role() == "Chief " + string(deploying_unit.role[100][17])) { + 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) { @@ -367,10 +366,10 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.dudes_hp[targ.men] = unit.hp(); targ.dudes_exp[targ.men] = unit.experience; targ.dudes_powers[targ.men] = unit.specials; - targ.dudes_wep1[targ.men] = deploying_unit.wep1[cooh][va]; - targ.dudes_wep2[targ.men] = deploying_unit.wep2[cooh][va]; - targ.dudes_gear[targ.men] = deploying_unit.gear[cooh][va]; - targ.dudges_mobi[targ.men] = deploying_unit.mobi[cooh][va]; + targ.dudes_wep1[targ.men] = obj_ini.wep1[cooh][va]; + targ.dudes_wep2[targ.men] = obj_ini.wep2[cooh][va]; + targ.dudes_gear[targ.men] = obj_ini.gear[cooh][va]; + targ.dudges_mobi[targ.men] = obj_ini.mobi[cooh][va]; new_combat.enemy_forces += 1; new_combat.enemy_max += 1; @@ -404,85 +403,85 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } // todo find out what more targ.dudes does, relevant to targ.men? - if (deploying_unit.armour[co][v] == "Scout Armour") { + if (obj_ini.armour[co][v] == "Scout Armour") { targ.dudes_ac[targ.men] = 8; } - if (deploying_unit.armour[co][v] == "MK3 Iron Armour") { + if (obj_ini.armour[co][v] == "MK3 Iron Armour") { targ.dudes_ac[targ.men] = 20; targ.dudes_ranged[targ.men] -= 0.1; } - if (deploying_unit.armour[co][v] == "MK4 Maximus") { + if (obj_ini.armour[co][v] == "MK4 Maximus") { targ.dudes_ac[targ.men] = 19; targ.dudes_ranged[targ.men] += 0.05; targ.dudes_attack[targ.men] += 0.05; } - if (deploying_unit.armour[co][v] == "MK5 Heresy") { + if (obj_ini.armour[co][v] == "MK5 Heresy") { targ.dudes_ac[targ.men] = 17; targ.dudes_attack[targ.men] += 0.1; targ.dudes_ranged[targ.men] -= 0.05; } - if (deploying_unit.armour[co][v] == "MK6 Corvus") { + if (obj_ini.armour[co][v] == "MK6 Corvus") { targ.dudes_ac[targ.men] = 18; targ.dudes_ranged[targ.men] += 0.1; } - if (deploying_unit.armour[co][v] == "MK7 Aquila") { + if (obj_ini.armour[co][v] == "MK7 Aquila") { targ.dudes_ac[targ.men] = 18; } - if (deploying_unit.armour[co][v] == "MK8 Errant") { + if (obj_ini.armour[co][v] == "MK8 Errant") { targ.dudes_ac[targ.men] = 19; } - if (deploying_unit.armour[co][v] == "Power Armour") { + if (obj_ini.armour[co][v] == "Power Armour") { targ.dudes_ac[targ.men] = 19; } - if (deploying_unit.armour[co][v] == "Artificer Armour") { + if (obj_ini.armour[co][v] == "Artificer Armour") { targ.dudes_ac[targ.men] = 35; targ.dudes_attack[targ.men] += 0.1; } - if (deploying_unit.armour[co][v] == "Terminator Armour") { + if (obj_ini.armour[co][v] == "Terminator Armour") { targ.dudes_ac[targ.men] = 40; targ.dudes_ranged[targ.men] -= 0.1; targ.dudes_attack[targ.men] += 0.2; } - if (deploying_unit.armour[co][v] == "Tartaros") { + if (obj_ini.armour[co][v] == "Tartaros") { targ.dudes_ac[targ.men] = 44; targ.dudes_ranged[targ.men] -= 0.05; targ.dudes_attack[targ.men] += 0.2; } - if (deploying_unit.armour[co][v] == "Dreadnought") { + if (obj_ini.armour[co][v] == "Dreadnought") { targ.dudes_ac[targ.men] = 40; } - if (deploying_unit.armour[co][v] == "Ork Armour") { + if (obj_ini.armour[co][v] == "Ork Armour") { targ.dudes_ac[targ.men] = 15; } - if (deploying_unit.wep1[co][v] == "Boarding Shield") { + if (obj_ini.wep1[co][v] == "Boarding Shield") { targ.dudes_ac[targ.men] += 4; } - if (deploying_unit.wep2[co][v] == "Boarding Shield") { + if (obj_ini.wep2[co][v] == "Boarding Shield") { targ.dudes_ac[targ.men] += 4; } - if (deploying_unit.wep1[co][v] == "Storm Shield") { + if (obj_ini.wep1[co][v] == "Storm Shield") { targ.dudes_ac[targ.men] += 8; } - if (deploying_unit.wep2[co][v] == "Storm Shield") { + if (obj_ini.wep2[co][v] == "Storm Shield") { targ.dudes_ac[targ.men] += 8; } - if (string_count("&", deploying_unit.armour[co][v]) > 0) { + if (string_count("&", obj_ini.armour[co][v]) > 0) { // Artifact armour - if (string_count("Power", deploying_unit.armour[co][v]) > 0) { + if (string_count("Power", obj_ini.armour[co][v]) > 0) { targ.dudes_ac[targ.men] = 30; } - if (string_count("Artificer", deploying_unit.armour[co][v]) > 0) { + if (string_count("Artificer", obj_ini.armour[co][v]) > 0) { targ.dudes_ac[targ.men] = 37; targ.dudes_attack[targ.men] += 0.1; } - if (string_count("Terminator", deploying_unit.armour[co][v]) > 0) { + if (string_count("Terminator", obj_ini.armour[co][v]) > 0) { targ.dudes_ac[targ.men] = 46; targ.dudes_ranged[targ.men] -= 0.1; targ.dudes_attack[targ.men] += 0.2; } - if (string_count("Dreadnought", deploying_unit.armour[co][v]) > 0) { + if (string_count("Dreadnought", obj_ini.armour[co][v]) > 0) { targ.dudes_ac[targ.men] = 44; } } @@ -507,26 +506,26 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if ((unit.role() == deploying_unit.role[100][6]) || (unit.role() == "Venerable " + string(deploying_unit.role[100][6]))) { + if ((unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) || (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role))) { targ.dudes_hp[targ.men] = targ.dudes_hp[targ.men] * 2; targ.dreads += 1; } - if (deploying_unit.mobi[cooh][va] == "Bike") { + if (obj_ini.mobi[cooh][va] == "Bike") { targ.dudes_hp[targ.men] += 25; } - if (deploying_unit.wep1[cooh][va] == "Boarding Shield") { + if (obj_ini.wep1[cooh][va] == "Boarding Shield") { targ.dudes_hp[targ.men] += 20; } - if (deploying_unit.wep2[cooh][va] == "Boarding Shield") { + if (obj_ini.wep2[cooh][va] == "Boarding Shield") { targ.dudes_hp[targ.men] += 20; } - if (deploying_unit.wep1[cooh][va] == "Storm Shield") { + if (obj_ini.wep1[cooh][va] == "Storm Shield") { targ.dudes_hp[targ.men] += 30; } - if (deploying_unit.wep2[cooh][va] == "Storm Shield") { + if (obj_ini.wep2[cooh][va] == "Storm Shield") { targ.dudes_hp[targ.men] += 30; } - if (deploying_unit.wep2[cooh][va] == "Iron Halo") { + if (obj_ini.wep2[cooh][va] == "Iron Halo") { targ.dudes_hp[targ.men] += 20; } @@ -544,32 +543,32 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { new_combat.player_starting_dudes += 1; } - if (unit.role() == deploying_unit.role[100][12]) { + if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { col = obj_controller.bat_scout_column; new_combat.scouts += 1; } - if (unit.role() == deploying_unit.role[100][8]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { col = obj_controller.bat_tactical_column; new_combat.tacticals += 1; } - if (unit.role() == deploying_unit.role[100][3]) { + if (unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { col = obj_controller.bat_veteran_column; new_combat.veterans += 1; } - if (unit.role() == deploying_unit.role[100][9]) { + if (unit.role() == obj_ini.player_role_data[eROLE.DEVASTATOR].role) { col = obj_controller.bat_devastator_column; new_combat.devastators += 1; } - if (unit.role() == deploying_unit.role[100][10]) { + if (unit.role() == obj_ini.player_role_data[eROLE.ASSAULT].role) { col = obj_controller.bat_assault_column; new_combat.assaults += 1; } - if (unit.role() == deploying_unit.role[100][17]) { + if (unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { col = obj_controller.bat_librarian_column; new_combat.librarians += 1; moov = 1; } - if (unit.role() == string(deploying_unit.role[100][17]) + " Aspirant") { + if (unit.role() == string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " Aspirant") { col = obj_controller.bat_librarian_column; new_combat.librarians += 1; moov = 1; @@ -590,25 +589,25 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { new_combat.librarians += 1; moov = 1; } - if (unit.role() == deploying_unit.role[100][16]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { col = obj_controller.bat_techmarine_column; new_combat.techmarines += 1; moov = 2; } - if (unit.role() == deploying_unit.role[100][2]) { + if (unit.role() == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { col = obj_controller.bat_honor_column; new_combat.honors += 1; } - if (unit.role() == deploying_unit.role[100][6]) { + if (unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { col = obj_controller.bat_dreadnought_column; new_combat.dreadnoughts += 1; } - if (unit.role() == "Venerable " + string(deploying_unit.role[100][6])) { + if (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { col = obj_controller.bat_dreadnought_column; new_combat.dreadnoughts += 1; } - if (unit.role() == deploying_unit.role[100][4]) { + if (unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { col = obj_controller.bat_terminator_column; new_combat.terminators += 1; } @@ -621,26 +620,26 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (co == 10) { col = obj_controller.bat_scout_column; } - if (deploying_unit.mobi[cooh][va] == "Jump Pack") { + if (obj_ini.mobi[cooh][va] == "Jump Pack") { col = obj_controller.bat_assault_column; } } } - if ((unit.role() == deploying_unit.role[100][15]) || (unit.role() == deploying_unit.role[100][14]) || (string_count("Aspirant", unit.role()) > 0)) { - if (unit.role() == string(deploying_unit.role[100][15]) + " Aspirant") { + if ((unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) || (unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) || (string_count("Aspirant", unit.role()) > 0)) { + if (unit.role() == string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " Aspirant") { col = obj_controller.bat_tactical_column; new_combat.tacticals += 1; } - if (unit.role() == string(deploying_unit.role[100][14]) + " Aspirant") { + if (unit.role() == string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " Aspirant") { col = obj_controller.bat_tactical_column; new_combat.tacticals += 1; } - if (unit.role() == deploying_unit.role[100][15]) { + if (unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) { new_combat.apothecaries += 1; } - if (unit.role() == deploying_unit.role[100][14]) { + 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; @@ -661,17 +660,17 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if ((unit.role() == deploying_unit.role[100][5]) || (unit.role() == deploying_unit.role[100][11]) || (unit.role() == deploying_unit.role[100][7])) { - if (unit.role() == deploying_unit.role[100][5]) { + 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() == deploying_unit.role[100][11]) { + if (unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { new_combat.standard_bearers += 1; } - if (unit.role() == deploying_unit.role[100][7]) { + if (unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role) { new_combat.champions += 1; } @@ -691,7 +690,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (co == 10) { col = obj_controller.bat_scout_column; } - if (deploying_unit.mobi[cooh][va] == "Jump Pack") { + if (obj_ini.mobi[cooh][va] == "Jump Pack") { col = obj_controller.bat_assault_column; } } @@ -721,7 +720,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { col = obj_controller.bat_command_column; new_combat.important_dudes += 1; } - if (unit.role() == "Chief " + string(deploying_unit.role[100][17])) { + 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) { diff --git a/scripts/scr_ship_occupants/scr_ship_occupants.gml b/scripts/scr_ship_occupants/scr_ship_occupants.gml index d6a51cd335..52b0e17826 100644 --- a/scripts/scr_ship_occupants/scr_ship_occupants.gml +++ b/scripts/scr_ship_occupants/scr_ship_occupants.gml @@ -5,9 +5,6 @@ function scr_ship_occupants(target_ship_id) { for (var co = 0; co < obj_ini.companies; co++) { var _co_length = company_length(co); for (var i = 0; i < _co_length; i++) { - if (obj_ini.role[co][i] == "") { - continue; - } var unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; From 9d5437244ad7817d622bf0626d23731ce5e77773 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 1 Aug 2026 19:08:11 +0100 Subject: [PATCH 25/82] more broken stuff --- scripts/scr_company_order/scr_company_order.gml | 2 +- scripts/scr_dialogue/scr_dialogue.gml | 16 ++++------------ scripts/scr_max_marine/scr_max_marine.gml | 8 ++++---- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 4d448235bb..244740160c 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -17,7 +17,7 @@ function sort_all_companies_to_map(map) { } function company_length(company){ - return obj_ini.TTRPG[company]; + return array_length(obj_ini.TTRPG[company]); } function scr_company_order(company) { diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index 5df76dc77a..b1d96dfe6a 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -2922,21 +2922,13 @@ function scr_dialogue(diplo_keyphrase, data = {}) { if (rando == 5) { obj_controller.useful_info += "CM|"; - var him_c = 0, him_i = 0, him_num = 0, him_cor = 0, split = ""; + var _unit = scr_max_marine("chaos"); - split = scr_max_marine("chaos"); - - explode_script(split, "|"); - him_c = real(explode[0]); - him_i = real(explode[1]); - him_num = string(explode[2]); - him_cor = real(explode[3]); - - if (him_cor == 0) { + if (_unit.company == 0) { diplo_text = "I have looked into the strands of fate, with your chapter, and found that the future is not suspect for any of your men. None of them have their minds poisoned by the taint of chaos."; } - if (him_cor > 0) { - diplo_text = "I have looked into the strands of fate, with your chapter. Your 'battle brother' " + string(him_num) + " has a clouded, dark future- it is advised you watch him carefully."; + else if (_unit.company > 0) { + diplo_text = $"I have looked into the strands of fate, with your chapter. Your 'battle brother' {_unit.name_role()} has a clouded, dark future- it is advised you watch him carefully."; } } // * Next random event * diff --git a/scripts/scr_max_marine/scr_max_marine.gml b/scripts/scr_max_marine/scr_max_marine.gml index 656bc6d013..299e6f2e8c 100644 --- a/scripts/scr_max_marine/scr_max_marine.gml +++ b/scripts/scr_max_marine/scr_max_marine.gml @@ -17,24 +17,24 @@ function scr_max_marine(max_type) { if (max_type == "chaos") { if (unit.corruption > value) { value = unit.corruption; - man_c = c; + man_c = co; man_i = i; } } else if (max_type == "age") { if (unit.age < value) { value = unit.age; - man_c = c; + man_c = co; man_i = i; } } else if (max_type == "exp") { if (unit.experience > value) { value = unit.experience; - man_c = c; + man_c = co; man_i = i; } } } } - return string(man_c) + "|" + string(man_i) + "|" + string(obj_ini.name[man_c][man_i]) + "|" + string(value) + "|"; + return fetch_unit([man_c, man_i]); } From 30357ecd7483f51f06d4533cb510ea0456fd8c02 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 3 Aug 2026 17:36:41 +0100 Subject: [PATCH 26/82] maybe it is done --- objects/obj_mass_equip/Step_0.gml | 139 ++++++----- scripts/scr_civil_roster/scr_civil_roster.gml | 236 +++++++++--------- .../scr_culture_visuals.gml | 16 +- scripts/scr_event_gossip/scr_event_gossip.gml | 15 +- .../scr_marine_struct/scr_marine_struct.gml | 8 +- scripts/scr_roster/scr_roster.gml | 6 +- scripts/scr_ship_battle/scr_ship_battle.gml | 2 +- .../scr_unit_equip_functions.gml | 10 +- 8 files changed, 223 insertions(+), 209 deletions(-) diff --git a/objects/obj_mass_equip/Step_0.gml b/objects/obj_mass_equip/Step_0.gml index b5872660b0..37218e1939 100644 --- a/objects/obj_mass_equip/Step_0.gml +++ b/objects/obj_mass_equip/Step_0.gml @@ -129,96 +129,97 @@ try { good4 = 0; good5 = 0; - req_armour = obj_ini.armour[100][role]; - req_wep1 = obj_ini.wep1[100][role]; - req_wep2 = obj_ini.wep2[100][role]; - req_gear = obj_ini.gear[100][role]; - req_mobi = obj_ini.mobi[100][role]; + var _cur_role = obj_ini.player_role_data[role]; + + req_armour = _cur_role.armour; + req_wep1 = _cur_role.wep1; + req_wep2 = _cur_role.wep2; + req_gear = _cur_role.gear; + req_mobi = _cur_role.mobi; for (var co = 0; co < 11; co++) { - for (var i = 0; i < array_length(obj_ini.role[co]); i++) { - if (obj_ini.role[co][i] == obj_ini.role[100][role]) { - role_number[co] += 1; - - // Weapon1 - var onc = 0; - if ((string_count("&", obj_ini.wep1[co][i]) > 0) && (onc == 0)) { - onc = 1; - have_wep1_num += 1; - } - if ((obj_ini.wep1[co][i] == req_wep1) && (onc == 0)) { - have_wep1_num += 1; - onc = 1; - } - if ((obj_ini.wep2[co][i] == req_wep1) && (onc == 0)) { - have_wep1_num += 1; - onc = 1; - } + for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { + var _unit = fetch_unit([co,i]); + if (_unit.role() != _cur_role.role) { + continue; + } + role_number[co]++; - // Weapon2 - onc = 0; - if ((string_count("&", obj_ini.wep2[co][i]) > 0) && (onc == 0)) { - onc = 1; - have_wep2_num += 1; - } - if ((obj_ini.wep1[co][i] == req_wep2) && (onc == 0)) { - have_wep2_num += 1; - onc = 1; - } - if ((obj_ini.wep2[co][i] == req_wep2) && (onc == 0)) { - have_wep2_num += 1; - onc = 1; - } - if (req_armour != "") { - var yes = false; + var _wep_one_found = false; + // Weapon1 + var _wep1 = _unit.weapon_one(true); + if (is_struct(_wep1) || _wep1 == req_wep1){ + have_wep1_num++; + _wep_one_found = true; + } - if (req_armour == STR_ANY_POWER_ARMOUR) { - if (array_contains(_list_basic_armour, obj_ini.armour[co][i])) { - yes = true; - } - } else if (req_armour == STR_ANY_TERMINATOR_ARMOUR) { - if (array_contains(_list_term_armour, obj_ini.armour[co][i])) { - yes = true; - } - } + var _wep2 = _unit.weapon_two(true); + if (is_struct(_wep2) || _wep2 == req_wep1 && !_wep_one_found){ + have_wep1_num++; + } + + var _wep_two_found = false; + if (is_struct(_wep1) || _wep1 == req_wep1){ + have_wep2_num++; + _wep_two_found = true; + } - if (string_count("&", obj_ini.armour[co][i]) > 0) { + var _wep2 = _unit.weapon_two(true); + if (is_struct(_wep2) || _wep2 == req_wep1 && !_wep_two_found){ + have_wep2_num++; + } + + var _armour = _unit.armour(); + if (req_armour != "") { + var yes = false; + + if (req_armour == STR_ANY_POWER_ARMOUR) { + if (array_contains(_list_basic_armour, _armour)) { yes = true; - } else if (obj_ini.armour[co][i] == req_armour) { + } + } else if (req_armour == STR_ANY_TERMINATOR_ARMOUR) { + if (array_contains(_list_term_armour, _armour)) { yes = true; } + } - if (yes == true) { - have_armour_num += 1; - } + if (string_count("&", obj_ini.armour[co][i]) > 0) { + yes = true; + } else if (_armour == req_armour) { + yes = true; } - if (req_gear != "") { - if (string_count("&", obj_ini.gear[co][i]) == 0) { - if (obj_ini.gear[co][i] == req_gear) { - have_gear_num += 1; - } - } + if (yes == true) { + have_armour_num += 1; } + } - if (req_mobi != "") { - if (string_count("&", obj_ini.mobi[co][i]) == 0) { - if (obj_ini.mobi[co][i] == req_mobi) { - have_mobi_num += 1; - } + var _gear = _unit.gear(); + if (req_gear != "") { + if (string_count("&", _gear) == 0) { + if (_gear == req_gear) { + have_gear_num += 1; } } } - if (obj_ini.role[co][i] == obj_ini.role[100][role]) { - var _slots = [obj_ini.wep1[co][i], obj_ini.wep2[co][i], obj_ini.armour[co][i], obj_ini.gear[co][i], obj_ini.mobi[co][i]]; - for (var s = 0; s < array_length(_slots); s++) { - if (!is_real(_slots[s])) { - _total_role_gear.add(_slots[s]); + var _mobi = _unit.mobility_item(); + if (req_mobi != "") { + if (string_count("&", _mobi) == 0) { + if (_mobi == req_mobi) { + have_mobi_num += 1; } } } + + + var _slots = [_unit.weapon_one(), _unit.weapon_two(), _unit.armour(), _unit.gear(), _unit.mobility_item()]; + for (var s = 0; s < array_length(_slots); s++) { + if (!is_real(_slots[s])) { + _total_role_gear.add(_slots[s]); + } + } } } diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index 32f4d829ef..88c3630301 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -42,7 +42,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { obj_controller.bat_whirlwind_column = obj_controller.bat_whirl_for[new_combat.formation_set]; obj_controller.bat_scout_column = obj_controller.bat_scou_for[new_combat.formation_set]; - var co, v, meeting, he_good, unit; + var co, v, meeting, he_good, _unit; co = 0; v = 0; meeting = true; @@ -104,31 +104,31 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { va = obj_temp_meeting.ide[v]; } } - unit = fetch_unit([cooh, va]); - if (!is_struct(unit)) { + _unit = fetch_unit([cooh, va]); + if (!is_struct(_unit)) { continue; } // Chaos corruption check here if (new_combat.battle_special == "cs_meeting_battle1") { - if (unit.corruption >= 30) { + if (_unit.corruption >= 30) { new_combat.fighting[cooh][va] = 1; } - if (unit.corruption < 30) { + if (_unit.corruption < 30) { new_combat.fighting[cooh][va] = -5; } - if (unit.role() == "Master of Sanctity") { + if (_unit.role() == "Master of Sanctity") { new_combat.fighting[cooh][va] = -5; } } if (new_combat.battle_special == "cs_meeting_battle2") { - if (unit.corruption >= 3) { + if (_unit.corruption >= 3) { new_combat.fighting[cooh][va] = 0; } - if (unit.corruption < 3) { + if (_unit.corruption < 3) { new_combat.fighting[cooh][va] = -5; } - if (unit.role() == "Master of Sanctity") { + if (_unit.role() == "Master of Sanctity") { new_combat.fighting[cooh][va] = -5; } } @@ -139,12 +139,12 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { new_combat.fighting[cooh][va] = 1; } if (new_combat.battle_special == "cs_meeting_battle7") { - if (unit.role() != obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + if (_unit.role() != obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { new_combat.fighting[cooh][va] = -5; } } - if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { new_combat.fighting[cooh][va] = 1; } if (new_combat.fighting[cooh][va] == 1) { @@ -162,71 +162,71 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ = 0; moov = 0; - if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { col = 22 - obj_controller.bat_scout_column; new_combat.en_scouts += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { col = 22 - obj_controller.bat_tactical_column; new_combat.en_tacticals += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { col = 22 - obj_controller.bat_veteran_column; new_combat.en_veterans += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.DEVASTATOR].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.DEVASTATOR].role) { col = 22 - obj_controller.bat_devastator_column; new_combat.en_devastators += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.ASSAULT].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.ASSAULT].role) { col = 22 - obj_controller.bat_assault_column; new_combat.en_assaults += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { col = 22 - obj_controller.bat_librarian_column; new_combat.en_librarians += 1; moov = 1; } - if (unit.role() == string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " Aspirant") { + if (_unit.role() == string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " Aspirant") { col = 22 - obj_controller.bat_librarian_column; new_combat.en_librarians += 1; moov = 1; } - if (unit.role() == "Codiciery") { + if (_unit.role() == "Codiciery") { col = 22 - obj_controller.bat_librarian_column; new_combat.en_librarians += 1; moov = 1; } - if (unit.role() == "Epistolary") { + if (_unit.role() == "Epistolary") { col = 22 - obj_controller.bat_librarian_column; new_combat.en_librarians += 1; moov = 1; } - if (unit.role() == "Lexicanum") { + if (_unit.role() == "Lexicanum") { col = 22 - obj_controller.bat_librarian_column; new_combat.en_librarians += 1; moov = 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { col = 22 - obj_controller.bat_techmarine_column; new_combat.en_techmarines += 1; moov = 2; } - if (unit.role() == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { col = 22 - obj_controller.bat_honor_column; new_combat.en_honors += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { col = 22 - obj_controller.bat_dreadnought_column; new_combat.en_dreadnoughts += 1; } - if (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { + if (_unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { col = 22 - obj_controller.bat_dreadnought_column; new_combat.en_dreadnoughts += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { col = 22 - obj_controller.bat_terminator_column; new_combat.en_terminators += 1; } @@ -245,20 +245,20 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if ((unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) || (unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) || (string_count("Aspirant", unit.role()) > 0)) { - if (unit.role() == string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " Aspirant") { + if ((_unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) || (_unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) || (string_count("Aspirant", _unit.role()) > 0)) { + if (_unit.role() == string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " Aspirant") { col = 22 - obj_controller.bat_tactical_column; new_combat.en_tacticals += 1; } - if (unit.role() == string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " Aspirant") { + if (_unit.role() == string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " Aspirant") { col = 22 - obj_controller.bat_tactical_column; new_combat.en_tacticals += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) { new_combat.en_apothecaries += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { new_combat.en_chaplains += 1; if (new_combat.en_big_mofo > 5) { new_combat.en_big_mofo = 5; @@ -267,10 +267,10 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { col = 22 - obj_controller.bat_tactical_column; - if (unit.armour() == "Terminator Armour") { + if (_unit.armour() == "Terminator Armour") { col = 22 - obj_controller.bat_terminator_column; } - if (unit.armour() == "Tartaros Armour") { + if (_unit.armour() == "Tartaros Armour") { col = 22 - obj_controller.bat_terminator_column; } @@ -279,27 +279,27 @@ 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) { + 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.en_captains += 1; if (new_combat.en_big_mofo > 5) { new_combat.en_big_mofo = 5; } } - if (unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { new_combat.en_standard_bearers += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role) { new_combat.champions += 1; } if (co == 1) { col = 22 - obj_controller.bat_veteran_column; - if (unit.armour() == "Terminator Armour") { + if (_unit.armour() == "Terminator Armour") { col = 22 - obj_controller.bat_terminator_column; } - if (unit.armour() == "Tartaros Armour") { + if (_unit.armour() == "Tartaros Armour") { col = 22 - obj_controller.bat_terminator_column; } } @@ -314,22 +314,22 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if (unit.role() == "Forge Master") { + if (_unit.role() == "Forge Master") { col = 22 - obj_controller.bat_command_column; new_combat.en_important_dudes += 1; } - if (unit.role() == "Master of Sanctity") { + 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") { + 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)) { + 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) { @@ -361,11 +361,11 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.men += 1; targ.dude_co[targ.men] = cooh; targ.dude_id[targ.men] = va; - targ.dudes[targ.men] = unit.role(); + targ.dudes[targ.men] = _unit.role(); targ.dudes_num[targ.men] = 1; - targ.dudes_hp[targ.men] = unit.hp(); - targ.dudes_exp[targ.men] = unit.experience; - targ.dudes_powers[targ.men] = unit.specials; + targ.dudes_hp[targ.men] = _unit.hp(); + targ.dudes_exp[targ.men] = _unit.experience; + targ.dudes_powers[targ.men] = _unit.specials; targ.dudes_wep1[targ.men] = obj_ini.wep1[cooh][va]; targ.dudes_wep2[targ.men] = obj_ini.wep2[cooh][va]; targ.dudes_gear[targ.men] = obj_ini.gear[cooh][va]; @@ -391,66 +391,66 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } targ.dudes_dr[targ.men] = dr; - if (unit.role() == "Death Company") { + if (_unit.role() == "Death Company") { // Ahahahahah var really; really = false; - if (string_count("Dreadnought", obj_ini.armour[co][v]) > 0) { + if (string_count("Dreadnought", _unit.armour) > 0) { really = true; } col = min(22 - obj_controller.bat_assault_column, 22 - obj_controller.bat_command_column, 22 - obj_controller.bat_honor_column, 22 - obj_controller.bat_dreadnought_column, 22 - obj_controller.bat_veteran_column); } // todo find out what more targ.dudes does, relevant to targ.men? - if (obj_ini.armour[co][v] == "Scout Armour") { + if (_unit.armour == "Scout Armour") { targ.dudes_ac[targ.men] = 8; } - if (obj_ini.armour[co][v] == "MK3 Iron Armour") { + if (_unit.armour == "MK3 Iron Armour") { targ.dudes_ac[targ.men] = 20; targ.dudes_ranged[targ.men] -= 0.1; } - if (obj_ini.armour[co][v] == "MK4 Maximus") { + if (_unit.armour == "MK4 Maximus") { targ.dudes_ac[targ.men] = 19; targ.dudes_ranged[targ.men] += 0.05; targ.dudes_attack[targ.men] += 0.05; } - if (obj_ini.armour[co][v] == "MK5 Heresy") { + if ( == "MK5 Heresy") { targ.dudes_ac[targ.men] = 17; targ.dudes_attack[targ.men] += 0.1; targ.dudes_ranged[targ.men] -= 0.05; } - if (obj_ini.armour[co][v] == "MK6 Corvus") { + if (_unit.armour == "MK6 Corvus") { targ.dudes_ac[targ.men] = 18; targ.dudes_ranged[targ.men] += 0.1; } - if (obj_ini.armour[co][v] == "MK7 Aquila") { + if (_unit.armour == "MK7 Aquila") { targ.dudes_ac[targ.men] = 18; } - if (obj_ini.armour[co][v] == "MK8 Errant") { + if (_unit.armour == "MK8 Errant") { targ.dudes_ac[targ.men] = 19; } - if (obj_ini.armour[co][v] == "Power Armour") { + if (_unit.armour == "Power Armour") { targ.dudes_ac[targ.men] = 19; } - if (obj_ini.armour[co][v] == "Artificer Armour") { + if (_unit.armour == "Artificer Armour") { targ.dudes_ac[targ.men] = 35; targ.dudes_attack[targ.men] += 0.1; } - if (obj_ini.armour[co][v] == "Terminator Armour") { + if (_unit.armour == "Terminator Armour") { targ.dudes_ac[targ.men] = 40; targ.dudes_ranged[targ.men] -= 0.1; targ.dudes_attack[targ.men] += 0.2; } - if (obj_ini.armour[co][v] == "Tartaros") { + if (_unit.armour == "Tartaros") { targ.dudes_ac[targ.men] = 44; targ.dudes_ranged[targ.men] -= 0.05; targ.dudes_attack[targ.men] += 0.2; } - if (obj_ini.armour[co][v] == "Dreadnought") { + if (_unit.armour == "Dreadnought") { targ.dudes_ac[targ.men] = 40; } - if (obj_ini.armour[co][v] == "Ork Armour") { + if (_unit.armour == "Ork Armour") { targ.dudes_ac[targ.men] = 15; } @@ -467,25 +467,25 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.dudes_ac[targ.men] += 8; } - if (string_count("&", obj_ini.armour[co][v]) > 0) { + if (string_count("&", _unit.armour) > 0) { // Artifact armour - if (string_count("Power", obj_ini.armour[co][v]) > 0) { + if (string_count("Power", _unit.armour) > 0) { targ.dudes_ac[targ.men] = 30; } - if (string_count("Artificer", obj_ini.armour[co][v]) > 0) { + if (string_count("Artificer", _unit.armour) > 0) { targ.dudes_ac[targ.men] = 37; targ.dudes_attack[targ.men] += 0.1; } - if (string_count("Terminator", obj_ini.armour[co][v]) > 0) { + if (string_count("Terminator", _unit.armour) > 0) { targ.dudes_ac[targ.men] = 46; targ.dudes_ranged[targ.men] -= 0.1; targ.dudes_attack[targ.men] += 0.2; } - if (string_count("Dreadnought", obj_ini.armour[co][v]) > 0) { + if (string_count("Dreadnought", _unit.armour) > 0) { targ.dudes_ac[targ.men] = 44; } } - if (obj_ini.armour[co][v] != "") { + if (_unit.armour != "") { // STC Bonuses if (obj_controller.stc_bonus[1] == 5) { @@ -506,7 +506,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if ((unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) || (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role))) { + if ((_unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) || (_unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role))) { targ.dudes_hp[targ.men] = targ.dudes_hp[targ.men] * 2; targ.dreads += 1; } @@ -543,71 +543,71 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { new_combat.player_starting_dudes += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { col = obj_controller.bat_scout_column; new_combat.scouts += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.TACTICAL].role) { col = obj_controller.bat_tactical_column; new_combat.tacticals += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.VETERAN].role) { col = obj_controller.bat_veteran_column; new_combat.veterans += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.DEVASTATOR].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.DEVASTATOR].role) { col = obj_controller.bat_devastator_column; new_combat.devastators += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.ASSAULT].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.ASSAULT].role) { col = obj_controller.bat_assault_column; new_combat.assaults += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.LIBRARIAN].role) { col = obj_controller.bat_librarian_column; new_combat.librarians += 1; moov = 1; } - if (unit.role() == string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " Aspirant") { + if (_unit.role() == string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " Aspirant") { col = obj_controller.bat_librarian_column; new_combat.librarians += 1; moov = 1; } - if (unit.role() == "Codiciery") { + if (_unit.role() == "Codiciery") { col = obj_controller.bat_librarian_column; new_combat.librarians += 1; moov = 1; } - if (unit.role() == "Epistolary") { + if (_unit.role() == "Epistolary") { col = obj_controller.bat_librarian_column; new_combat.librarians += 1; moov = 1; } - if (unit.role() == "Lexicanum") { + if (_unit.role() == "Lexicanum") { col = obj_controller.bat_librarian_column; new_combat.librarians += 1; moov = 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { col = obj_controller.bat_techmarine_column; new_combat.techmarines += 1; moov = 2; } - if (unit.role() == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.HONOURGUARD].role) { col = obj_controller.bat_honor_column; new_combat.honors += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { col = obj_controller.bat_dreadnought_column; new_combat.dreadnoughts += 1; } - if (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { + if (_unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { col = obj_controller.bat_dreadnought_column; new_combat.dreadnoughts += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.TERMINATOR].role) { col = obj_controller.bat_terminator_column; new_combat.terminators += 1; } @@ -626,20 +626,20 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if ((unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) || (unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) || (string_count("Aspirant", unit.role()) > 0)) { - if (unit.role() == string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " Aspirant") { + if ((_unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) || (_unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) || (string_count("Aspirant", _unit.role()) > 0)) { + if (_unit.role() == string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " Aspirant") { col = obj_controller.bat_tactical_column; new_combat.tacticals += 1; } - if (unit.role() == string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " Aspirant") { + if (_unit.role() == string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " Aspirant") { col = obj_controller.bat_tactical_column; new_combat.tacticals += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.APOTHECARY].role) { new_combat.apothecaries += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { + 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; @@ -648,10 +648,10 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { col = obj_controller.bat_tactical_column; - if (unit.armour() == "Terminator Armour") { + if (_unit.armour() == "Terminator Armour") { col = obj_controller.bat_terminator_column; } - if (unit.armour() == "Tartaros Armour") { + if (_unit.armour() == "Tartaros Armour") { col = obj_controller.bat_terminator_column; } @@ -660,27 +660,27 @@ 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) { + 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) { + if (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role) { new_combat.standard_bearers += 1; } - if (unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAMPION].role) { new_combat.champions += 1; } if (co == 1) { col = obj_controller.bat_veteran_column; - if (unit.armour() == "Terminator Armour") { + if (_unit.armour() == "Terminator Armour") { col = obj_controller.bat_terminator_column; } - if (unit.armour() == "Tartaros Armour") { + if (_unit.armour() == "Tartaros Armour") { col = obj_controller.bat_terminator_column; } } @@ -695,32 +695,32 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } } - if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + 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) { + if (string_count("0", _unit.specials) > 0) { new_combat.chapter_master_psyker = 1; } else { new_combat.chapter_master_psyker = 0; } } - if (unit.role() == "Forge Master") { + if (_unit.role() == "Forge Master") { col = obj_controller.bat_command_column; new_combat.important_dudes += 1; } - if (unit.role() == "Master of Sanctity") { + 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") { + 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)) { + 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) { @@ -735,27 +735,27 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { /// @type {Asset.GMObject.obj_pnunit} targ = instance_nearest(col * 10, 240, obj_pnunit); targ.men += 1; - targ.unit_struct[targ.men] = unit; - targ.marine_co[targ.men] = unit.company; + targ.unit_struct[targ.men] = _unit; + targ.marine_co[targ.men] = _unit.company; targ.marine_id[targ.men] = v; - targ.marine_type[targ.men] = unit.role(); - targ.marine_wep1[targ.men] = unit.weapon_one(); - targ.marine_wep2[targ.men] = unit.weapon_two(); - targ.marine_armour[targ.men] = unit.armour(); - targ.marine_gear[targ.men] = unit.gear(); - targ.marine_mobi[targ.men] = unit.mobility_item(); - targ.marine_hp[targ.men] = unit.hp(); - targ.marine_exp[targ.men] = unit.experience; - targ.marine_powers[targ.men] = unit.specials; - targ.marine_ranged[targ.men] = unit.ranged_attack(); - targ.marine_ac[targ.men] = unit.armour_calc(); - targ.marine_attack[targ.men] = unit.melee_attack(); + targ.marine_type[targ.men] = _unit.role(); + targ.marine_wep1[targ.men] = _unit.weapon_one(); + targ.marine_wep2[targ.men] = _unit.weapon_two(); + targ.marine_armour[targ.men] = _unit.armour(); + targ.marine_gear[targ.men] = _unit.gear(); + targ.marine_mobi[targ.men] = _unit.mobility_item(); + targ.marine_hp[targ.men] = _unit.hp(); + targ.marine_exp[targ.men] = _unit.experience; + targ.marine_powers[targ.men] = _unit.specials; + targ.marine_ranged[targ.men] = _unit.ranged_attack(); + targ.marine_ac[targ.men] = _unit.armour_calc(); + targ.marine_attack[targ.men] = _unit.melee_attack(); if (okay == 2) { targ.marine_local[targ.men] = 1; } - if (unit.role() == "Death Company") { + if (_unit.role() == "Death Company") { // Ahahahahah var really = false; diff --git a/scripts/scr_culture_visuals/scr_culture_visuals.gml b/scripts/scr_culture_visuals/scr_culture_visuals.gml index 25a74819a7..aee6226ef5 100644 --- a/scripts/scr_culture_visuals/scr_culture_visuals.gml +++ b/scripts/scr_culture_visuals/scr_culture_visuals.gml @@ -2206,10 +2206,14 @@ function DummyMarine() constructor { return "jeff"; }; + static role(){ + return obj_creation.livery_picker.role_set > 0 ? obj_creation.livery_picker.role_set : eROLE.TACTICAL; + } + static role = function() { with (obj_creation) { if (obj_creation.livery_selection_options.current_selection == 2) { - return role[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; + return player_role_data[role()].role; } else { return player_role_data[eROLE.TACTICAL].role; } @@ -2218,7 +2222,7 @@ function DummyMarine() constructor { static weapon_one = function() { with (obj_creation) { - return wep1[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; + return player_role_data[role()].wep1; } }; @@ -2228,7 +2232,7 @@ function DummyMarine() constructor { static weapon_two = function() { with (obj_creation) { - return wep2[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; + return player_role_data[role()].wep2; } }; @@ -2240,7 +2244,7 @@ function DummyMarine() constructor { var _armour = ""; with (obj_creation) { if (!livery_picker.freeze_armour) { - _armour = armour[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; + _armour = player_role_data[role()].armour; if (array_contains(armours, _armour) || _armour == STR_ANY_POWER_ARMOUR) { _armour = array_random_element(armours); } else if (array_contains(global.list_terminator_armour, _armour) || _armour == STR_ANY_POWER_ARMOUR) { @@ -2264,13 +2268,13 @@ function DummyMarine() constructor { static gear = function() { with (obj_creation) { - return gear[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; + return player_role_data[role()].gear; } }; static mobility_item = function() { with (obj_creation) { - return mobi[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; + return player_role_data[role()].mobi; } }; diff --git a/scripts/scr_event_gossip/scr_event_gossip.gml b/scripts/scr_event_gossip/scr_event_gossip.gml index 8502eb230f..e4e33cb47f 100644 --- a/scripts/scr_event_gossip/scr_event_gossip.gml +++ b/scripts/scr_event_gossip/scr_event_gossip.gml @@ -25,24 +25,29 @@ function scr_event_gossip(argument0) { p += 1; gossip[p] = "past_battles"; } - if (string_count("&", obj_ini.armour[attend_co[argument0]][attend_id[argument0]]) > 0) { + + var _comp = attend_co[argument0]; + var _num = attend_id[argument0]; + var _unit = fetch_unit([_comp, _num]); + + if (is_struct(_unit.armour(true))) { p += 1; gossip[p] = "artifact_armour"; } - if (string_count("&", obj_ini.wep1[attend_co[argument0]][attend_id[argument0]]) > 0) { + if (is_struct(_unit.weapon_one(true))) { p += 1; gossip[p] = "artifact_wep"; } - if (string_count("&", obj_ini.wep2[attend_co[argument0]][attend_id[argument0]]) > 0) { + if (is_struct(_unit.weapon_two(true))){ p += 1; gossip[p] = "artifact_wep"; } // if (string_count("&",obj_ini.gear[attend_co[argument0],attend_id[argument0]])>0){p+=1;gossip[p]="artifact_gear";} - if (obj_ini.mobi[attend_co[argument0]][attend_id[argument0]] == "Bike") { + if (_unit.mobility_item() == "Bike") { p += 1; gossip[p] = "mah_bike"; } - if (obj_ini.mobi[attend_co[argument0]][attend_id[argument0]] == "Jump Pack") { + if (_unit.mobility_item() == "Jump Pack") { p += 1; gossip[p] = "mah_jump"; } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index bab8a8d014..ae1da23ed6 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -535,8 +535,9 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } }; + mobi1 = ""; static mobility_item = function(raw = false) { - var wep = obj_ini.mobi[company][marine_number]; + var wep = mobi1; if (is_string(wep) || raw) { return wep; } @@ -1060,9 +1061,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} ]; }; + wep2 = ""; static weapon_two = function(raw = false) { - var wep = obj_ini.wep2[company][marine_number]; - if (is_string(wep) || raw) { + var _wep = wep2; + if (is_string(_wep) || raw) { return wep; } var arti = fetch_artifact(wep); diff --git a/scripts/scr_roster/scr_roster.gml b/scripts/scr_roster/scr_roster.gml index dd07b674ab..f08421d2b7 100644 --- a/scripts/scr_roster/scr_roster.gml +++ b/scripts/scr_roster/scr_roster.gml @@ -602,7 +602,9 @@ function add_unit_to_battle(unit, meeting, is_local) { if (company == 10) { col = obj_controller.bat_scout_column; } - if (obj_ini.mobi[cooh][va] == "Jump Pack") { + + //TODO update to check item tag for jup + if (unit.mobility_item() == "Jump Pack") { col = obj_controller.bat_assault_column; } } @@ -654,7 +656,7 @@ function add_unit_to_battle(unit, meeting, is_local) { if (company == 10) { col = obj_controller.bat_scout_column; } - if (obj_ini.mobi[cooh][va] == "Jump Pack") { + if (unit.mobility_item() == "Jump Pack") { col = obj_controller.bat_assault_column; } } diff --git a/scripts/scr_ship_battle/scr_ship_battle.gml b/scripts/scr_ship_battle/scr_ship_battle.gml index 2a184dc78b..f647bfc0fd 100644 --- a/scripts/scr_ship_battle/scr_ship_battle.gml +++ b/scripts/scr_ship_battle/scr_ship_battle.gml @@ -171,7 +171,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { if (co == 10) { col = obj_controller.bat_scout_column; } - if (obj_ini.mobi[co][v] == "Jump Pack") { + if (unit.mobility_item == "Jump Pack") { col = obj_controller.bat_assault_column; } } diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index bd890e8a4a..dd5f304b85 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -97,7 +97,7 @@ function scr_update_unit_armour(new_armour, from_armoury = true, to_armoury = tr } var portion = hp_portion(); - obj_ini.armour[company][marine_number] = is_artifact ? artifact_id : new_armour; + armour1 = is_artifact ? artifact_id : new_armour; if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); @@ -204,7 +204,7 @@ function scr_update_unit_weapon_one(new_weapon, from_armoury = true, to_armoury } } - obj_ini.wep1[company][marine_number] = is_artifact ? artifact_id : new_weapon; + wep1 = is_artifact ? artifact_id : new_weapon; if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); @@ -262,7 +262,7 @@ function scr_update_unit_weapon_two(new_weapon, from_armoury = true, to_armoury } } - obj_ini.wep2[company][marine_number] = is_artifact ? artifact_id : new_weapon; + wep2 = is_artifact ? artifact_id : new_weapon; if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); @@ -328,7 +328,7 @@ function scr_update_unit_gear(new_gear, from_armoury = true, to_armoury = true, } var portion = hp_portion(); - obj_ini.gear[company][marine_number] = is_artifact ? artifact_id : new_gear; + gear1 = is_artifact ? artifact_id : new_gear; if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); @@ -427,7 +427,7 @@ function scr_update_unit_mobility_item(new_mobility_item, from_armoury = true, t } var portion = hp_portion(); - obj_ini.mobi[company][marine_number] = is_artifact ? artifact_id : new_mobility_item; + mobi1 = is_artifact ? artifact_id : new_mobility_item; if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); From 61afd3a4bfe39898091648108c3d5c771da51c4c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 3 Aug 2026 18:14:27 +0100 Subject: [PATCH 27/82] remove all parallel role references --- docs/ARCHITECTURE.md | 1 - objects/obj_controller/Create_0.gml | 2 +- objects/obj_controller/Mouse_50.gml | 5 +- objects/obj_controller/Step_0.gml | 2 +- objects/obj_creation_popup/Draw_0.gml | 5 +- objects/obj_creation_popup/Step_0.gml | 12 +- objects/obj_mass_equip/Step_0.gml | 138 +++++++++--------- objects/obj_ncombat/Alarm_5.gml | 2 +- objects/obj_ncombat/Alarm_7.gml | 20 +-- scripts/ArtifactStruct/ArtifactStruct.gml | 2 +- scripts/scr_civil_roster/scr_civil_roster.gml | 104 ++++--------- .../scr_company_order/scr_company_order.gml | 2 +- .../scr_company_struct/scr_company_struct.gml | 2 +- .../scr_complex_colour_kit.gml | 2 +- .../scr_destroy_planet/scr_destroy_planet.gml | 2 +- scripts/scr_dialogue/scr_dialogue.gml | 12 +- scripts/scr_event_dudes/scr_event_dudes.gml | 43 ++---- scripts/scr_event_gossip/scr_event_gossip.gml | 5 +- scripts/scr_kill_unit/scr_kill_unit.gml | 9 +- .../scr_marine_struct/scr_marine_struct.gml | 5 +- .../scr_mission_functions.gml | 4 +- .../scr_player_ship_functions.gml | 2 +- scripts/scr_recruit_data/scr_recruit_data.gml | 2 +- scripts/scr_roster/scr_roster.gml | 4 +- scripts/scr_ship_battle/scr_ship_battle.gml | 80 +++++----- .../scr_specialist_training.gml | 2 +- scripts/scr_start_load/scr_start_load.gml | 2 +- scripts/scr_ui_advisors/scr_ui_advisors.gml | 8 +- scripts/scr_ui_settings/scr_ui_settings.gml | 7 +- 29 files changed, 212 insertions(+), 274 deletions(-) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index b649665934..16405d79a5 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -36,7 +36,6 @@ Get a random marine with filter /// if no marine is available with give parameters returns "none" function scr_random_marine(role, exp_req, search_params="none") /// @example - finding a random chaplain candidate -random_marine=scr_random_marine([obj_ini.role[100][8],obj_ini.role[100][18],obj_ini.role[100][10],obj_ini.role[100][9]],60,{"stat":[["piety", 35, "more"],["charisma", 30, "more"]]}); ``` ## Visual and draw functions diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 97f132c70c..d1c485a392 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1351,7 +1351,7 @@ temp[33] = string_upper(scr_thought()); // Thought of the day // Game start welcoming message LOGGER.info("Game start welcoming message"); -var _canon = obj_ini.role[100]; +var _canon = active_roles(); var _build_clause = function(_prefix, _parts) { if (array_length(_parts) == 0) { diff --git a/objects/obj_controller/Mouse_50.gml b/objects/obj_controller/Mouse_50.gml index 521059fcc9..42e7f2e9e5 100644 --- a/objects/obj_controller/Mouse_50.gml +++ b/objects/obj_controller/Mouse_50.gml @@ -15,7 +15,8 @@ if ((menu == eMENU.RECLUSIAM) && (cooldown <= 0) && (penitorium > 0)) { cooldown = 20; var c = penit_co[qp], e = penit_id[qp]; - if (obj_ini.role[c][e] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + var _unit = fetch_unit([c,e]); + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { alarm[7] = 5; global.defeat = 3; } @@ -31,7 +32,7 @@ if ((menu == eMENU.RECLUSIAM) && (cooldown <= 0) && (penitorium > 0)) { if ((mouse_x >= xx + 1508) && (mouse_x < xx + 1567)) { cooldown = 20; var c = penit_co[qp], e = penit_id[qp]; - obj_ini.TTRPG[c][e].god_status -= 10; + _unit.god_status -= 10; re = 1; } } diff --git a/objects/obj_controller/Step_0.gml b/objects/obj_controller/Step_0.gml index 216d10b3e8..b814fb0467 100644 --- a/objects/obj_controller/Step_0.gml +++ b/objects/obj_controller/Step_0.gml @@ -490,7 +490,7 @@ try { } if (menu == eMENU.DEFAULT && !instances_exist_any([obj_ncombat, obj_fleet_controller])) { - if (!array_contains(obj_ini.role[0], obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) && (alarm[7] == -1)) { + if (chapter_master.get_struct().role() != obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) && (alarm[7] == -1)) { alarm[7] = 15; } } diff --git a/objects/obj_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index bdeeb842f6..bf23066cc6 100644 --- a/objects/obj_creation_popup/Draw_0.gml +++ b/objects/obj_creation_popup/Draw_0.gml @@ -69,7 +69,8 @@ try { draw_set_font(fnt_40k_30b); - var _role_name = obj_creation.role[co][ide]; + var _role_data = obj_creation.player_role_data[ide]; + var _role_name = _role_data.role; var _text_selected = obj_creation.text_selected; var _sel_key = "unit_name" + string(ide); @@ -96,7 +97,7 @@ try { } if (_text_selected == _sel_key) { - obj_creation.role[co][ide] = keyboard_string; + _role_data.role = keyboard_string; } draw_rectangle(444 - 1, 550 - 1, 822, 550 + _height, 1); diff --git a/objects/obj_creation_popup/Step_0.gml b/objects/obj_creation_popup/Step_0.gml index f8c2dfc42e..a56a056cfc 100644 --- a/objects/obj_creation_popup/Step_0.gml +++ b/objects/obj_creation_popup/Step_0.gml @@ -45,7 +45,7 @@ if (!is_string(type)) { if (i == 13) { idd = 12; } - role_names_all += string(obj_creation.role[100][idd]) + "|"; + role_names_all += string(obj_creation.player_role_data[idd].role) + "|"; } role_names_all += "Chapter Master|"; @@ -53,13 +53,9 @@ if (!is_string(type)) { role_names_all += "Master of the Apothecarion|"; role_names_all += "Forge Master|"; - if (obj_creation.role[100][z] != "") { - if (string_count(obj_creation.role[100][z], role_names_all) > 1) { - badname = 1; - } - if (string_count(obj_creation.role[100][z], role_names_all) <= 1) { - badname = 0; - } + var _r_name = obj_creation.player_role_data[z].role; + if (_r_name != "") { + badname = (string_count(_r_name, role_names_all) > 1); } } } diff --git a/objects/obj_mass_equip/Step_0.gml b/objects/obj_mass_equip/Step_0.gml index 37218e1939..d5486262ea 100644 --- a/objects/obj_mass_equip/Step_0.gml +++ b/objects/obj_mass_equip/Step_0.gml @@ -9,88 +9,90 @@ try { if (engage == true) { for (var co = 0; co <= obj_ini.companies; co++) { if (role_number[co] > 0) { - for (var i = 0; i < array_length(obj_ini.role[co]); i++) { - if (obj_ini.role[co][i] == obj_ini.role[100][role]) { - var _unit = fetch_unit([co, i]); - if (!is_struct(_unit)) { + for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { + var _unit = fetch_unit([co, i]); + if (!role_compare(_unit, role)) { + continue; + } + var _unit = fetch_unit([co, i]); + if (!is_struct(_unit)) { + continue; + } + if (_unit.squad != "none") { + var _squad = fetch_squad(_unit.squad); + if (!_squad.allow_bulk_swap) { continue; } - if (_unit.squad != "none") { - var _squad = fetch_squad(_unit.squad); - if (!_squad.allow_bulk_swap) { - continue; - } - } + } - // ** Start Armour ** - var unit_armour = _unit.get_armour_data(); - var has_valid_armour = is_struct(unit_armour); - - // Check if unit_armour is a struct and evaluate tag-based or name-based compatibility - if (has_valid_armour) { - switch (req_armour) { - case STR_ANY_POWER_ARMOUR: - has_valid_armour = array_contains(_list_basic_armour, unit_armour.name); - break; - case STR_ANY_TERMINATOR_ARMOUR: - has_valid_armour = array_contains(_list_term_armour, unit_armour.name); - break; - default: - has_valid_armour = req_armour == unit_armour.name; - } + // ** Start Armour ** + var unit_armour = _unit.get_armour_data(); + var has_valid_armour = is_struct(unit_armour); + + // Check if unit_armour is a struct and evaluate tag-based or name-based compatibility + if (has_valid_armour) { + switch (req_armour) { + case STR_ANY_POWER_ARMOUR: + has_valid_armour = array_contains(_list_basic_armour, unit_armour.name); + break; + case STR_ANY_TERMINATOR_ARMOUR: + has_valid_armour = array_contains(_list_term_armour, unit_armour.name); + break; + default: + has_valid_armour = req_armour == unit_armour.name; } + } - // Attempt to equip if not valid - if (!has_valid_armour) { - var result = _unit.update_armour(req_armour); - - // Fallback: If request was for Power Armour but update failed, try Terminator - if (result != "complete" && req_armour == STR_ANY_POWER_ARMOUR) { - _unit.update_armour(STR_ANY_TERMINATOR_ARMOUR); - } + // Attempt to equip if not valid + if (!has_valid_armour) { + var result = _unit.update_armour(req_armour); - // Refresh unit_armour after update - unit_armour = _unit.get_armour_data(); + // Fallback: If request was for Power Armour but update failed, try Terminator + if (result != "complete" && req_armour == STR_ANY_POWER_ARMOUR) { + _unit.update_armour(STR_ANY_TERMINATOR_ARMOUR); } - // ** End Armour ** - - // ** Start Weapons ** - if (_unit.weapon_one() != req_wep1) { - if (is_string(_unit.weapon_one(true))) { - if (can_assign_weapon(_unit, req_wep1)) { - _unit.update_weapon_one(req_wep1); - } + + // Refresh unit_armour after update + unit_armour = _unit.get_armour_data(); + } + // ** End Armour ** + + // ** Start Weapons ** + if (_unit.weapon_one() != req_wep1) { + if (is_string(_unit.weapon_one(true))) { + if (can_assign_weapon(_unit, req_wep1)) { + _unit.update_weapon_one(req_wep1); } } - if (_unit.weapon_two() != req_wep2) { - if (is_string(_unit.weapon_two(true))) { - if (can_assign_weapon(_unit, req_wep2)) { - _unit.update_weapon_two(req_wep2); - } + } + if (_unit.weapon_two() != req_wep2) { + if (is_string(_unit.weapon_two(true))) { + if (can_assign_weapon(_unit, req_wep2)) { + _unit.update_weapon_two(req_wep2); } } - // ** Start Gear ** - if (is_string(_unit.gear(true))) { - _unit.update_gear(req_gear); - } + } + // ** Start Gear ** + if (is_string(_unit.gear(true))) { + _unit.update_gear(req_gear); + } - // ** Start Mobility Items ** - if (_unit.mobility_item() != req_mobi) { - var _forbidden_tags = [ - "terminator", - "dreadnought", - ]; - if (is_struct(unit_armour) && unit_armour.has_tags(_forbidden_tags)) { - _unit.update_mobility_item(""); - } else { - _unit.update_mobility_item(req_mobi); - } + // ** Start Mobility Items ** + if (_unit.mobility_item() != req_mobi) { + var _forbidden_tags = [ + "terminator", + "dreadnought", + ]; + if (is_struct(unit_armour) && unit_armour.has_tags(_forbidden_tags)) { + _unit.update_mobility_item(""); + } else { + _unit.update_mobility_item(req_mobi); } - // ** End role check ** } - // ** End this marine ** + // ** End role check ** } - // ** End this company ** + // ** End this marine ** + } // ** End repeat ** } @@ -255,7 +257,7 @@ try { } total_roles = ""; if (total_role_number > 0) { - var _role_name = obj_ini.role[100][role]; + var _role_name = obj_ini.player_role_data[role].role; total_roles = $"You currently have {total_role_number}x {_role_name} across all companies."; for (var i = 0; i < 11; i++) { var romanNumerals = scr_roman_numerals(); diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 4d8ae3f165..ea5468bad1 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -11,7 +11,7 @@ if (turn_count >= 50) { var p_data = battle_object.get_planet_data(battle_id); // check for wounded marines here to finish off, if defeated defending -var roles = obj_ini.role[100]; +var roles = active_roles(); var ground_mission = instance_exists(obj_ground_mission); with (obj_pnunit) { diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 85b0248988..2b3420d511 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -54,31 +54,25 @@ try { if (name == obj_ncombat.battle_loc) { instance_create(x, y, obj_temp_meeting); var master_present = 0; - - var master_index = array_get_index(obj_ini.role[0], obj_ini.player_role_data[eROLE.CHAPTERMASTER].role); - var _fetched_chaos = fetch_unit([0, master_index]); + var _fetched_chaos = obj_controlle.chapter_master.get_struct(); if (!is_struct(_fetched_chaos)) { LOGGER.error($"fetch_unit guardrail triggered for chapter master [0, {master_index}] in cs_meeting post-battle"); exit; } var chaos_meeting = _fetched_chaos.planet_location; - for (var co = 0; co <= 10; co++) { + for (var co = 0; co <= obj_ini.companies; co++) { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var good = 0; var _unit = fetch_unit([co, i]); - if (!is_struct(_unit) || _unit.role() == "" || _unit.location_string != name) { + if (_unit.location_string != name) { continue; } if (_unit.planet_location == floor(chaos_meeting)) { good += 1; } - if ((obj_ini.role[co][i] != obj_ini.player_role_data[eROLE.DREADNOUGHT].role) && (obj_ini.role[co][i] != "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role))) { - good += 1; - } - if ((string_count("Dread", obj_ini.armour[co][i]) == 0) || (obj_ini.role[co][i] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role)) { - good += 1; - } + + good = !_unit.is_dreadnought(); if (good >= 3) { obj_temp_meeting.dudes += 1; @@ -86,9 +80,7 @@ try { obj_temp_meeting.present[otm] = 1; obj_temp_meeting.co[otm] = co; obj_temp_meeting.ide[otm] = i; - if (obj_ini.role[co][i] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { - master_present = 1; - } + master_present = role_compare(_unit, eROLE.CHAPTERMASTER) } } } diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index 8a063ddd32..22a2e097e4 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -290,7 +290,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, if (has_tag("daemonic") || has_tag("chaos")) { unit.corruption += irandom(DAEMON_CORRUPTION_MAX); - if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (role_compare(unit, eROLE.CHAPTERMASTER) { /// @type {Asset.GMObject.obj_popup} var pip = instance_create(0, 0, obj_popup); pip.title = "Daemon Artifacts"; diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index 88c3630301..2d617389d7 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -239,7 +239,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (co == 10) { col = 22 - obj_controller.bat_scout_column; } - if (obj_ini.mobi[cooh][va] == "Jump Pack") { + if (_unit.mobility_item() == "Jump Pack") { col = 22 - obj_controller.bat_assault_column; } } @@ -309,7 +309,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (co == 10) { col = 22 - obj_controller.bat_scout_column; } - if (obj_ini.mobi[cooh][va] == "Jump Pack") { + if (_unit.mobility_item() == "Jump Pack") { col = 22 - obj_controller.bat_assault_column; } } @@ -366,10 +366,10 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.dudes_hp[targ.men] = _unit.hp(); targ.dudes_exp[targ.men] = _unit.experience; targ.dudes_powers[targ.men] = _unit.specials; - targ.dudes_wep1[targ.men] = obj_ini.wep1[cooh][va]; - targ.dudes_wep2[targ.men] = obj_ini.wep2[cooh][va]; + targ.dudes_wep1[targ.men] = _unit.weapon_one(); + targ.dudes_wep2[targ.men] = _unit.weapon_two(); targ.dudes_gear[targ.men] = obj_ini.gear[cooh][va]; - targ.dudges_mobi[targ.men] = obj_ini.mobi[cooh][va]; + targ.dudges_mobi[targ.men] = _unit.mobility_item(); new_combat.enemy_forces += 1; new_combat.enemy_max += 1; @@ -396,96 +396,50 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { var really; really = false; - if (string_count("Dreadnought", _unit.armour) > 0) { - really = true; - } + really = _unit.is_dreadnought() col = min(22 - obj_controller.bat_assault_column, 22 - obj_controller.bat_command_column, 22 - obj_controller.bat_honor_column, 22 - obj_controller.bat_dreadnought_column, 22 - obj_controller.bat_veteran_column); } // todo find out what more targ.dudes does, relevant to targ.men? - if (_unit.armour == "Scout Armour") { - targ.dudes_ac[targ.men] = 8; - } - if (_unit.armour == "MK3 Iron Armour") { - targ.dudes_ac[targ.men] = 20; - targ.dudes_ranged[targ.men] -= 0.1; - } - if (_unit.armour == "MK4 Maximus") { - targ.dudes_ac[targ.men] = 19; - targ.dudes_ranged[targ.men] += 0.05; - targ.dudes_attack[targ.men] += 0.05; - } - if ( == "MK5 Heresy") { - targ.dudes_ac[targ.men] = 17; - targ.dudes_attack[targ.men] += 0.1; - targ.dudes_ranged[targ.men] -= 0.05; - } - if (_unit.armour == "MK6 Corvus") { - targ.dudes_ac[targ.men] = 18; - targ.dudes_ranged[targ.men] += 0.1; - } - if (_unit.armour == "MK7 Aquila") { - targ.dudes_ac[targ.men] = 18; - } - if (_unit.armour == "MK8 Errant") { - targ.dudes_ac[targ.men] = 19; - } - if (_unit.armour == "Power Armour") { - targ.dudes_ac[targ.men] = 19; - } - if (_unit.armour == "Artificer Armour") { - targ.dudes_ac[targ.men] = 35; - targ.dudes_attack[targ.men] += 0.1; - } - if (_unit.armour == "Terminator Armour") { - targ.dudes_ac[targ.men] = 40; - targ.dudes_ranged[targ.men] -= 0.1; - targ.dudes_attack[targ.men] += 0.2; - } - if (_unit.armour == "Tartaros") { - targ.dudes_ac[targ.men] = 44; - targ.dudes_ranged[targ.men] -= 0.05; - targ.dudes_attack[targ.men] += 0.2; - } - if (_unit.armour == "Dreadnought") { - targ.dudes_ac[targ.men] = 40; - } - if (_unit.armour == "Ork Armour") { - targ.dudes_ac[targ.men] = 15; + var _armour_data = _unit.get_armour_dsata(); + if (is_struct(_armour_data)){ + targ.dudes_ac += _armour_data.armour_value; + arg.dudes_ranged += _armour_data.ranged_mod/100; + arg.dudes_attack += _armour_data.melee_mod/100; } - if (obj_ini.wep1[co][v] == "Boarding Shield") { + if (_unit.weapon_one() == "Boarding Shield") { targ.dudes_ac[targ.men] += 4; } - if (obj_ini.wep2[co][v] == "Boarding Shield") { + if (_unit.weapon_two() == "Boarding Shield") { targ.dudes_ac[targ.men] += 4; } - if (obj_ini.wep1[co][v] == "Storm Shield") { + if (_unit.weapon_one() == "Storm Shield") { targ.dudes_ac[targ.men] += 8; } - if (obj_ini.wep2[co][v] == "Storm Shield") { + if (_unit.weapon_two() == "Storm Shield") { targ.dudes_ac[targ.men] += 8; } - if (string_count("&", _unit.armour) > 0) { + if (string_count("&", _unit.armour()) > 0) { // Artifact armour - if (string_count("Power", _unit.armour) > 0) { + if (string_count("Power", _unit.armour()) > 0) { targ.dudes_ac[targ.men] = 30; } - if (string_count("Artificer", _unit.armour) > 0) { + if (string_count("Artificer", _unit.armour()) > 0) { targ.dudes_ac[targ.men] = 37; targ.dudes_attack[targ.men] += 0.1; } - if (string_count("Terminator", _unit.armour) > 0) { + if (string_count("Terminator", _unit.armour()) > 0) { targ.dudes_ac[targ.men] = 46; targ.dudes_ranged[targ.men] -= 0.1; targ.dudes_attack[targ.men] += 0.2; } - if (string_count("Dreadnought", _unit.armour) > 0) { + if (string_count("Dreadnought", _unit.armour()) > 0) { targ.dudes_ac[targ.men] = 44; } } - if (_unit.armour != "") { + if (_unit.armour() != "") { // STC Bonuses if (obj_controller.stc_bonus[1] == 5) { @@ -510,22 +464,22 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.dudes_hp[targ.men] = targ.dudes_hp[targ.men] * 2; targ.dreads += 1; } - if (obj_ini.mobi[cooh][va] == "Bike") { + if (_unit.mobility_item() == "Bike") { targ.dudes_hp[targ.men] += 25; } - if (obj_ini.wep1[cooh][va] == "Boarding Shield") { + if (_unit.weapon_one() == "Boarding Shield") { targ.dudes_hp[targ.men] += 20; } - if (obj_ini.wep2[cooh][va] == "Boarding Shield") { + if (_unit.weapon_two() == "Boarding Shield") { targ.dudes_hp[targ.men] += 20; } - if (obj_ini.wep1[cooh][va] == "Storm Shield") { + if (_unit.weapon_one() == "Storm Shield") { targ.dudes_hp[targ.men] += 30; } - if (obj_ini.wep2[cooh][va] == "Storm Shield") { + if (_unit.weapon_two() == "Storm Shield") { targ.dudes_hp[targ.men] += 30; } - if (obj_ini.wep2[cooh][va] == "Iron Halo") { + if (_unit.weapon_two() == "Iron Halo") { targ.dudes_hp[targ.men] += 20; } @@ -620,7 +574,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (co == 10) { col = obj_controller.bat_scout_column; } - if (obj_ini.mobi[cooh][va] == "Jump Pack") { + if (_unit.mobility_item() == "Jump Pack") { col = obj_controller.bat_assault_column; } } @@ -690,7 +644,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { if (co == 10) { col = obj_controller.bat_scout_column; } - if (obj_ini.mobi[cooh][va] == "Jump Pack") { + if (_unit.mobility_item() == "Jump Pack") { col = obj_controller.bat_assault_column; } } diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 244740160c..a7324b535d 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -138,7 +138,7 @@ function scr_company_order(company) { } function role_hierarchy() { - var _roles = obj_ini.role[100]; + var _roles = active_roles(); var hierarchy = [ _roles[eROLE.CHAPTERMASTER], "Forge Master", diff --git a/scripts/scr_company_struct/scr_company_struct.gml b/scripts/scr_company_struct/scr_company_struct.gml index d4f1c52880..0042c9a0c6 100644 --- a/scripts/scr_company_struct/scr_company_struct.gml +++ b/scripts/scr_company_struct/scr_company_struct.gml @@ -423,7 +423,7 @@ function CompanyStruct(comp) constructor { if (company > 0 && company < 11) { var _unit; var company_units = obj_controller.display_unit; - var role_set = obj_ini.role[100]; + var role_set = active_roles(); for (var i = 0; i < array_length(company_units); i++) { if (is_struct(company_units[i])) { _unit = company_units[i]; diff --git a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml index e67c0e8b57..26cfcfebba 100644 --- a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml +++ b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml @@ -64,7 +64,7 @@ function setup_complex_livery_shader(setup_role, unit = "none") { } } else { var _full_liveries = obj_ini.full_liveries; - var _roles = obj_ini.role[100]; + var _roles = active_roles(); data_set = obj_ini.full_liveries[0]; if (is_specialist(setup_role, SPECIALISTS_LIBRARIANS)) { data_set = _full_liveries[eROLE.LIBRARIAN]; diff --git a/scripts/scr_destroy_planet/scr_destroy_planet.gml b/scripts/scr_destroy_planet/scr_destroy_planet.gml index 233e41c796..467955ef91 100644 --- a/scripts/scr_destroy_planet/scr_destroy_planet.gml +++ b/scripts/scr_destroy_planet/scr_destroy_planet.gml @@ -41,7 +41,7 @@ function scr_destroy_planet(destruction_method) { // No survivors! for (var cah = 0; cah <= obj_ini.companies; cah++) { - for (var ed = 0; ed < array_length(obj_ini.role[cah]); ed++) { + for (var ed = 0; ed < array_length(obj_ini.TTRPG[cah]); ed++) { var unit = fetch_unit([cah, ed]); if (!is_struct(unit)) { continue; diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index 4e910ad9d6..e4c76d5931 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -112,7 +112,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { repeat (obj_temp_meeting.dudes) { ii += 1; if (mos == false) { - if (obj_ini.role[obj_temp_meeting.co[ii]][obj_temp_meeting.ide[ii]] == "Master of Sanctity") { + if (fetch_unit([obj_temp_meeting.co[ii], obj_temp_meeting.ide[ii]]).role() == "Master of Sanctity") { mos = true; } } @@ -346,12 +346,10 @@ function scr_dialogue(diplo_keyphrase, data = {}) { } var born = false; - for (var ii = 1; ii < 200; ii++) { - if (obj_ini.role[0][ii] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { - var _unit = fetch_unit([0, ii]); - if (is_struct(_unit)) { - _unit.corruption += floor(random_range(30, 50)); - } + for (var ii = 0; ii < array_length(obj_ini.TTRPG[0]); ii++) { + var _unit - fetch_unit([0,ii]); + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + _unit.corruption += floor(random_range(30, 50)); } } obj_controller.chaos_rating += 1; diff --git a/scripts/scr_event_dudes/scr_event_dudes.gml b/scripts/scr_event_dudes/scr_event_dudes.gml index 0ffd1523ca..ee65288afc 100644 --- a/scripts/scr_event_dudes/scr_event_dudes.gml +++ b/scripts/scr_event_dudes/scr_event_dudes.gml @@ -27,7 +27,7 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { } } - var coh, ide, oc, ocn, ty, g, good, blur, unit; + var coh, ide, oc, ocn, ty, g, good, blur, _unit; coh = -1; ide = 0; ide = -1; @@ -46,31 +46,20 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { repeat (11) { coh += 1; ide = 0; - repeat (300) { + for (var ide = 0; ide < array_length(obj_ini.TTRPG[coh]), ide++) { ide += 1; var adding; adding = false; - if (obj_ini.name[coh][ide] == "") { - continue; - } - unit = fetch_unit([coh, ide]); - if (!is_struct(unit)) { - continue; - } + _unit = fetch_unit([coh, ide]); + - if ((is_planet == 0) && (unit.ship_location == location_id)) { + if ((is_planet == 0) && (_unit.ship_location == location_id)) { adding = true; - } else if ((is_planet == 1) && (unit.location_string == system_name) && (unit.planet_location == location_id)) { + } else if ((is_planet == 1) && (_unit.location_string == system_name) && (_unit.planet_location == location_id)) { adding = true; } - if (obj_ini.role[coh][ide] == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { - adding = false; - } - if (obj_ini.role[coh][ide] == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { - adding = false; - } - if (string_count("Dread", obj_ini.armour[coh][ide]) > 0) { + if (_unit.is_dreadnought()) { adding = false; } @@ -81,7 +70,7 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { repeat (100) { g += 1; if (good == 0) { - if (oc[g] == obj_ini.role[coh][ide]) { + if (oc[g] == _unit.role()) { good = 1; ocn[g] += 1; } @@ -89,7 +78,7 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { } if (good == 0) { ty += 1; - oc[ty] = obj_ini.role[coh][ide]; + oc[ty] = _unit.role(); ocn[ty] = 1; good = 1; } @@ -98,15 +87,15 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { // Don't compile a list and create an array in obj_event instead if ((adding == true) && (do_action == 1)) { var speshul = false; - if (unit.IsSpecialist(SPECIALISTS_HEADS)) { + if (_unit.IsSpecialist(SPECIALISTS_HEADS)) { speshul = true; } if (speshul == true) { obj_event.avatars += 1; - obj_event.avatar_name[obj_event.avatars] = obj_ini.name[coh][ide]; - obj_event.avatar_rank[obj_event.avatars] = obj_ini.role[coh][ide]; + obj_event.avatar_name[obj_event.avatars] = _unit.name(); + obj_event.avatar_rank[obj_event.avatars] = _unit.role(); if (obj_controller.trim == 0) { obj_event.avatar_image[obj_event.avatars] = 1; } @@ -130,7 +119,7 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { obj_event.attendants += 1; obj_event.attend_co[obj_event.attendants] = coh; obj_event.attend_id[obj_event.attendants] = ide; - obj_event.attend_corruption[obj_event.attendants] = unit.corruption; + obj_event.attend_corruption[obj_event.attendants] = _unit.corruption; obj_event.attend_race[obj_event.attendants] = obj_ini.race[coh][ide]; // Determine attend confused here @@ -144,13 +133,13 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { if (obj_controller.fest_feature2 == 1) { base_confusion += 1; } - if ((obj_controller.fest_feature3 == 1) && (unit.corruption < 50)) { + if ((obj_controller.fest_feature3 == 1) && (_unit.corruption < 50)) { base_confusion += 1; } - if (unit.corruption > 20) { + if (_unit.corruption > 20) { base_confusion -= 1; } - if (unit.corruption > 50) { + if (_unit.corruption > 50) { base_confusion -= 2; } } diff --git a/scripts/scr_event_gossip/scr_event_gossip.gml b/scripts/scr_event_gossip/scr_event_gossip.gml index e4e33cb47f..f82758b540 100644 --- a/scripts/scr_event_gossip/scr_event_gossip.gml +++ b/scripts/scr_event_gossip/scr_event_gossip.gml @@ -177,8 +177,9 @@ function scr_event_gossip(argument0) { that_type = string(gossip[that]); var na, ra; - na = obj_ini.name[attend_co[argument0]][attend_id[argument0]]; - ra = obj_ini.role[attend_co[argument0]][attend_id[argument0]]; + var _unit = fetch_unit([attend_co[argument0], attend_id[argument0]]) + na = _unit.name(); + ra = _unit.role()(); // Getting there words = string(ra) + " " + string(na) + " "; diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 2836c87dff..7f268abd0a 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -1,11 +1,12 @@ /// @self Asset.GMObject.obj_controller function scr_kill_unit(company, unit_slot) { try { - if (obj_ini.role[company][unit_slot] == "Forge Master") { - array_push(obj_ini.previous_forge_masters, obj_ini.name[company][unit_slot]); + var _unit = fetch_unit([company, unit_slot]) + if (_unit.role() == "Forge Master") { + array_push(obj_ini.previous_forge_masters, _unit.name()); } - if (obj_ini.role[company][unit_slot] == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { tek = "c"; alarm[7] = 5; global.defeat = 1; @@ -62,7 +63,7 @@ function kill_and_recover(company, unit_slot, equipment = true, gene_seed_collec } } if (obj_ini.base_group == "astartes") { - if (is_specialist(obj_ini.role[company][unit_slot])) { + if (unit.IsSpecialist()) { obj_controller.command -= 1; } else { obj_controller.marines -= 1; diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index ae1da23ed6..021ee89ca0 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -253,7 +253,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (instance_exists(obj_controller)) { role_history = [ [ - obj_ini.role[company][marine_number], + role1, obj_controller.turn, ], ]; //marines_promotion and demotion history @@ -453,6 +453,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return is_specialist(role(), search_type, include_trainee, include_heads); }; + role1 = ""; static update_role = function(new_role) { if (role() == new_role) { return "no change"; @@ -477,7 +478,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } } } - obj_ini.role[company][marine_number] = new_role; + role1 = new_role; if (instance_exists(obj_controller)) { array_push(role_history, [role(), obj_controller.turn]); } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index dee30c62a4..423176ba1e 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -224,7 +224,7 @@ function problem_end_turn_checks() { var me = 0; for (var co = 0; co <= obj_ini.companies; co++) { me = 0; - for (me = 0; me < array_length(obj_ini.role[co]); me++) { + for (me = 0; me < array_length(obj_ini.TTRPG[co]); me++) { if (obj_ini.base_group == "astartes") { _unit = fetch_unit([co, me]); if (!is_struct(_unit)) { @@ -387,7 +387,7 @@ function init_beast_hunt_mission(planet, star, mission_slot) { } function role_compare(unit, role) { - return unit.role() == obj_ini.role[100][role]; + return unit.role() == obj_ini.player_role_data[role].role; } function init_protect_raider_mission(squad) { diff --git a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml index 16d2386fb4..65a7569a17 100644 --- a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml +++ b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml @@ -209,7 +209,7 @@ function loose_ship_to_warp_event() { var unit; for (var company = 0; company <= obj_ini.companies; company++) { - for (var marine = 0; marine < array_length(obj_ini.role[company]); marine++) { + for (var marine = 0; marine < array_length(obj_ini.TTRPG[company]); marine++) { if (obj_ini.name[company][marine] == "") { continue; } diff --git a/scripts/scr_recruit_data/scr_recruit_data.gml b/scripts/scr_recruit_data/scr_recruit_data.gml index 9de06bec2b..4e7200ce58 100644 --- a/scripts/scr_recruit_data/scr_recruit_data.gml +++ b/scripts/scr_recruit_data/scr_recruit_data.gml @@ -369,7 +369,7 @@ function planet_training_sequence(local_apothecary_points) { } function scr_trial_data(wanted = -1) { - var role_data = instance_exists(obj_ini) ? obj_ini.role[100] : obj_creation.role[100]; + var role_data = active_roles() var data = [ { name: "Blood Duel", diff --git a/scripts/scr_roster/scr_roster.gml b/scripts/scr_roster/scr_roster.gml index f08421d2b7..c4ec70d87a 100644 --- a/scripts/scr_roster/scr_roster.gml +++ b/scripts/scr_roster/scr_roster.gml @@ -273,7 +273,7 @@ function Roster() constructor { var _company_present = false; for (var co = 0; co <= obj_ini.companies; co++) { _company_present = false; - for (var i = 0; i < array_length(obj_ini.role[co]); i++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var _allow = false; var _unit = fetch_unit([co, i]); if (!is_struct(_unit) || _unit.name() == "" || _unit.role() == "") { @@ -520,7 +520,7 @@ function add_unit_to_battle(unit, meeting, is_local) { var man_size = 1; //Same as co/company and v, but with extra comprovations in case of a meeting (meeting?) - var _role = obj_ini.role[100]; + var _role = active_roles(); var cooh = 0; var va = 0; var v = unit.marine_number; diff --git a/scripts/scr_ship_battle/scr_ship_battle.gml b/scripts/scr_ship_battle/scr_ship_battle.gml index f647bfc0fd..e26ca1a589 100644 --- a/scripts/scr_ship_battle/scr_ship_battle.gml +++ b/scripts/scr_ship_battle/scr_ship_battle.gml @@ -5,7 +5,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { // set battle special // if (argument2=true){ - var co, v, stop, okay, sofar, unit; + var co, v, stop, okay, sofar, _unit; co = 0; v = 0; stop = 0; @@ -30,18 +30,18 @@ function scr_ship_battle(target_ship_id, cooridor_width) { if (obj_ini.name[co][v] == "") { continue; } - unit = fetch_unit([co, v]); - if (!is_struct(unit)) { + _unit = fetch_unit([co, v]); + if (!is_struct(_unit)) { continue; } - if ((unit.ship_location == target_ship_id) && unit.hp()) { + if ((_unit.ship_location == target_ship_id) && _unit.hp()) { okay = 1; } - if ((unit.ship_location == cooridor_width) && (cooridor_width == cooridor_width) && unit.hp()) { + if ((_unit.ship_location == cooridor_width) && (cooridor_width == cooridor_width) && _unit.hp()) { okay = 1; } - if ((string_count("spyrer", obj_ncombat.battle_special) > 0) && ((obj_ini.role[co][v] == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) || (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)))) { + if ((string_count("spyrer", obj_ncombat.battle_special) > 0) && (_unit.is_dreadnought())) { okay = 0; } if (string_count("spyrer", obj_ncombat.battle_special) > 0) { @@ -49,7 +49,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { okay = 0; } } - if (string_count("Aspirant", obj_ini.role[co][v]) > 0) { + if (string_count("Aspirant", _unit.role()) > 0) { okay = 0; } @@ -62,68 +62,68 @@ function scr_ship_battle(target_ship_id, cooridor_width) { var col = 0, targ = 0; - if (unit.role() == obj_ini.player_role_data[eROLE.SCOUT].role) { + 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) { + 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) { + 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) { + 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) { + 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) { + 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") { + if (_unit.role() == "Codiciery") { col = obj_controller.bat_librarian_column; obj_ncombat.librarians += 1; } - if (unit.role() == "Epistolary") { + if (_unit.role() == "Epistolary") { col = obj_controller.bat_librarian_column; obj_ncombat.librarians += 1; } - if (unit.role() == "Lexicanum") { + 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) { + 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) { + 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) { + if (_unit.role() == obj_ini.player_role_data[eROLE.DREADNOUGHT].role) { col = obj_controller.bat_dreadnought_column; obj_ncombat.dreadnoughts += 1; } - if (unit.role() == "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role)) { + if (_unit.role() == "Venerable " + string(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) { + 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) { + 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) { + 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; @@ -131,10 +131,10 @@ function scr_ship_battle(target_ship_id, cooridor_width) { } col = obj_controller.bat_tactical_column; - if (obj_ini.armour[co][v] == "Terminator Armour") { + if (_unit.armour() == "Terminator Armour") { col = obj_controller.bat_terminator_column; } - if (obj_ini.armour[co][v] == "Tartaros Armour") { + if (_unit.armour() == "Tartaros Armour") { col = obj_controller.bat_terminator_column; } if (co == 10) { @@ -142,26 +142,26 @@ function scr_ship_battle(target_ship_id, cooridor_width) { } } - 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) { + 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) { + 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) { + 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 (obj_ini.armour[co][v] == "Terminator Armour") { + if (_unit.armour() == "Terminator Armour") { col = obj_controller.bat_terminator_column; } - if (obj_ini.armour[co][v] == "Tartaros Armour") { + if (_unit.armour() == "Tartaros Armour") { col = obj_controller.bat_terminator_column; } } @@ -171,32 +171,32 @@ function scr_ship_battle(target_ship_id, cooridor_width) { if (co == 10) { col = obj_controller.bat_scout_column; } - if (unit.mobility_item == "Jump Pack") { + if (_unit.mobility_item == "Jump Pack") { col = obj_controller.bat_assault_column; } } - if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + 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") { + if (_unit.role() == "Forge Master") { col = obj_controller.bat_command_column; obj_ncombat.important_dudes += 1; } - if (unit.role() == "Master of Sanctity") { + 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") { + 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)) { + 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) { @@ -204,7 +204,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { } } - if (unit.role() == "Death Company") { + 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); } @@ -215,7 +215,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { targ = instance_nearest(col * 10, 240, obj_pnunit); with (targ) { - scr_add_unit_to_roster(unit); + scr_add_unit_to_roster(_unit); } } } diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index c71423c484..bbac1ca0a3 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -220,7 +220,7 @@ function chaplain_training() { unit.add_exp(10); chaplain_aspirant = 0; var _warn = ""; - var _outcome = unit.alter_equipment(_tech_role, true, true); + var _outcome = unit.alter_equipment(_chap_role, true, true); if (!_outcome.success) { scr_alert("red", "recruitment", $"{_outcome.description}!", 0, 0); diff --git a/scripts/scr_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index 3e9d9ac1e5..cab0dd7b1d 100644 --- a/scripts/scr_start_load/scr_start_load.gml +++ b/scripts/scr_start_load/scr_start_load.gml @@ -93,7 +93,7 @@ function scr_start_load(fleet, load_from_star, load_options) { var company_vehicle = []; //array of companies vehicles var ship_fit = true; - for (var _unit = 0; _unit < (array_length(obj_ini.role[_comp]) - 1); _unit++) { + for (var _unit = 0; _unit < (array_length(obj_ini.TTRPG[_comp]) - 1); _unit++) { var _marine = fetch_unit([_comp, _unit]); // check if marine exists if (is_struct(_marine) && _marine.name() != "") { diff --git a/scripts/scr_ui_advisors/scr_ui_advisors.gml b/scripts/scr_ui_advisors/scr_ui_advisors.gml index de754de931..cfa6e6b679 100644 --- a/scripts/scr_ui_advisors/scr_ui_advisors.gml +++ b/scripts/scr_ui_advisors/scr_ui_advisors.gml @@ -75,11 +75,12 @@ function scr_ui_advisors() { draw_set_font(fnt_40k_14); draw_set_alpha(1); draw_set_color(c_gray); + var _active_roles = active_roles(); if (temp[36] != "0") { blurp = $"Sir! You requested a report? Currently, we have deployed {temp[36]} {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s to watch over the health of our Battle-Brothers in the field. We have an additional " + string(temp[37]) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + "s who await only your order to carry the word to the troops."; } if (temp[36] == "0") { - blurp = "Sir! You requested a report? Currently, we have {temp[37]} {obj_ini.role[100, 14]}s who await only your order to carry the word to the troops."; + blurp = $"Sir! You requested a report? Currently, we have {temp[37]} {_active_roles[14]}s who await only your order to carry the word to the troops."; } if ((global.chapter_name != "Space Wolves") && (global.chapter_name != "Iron Hands")) { blurp += "##Currently, we are training additional " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " at a "; @@ -201,8 +202,9 @@ function scr_ui_advisors() { } if (fest_honoring == 3) { blurp2 += " in honor of "; - blurp2 += string(obj_ini.role[fest_honor_co][fest_honor_id]) + " "; - blurp2 += string(obj_ini.name[fest_honor_co][fest_honor_id]) + " (" + romanNumerals[fest_honor_co] + " Company). "; + var _unit = fetch_unit([fest_honor_co, fest_honor_id]) + blurp2 += $"{_unit.role()} "; + blurp2 += $"{_unit.name()} {romanNumerals[fest_honor_co]} Company). "; } if (fest_honoring == 4) { // faction diff --git a/scripts/scr_ui_settings/scr_ui_settings.gml b/scripts/scr_ui_settings/scr_ui_settings.gml index 86a42c69c3..ecefd9f6ad 100644 --- a/scripts/scr_ui_settings/scr_ui_settings.gml +++ b/scripts/scr_ui_settings/scr_ui_settings.gml @@ -75,16 +75,17 @@ function setup_ui_chapter_settings() { var _role_id = _role_order[i]; var _active = obj_ini.player_role_data[_role_id].available_to_player; + var _r_data = obj_ini.player_role_data[_role_id]; var _button = new UnitButtonObject({ style: "pixel", x1: _but_x, y1: _but_y, - label: obj_ini.role[100][_role_id], + label: _r_data.role, set_width: true, w: 289, active: _active, role_id: _role_id, - tooltip: string(obj_ini.role[100][_role_id]) + " Settings\n" + _base_tool, + tooltip: $"{_r_data.role} Settings\n" + _base_tool, }); _but_y += 30; @@ -704,7 +705,7 @@ function scr_draw_mass_equip_gui() { draw_set_color(c_gray); draw_rectangle(114, 626, 560, 665, 0); draw_set_color(0); - draw_text(333, 636, $"Requip All {obj_ini.role[100][role]} With Default Items"); + draw_text(333, 636, $"Requip All {obj_ini.player_role_data[_role_id].role} With Default Items"); if (scr_hit(114, 626, 560, 665) == true) { draw_set_color(c_white); draw_set_alpha(0.2); From 106d8b6f110a4f5b4f5d75fe81253f2e007496b3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 3 Aug 2026 18:21:53 +0100 Subject: [PATCH 28/82] remomve all armour references --- objects/obj_mass_equip/Step_0.gml | 2 +- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 35 +++++++++++---------- scripts/scr_ui_settings/scr_ui_settings.gml | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/objects/obj_mass_equip/Step_0.gml b/objects/obj_mass_equip/Step_0.gml index d5486262ea..95184255bf 100644 --- a/objects/obj_mass_equip/Step_0.gml +++ b/objects/obj_mass_equip/Step_0.gml @@ -186,7 +186,7 @@ try { } } - if (string_count("&", obj_ini.armour[co][i]) > 0) { + if (string_count("&", _armour) > 0) { yes = true; } else if (_armour == req_armour) { yes = true; diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index 932851cc26..d1ae7559bc 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -742,27 +742,28 @@ function scr_enemy_ai_e() { var otm = 0; var master_present = false; - for (var co = 0; co <= 10; co++) { - for (var i = 1; i <= 200; i++) { + var _is_a_chaos_meeting = _unit.planet_location == floor(chaos_meeting); + for (var co = 0; co <= 10 && _is_a_chaos_meeting; co++) { + for (var i = 0; i <= array_length(obj_ini.TTRPG[co]); i++) { var _unit = fetch_unit([co, i]); if (!is_struct(_unit)) { continue; } - var _is_unit_real_and_here = _unit.role() != "" && _unit.location_string == name; - var _is_this_a_chaos_meeting = _unit.planet_location == floor(chaos_meeting); - var _unit_does_not_have_dreadnought_role = _unit.role() != obj_ini.player_role_data[eROLE.DREADNOUGHT].role; - var _unit_is_not_venerable = _unit.role() != "Venerable " + string(obj_ini.player_role_data[eROLE.DREADNOUGHT].role); - var _unit_does_not_have_dreadnought_armour = string_count("Dread", obj_ini.armour[co][i]) == 0; - var _is_chapter_master = _unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role; - if (_is_unit_real_and_here && _is_this_a_chaos_meeting && _unit_does_not_have_dreadnought_role && _unit_is_not_venerable && (_unit_does_not_have_dreadnought_armour || _is_chapter_master)) { - _meeting.dudes += 1; - otm = _meeting.dudes; - _meeting.present[otm] = 1; - _meeting.co[otm] = co; - _meeting.ide[otm] = i; - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { - master_present = true; - } + if (_unit.is_dreadnought() && !role_compare(_unit, eROLE.CHAPTERMASTER)){ + continue; + } + if (_unit.location_string != name){ + continue; + } + + + _meeting.dudes += 1; + otm = _meeting.dudes; + _meeting.present[otm] = 1; + _meeting.co[otm] = co; + _meeting.ide[otm] = i; + if (co <= 0) { + master_present = role_compare(_unit, eROLE.CHAPTERMASTER); } } } diff --git a/scripts/scr_ui_settings/scr_ui_settings.gml b/scripts/scr_ui_settings/scr_ui_settings.gml index ecefd9f6ad..f2b6ffbc0a 100644 --- a/scripts/scr_ui_settings/scr_ui_settings.gml +++ b/scripts/scr_ui_settings/scr_ui_settings.gml @@ -934,7 +934,7 @@ function scr_draw_role_settings_ui() { var _but = _buttons[i]; var _allow_click = true; if (i == eEQUIPMENT_SLOT.GEAR) { - var _armour = obj_ini.armour[100][_index]; + var _armour = obj_ini.player_role_data[_index].armour; var _armour_tags = gear_weapon_data("armour", _armour, "tags"); if (_armour_tags != 0) { if (array_contains(_armour_tags, "terminator") || array_contains(_armour_tags, "dreadnought")) { From 2d33237134d49d97649d09c29d95057d5e228d60 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 3 Aug 2026 18:52:38 +0100 Subject: [PATCH 29/82] remome final gear references --- objects/obj_p_assra/Step_0.gml | 4 +- scripts/scr_civil_roster/scr_civil_roster.gml | 2 +- scripts/scr_crusade/scr_crusade.gml | 40 +++++++++---------- scripts/scr_event_gossip/scr_event_gossip.gml | 1 - scripts/scr_kill_unit/scr_kill_unit.gml | 4 +- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/objects/obj_p_assra/Step_0.gml b/objects/obj_p_assra/Step_0.gml index 87aa539672..85a09c87cf 100644 --- a/objects/obj_p_assra/Step_0.gml +++ b/objects/obj_p_assra/Step_0.gml @@ -199,7 +199,7 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in // Damaging var to_bomb; to_bomb = false; - if ((plasma_bomb == true) && (obj_ini.gear[co][i] == "Plasma Bomb")) { + if ((plasma_bomb == true) && (unit.gear() == "Plasma Bomb")) { to_bomb = true; } if (choose(1, 2, 3, 4, 5) < 4) { @@ -211,7 +211,7 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in } else if (to_bomb) { target.hp -= 200; damaged_ship = 2; - obj_ini.gear[co][i] = ""; + unit.update_gear("",false,false); } } diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index 2d617389d7..ca8a7eb250 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -368,7 +368,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { targ.dudes_powers[targ.men] = _unit.specials; targ.dudes_wep1[targ.men] = _unit.weapon_one(); targ.dudes_wep2[targ.men] = _unit.weapon_two(); - targ.dudes_gear[targ.men] = obj_ini.gear[cooh][va]; + targ.dudes_gear[targ.men] = _unit.gear(); targ.dudges_mobi[targ.men] = _unit.mobility_item(); new_combat.enemy_forces += 1; diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index ea29f7ddcf..b1df0be907 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -3,7 +3,7 @@ function scr_crusade() { // Executed to kill the fuck out of the player's marines // Think it is ran in the obj_p_fleet object when arriving back from crusade - var unit; + var _unit; var co = 0, i = 0, apoth = 0, death_determination = 0, death_determination_2 = 0, roll3 = 0, type = "", artifacts = 0, clean = 0; seed = 0; marines_lost = 0; @@ -65,53 +65,53 @@ function scr_crusade() { for (co = 0; co <= obj_ini.companies; co++) { for (i = 0; i < company_length(co); i++) { dead = false; - unit = fetch_unit([co, i]); - if (!is_struct(unit)) { + _unit = fetch_unit([co, i]); + if (!is_struct(_unit)) { continue; } - if (unit.ship_location == -1) { + if (_unit.ship_location == -1) { continue; } - if (array_contains(total_ship_id, unit.ship_location)) { + if (array_contains(total_ship_id, _unit.ship_location)) { death_determination = floor(random(100)) + 1; //specialist trait greatly reduces death risk //TODO figure out how to quantify and present these risks so the player knows to protect dudes with trait - if (unit.has_trait("very_hard_to_kill")) { + if (_unit.has_trait("very_hard_to_kill")) { death_determination -= 20; } death_determination_2 = death_determination; - death_determination -= unit.experience / 2; + death_determination -= _unit.experience / 2; //more generalised trait bonus mainly linked to chapter advantage of same name - if (unit.has_trait("slow_and_purposeful")) { + if (_unit.has_trait("slow_and_purposeful")) { death_determination -= 10; } var _dead = false; if (death_determination > death_data[0] || death_determination_2 > death_data[1]) { _dead = true; - if (unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { - if (irandom(20) < unit.luck) { + if (_unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { + if (irandom(20) < _unit.luck) { _dead = false; } else { - if (irandom(100) < unit.weapon_skill) { + if (irandom(100) < _unit.weapon_skill) { var heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); //TODO figure out a blance in reward for captains or high rnaking death on crusade //adds dynamacism as itt creates reward for the potential loss of men and talent during crusades //var consolations = ["ship", "req",""] //var consolation_prize = irandom(2) - var heroic_death = $"{unit.full_title()} died {heroic_deed} {unit.name()} dies a hero of the {global.chapter_name}"; + var heroic_death = $"{_unit.full_title()} died {heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; array_push(heroics_strings, heroic_death); } } - } else if (unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role || unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + } else if (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role || _unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { _dead = false; } } if (_dead) { var man_size = 0; - obj_ini.ship_carrying[unit.ship_location] -= unit.get_unit_size(); - if (unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { + obj_ini.ship_carrying[_unit.ship_location] -= _unit.get_unit_size(); + if (_unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { obj_controller.command--; } else { obj_controller.marines--; @@ -122,15 +122,15 @@ function scr_crusade() { scr_kill_unit(co, i); seed += 2; } else { - if (unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (obj_ini.gear[co][i] == "Narthecium")) { + if (_unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (_unit.gear() == "Narthecium")) { apoth++; } - unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); + _unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); - if (irandom(99) == 1 && irandom(20) < unit.luck) { + if (irandom(99) == 1 && irandom(20) < _unit.luck) { var heroic_deed = choose("still_standing", "lone_survivor", "beast_slayer"); - unit.add_trait(heroic_deed); - array_push(heroics_strings, string(global.trait_list[$ heroic_deed].flavour_text, unit.full_title())); + _unit.add_trait(heroic_deed); + array_push(heroics_strings, string(global.trait_list[$ heroic_deed].flavour_text, _unit.full_title())); } } } diff --git a/scripts/scr_event_gossip/scr_event_gossip.gml b/scripts/scr_event_gossip/scr_event_gossip.gml index f82758b540..2b64cf00b4 100644 --- a/scripts/scr_event_gossip/scr_event_gossip.gml +++ b/scripts/scr_event_gossip/scr_event_gossip.gml @@ -42,7 +42,6 @@ function scr_event_gossip(argument0) { p += 1; gossip[p] = "artifact_wep"; } - // if (string_count("&",obj_ini.gear[attend_co[argument0],attend_id[argument0]])>0){p+=1;gossip[p]="artifact_gear";} if (_unit.mobility_item() == "Bike") { p += 1; gossip[p] = "mah_bike"; diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 7f268abd0a..9aa48b1ee3 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -6,14 +6,12 @@ function scr_kill_unit(company, unit_slot) { array_push(obj_ini.previous_forge_masters, _unit.name()); } - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + if (compare_role(_unit eROLE.CHAPTERMASTER)) { tek = "c"; alarm[7] = 5; global.defeat = 1; } - var _unit = fetch_unit([company, unit_slot]); - if (is_struct(_unit)) { if (_unit.weapon_one() == "Company Standard" || _unit.weapon_two() == "Company Standard") { scr_loyalty("Lost Standard", "+"); From b47ed4977e99beff66d956b970b44a1326be6526 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 3 Aug 2026 19:58:44 +0100 Subject: [PATCH 30/82] so close i can taste it --- ChapterMaster.yyp | 2 +- objects/obj_controller/Step_0.gml | 2 +- objects/obj_creation/Create_0.gml | 27 +------- objects/obj_p_assra/Alarm_0.gml | 4 +- scripts/ArtifactStruct/ArtifactStruct.gml | 2 +- scripts/scr_chapter_new/scr_chapter_new.gml | 3 +- .../scr_company_order/scr_company_order.gml | 2 +- scripts/scr_company_view/scr_company_view.gml | 2 +- scripts/scr_creation/scr_creation.gml | 8 +-- .../scr_culture_visuals.gml | 66 ++++++++----------- scripts/scr_dialogue/scr_dialogue.gml | 2 +- scripts/scr_event_dudes/scr_event_dudes.gml | 24 +++---- .../scr_initialize_custom.gml | 2 - scripts/scr_kill_unit/scr_kill_unit.gml | 2 +- .../scr_marine_struct/scr_marine_struct.gml | 4 +- scripts/scr_role_setup/scr_role_setup.gml | 33 ++++++++-- 16 files changed, 82 insertions(+), 103 deletions(-) diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 5e78d5f4c2..dda4568f31 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -957,8 +957,8 @@ {"id":{"name":"scr_vehicle_order","path":"scripts/scr_vehicle_order/scr_vehicle_order.yy",},}, {"id":{"name":"scr_void_click","path":"scripts/scr_void_click/scr_void_click.yy",},}, {"id":{"name":"scr_wait_and_execute","path":"scripts/scr_wait_and_execute/scr_wait_and_execute.yy",},}, - {"id":{"name":"SectorHandler","path":"scripts/SectorHandler/SectorHandler.yy",},}, {"id":{"name":"scr_zoom","path":"scripts/scr_zoom/scr_zoom.yy",},}, + {"id":{"name":"SectorHandler","path":"scripts/SectorHandler/SectorHandler.yy",},}, {"id":{"name":"Set","path":"scripts/Set/Set.yy",},}, {"id":{"name":"SettingsManager","path":"scripts/SettingsManager/SettingsManager.yy",},}, {"id":{"name":"TooltipBuilder","path":"scripts/TooltipBuilder/TooltipBuilder.yy",},}, diff --git a/objects/obj_controller/Step_0.gml b/objects/obj_controller/Step_0.gml index b814fb0467..f1ddbdcbbf 100644 --- a/objects/obj_controller/Step_0.gml +++ b/objects/obj_controller/Step_0.gml @@ -490,7 +490,7 @@ try { } if (menu == eMENU.DEFAULT && !instances_exist_any([obj_ncombat, obj_fleet_controller])) { - if (chapter_master.get_struct().role() != obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) && (alarm[7] == -1)) { + if (role_compare(chapter_master.get_struct(), eROLE.CHAPTERMASTER) && (alarm[7] == -1)) { alarm[7] = 15; } } diff --git a/objects/obj_creation/Create_0.gml b/objects/obj_creation/Create_0.gml index 6d18b6c5ae..ec4aec314f 100644 --- a/objects/obj_creation/Create_0.gml +++ b/objects/obj_creation/Create_0.gml @@ -542,30 +542,9 @@ chapter_trait_meta = []; setup_chapter_traits(); - -function role_data_set(){ - return { - role : "", - wep1 : "", - wep2 : "", - armour : "", - mobi : "", - gear : "", - race : 1 - } -} player_role_data = []; -default_role_data = []; - -// Default Marine Loadouts - -for (var i = 0; i <= 50; i++) { - player_role_data[i] = role_data_set(); - default_role_data[i] = role_data_set(); -} - - -defaults_slot = 100; +setup_default_gears(); +player_role_data = variable_clone(default_role_data) /// @description /// @param {Real} _role_id @@ -577,8 +556,6 @@ defaults_slot = 100; /// @param {String} _gear -setup_default_gears(); - col = []; col_r = []; col_g = []; diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index dc3a1d6631..b13cc016cf 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -7,7 +7,7 @@ for (o = 0; o < array_length(origin.board_co); o++) { if (!is_struct(_unit)) { continue; } - if ((_unit.hp() <= -15) && (_unnit.base_group != "astartes") { + if (_unit.hp() <= -15 && _unit.base_group != "astartes") { var seed_lost = 0; if (apothecary <= 0) { if (_unit.IsSpecialist(SPECIALISTS_STANDARD)) { @@ -23,7 +23,7 @@ for (o = 0; o < array_length(origin.board_co); o++) { } // obj_fleet.marines_lost+=1; - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + if (role_compare(_unit, eROLE.CHAPTERMASTER)) { obj_controller.alarm[7] = 1; if (global.defeat <= 1) { global.defeat = 1; diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index 22a2e097e4..b26bb052de 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -290,7 +290,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, if (has_tag("daemonic") || has_tag("chaos")) { unit.corruption += irandom(DAEMON_CORRUPTION_MAX); - if (role_compare(unit, eROLE.CHAPTERMASTER) { + if (role_compare(unit, eROLE.CHAPTERMASTER) ){ /// @type {Asset.GMObject.obj_popup} var pip = instance_create(0, 0, obj_popup); pip.title = "Daemon Artifacts"; diff --git a/scripts/scr_chapter_new/scr_chapter_new.gml b/scripts/scr_chapter_new/scr_chapter_new.gml index a1a1f8c1c9..54ea349d1e 100644 --- a/scripts/scr_chapter_new/scr_chapter_new.gml +++ b/scripts/scr_chapter_new/scr_chapter_new.gml @@ -210,9 +210,8 @@ function scr_chapter_new(chapter_identifier) { points = 100; maxpoints = 100; - player_role_data = []; - default_role_data = []; setup_default_gears(); + player_role_data = variable_clone(default_role_data); for (var c = 0; c < array_length(all_chapters); c++) { if (chapter_identifier == all_chapters[c].name && all_chapters[c].json == true) { diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index a7324b535d..023fd9efaf 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -116,7 +116,7 @@ function scr_company_order(company) { var _temps = []; for (var i = 0; i < array_length(_company_marines.units); i++) { var _unit = _company_marines.units[i]; - array_push(_temps, {unit: _unit); + array_push(_temps, {unit: _unit}); } var _new_length = array_length(_temps); diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index 4bb98f1171..d147769d81 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -45,7 +45,7 @@ function find_company_open_slot(target_company) { var good = -1; var _company_length = array_length(obj_ini.name[target_company]); for (var i = 0; i < _company_length; i++) { - if (is_undefined(obj_ini.TTRPG[target_company]) { + if (is_undefined(obj_ini.TTRPG[target_company])) { good = i; break; } diff --git a/scripts/scr_creation/scr_creation.gml b/scripts/scr_creation/scr_creation.gml index 4d037a88e1..a717bc17bb 100644 --- a/scripts/scr_creation/scr_creation.gml +++ b/scripts/scr_creation/scr_creation.gml @@ -64,12 +64,12 @@ function set_complex_livery_buttons() { /// @self Asset.GMObject.obj_creation function update_creation_roles_radio(start_role = 1) { - var _role_data = []; + var _role_choice_array = []; - for (var i = start_role; i <= 19; i++) { + for (var i = start_role; i < array_length(player_role_data); i++) { var _role_data = player_role_data[i]; if (_role_data.available_to_player && _role_data.role != "") { - array_push(_role_data, {str1: role[100][i], font: fnt_40k_14b, role_id: i}); + array_push(_role_choice_array, {str1: _role_data.role, font: fnt_40k_14b, role_id: i}); } } @@ -79,7 +79,7 @@ function update_creation_roles_radio(start_role = 1) { y1: 220, y_gap: 1, }; - roles_radio = new RadioSet(_role_data, "Role Settings", _radio_data); + roles_radio = new RadioSet(_role_choice_array, "Role Settings", _radio_data); roles_radio.current_selection = -1; } diff --git a/scripts/scr_culture_visuals/scr_culture_visuals.gml b/scripts/scr_culture_visuals/scr_culture_visuals.gml index aee6226ef5..b826c5d24d 100644 --- a/scripts/scr_culture_visuals/scr_culture_visuals.gml +++ b/scripts/scr_culture_visuals/scr_culture_visuals.gml @@ -2206,24 +2206,22 @@ function DummyMarine() constructor { return "jeff"; }; - static role(){ + static role_index = function(){ return obj_creation.livery_picker.role_set > 0 ? obj_creation.livery_picker.role_set : eROLE.TACTICAL; } static role = function() { - with (obj_creation) { - if (obj_creation.livery_selection_options.current_selection == 2) { - return player_role_data[role()].role; - } else { - return player_role_data[eROLE.TACTICAL].role; - } + + if (obj_creation.livery_selection_options.current_selection == 2) { + return obj_creation.player_role_data[role_index()].role; + } else { + return obj_creation.player_role_data[eROLE.TACTICAL].role; } + }; static weapon_one = function() { - with (obj_creation) { - return player_role_data[role()].wep1; - } + return obj_creation.player_role_data[role_index()].wep1; }; static race = function() { @@ -2231,9 +2229,7 @@ function DummyMarine() constructor { }; static weapon_two = function() { - with (obj_creation) { - return player_role_data[role()].wep2; - } + return obj_creation.player_role_data[role_index()].wep2; }; last_armour = "MK7 Aquila"; @@ -2242,24 +2238,24 @@ function DummyMarine() constructor { var armours = global.list_basic_power_armour; var _last_armour = last_armour; var _armour = ""; - with (obj_creation) { - if (!livery_picker.freeze_armour) { - _armour = player_role_data[role()].armour; - if (array_contains(armours, _armour) || _armour == STR_ANY_POWER_ARMOUR) { - _armour = array_random_element(armours); - } else if (array_contains(global.list_terminator_armour, _armour) || _armour == STR_ANY_POWER_ARMOUR) { - _armour = array_random_element(global.list_terminator_armour); - } - if (_armour == "Power Armour") { - _armour = "MK7 Aquila"; - } - } else { - _armour = _last_armour; + var _picker = obj_creation.livery_picker; + var _roles = obj_creation.player_role_data + if (!_picker.freeze_armour) { + _armour = _roles[role_index()].armour; + if (array_contains(armours, _armour) || _armour == STR_ANY_POWER_ARMOUR) { + _armour = array_random_element(armours); + } else if (array_contains(global.list_terminator_armour, _armour) || _armour == STR_ANY_POWER_ARMOUR) { + _armour = array_random_element(global.list_terminator_armour); } - if (obj_creation.livery_selection_options.current_selection == 2) { - if (!array_contains(armours, _armour)) { - _armour = "MK7 Aquila"; - } + if (_armour == "Power Armour") { + _armour = "MK7 Aquila"; + } + } else { + _armour = _last_armour; + } + if (obj_creation.livery_selection_options.current_selection == 2) { + if (!array_contains(armours, _armour)) { + _armour = "MK7 Aquila"; } } last_armour = _armour; @@ -2267,19 +2263,15 @@ function DummyMarine() constructor { }; static gear = function() { - with (obj_creation) { - return player_role_data[role()].gear; - } + return obj_creation.player_role_data[role_index()].gear; }; static mobility_item = function() { - with (obj_creation) { - return player_role_data[role()].mobi; - } + return obj_creation.player_role_data[role_index()].mobi; }; static IsSpecialist = function(search_type = SPECIALISTS_STANDARD, include_trainee = false, include_heads = true) { - return is_specialist(role(), search_type, include_trainee, include_heads); + return is_specialist(role_index(), search_type, include_trainee, include_heads); }; static has_trait = function(_wanted_trait, _any = true) { diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index e4c76d5931..9277b4a7b9 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -347,7 +347,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { var born = false; for (var ii = 0; ii < array_length(obj_ini.TTRPG[0]); ii++) { - var _unit - fetch_unit([0,ii]); + var _unit = fetch_unit([0,ii]); if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { _unit.corruption += floor(random_range(30, 50)); } diff --git a/scripts/scr_event_dudes/scr_event_dudes.gml b/scripts/scr_event_dudes/scr_event_dudes.gml index ee65288afc..db53deadd9 100644 --- a/scripts/scr_event_dudes/scr_event_dudes.gml +++ b/scripts/scr_event_dudes/scr_event_dudes.gml @@ -27,30 +27,22 @@ function scr_event_dudes(do_action, is_planet, system_name, location_id) { } } - var coh, ide, oc, ocn, ty, g, good, blur, _unit; - coh = -1; + var ty, g, good, blur; ide = 0; - ide = -1; ty = 0; g = 0; good = 0; blur = ""; - repeat (200) { - ide += 1; - oc[ide] = ""; - ocn[ide] = 0; - } - co = -1; - ide = 0; - repeat (11) { - coh += 1; - ide = 0; - for (var ide = 0; ide < array_length(obj_ini.TTRPG[coh]), ide++) { - ide += 1; + var oc = array_create(200, ""); + var ocn = array_create(200, 0); + + + for (var coh = 0; coh <= obj_ini.companies; coh++) { + for (var ide = 0; ide < array_length(obj_ini.TTRPG[coh]); ide++) { var adding; adding = false; - _unit = fetch_unit([coh, ide]); + var _unit = fetch_unit([coh, ide]); if ((is_planet == 0) && (_unit.ship_location == location_id)) { diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 9dc14be3fb..c83757cca1 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1471,8 +1471,6 @@ function scr_initialize_custom() { _hi_qual_armour = STR_ANY_POWER_ARMOUR; } - setup_default_gears(); - if (variable_instance_exists(obj_creation, "custom_roles")) { var c_roles = obj_creation.custom_roles; var possible_custom_roles = [ diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 00488c08b8..7f15b9f0d7 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -6,7 +6,7 @@ function scr_kill_unit(company, unit_slot) { array_push(obj_ini.previous_forge_masters, _unit.name()); } - if (compare_role(_unit eROLE.CHAPTERMASTER)) { + if (compare_role(_unit, eROLE.CHAPTERMASTER)) { tek = "c"; alarm[7] = 5; global.defeat = 1; diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index d5e96a7ff8..bce51b9924 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -410,7 +410,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static handle_stat_growth = unit_stat_growth; - static move_to_company(new_company){ + static move_to_company = function(new_company){ var _slot = find_company_open_slot(new_company); var _old_loc = [company, marine_number]; movement_after_math(new_company , _slot); @@ -2084,7 +2084,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static get_role_data = function(){ for (var i = 0; i < 24; i++) { - var _role_data == obj_ini.player_role_data[i]; + var _role_data = obj_ini.player_role_data[i]; if (_role_data.role == role()) { return _role_data; } diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index 46f3cc1d33..4477b33377 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -1,6 +1,19 @@ -function setup_default_gears = function(){ +function role_data_set(){ + return { + role : "", + wep1 : "", + wep2 : "", + armour : "", + mobi : "", + gear : "", + available_to_player : false + } +} + +function setup_default_gears (){ + default_role_data = []; load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { default_role_data[_role_id] = { role : _role_name, @@ -9,9 +22,11 @@ function setup_default_gears = function(){ armour : _armour, mobi : _mobi, gear : _gear, - available_to_player : 1 - }} + available_to_player : true + } }; + + load_default_gear(eROLE.CHAPTERMASTER, "Chapter Master", "Power Sword", "Bolter", "Artificer Armour", "", ""); load_default_gear(eROLE.HONOURGUARD, "Honour Guard", "Power Sword", "Bolter", "Artificer Armour", "", ""); load_default_gear(eROLE.VETERAN, "Veteran", "Combiflamer", "Combat Knife", STR_ANY_POWER_ARMOUR, "", ""); load_default_gear(eROLE.TERMINATOR, "Terminator", "Power Fist", "Storm Bolter", "Terminator Armour", "", ""); @@ -29,6 +44,12 @@ function setup_default_gears = function(){ load_default_gear(eROLE.LIBRARIAN, "Librarian", "Force Staff", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", "Psychic Hood"); load_default_gear(eROLE.SERGEANT, "Sergeant", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); load_default_gear(eROLE.VETERANSERGEANT, "Veteran Sergeant", "Chainsword", "Plasma Pistol", STR_ANY_POWER_ARMOUR, "", ""); + + for (var i = 0; i < array_length(player_role_data); i++) { + if (default_role_data[i] == 0){ + default_role_data[i] = role_data_set(); + } + } } function update_role_data_wth_defaults(){ @@ -188,7 +209,7 @@ function scr_role_setup() { draw_set_font(fnt_40k_14b); draw_set_halign(fa_right); var _apoths_allowed = player_role_data[eROLE.APOTHECARY].available_to_player; - var _chaps_allowed = player_role_data[eROLE.CHAPLAINA].available_to_player; + var _chaps_allowed = player_role_data[eROLE.CHAPLAIN].available_to_player; var _libs_allowed = player_role_data[eROLE.LIBRARIAN].available_to_player; var _techs_allowed = player_role_data[eROLE.TECHMARINE].available_to_player; @@ -196,7 +217,7 @@ function scr_role_setup() { if (_apoths_allowed) { draw_text(594, 575, "Chief Apothecary: "); } - if (player_role_data[eROLE.CHAPLAINA].available_to_player) { + if (player_role_data[eROLE.CHAPLAIN].available_to_player) { draw_text(594, 597, "High Chaplain: "); } if (player_role_data[eROLE.LIBRARIAN].available_to_player) { @@ -209,7 +230,7 @@ function scr_role_setup() { draw_text(594, 685, "Master of the Fleet: "); draw_set_halign(fa_left); - if (_apoths_allowed0) { + if (_apoths_allowed) { draw_set_color(CM_GREEN_COLOR); if (hapothecary == "") { draw_set_color(c_red); From c3eae2ff00ff718caa7e8aa7c7c339aaa347e834 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 3 Aug 2026 20:35:02 +0100 Subject: [PATCH 31/82] closer ,so very close --- objects/obj_controller/Create_0.gml | 2 +- objects/obj_p_ship/Alarm_0.gml | 2 +- .../scr_add_corruption/scr_add_corruption.gml | 2 +- .../scr_apothecary_ground.gml | 2 +- scripts/scr_company_view/scr_company_view.gml | 2 +- .../scr_initialize_custom.gml | 34 ++------ .../scr_marine_struct/scr_marine_struct.gml | 87 ++++++++++--------- .../scr_player_fleet_combat_functions.gml | 2 +- .../scr_player_fleet_functions.gml | 2 +- .../scr_random_marine/scr_random_marine.gml | 2 +- scripts/scr_start_allow/scr_start_allow.gml | 6 +- .../scr_system_spawn_functions.gml | 2 +- 12 files changed, 65 insertions(+), 80 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index f86259ad8f..2f37fcd8b8 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1332,7 +1332,7 @@ if (global.load == -1) { #region Intro Scroll temp[30] = obj_ini.sector_handler.date(); // Date temp[31] = string_upper(adept_name); // Adept name -temp[32] = string_upper(obj_ini.name[0][0]); // Master name +temp[32] = chapter_master.get_struct.name(); // Master name temp[33] = string_upper(scr_thought()); // Thought of the day // Game start welcoming message diff --git a/objects/obj_p_ship/Alarm_0.gml b/objects/obj_p_ship/Alarm_0.gml index bc2191ebac..75458ee382 100644 --- a/objects/obj_p_ship/Alarm_0.gml +++ b/objects/obj_p_ship/Alarm_0.gml @@ -185,7 +185,7 @@ if (obj_controller.stc_bonus[6] == 2) { } for (var co = 0; co <= obj_ini.companies; co++) { - for (var i = 0; i < array_length(obj_ini.name[co]); i++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { if (obj_ini.name[co][i] == "") { continue; } diff --git a/scripts/scr_add_corruption/scr_add_corruption.gml b/scripts/scr_add_corruption/scr_add_corruption.gml index 878da9acc2..e0180bc52e 100644 --- a/scripts/scr_add_corruption/scr_add_corruption.gml +++ b/scripts/scr_add_corruption/scr_add_corruption.gml @@ -22,7 +22,7 @@ function scr_add_corruption(is_fleet, modifier_type) { } } for (var co = 0; co <= 10; co++) { - for (var i = 0; i < array_length(obj_ini.name[co]); i++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { if (obj_ini.name[co][i] == "") { continue; } diff --git a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml index e12474d8d7..68e0d07bcd 100644 --- a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml +++ b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml @@ -24,7 +24,7 @@ function calculate_full_chapter_spread() { var _apoth_spread = {}; var _unit_spread = {}; for (var company = 0; company < 11; company++) { - var _marine_len = array_length(obj_ini.name[company]) - 1; + var _marine_len = array_length(obj_ini.TTRPG[company]) - 1; var _veh_len = array_length(obj_ini.veh_hp[company]) - 1; var _company_length = max(_marine_len, _veh_len); diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index d147769d81..ad88e6ea27 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -43,7 +43,7 @@ function reset_manage_arrays() { function find_company_open_slot(target_company) { var good = -1; - var _company_length = array_length(obj_ini.name[target_company]); + var _company_length = array_length(obj_ini.TTRPG[target_company]); for (var i = 0; i < _company_length; i++) { if (is_undefined(obj_ini.TTRPG[target_company])) { good = i; diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index c83757cca1..e39876d301 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1551,7 +1551,6 @@ function scr_initialize_custom() { /** * check whether the json structure exists to populate custom role names and * attributes then set them using the map above - * role[100] is the 'default role name' storage spot, or something */ for (var c = 0; c < array_length(possible_custom_roles); c++) { if (struct_exists(c_roles, possible_custom_roles[c][0])) { @@ -1900,19 +1899,15 @@ function scr_initialize_custom() { */ #endregion - for (var i = 0; i < array_length(role[defaults_slot]); i++) { - if (role[defaults_slot][i] != "") { - scr_start_allow(i, "wep1", wep1[defaults_slot][i]); - } - if (role[defaults_slot][i] != "") { - scr_start_allow(i, "wep2", wep2[defaults_slot][i]); - } - if (role[defaults_slot][i] != "") { - scr_start_allow(i, "mobi", mobi[defaults_slot][i]); - } - if (role[defaults_slot][i] != "") { - scr_start_allow(i, "gear", gear[defaults_slot][i]); + for (var i = 0; i < array_length(player_role_data); i++) { + if (player_role_data[i].role == "") { + continue; } + var _data = player_role_data[i]; + scr_start_allow(i, "wep1", _data.wep1); + scr_start_allow(i, "wep2", _data.wep2); + scr_start_allow(i, "mobi", _data.mobi); + scr_start_allow(i, "gear", _data.gear); // check for allowable starting equipment here } @@ -2781,17 +2776,6 @@ function scr_initialize_custom() { #endregion - //? Seems to be dead code; prove me wrong - // _marine_i = 0; - // company = 0; - // for (var c = 0; c <= 200; c++) { - // if (_marine_i == 0) { - // if ((role[0][c] != "") && (role[0][c + 1] == "")) { - // _marine_i = c; - // } - // } - // } - scr_add_item("Bolter", 20); scr_add_item("Chainsword", 20); scr_add_item("Bolt Pistol", 5); @@ -2963,8 +2947,6 @@ function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 spawn_unit.update_role(role_name) spawn_unit.unit_race = 1; spawn_unit.location_string = obj_ini.home_name; - spawn_unit.update_role(role_name) - if (spawn_unit.name() == "") { spawn_unit.set_name(global.name_generator.ChapterMemberNameGeneration()) } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index bce51b9924..5ddc4bf0f8 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -168,6 +168,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} // Customization personal_livery = {}; + //TODO ca finally merge these into a coherent struct // Equipment gear_quality = "standard"; armour_quality = "standard"; @@ -177,6 +178,13 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} weapon_one_data = { quality: "standard", }; + role1 = ""; + wep1 = ""; + gear1 = ""; + armour1 = ""; + wep2 = ""; + unit_name = ""; + mobi1 = ""; // Combat States encumbered_ranged = false; @@ -362,7 +370,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } var _cloak_chance = 5; - if (role() == obj_ini.player_role_data[eROLE.CHAPLAIN].role) { + if (role_compare(self, eROLE.CHAPLAIN)) { _cloak_chance += 25; } else if (IsSpecialist(SPECIALISTS_LIBRARIANS)) { _cloak_chance += 75; @@ -426,20 +434,17 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} array_delete(obj_ini.TTRP[_old_loc[0]] , _old_loc[1] , 1); } - armour1 = ""; static armour = function(raw = false) { - var wep = armour1; - if (is_string(wep) || raw) { - return wep; + var _wep = armour1; + if (is_string(_wep) || raw) { + return _wep; } - var arti = fetch_artifact(wep); + var arti = fetch_artifact(_wep); return arti.get_type_name(); }; - current_role = ""; - static role = function() { - return current_role; + return role1; }; static squad_role = function() { @@ -460,34 +465,36 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return is_specialist(role(), search_type, include_trainee, include_heads); }; - role1 = ""; static update_role = function(new_role) { if (role() == new_role) { return "no change"; } - if (base_group == "astartes") { + var _astartes = base_group == "astartes"; + if (_astartes) { if (role() == obj_ini.player_role_data[eROLE.SCOUT].role && new_role != obj_ini.player_role_data[eROLE.SCOUT].role) { if (!get_body_data("black_carapace", "torso")) { alter_body("torso", "black_carapace", true); stat_boosts({strength: 4, constitution: 4, dexterity: 4}); //will decide on if these are needed } } - if (!is_specialist(role())) { - //logs changes too and from specialist status - if (is_specialist(new_role)) { - obj_controller.marines -= 1; - obj_controller.command += 1; - } - } else { - if (!is_specialist(new_role)) { - obj_controller.marines += 1; - obj_controller.command -= 1; - } - } } role1 = new_role; if (instance_exists(obj_controller)) { array_push(role_history, [role(), obj_controller.turn]); + if (_astartes) { + if (!is_specialist(role())) { + //logs changes too and from specialist status + if (is_specialist(new_role)) { + obj_controller.marines -= 1; + obj_controller.command += 1; + } + } else { + if (!is_specialist(new_role)) { + obj_controller.marines += 1; + obj_controller.command -= 1; + } + } + } } if (new_role == obj_ini.player_role_data[eROLE.CAPTAIN].role) { if (company == 2) { @@ -543,13 +550,12 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } }; - mobi1 = ""; static mobility_item = function(raw = false) { - var wep = mobi1; - if (is_string(wep) || raw) { - return wep; + var _wep = mobi1; + if (is_string(_wep) || raw) { + return _wep; } - var arti = fetch_artifact(wep); + var arti = fetch_artifact(_wep); return arti.get_type_name(); }; @@ -976,7 +982,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } array_push(epithets, epithet); }; - unit_name = ""; static name = function(update) { return obj_ini.name[company][marine_number]; }; // get marine name @@ -990,23 +995,20 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return new_name; }; - gear1 = ""; static gear = function(raw = false) { - var wep = gear1; - if (is_string(wep) || raw) { - return wep; + var _wep = gear1; + if (is_string(_wep) || raw) { + return _wep; } - var arti = fetch_artifact(wep); + var arti = fetch_artifact(_wep); return arti.get_type_name(); }; - - wep1 = ""; static weapon_one = function(raw = false) { - var wep = wep1; - if (is_string(wep) || raw) { - return wep; + var _wep = wep1; + if (is_string(_wep) || raw) { + return _wep; } - var arti = fetch_artifact(wep); + var arti = fetch_artifact(_wep); return arti.get_type_name(); }; @@ -1080,13 +1082,12 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} ]; }; - wep2 = ""; static weapon_two = function(raw = false) { var _wep = wep2; if (is_string(_wep) || raw) { - return wep; + return _wep; } - var arti = fetch_artifact(wep); + var arti = fetch_artifact(_wep); return arti.get_type_name(); }; diff --git a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml index 4ece26f009..98c0403c15 100644 --- a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml +++ b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml @@ -346,7 +346,7 @@ function setup_player_combat_ship() { var i = 0; for (var co = 0; co <= obj_ini.companies; co++) { - for (i = 0; i < array_length(obj_ini.name[co]); i++) { + for (i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { if (obj_ini.name[co][i] == "") { continue; } diff --git a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml index 98fc6bb510..50491a263e 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -493,7 +493,7 @@ function set_fleet_location(location) { } } for (var co = 0; co <= obj_ini.companies; co++) { - for (var i = 0; i < array_length(obj_ini.name[co]); i++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; diff --git a/scripts/scr_random_marine/scr_random_marine.gml b/scripts/scr_random_marine/scr_random_marine.gml index b0e846a523..07c956777e 100644 --- a/scripts/scr_random_marine/scr_random_marine.gml +++ b/scripts/scr_random_marine/scr_random_marine.gml @@ -30,7 +30,7 @@ function scr_random_marine(role, exp_req, search_params = {}) { } } if (company <= 10) { - var comp_size = array_length(obj_ini.name[company]); + var comp_size = array_length(obj_ini.TTRPG[company]); //This makes sure that cmopanies are searched randomly by creating an array of array positions to be randomly accessed var marine_list = []; diff --git a/scripts/scr_start_allow/scr_start_allow.gml b/scripts/scr_start_allow/scr_start_allow.gml index f9d9586e2c..658d692c8f 100644 --- a/scripts/scr_start_allow/scr_start_allow.gml +++ b/scripts/scr_start_allow/scr_start_allow.gml @@ -3,7 +3,7 @@ function scr_start_allow(role_id, equip_area, equipment) { var _veteran_level = 0; if (role_id == eROLE.DREADNOUGHT) { - equip_area[101][role_id] = equipment; + player_role_data[role_id][$ equip_area] = equipment; return; } @@ -69,7 +69,9 @@ function scr_start_allow(role_id, equip_area, equipment) { } if (_allow) { - equip_area[101][role_id] = equipment; + player_role_data[role_id][$ equip_area] = equipment; + } else { + player_role_data[role_id][$ equip_area] = default_role_data[role_id][$ equip_area]; } return; } diff --git a/scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml b/scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml index 60f2e71db0..1d3b06aa3e 100644 --- a/scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml +++ b/scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml @@ -111,7 +111,7 @@ function player_home_planet(home_planet) { p_player[home_planet] = obj_ini.man_size; for (var co = 0; co <= obj_ini.companies; co++) { - for (var i = 0; i < array_length(obj_ini.name[co]); i++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; From 72e7739083ab68d0ea7a184cf64daf0491c807b8 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 16:53:13 +0100 Subject: [PATCH 32/82] remove un-needed scripts --- ChapterMaster.yyp | 1 - objects/obj_controller/Alarm_5.gml | 6 +- objects/obj_controller/Create_0.gml | 2 +- objects/obj_p_ship/Alarm_0.gml | 5 +- objects/obj_popup/Destroy_0.gml | 6 +- objects/obj_star_select/Draw_64.gml | 3 +- scripts/Armamentarium/Armamentarium.gml | 2 +- .../scr_ChapterTraits/scr_ChapterTraits.gml | 41 ++++++ .../scr_add_corruption/scr_add_corruption.gml | 3 - scripts/scr_add_man/scr_add_man.gml | 21 ++- scripts/scr_apothecarium/scr_apothecarium.gml | 6 +- .../scr_apothecary_ground.gml | 126 +++++++++--------- .../scr_count_marines_on_ship.gml | 12 +- scripts/scr_dialogue/scr_dialogue.gml | 10 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 6 +- scripts/scr_librarium/scr_librarium.gml | 15 ++- .../scr_marine_struct/scr_marine_struct.gml | 7 +- scripts/scr_master_loc/scr_master_loc.gml | 43 ------ scripts/scr_master_loc/scr_master_loc.yy | 13 -- .../scr_secret_lair_view.gml | 2 +- scripts/scr_ship_battle/scr_ship_battle.gml | 3 - scripts/scr_start_load/scr_start_load.gml | 4 +- 22 files changed, 157 insertions(+), 180 deletions(-) delete mode 100644 scripts/scr_master_loc/scr_master_loc.gml delete mode 100644 scripts/scr_master_loc/scr_master_loc.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index dda4568f31..190b27c291 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -859,7 +859,6 @@ {"id":{"name":"scr_map_and_warp_functions","path":"scripts/scr_map_and_warp_functions/scr_map_and_warp_functions.yy",},}, {"id":{"name":"scr_marine_count","path":"scripts/scr_marine_count/scr_marine_count.yy",},}, {"id":{"name":"scr_marine_struct","path":"scripts/scr_marine_struct/scr_marine_struct.yy",},}, - {"id":{"name":"scr_master_loc","path":"scripts/scr_master_loc/scr_master_loc.yy",},}, {"id":{"name":"scr_max_marine","path":"scripts/scr_max_marine/scr_max_marine.yy",},}, {"id":{"name":"scr_mechanicus_missions","path":"scripts/scr_mechanicus_missions/scr_mechanicus_missions.yy",},}, {"id":{"name":"scr_mission_eta","path":"scripts/scr_mission_eta/scr_mission_eta.yy",},}, diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 3de2de1833..9d10ceb57f 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -581,12 +581,12 @@ try { if ((fest_scheduled > 0) && (fest_repeats > 0)) { var cm_present = false; fest_repeats--; - var lock = scr_master_loc(); + var _cm = chapter_master.get_struct(); - if ((fest_sid > 0) && (obj_ini.ship[fest_sid] == lock)) { + if (fest_sid _cm.ship_location)) { cm_present = true; } - if ((fest_wid > 0) && (string(fest_star) + "." + string(fest_wid) == lock)) { + if (fest_wid > 0 && _cm.is_at_location(fest_star, fest_wid)) { cm_present = true; } diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 2f37fcd8b8..5c4f2ef569 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1380,7 +1380,7 @@ var _parts = []; for (var i = 0, l = array_length(_command_staff); i < l; i++) { var _officer = _command_staff[i]; if (_hq_index.has_role(_officer.role)) { - array_push(_parts, $"{_officer.prefix}{_officer.role} {obj_ini.name[0][_officer.name_slot]}"); + array_push(_parts, $"{_officer.prefix}{_officer.role} {TTRPG[0][_officer.name_slot].name()}"); } } temp[34] = _build_clause("Command staff made of", _parts); diff --git a/objects/obj_p_ship/Alarm_0.gml b/objects/obj_p_ship/Alarm_0.gml index 75458ee382..9df24b9a44 100644 --- a/objects/obj_p_ship/Alarm_0.gml +++ b/objects/obj_p_ship/Alarm_0.gml @@ -185,10 +185,7 @@ if (obj_controller.stc_bonus[6] == 2) { } for (var co = 0; co <= obj_ini.companies; co++) { - for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { - if (obj_ini.name[co][i] == "") { - continue; - } + for (var i = 0; i < company_length(co); i++) { var unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; diff --git a/objects/obj_popup/Destroy_0.gml b/objects/obj_popup/Destroy_0.gml index e374d0c053..368b33e8b1 100644 --- a/objects/obj_popup/Destroy_0.gml +++ b/objects/obj_popup/Destroy_0.gml @@ -56,11 +56,11 @@ if (instance_exists(obj_controller)) { } if (meeting_star == noone) { instance_activate_object(obj_star); + var _cm = obj_controller.chapter_master.get_struct(); with (obj_star) { - if (string_count(name, scr_master_loc()) > 0) { + if (_cm.planet_location > 0 && _cm.location_string == name) { meeting_star = self.id; - var _fetched = fetch_unit([0, 1]); - meeting_planet = is_struct(_fetched) ? _fetched.planet_location : 0; + meeting_planet = _cm.planet_location; } } } diff --git a/objects/obj_star_select/Draw_64.gml b/objects/obj_star_select/Draw_64.gml index 78a8af428f..856b105b1a 100644 --- a/objects/obj_star_select/Draw_64.gml +++ b/objects/obj_star_select/Draw_64.gml @@ -300,7 +300,8 @@ try { if (p_data.has_upgrade(eP_FEATURES.GENE_VAULT)) { building.gene_vault = 1; } - obj_controller.temp[104] = string(scr_master_loc()); + //is cm at this location + obj_controller.temp[104] = obj_controller.chapter_master.get_struct().is_at_location(target.name, obj_controller.selecting_planet); obj_controller.menu = 60; with (obj_star_select) { instance_destroy(); diff --git a/scripts/Armamentarium/Armamentarium.gml b/scripts/Armamentarium/Armamentarium.gml index 5e3708b92e..2d3a495ca6 100644 --- a/scripts/Armamentarium/Armamentarium.gml +++ b/scripts/Armamentarium/Armamentarium.gml @@ -951,7 +951,7 @@ function Armamentarium(_controller) constructor { draw_text(352, 66, is_in_forge ? "Forge" : "Armamentarium"); draw_set_font(fnt_aldrich_12); - var _sub = _is_adept ? $"Adept {controller.adept_name}" : $"Forge Master {obj_ini.name[0][1]}"; + var _sub = _is_adept ? $"Adept {controller.adept_name}" : $"Forge Master {fetch_unit([0,1]).name()}"; draw_text(352, 100, _sub); }; diff --git a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml index 2cabf3746f..016a0db877 100644 --- a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml +++ b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml @@ -3,6 +3,47 @@ enum eCHAPTER_TRAIT_TYPE { ADV, } +enum eCHAPTER_DEPARTMENTS { + HQ = 0, + FORGE = 1, + CHAP = 2, + APOTH = 3, + LIB = 4 +} + +function get_department_head(head_type = eCHAPTER_DEPARTMENTS.HQ){ + if (head_type < array_length(obj_ini.TTRPG[0])){ + var _unit = fetch_unit([0, head_type]); + } else { + return undefined; + } + + switch(head_type){ + case eCHAPTER_DEPARTMENTS.HQ: + if (!role_compare(_unit, eROLE.CHAPTERMASTER)){ + return undefined; + } + case eCHAPTER_DEPARTMENTS.FORGE: + if (_unit.role() != "Forge Master"){ + return undefined; + } + case eCHAPTER_DEPARTMENTS.CHAP: + if (_unit.role() != "Master of Sanctity"){ + return undefined; + } + case eCHAPTER_DEPARTMENTS.APOTH: + if (_unit.role() != "Master of the Apothecarion"){ + return undefined; + } + case eCHAPTER_DEPARTMENTS.LIB: + if (_unit.role() != $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role}"){ + return undefined; + } + } + + return _unnit +} + function selected_chapter_trait(trait) { var _array = array_join(obj_creation.all_advantages, obj_creation.all_disadvantages); for (var i = 0; i < array_length(_array); i++) { diff --git a/scripts/scr_add_corruption/scr_add_corruption.gml b/scripts/scr_add_corruption/scr_add_corruption.gml index e0180bc52e..5f34031328 100644 --- a/scripts/scr_add_corruption/scr_add_corruption.gml +++ b/scripts/scr_add_corruption/scr_add_corruption.gml @@ -23,9 +23,6 @@ function scr_add_corruption(is_fleet, modifier_type) { } for (var co = 0; co <= 10; co++) { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { - if (obj_ini.name[co][i] == "") { - continue; - } var unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index f36a3b3701..fd18b44884 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -65,40 +65,36 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption // TODO: Implement Chaos Spawn (Race 12, Possessed Claws) } } + var _name = ""; switch (spawn_name) { case "": case "imperial": - obj_ini.name[target_company][_company_slot] = global.name_generator.ChapterMemberNameGeneration(); + _name = global.name_generator.ChapterMemberNameGeneration(); break; default: - obj_ini.name[target_company][_company_slot] = spawn_name; + _name = spawn_name; break; } switch (man_role) { case "Ranger": - obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateMultiSyllable("eldar", 2); + _name = global.name_generator.GenerateMultiSyllable("eldar", 2); break; case "Ork Sniper": case "Flash Git": - obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateComposite("ork", false); + _name = global.name_generator.GenerateComposite("ork", false); break; case "Sister of Battle": case "Sister Hospitaler": - obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateFromSet("imperial_female"); + _name = global.name_generator.GenerateFromSet("imperial_female"); break; } + if (!array_contains(non_marine_roles, man_role)) { if (man_role == obj_ini.player_role_data[eROLE.SCOUT].role) { - _gear = { - wep2: obj_ini.player_role_data[eROLE.SCOUT].wep2, - wep1: obj_ini.player_role_data[eROLE.SCOUT].wep1, - armour: obj_ini.player_role_data[eROLE.SCOUT].armour, - gear: obj_ini.player_role_data[eROLE.SCOUT].gear, - mobi: obj_ini.player_role_data[eROLE.SCOUT].mobi, - }; + _gear = obj_ini.player_role_data[eROLE.SCOUT]; } _unit = new TTRPG_stats("chapter", target_company, _company_slot, "scout", other_data); @@ -108,6 +104,7 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption marines += 1; } obj_ini.TTRPG[target_company][_company_slot] = _unit; + _unit.set_name(_name) _unit.add_exp(spawn_exp); _unit.allocate_unit_to_fresh_spawn(home_spot); _unit.update_role(man_role); diff --git a/scripts/scr_apothecarium/scr_apothecarium.gml b/scripts/scr_apothecarium/scr_apothecarium.gml index c6861e1023..544105a0c7 100644 --- a/scripts/scr_apothecarium/scr_apothecarium.gml +++ b/scripts/scr_apothecarium/scr_apothecarium.gml @@ -63,8 +63,8 @@ function scr_apothecarium() { draw_set_alpha(1); draw_set_color(c_gray); draw_rectangle(xx + 945, yy + 66, xx + 1580, yy + 818, 1); - - if (obj_controller.menu_adept == 0) { + var _head = get_department_head(eCHAPTER_DEPARTMENTS.APOTH); + if (is_struct(_head)) { if (struct_exists(obj_ini.custom_advisors, "apothecary")) { scr_image("advisor/splash", obj_ini.custom_advisors.apothecary, xx + 16, yy + 43, 310, 828); } else { @@ -74,7 +74,7 @@ function scr_apothecarium() { draw_set_color(c_gray); draw_set_font(fnt_40k_30b); draw_text_transformed(xx + 352, yy + 66, "Apothecarium", 1, 1, 0); - draw_text_transformed(xx + 352, yy + 100, "Master of the Apothecarion " + string(obj_ini.name[0][3]), 0.6, 0.6, 0); + draw_text_transformed(xx + 352, yy + 100, _head.name_role(), 0.6, 0.6, 0); draw_set_font(fnt_40k_14); } else if (obj_controller.menu_adept == 1) { scr_image("advisor/splash", 1, xx + 16, yy + 43, 310, 828); diff --git a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml index 68e0d07bcd..cdb6536e2f 100644 --- a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml +++ b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml @@ -31,76 +31,76 @@ function calculate_full_chapter_spread() { for (var v = 0; v < _company_length; v++) { key_val = ""; if (v < _marine_len) { - if (obj_ini.name[company][v] != "") { - _unit = fetch_unit([company, v]); - _mar_loc = _unit.marine_location(); - if (_unit.base_group == "astartes") { - if (_unit.IsSpecialist()) { - obj_controller.command++; - } else { - obj_controller.marines++; - } - } - forge_equipment_maintenance += _unit.equipment_maintenance_burden(); - _is_tech = _unit.IsSpecialist(SPECIALISTS_TECHS); - if (_is_tech) { - add_forge_points_to_stack(_unit); - } - is_healer = ((_unit.IsSpecialist(SPECIALISTS_APOTHECARIES, true) && _unit.gear() == "Narthecium") || (_unit.role() == "Sister Hospitaler")) && _unit.hp() >= 10; - if (is_healer) { - add_apoth_points_to_stack(_unit); + + _unit = fetch_unit([company, v]); + _mar_loc = _unit.marine_location(); + if (_unit.base_group == "astartes") { + if (_unit.IsSpecialist()) { + obj_controller.command++; + } else { + obj_controller.marines++; } - if (_mar_loc[2] != "Warp" && _mar_loc[2] != "Lost") { - if (_mar_loc[0] == eLOCATION_TYPES.PLANET) { - array_slot = _mar_loc[1]; - } else if (_mar_loc[0] == eLOCATION_TYPES.SHIP) { - array_slot = eSYSTEM_LOC.ORBIT; - } - key_val = _mar_loc[2]; + } + forge_equipment_maintenance += _unit.equipment_maintenance_burden(); + _is_tech = _unit.IsSpecialist(SPECIALISTS_TECHS); + if (_is_tech) { + add_forge_points_to_stack(_unit); + } + is_healer = ((_unit.IsSpecialist(SPECIALISTS_APOTHECARIES, true) && _unit.gear() == "Narthecium") || (_unit.role() == "Sister Hospitaler")) && _unit.hp() >= 10; + if (is_healer) { + add_apoth_points_to_stack(_unit); + } + if (_mar_loc[2] != "Warp" && _mar_loc[2] != "Lost") { + if (_mar_loc[0] == eLOCATION_TYPES.PLANET) { + array_slot = _mar_loc[1]; } else if (_mar_loc[0] == eLOCATION_TYPES.SHIP) { - if (instance_exists(obj_p_fleet)) { - with (obj_p_fleet) { - if (array_contains(capital_num, _mar_loc[1]) || array_contains(frigate_num, _mar_loc[1]) || array_contains(escort_num, _mar_loc[1])) { - key_val = $"{id}"; - array_slot = eSYSTEM_LOC.ORBIT; - break; - } + array_slot = eSYSTEM_LOC.ORBIT; + } + key_val = _mar_loc[2]; + } else if (_mar_loc[0] == eLOCATION_TYPES.SHIP) { + if (instance_exists(obj_p_fleet)) { + with (obj_p_fleet) { + if (array_contains(capital_num, _mar_loc[1]) || array_contains(frigate_num, _mar_loc[1]) || array_contains(escort_num, _mar_loc[1])) { + key_val = $"{id}"; + array_slot = eSYSTEM_LOC.ORBIT; + break; } } } - if (key_val != "") { - if (!struct_exists(_unit_spread, key_val)) { - _unit_spread[$ key_val] = [ - [], - [], - [], - [], - [], - ]; - _tech_spread[$ key_val] = [ - [], - [], - [], - [], - [], - ]; - _apoth_spread[$ key_val] = [ - [], - [], - [], - [], - [], - ]; - } - array_push(_unit_spread[$ key_val][array_slot], _unit); - if (_is_tech) { - array_push(_tech_spread[$ key_val][array_slot], _unit); - } - if (is_healer) { - array_push(_apoth_spread[$ key_val][array_slot], _unit); - } + } + if (key_val != "") { + if (!struct_exists(_unit_spread, key_val)) { + _unit_spread[$ key_val] = [ + [], + [], + [], + [], + [], + ]; + _tech_spread[$ key_val] = [ + [], + [], + [], + [], + [], + ]; + _apoth_spread[$ key_val] = [ + [], + [], + [], + [], + [], + ]; + } + array_push(_unit_spread[$ key_val][array_slot], _unit); + if (_is_tech) { + array_push(_tech_spread[$ key_val][array_slot], _unit); + } + if (is_healer) { + array_push(_apoth_spread[$ key_val][array_slot], _unit); } } + } key_val = ""; diff --git a/scripts/scr_count_marines_on_ship/scr_count_marines_on_ship.gml b/scripts/scr_count_marines_on_ship/scr_count_marines_on_ship.gml index fc3de2b5fe..6f32827990 100644 --- a/scripts/scr_count_marines_on_ship/scr_count_marines_on_ship.gml +++ b/scripts/scr_count_marines_on_ship/scr_count_marines_on_ship.gml @@ -2,13 +2,13 @@ function scr_count_marines_on_ship(ship_number) { var count = 0; for (var company = 0; company <= 10; company++) { var _company_size = array_length(obj_ini.TTRPG[company]); - for (var marine = 1; marine < _company_size; marine++) { - if (obj_ini.name[company][marine] != "") { - var _unit = fetch_unit([company, marine]); - if (is_struct(_unit) && _unit.ship_location == ship_number) { - count++; - } + for (var marine = 0; marine < _company_size; marine++) { + + var _unit = fetch_unit([company, marine]); + if (is_struct(_unit) && _unit.ship_location == ship_number) { + count++; } + } } return count; diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index 9277b4a7b9..ee894c4e08 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -168,7 +168,9 @@ function scr_dialogue(diplo_keyphrase, data = {}) { // MoS cuts in if (diplo_keyphrase == "cs_meeting_m1") { diplomacy = -5.2; - diplo_text = $"[[{obj_ini.name[0][3]} hisses your name over a private vox channel.]]\n"; + var _head = get_department_head(eCHAPTER_DEPARTMENTS.CHAP); + var _who = is_struct(_head) ? $"{_head.name_role()} hisses your name" : "Your name is hissed" + diplo_text = $"[[{_who} over a private vox channel.]]\n"; diplo_text += "My lord! What are we doing here, treating with this monster of the Traitor Legions? The very existence of the Archenemy is a threat to everything the Chapter stands for, and we endanger our immortal souls just being here. You know this! I demand to know your intentions! And I warn you, I will not hesitate to do what I must, for the good of the Chapter and the Imperium."; var _goto = "cs_meeting_m2"; @@ -191,13 +193,15 @@ function scr_dialogue(diplo_keyphrase, data = {}) { } } if (diplo_keyphrase == "cs_meeting_m2") { + var _head = get_department_head(eCHAPTER_DEPARTMENTS.CHAP); event_log = $"The {global.chapter_name} Master of Sanctity takes a stand against you."; scr_event_log("purple", event_log); // scr_alert("purple","lol",string(tix),0,0); - diplo_text = "You have besmirched the honor of our chapter this day, and I will not forget it /my lord Chapter Master/.\n[[" + string(obj_ini.name[0][3]) + " strides forward and his shout erupts from his external vox speakers with a boom that shatters the silence in the room.]]\nWe will not stand idly by and bandy words with heretic scum! To me my brothers! Slay these traitors in the name of our Emperor!"; + diplo_text = $"You have besmirched the honor of our chapter this day, and I will not forget it /my lord Chapter Master/.\n[[{head.name_role()} strides forward and his shout erupts from his external vox speakers with a boom that shatters the silence in the room.]]\nWe will not stand idly by and bandy words with heretic scum! To me my brothers! Slay these traitors in the name of our Emperor!"; add_diplomacy_option({option_text: "[Continue]", goto: "cs_meeting9"}); } if (diplo_keyphrase == "cs_meeting_m3") { - diplo_text = "[[" + string(obj_ini.name[0][3]) + " is silent for a moment, before giving you an imperceptible nod.]]\nI stand with you, Lord " + string(obj_ini.master_name) + ". Let us face this together."; + var _head = get_department_head(eCHAPTER_DEPARTMENTS.CHAP); + diplo_text = $"[[{_head.name_role()} is silent for a moment, before giving you an imperceptible nod.]]\nI stand with you, Lord " + string(obj_ini.master_name) + ". Let us face this together."; add_diplomacy_option({option_text: "[Continue]", goto: "cs_meeting20"}); obj_controller.useful_info += "CRMOS|"; } diff --git a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml index 74caa6583f..748b7d7e55 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -159,8 +159,10 @@ function scr_enemy_ai_d() { var woop = scr_role_count("Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role), ""); var yep = !scr_has_disadv("Psyker Intolerant"); - if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop != 0) && yep) { - scr_popup("Shadow in the Warp", $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role} " + string(obj_ini.name[0][5]) + " reports a disturbance in the warp. He claims it is like a shadow.", "shadow", ""); + var _head = get_department_head(eCHAPTER_DEPARTMENTS.LIB); + + if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop != 0) && yep && is_struct(_head)) { + scr_popup("Shadow in the Warp", $"Chief {_head.name_role()} reports a disturbance in the warp. He claims it is like a shadow.", "shadow", ""); scr_event_log("red", $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role} reports a disturbance in the warp. He claims it is like a shadow."); } if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop == 0) && yep) { diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index 76af78206a..0f521229cd 100644 --- a/scripts/scr_librarium/scr_librarium.gml +++ b/scripts/scr_librarium/scr_librarium.gml @@ -128,7 +128,9 @@ function scr_librarium() { draw_set_color(c_gray); draw_rectangle(xx + 945, yy + 66, xx + 1580, yy + 818, 1); // Right librarium box - if (menu_adept == 0) { + var _head = get_department_head(eCHAPTER_DEPARTMENTS.LIB); + var _head_found = is_struct(_head); + if (_head_found) { if (struct_exists(obj_ini.custom_advisors, "librarian")) { scr_image("advisor/splash", obj_ini.custom_advisors.librarian, xx + 16, yy + 43, 310, 828); } else { @@ -138,7 +140,7 @@ function scr_librarium() { draw_set_color(c_gray); draw_set_font(fnt_40k_30b); draw_text_transformed(xx + 352, yy + 66, "Librarium", 1, 1, 0); - draw_text_transformed(xx + 352, yy + 100, string_hash_to_newline("Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " " + string(obj_ini.name[0][4])), 0.6, 0.6, 0); + draw_text_transformed(xx + 352, yy + 100, _head.name_role(), 0.6, 0.6, 0); draw_set_font(fnt_40k_14); } if (menu_adept == 1) { @@ -147,7 +149,7 @@ function scr_librarium() { draw_set_color(c_gray); draw_set_font(fnt_large); draw_text_transformed(xx + 352, yy + 66, "Librarium", 1, 1, 0); - draw_text_transformed(xx + 352, yy + 100, string_hash_to_newline("Adept " + string(obj_controller.adept_name)), 0.6, 0.6, 0); + draw_text_transformed(xx + 352, yy + 100, $"Adept {obj_controller.adept_name"}, 0.6, 0.6, 0); draw_set_font(fnt_40k_14); } @@ -168,10 +170,11 @@ function scr_librarium() { } // Greetings message - if (menu_adept == 0) { - draw_text_ext(xx + 352, yy + 130, string_hash_to_newline($"Chapter Master {obj_ini.name[0][0]}, greetings.#I assume you've come for the report? The Chapter currently possesses {temp[36]} Epistolaries, {temp[37]} Codiceries, and {temp[38]} Lexicanum. We are working to identify additional warp-sensitive brothers before they cause harm, and the training is {blurp}.##We could likely speed up the identification and application of appropriate training, but we would need more resources...I don't suppose we can spare some?##Our Chapter has {artif}"), -1, 536); + if (_head_found) { + var _cm = obj_controller.chapter_master.get_struct(); + draw_text_ext(xx + 352, yy + 130, string_hash_to_newline($"{_cm.name_role()}, greetings.#I assume you've come for the report? The Chapter currently possesses {temp[36]} Epistolaries, {temp[37]} Codiceries, and {temp[38]} Lexicanum. We are working to identify additional warp-sensitive brothers before they cause harm, and the training is {blurp}.##We could likely speed up the identification and application of appropriate training, but we would need more resources...I don't suppose we can spare some?##Our Chapter has {artif}"), -1, 536); } - if (menu_adept == 1) { + else { draw_text_ext(xx + 352, yy + 130, string_hash_to_newline($"Your Chapter contains {temp[36]} {obj_ini.player_role_data[eROLE.LIBRARIAN].role}s, {temp[37]} Codiceries, and {temp[38]} Lexicanum.##Training of more {obj_ini.player_role_data[eROLE.LIBRARIAN].role}s is {blurp}.##Your chapter has {artif}"), -1, 536); } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 5ddc4bf0f8..4039d99dea 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -983,18 +983,13 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} array_push(epithets, epithet); }; static name = function(update) { - return obj_ini.name[company][marine_number]; + return unit_name; }; // get marine name static set_name = function(val){ unit_name = val; } - static set_name = function(new_name) { - obj_ini.name[company][marine_number] = new_name; - return new_name; - }; - static gear = function(raw = false) { var _wep = gear1; if (is_string(_wep) || raw) { diff --git a/scripts/scr_master_loc/scr_master_loc.gml b/scripts/scr_master_loc/scr_master_loc.gml deleted file mode 100644 index b17f2fa6c6..0000000000 --- a/scripts/scr_master_loc/scr_master_loc.gml +++ /dev/null @@ -1,43 +0,0 @@ -function scr_master_loc() { - var lick = ""; - var good = true; - var co = 0; - var v = 0; - var unit; - - for (var i = 0; i < 3600; i++) { - if (good == true) { - if (co < 11) { - v += 1; - if (v > 300) { - co += 1; - v = 1; /*show_message("mahreens at the start of company "+string(co)+" is equal to "+string(info_mahreens));*/ - } - if (co > 10) { - good = false; - } - if (good == true) { - if (obj_ini.name[co][v] == "") { - continue; - } - unit = fetch_unit([co, v]); - if (!is_struct(unit)) { - continue; - } - if (unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { - if ((unit.planet_location > 0) && (unit.ship_location < 0)) { - lick = $"{unit.location_string}." + string(unit.planet_location); - } - if ((unit.planet_location <= 0) && (unit.ship_location > -1)) { - lick = string(obj_ini.ship[unit.ship_location]); - } - if (lick != "") { - good = false; - return lick; - } - } - } - } - } - } -} diff --git a/scripts/scr_master_loc/scr_master_loc.yy b/scripts/scr_master_loc/scr_master_loc.yy deleted file mode 100644 index cddc008e5e..0000000000 --- a/scripts/scr_master_loc/scr_master_loc.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_master_loc", - "isCompatibility":false, - "isDnD":false, - "name":"scr_master_loc", - "parent":{ - "name":"Interface Help", - "path":"folders/Scripts/Interface Help.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file diff --git a/scripts/scr_secret_lair_view/scr_secret_lair_view.gml b/scripts/scr_secret_lair_view/scr_secret_lair_view.gml index c8644a40ce..b288d6525b 100644 --- a/scripts/scr_secret_lair_view/scr_secret_lair_view.gml +++ b/scripts/scr_secret_lair_view/scr_secret_lair_view.gml @@ -334,7 +334,7 @@ function scr_secret_lair_view() { if (lair_struct.throne == 1) { lair_window_description_text += " The center chamber is dominated by "; - if (obj_controller.temp[104] == string(obj_temp_build.target.name) + "." + string(obj_controller.selecting_planet)) { + if (obj_controller.temp[104]) { lair_window_description_text += "a massive throne, which you are currently seated upon. "; } else { lair_window_description_text += "a massive throne, though it is currently vacant. "; diff --git a/scripts/scr_ship_battle/scr_ship_battle.gml b/scripts/scr_ship_battle/scr_ship_battle.gml index e26ca1a589..be87642413 100644 --- a/scripts/scr_ship_battle/scr_ship_battle.gml +++ b/scripts/scr_ship_battle/scr_ship_battle.gml @@ -27,9 +27,6 @@ function scr_ship_battle(target_ship_id, cooridor_width) { } if (stop == 0) { - if (obj_ini.name[co][v] == "") { - continue; - } _unit = fetch_unit([co, v]); if (!is_struct(_unit)) { continue; diff --git a/scripts/scr_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index cab0dd7b1d..d5e18d4c75 100644 --- a/scripts/scr_start_load/scr_start_load.gml +++ b/scripts/scr_start_load/scr_start_load.gml @@ -27,8 +27,8 @@ function scr_start_load(fleet, load_from_star, load_options) { var comp_has_units = []; for (var _comp = 0; _comp < 10; _comp++) { comp_has_units[_comp] = false; - for (var _unit = 0; _unit < 20; _unit++) { - if (obj_ini.name[_comp][_unit] != "") { + for (var _unit = 0; _unit < get_company_length(_comp); _unit++) { + if (is_struct(fetch_unit([_comp, _unit]))) { comp_has_units[_comp] = true; break; } From 30e30ff54e33a76075cc0d5cac091edc1f8d1dcc Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 17:06:40 +0100 Subject: [PATCH 33/82] removal of all uses of obj_ini.name --- .../scr_player_fleet_combat_functions.gml | 3 --- .../scr_player_ship_functions.gml | 3 --- scripts/scr_promote/scr_promote.gml | 14 ++----------- scripts/scr_random_event/scr_random_event.gml | 20 ++++++++----------- scripts/scr_recruit_data/scr_recruit_data.gml | 3 ++- scripts/scr_special_view/scr_special_view.gml | 3 --- .../scr_transfer_marines.gml | 1 - scripts/scr_ui_advisors/scr_ui_advisors.gml | 9 ++++++--- 8 files changed, 18 insertions(+), 38 deletions(-) diff --git a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml index 98c0403c15..1c411786a9 100644 --- a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml +++ b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml @@ -347,9 +347,6 @@ function setup_player_combat_ship() { for (var co = 0; co <= obj_ini.companies; co++) { for (i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { - if (obj_ini.name[co][i] == "") { - continue; - } var unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; diff --git a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml index 65a7569a17..831be96c1f 100644 --- a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml +++ b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml @@ -210,9 +210,6 @@ function loose_ship_to_warp_event() { var unit; for (var company = 0; company <= obj_ini.companies; company++) { for (var marine = 0; marine < array_length(obj_ini.TTRPG[company]); marine++) { - if (obj_ini.name[company][marine] == "") { - continue; - } unit = fetch_unit([company, marine]); if (!is_struct(unit)) { continue; diff --git a/scripts/scr_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index c941e7830c..aadb2b703f 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -32,18 +32,8 @@ function setup_promotion_popup() { label: "Promote", }); promote_button.bind_method = function() { - var mahreens = 0; - - if (target_comp > 10) { - target_comp = 0; - } - - for (var i = 0; i < 498; i++) { - if (obj_ini.name[target_comp][i] == "" && obj_ini.name[target_comp][i + 1] == "") { - mahreens = i; - break; - } - } + + var _company_length = company_length(obj_ini.TTRPG[target_comp]); // Gets the number of marines in the target company var unit, squad_mover, moveable; var role_squad_equivilances = {}; //this is the only way to set variables as keys in gml diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 39e3af72d7..7f39620d77 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -705,19 +705,15 @@ function scr_random_event(execute_now) { add_event({e_id: "chaos_invasion", duration: 1}); var psyker_intolerant = scr_has_disadv("Psyker Intolerant"); - var has_chief_psyker = scr_role_count("Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role), "") >= 1; - var cm_is_psyker = false; - for (var i = 0; i < array_length(TTRPG[0]); i++) { - var _unit = fetch_unit([0 ,i]); - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role && string_count("0", _unit.specials) > 0) { - cm_is_psyker = true; - break; - } - } + var _head = get_department_head(eCHAPTER_DEPARTMENTS.LIB); + var _has_chief_psyker = is_struct(_head); + + var _cm = obj_controller.chapter_master.get_struct(); + var _cm_is_psyker = string_count("0", _cm.specials) > 0; - if ((!psyker_intolerant) && has_chief_psyker) { - scr_popup("The Maw of the Warp Yawns Wide", "Chief " + string(obj_ini.player_role_data[eROLE.LIBRARIAN].role) + " " + string(obj_ini.name[0][5]) + " reports that the barrier between the realm of man and the Immaterium feels thin and tested.", "Warp", ""); - } else if ((psyker_intolerant || !has_chief_psyker) && cm_is_psyker) { + if ((!psyker_intolerant) && _has_chief_psyker) { + scr_popup("The Maw of the Warp Yawns Wide", $"Chief {_head.name_role()} reports that the barrier between the realm of man and the Immaterium feels thin and tested.", "Warp", ""); + } else if ((psyker_intolerant || !_has_chief_psyker) && _cm_is_psyker) { scr_popup("The Maw of the Warp Yawns Wide", "The barrier between the realm of man and the Immaterium feels thin and tested to you. Dark forces are afoot.", "Warp", ""); } } else if (chosen_event == eEVENT.NECRON_AWAKEN) { diff --git a/scripts/scr_recruit_data/scr_recruit_data.gml b/scripts/scr_recruit_data/scr_recruit_data.gml index 4e7200ce58..0bd5c8bda4 100644 --- a/scripts/scr_recruit_data/scr_recruit_data.gml +++ b/scripts/scr_recruit_data/scr_recruit_data.gml @@ -874,8 +874,9 @@ function scr_draw_recruit_advisor() { draw_set_font(fnt_40k_14); } + var _cm = obj_controller.chapter_master.get_struct(); if (menu_adept == 0) { - blurp = $"Hail {obj_ini.name[0][0]}! You asked for a report?\n\n"; + blurp = $"Hail {_cm.name()}! You asked for a report?\n\n"; } if (obj_ini.doomed == 0) { diff --git a/scripts/scr_special_view/scr_special_view.gml b/scripts/scr_special_view/scr_special_view.gml index e58e10b777..10603537c7 100644 --- a/scripts/scr_special_view/scr_special_view.gml +++ b/scripts/scr_special_view/scr_special_view.gml @@ -76,9 +76,6 @@ function scr_special_view(command_group) { //HQ units for (var v = 0; v < array_length(obj_ini.TTRPG[0]); v++) { bad = 0; - if (obj_ini.name[0][v] == "") { - continue; - } var _unit = fetch_unit([0, v]); if (!is_struct(_unit)) { continue; diff --git a/scripts/scr_transfer_marines/scr_transfer_marines.gml b/scripts/scr_transfer_marines/scr_transfer_marines.gml index 33550591d3..18c383d0ec 100644 --- a/scripts/scr_transfer_marines/scr_transfer_marines.gml +++ b/scripts/scr_transfer_marines/scr_transfer_marines.gml @@ -63,7 +63,6 @@ function transfer_marines() { continue; } unit.move_to_company(target_comp, false); - scr_move_unit_info(member_unit.company, target_comp, member_unit.marine_number, mahreens, false); _unit.squad = move_squad; squad.members[mem][0] = _unit.company; squad.members[mem][1] = _unit.marine_number; diff --git a/scripts/scr_ui_advisors/scr_ui_advisors.gml b/scripts/scr_ui_advisors/scr_ui_advisors.gml index cfa6e6b679..ad7f755f78 100644 --- a/scripts/scr_ui_advisors/scr_ui_advisors.gml +++ b/scripts/scr_ui_advisors/scr_ui_advisors.gml @@ -51,7 +51,10 @@ function scr_ui_advisors() { draw_set_color(c_gray); draw_rectangle(xx + 945, yy + 66, xx + 1580, yy + 818, 1); - if (menu_adept == 0) { + var _head = get_department_head(eCHAPTER_DEPARTMENTS.CHAP); + + var _has_head = is_struct(_head); + if (_has_head) { if (struct_exists(obj_ini.custom_advisors, "chaplain")) { scr_image("advisor/splash", obj_ini.custom_advisors.chaplain, xx + 16, yy + 43, 310, 828); } else { @@ -61,9 +64,9 @@ function scr_ui_advisors() { draw_set_color(c_gray); draw_set_font(fnt_40k_30b); draw_text_transformed(xx + 336 + 16, yy + 66, "Reclusium", 1, 1, 0); - draw_text_transformed(xx + 336 + 16, yy + 100, string_hash_to_newline("Master of Sanctity " + string(obj_ini.name[0][2])), 0.6, 0.6, 0); + draw_text_transformed(xx + 336 + 16, yy + 100, _head.name_role(), 0.6, 0.6, 0); } - if (menu_adept == 1) { + else { scr_image("advisor/splash", 1, xx + 16, yy + 43, 310, 828); draw_set_halign(fa_left); draw_set_color(c_gray); From 8597329c1178bd48d737572d4ce6035e138533a7 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 17:07:43 +0100 Subject: [PATCH 34/82] syntax updates --- scripts/scr_ui_advisors/scr_ui_advisors.gml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/scr_ui_advisors/scr_ui_advisors.gml b/scripts/scr_ui_advisors/scr_ui_advisors.gml index ad7f755f78..4b3da932c7 100644 --- a/scripts/scr_ui_advisors/scr_ui_advisors.gml +++ b/scripts/scr_ui_advisors/scr_ui_advisors.gml @@ -86,7 +86,7 @@ function scr_ui_advisors() { blurp = $"Sir! You requested a report? Currently, we have {temp[37]} {_active_roles[14]}s who await only your order to carry the word to the troops."; } if ((global.chapter_name != "Space Wolves") && (global.chapter_name != "Iron Hands")) { - blurp += "##Currently, we are training additional " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + " at a "; + blurp += $"##Currently, we are training additional {obj_ini.player_role_data[eROLE.CHAPLAIN].role} at a "; var _recruit_rates = global.recruitment_rates; blurp += _recruit_rates[training_chaplain]; if (training_chaplain > 0 && training_chaplain <= 6) { @@ -95,7 +95,7 @@ function scr_ui_advisors() { } blurp += " rate"; if (training_chaplain > 0) { - blurp += " and expect to see a new one in " + string(eta) + " month's time."; + blurp += " and expect to see a new one in {eta} month's time."; } if (training_chaplain < 5) { blurp += "We can increase this rate, but it will require us to requisition additional facilities, as well as upkeep, Sir."; From 777efb828fd6166456b88297e23f692ca5d54b4e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 17:39:37 +0100 Subject: [PATCH 35/82] refactor start allow --- ChapterMaster.yyp | 1 - .../scr_initialize_custom.gml | 10 +- scripts/scr_start_allow/scr_start_allow.gml | 77 ---------- scripts/scr_start_allow/scr_start_allow.yy | 13 -- .../scr_unit_equip_functions.gml | 132 ++++++++++++++++-- 5 files changed, 122 insertions(+), 111 deletions(-) delete mode 100644 scripts/scr_start_allow/scr_start_allow.gml delete mode 100644 scripts/scr_start_allow/scr_start_allow.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 190b27c291..a4e966f7a4 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -920,7 +920,6 @@ {"id":{"name":"scr_squads","path":"scripts/scr_squads/scr_squads.yy",},}, {"id":{"name":"scr_star_ownership","path":"scripts/scr_star_ownership/scr_star_ownership.yy",},}, {"id":{"name":"scr_star_travel_algorithm","path":"scripts/scr_star_travel_algorithm/scr_star_travel_algorithm.yy",},}, - {"id":{"name":"scr_start_allow","path":"scripts/scr_start_allow/scr_start_allow.yy",},}, {"id":{"name":"scr_start_load","path":"scripts/scr_start_load/scr_start_load.yy",},}, {"id":{"name":"scr_string_functions","path":"scripts/scr_string_functions/scr_string_functions.yy",},}, {"id":{"name":"scr_struct_functions","path":"scripts/scr_struct_functions/scr_struct_functions.yy",},}, diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index e39876d301..1cf6b1cdb6 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1903,11 +1903,11 @@ function scr_initialize_custom() { if (player_role_data[i].role == "") { continue; } - var _data = player_role_data[i]; - scr_start_allow(i, "wep1", _data.wep1); - scr_start_allow(i, "wep2", _data.wep2); - scr_start_allow(i, "mobi", _data.mobi); - scr_start_allow(i, "gear", _data.gear); + var _data = new UnitEquipment(player_role_data[i]); + var _allowed_equip = _data.start_allowance(); + with (player_role_data[i]){ + move_data_to_current_scope(_allowed_equip); + } // check for allowable starting equipment here } diff --git a/scripts/scr_start_allow/scr_start_allow.gml b/scripts/scr_start_allow/scr_start_allow.gml deleted file mode 100644 index 658d692c8f..0000000000 --- a/scripts/scr_start_allow/scr_start_allow.gml +++ /dev/null @@ -1,77 +0,0 @@ -function scr_start_allow(role_id, equip_area, equipment) { - var _allow = false; - var _veteran_level = 0; - - if (role_id == eROLE.DREADNOUGHT) { - player_role_data[role_id][$ equip_area] = equipment; - return; - } - - if (array_contains([eROLE.SERGEANT, eROLE.VETERAN, eROLE.TERMINATOR], role_id)) { - _veteran_level = 1; - } else if (array_contains([eROLE.VETERANSERGEANT, eROLE.ANCIENT, eROLE.CAPTAIN, eROLE.HONOURGUARD], role_id)) { - _veteran_level = 2; - } else if (array_contains([eROLE.CHAPLAIN, eROLE.APOTHECARY, eROLE.LIBRARIAN, eROLE.TECHMARINE], role_id)) { - _veteran_level = 5; - } - - var _normal_equipment = [ - "Combat Knife", - "Chainsword", - "Chainaxe", - "Boarding Shield", - "Bolt Pistol", - "Bolter", - "Flamer", - "Sniper Rifle", - ]; - _allow = array_contains(_normal_equipment, equipment); - - if (_veteran_level > 0) { - var _special_equipment = [ - "Storm Bolter", - "Meltagun", - "Power Fist", - "Power Sword", - "Power Axe", - ]; - _allow = array_contains(_special_equipment, equipment); - } - - if (equip_area == "mobi") { - if (equipment == "Jump Pack" && (_veteran_level > 0 || role_id == eROLE.ASSAULT)) { - if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { - _allow = true; - } - } else if (equipment == "Bike" && (_veteran_level > 0 || role_id == eROLE.ASSAULT)) { - if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { - _allow = true; - } - } else if (equipment == "Heavy Weapons Pack" && role_id == eROLE.DEVASTATOR) { - _allow = true; - } - } - - if (equip_area == "gear") { - if (_veteran_level == 5) { - if (role_id == eROLE.CHAPLAIN && equipment == "Rosarius") { - _allow = true; - } else if (role_id == eROLE.TECHMARINE) { - if (array_contains(["Servo-arm", "Servo-harness"], equipment)) { - _allow = true; - } - } else if (role_id == eROLE.LIBRARIAN && equipment == "Psychic Hood") { - _allow = true; - } else if (role_id == eROLE.APOTHECARY && equipment == "Narthecium") { - _allow = true; - } - } - } - - if (_allow) { - player_role_data[role_id][$ equip_area] = equipment; - } else { - player_role_data[role_id][$ equip_area] = default_role_data[role_id][$ equip_area]; - } - return; -} diff --git a/scripts/scr_start_allow/scr_start_allow.yy b/scripts/scr_start_allow/scr_start_allow.yy deleted file mode 100644 index 12a3867297..0000000000 --- a/scripts/scr_start_allow/scr_start_allow.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_start_allow", - "isCompatibility":false, - "isDnD":false, - "name":"scr_start_allow", - "parent":{ - "name":"Scripts", - "path":"folders/Scripts.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 37d4bf2930..baad776702 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -588,21 +588,25 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { } } - items = [ - equipment.wep1, - equipment.wep2, - equipment.armour, - equipment.gear, - equipment.mobi, - ]; - - item_names = [ - equipment.wep1.name, - equipment.wep2.name, - equipment.armour.name, - equipment.gear.name, - equipment.mobi.name, - ]; + static update_arrays = function(){ + items = [ + equipment.wep1, + equipment.wep2, + equipment.armour, + equipment.gear, + equipment.mobi, + ]; + + item_names = [ + equipment.wep1.name, + equipment.wep2.name, + equipment.armour.name, + equipment.gear.name, + equipment.mobi.name, + ]; + } + + update_arrays(); present_items = []; @@ -618,6 +622,16 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { "gear": eEQUIPMENT_SLOT.GEAR, }; + static basic_map = function(){ + return { + "wep1": item_names[eEQUIPMENT_SLOT.WEAPON_ONE], + "wep2":item_names[eEQUIPMENT_SLOT.WEAPON_TWO], + "armour": item_names[eEQUIPMENT_SLOT.ARMOUR], + "mobi": item_names[eEQUIPMENT_SLOT.MOBILITY], + "gear": item_names[eEQUIPMENT_SLOT.GEAR], + } + } + static map_string_to_enum = function(slot) { slot = slot_map[$ slot]; return slot; @@ -904,4 +918,92 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { equipment_found_and_valid, }; }; + + static start_allowable_weapons(slot){ + var _normal_equipment = [ + "Combat Knife", + "Chainsword", + "Chainaxe", + "Boarding Shield", + "Bolt Pistol", + "Bolter", + "Flamer", + "Sniper Rifle", + ]; + _allow = array_contains(_normal_equipment, equipment[$ slot]); + + if (_veteran_level > 0) { + var _special_equipment = [ + "Storm Bolter", + "Meltagun", + "Power Fist", + "Power Sword", + "Power Axe", + ]; + _allow = array_contains(_special_equipment, equipment[$ slot]); + } + + if (!allow){ + fiinal_gear[$ slot] = default_options[$slot]; + } + final_gear[$ slot] = allow ? equipment[$slot].name : default_options[$slot]; + } + + static start_allowable_mobi(){ + if (equipment == "Jump Pack" && (_veteran_level > 0 || role_id == eROLE.ASSAULT)) { + if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { + _allow = true; + } + } else if (equipment == "Bike" && (_veteran_level > 0 || role_id == eROLE.ASSAULT)) { + if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { + _allow = true; + } + } else if (equipment == "Heavy Weapons Pack" && role_id == eROLE.DEVASTATOR) { + _allow = true; + } + + final_gear.mobi = allow ? equipment.mobi.name : default_options.mobi; + } + + static start_allowable_gear(){ + if (_veteran_level == 5) { + if (role_id == eROLE.CHAPLAIN && equipment == "Rosarius") { + _allow = true; + } else if (role_id == eROLE.TECHMARINE) { + if (array_contains(["Servo-arm", "Servo-harness"], equipment)) { + _allow = true; + } + } else if (role_id == eROLE.LIBRARIAN && equipment == "Psychic Hood") { + _allow = true; + } else if (role_id == eROLE.APOTHECARY && equipment == "Narthecium") { + _allow = true; + } + } + + final_gear.gear = allow ? equipment.gear.name : default_options.gear; + } + + static start_allowance(role_id){ + final_gear = {}; + veteran_level = 0; + default_options = setup_default_gears()[role_id]; + self.role_id = role_id; + if (role_id == eROLE.DREADNOUGHT) { + return; + } + if (array_contains([eROLE.SERGEANT, eROLE.VETERAN, eROLE.TERMINATOR], role_id)) { + veteran_level = 1; + } else if (array_contains([eROLE.VETERANSERGEANT, eROLE.ANCIENT, eROLE.CAPTAIN, eROLE.HONOURGUARD], role_id)) { + veteran_level = 2; + } else if (array_contains([eROLE.CHAPLAIN, eROLE.APOTHECARY, eROLE.LIBRARIAN, eROLE.TECHMARINE], role_id)) { + veteran_level = 5; + } + + start_allowable_weapons("wep1"); + start_allowable_weapons("wep2"); + start_allowable_mobi(); + start_allowable_gear(); + + return final_gear; + } } From 07d153be594bce56e348ae0efeaff2a6d38a2a83 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 17:47:06 +0100 Subject: [PATCH 36/82] variable setting and reove no longer used script --- ChapterMaster.yyp | 1 - scripts/scr_move_unit_info/scr_move_unit_info.gml | 0 scripts/scr_move_unit_info/scr_move_unit_info.yy | 13 ------------- .../scr_unit_equip_functions.gml | 5 ++++- 4 files changed, 4 insertions(+), 15 deletions(-) delete mode 100644 scripts/scr_move_unit_info/scr_move_unit_info.gml delete mode 100644 scripts/scr_move_unit_info/scr_move_unit_info.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index a4e966f7a4..05851a56b7 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -864,7 +864,6 @@ {"id":{"name":"scr_mission_eta","path":"scripts/scr_mission_eta/scr_mission_eta.yy",},}, {"id":{"name":"scr_mission_functions","path":"scripts/scr_mission_functions/scr_mission_functions.yy",},}, {"id":{"name":"scr_mission_reward","path":"scripts/scr_mission_reward/scr_mission_reward.yy",},}, - {"id":{"name":"scr_move_unit_info","path":"scripts/scr_move_unit_info/scr_move_unit_info.yy",},}, {"id":{"name":"scr_necron_tombs","path":"scripts/scr_necron_tombs/scr_necron_tombs.yy",},}, {"id":{"name":"scr_ork_fleet_functions","path":"scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.yy",},}, {"id":{"name":"scr_ork_planet_functions","path":"scripts/scr_ork_planet_functions/scr_ork_planet_functions.yy",},}, diff --git a/scripts/scr_move_unit_info/scr_move_unit_info.gml b/scripts/scr_move_unit_info/scr_move_unit_info.gml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/scripts/scr_move_unit_info/scr_move_unit_info.yy b/scripts/scr_move_unit_info/scr_move_unit_info.yy deleted file mode 100644 index c2001eb0bd..0000000000 --- a/scripts/scr_move_unit_info/scr_move_unit_info.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_move_unit_info", - "isCompatibility":false, - "isDnD":false, - "name":"scr_move_unit_info", - "parent":{ - "name":"Scripts", - "path":"folders/Scripts.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index baad776702..0c318ff9c5 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -920,6 +920,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { }; static start_allowable_weapons(slot){ + var _allow = true; var _normal_equipment = [ "Combat Knife", "Chainsword", @@ -932,7 +933,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { ]; _allow = array_contains(_normal_equipment, equipment[$ slot]); - if (_veteran_level > 0) { + if (_veteran_level > 0 && !_allow) { var _special_equipment = [ "Storm Bolter", "Meltagun", @@ -950,6 +951,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { } static start_allowable_mobi(){ + var _allow = true; if (equipment == "Jump Pack" && (_veteran_level > 0 || role_id == eROLE.ASSAULT)) { if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { _allow = true; @@ -966,6 +968,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { } static start_allowable_gear(){ + var _allow = true; if (_veteran_level == 5) { if (role_id == eROLE.CHAPLAIN && equipment == "Rosarius") { _allow = true; From 4c7e1f3fa18821e85100b52cbcb946ca3a1dded3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 18:18:19 +0100 Subject: [PATCH 37/82] handful of review points --- scripts/scr_company_view/scr_company_view.gml | 2 +- .../scr_initialize_custom.gml | 4 +-- .../scr_unit_equip_functions.gml | 25 ++++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index ad88e6ea27..36826c9396 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -52,7 +52,7 @@ function find_company_open_slot(target_company) { } if (good == -1) { array_push(obj_ini.TTRPG[target_company], undefined); - good = array_length(obj_ini.TTRPG[target_company]) - 1; + good = _company_length; } return good; } diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 1cf6b1cdb6..9d0e8d3770 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1903,8 +1903,8 @@ function scr_initialize_custom() { if (player_role_data[i].role == "") { continue; } - var _data = new UnitEquipment(player_role_data[i]); - var _allowed_equip = _data.start_allowance(); + var _data = new UnitEquipment(variable_clone(player_role_data[i])); + var _allowed_equip = _data.start_allowance(i); with (player_role_data[i]){ move_data_to_current_scope(_allowed_equip); } diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 0c318ff9c5..7b2c2de7e7 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -921,6 +921,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { static start_allowable_weapons(slot){ var _allow = true; + var _item = equipment[$ slot].name; var _normal_equipment = [ "Combat Knife", "Chainsword", @@ -931,9 +932,9 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { "Flamer", "Sniper Rifle", ]; - _allow = array_contains(_normal_equipment, equipment[$ slot]); + _allow = array_contains(_normal_equipment, _item); - if (_veteran_level > 0 && !_allow) { + if (veteran_level > 0 && !_allow) { var _special_equipment = [ "Storm Bolter", "Meltagun", @@ -941,22 +942,22 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { "Power Sword", "Power Axe", ]; - _allow = array_contains(_special_equipment, equipment[$ slot]); + _allow = array_contains(_special_equipment, _item); } - if (!allow){ - fiinal_gear[$ slot] = default_options[$slot]; + if (!_allow){ + final_gear[$ slot] = default_options[$slot]; } - final_gear[$ slot] = allow ? equipment[$slot].name : default_options[$slot]; + final_gear[$ slot] = _allow ? _item : default_options[$slot]; } static start_allowable_mobi(){ var _allow = true; - if (equipment == "Jump Pack" && (_veteran_level > 0 || role_id == eROLE.ASSAULT)) { + if (equipment == "Jump Pack" && (veteran_level > 0 || role_id == eROLE.ASSAULT)) { if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { _allow = true; } - } else if (equipment == "Bike" && (_veteran_level > 0 || role_id == eROLE.ASSAULT)) { + } else if (equipment == "Bike" && (veteran_level > 0 || role_id == eROLE.ASSAULT)) { if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { _allow = true; } @@ -964,12 +965,12 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { _allow = true; } - final_gear.mobi = allow ? equipment.mobi.name : default_options.mobi; + final_gear.mobi = _allow ? equipment.mobi.name : default_options.mobi; } static start_allowable_gear(){ var _allow = true; - if (_veteran_level == 5) { + if (veteran_level == 5) { if (role_id == eROLE.CHAPLAIN && equipment == "Rosarius") { _allow = true; } else if (role_id == eROLE.TECHMARINE) { @@ -983,7 +984,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { } } - final_gear.gear = allow ? equipment.gear.name : default_options.gear; + final_gear.gear = _allow ? equipment.gear.name : default_options.gear; } static start_allowance(role_id){ @@ -992,7 +993,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { default_options = setup_default_gears()[role_id]; self.role_id = role_id; if (role_id == eROLE.DREADNOUGHT) { - return; + return {}; } if (array_contains([eROLE.SERGEANT, eROLE.VETERAN, eROLE.TERMINATOR], role_id)) { veteran_level = 1; From 2ec2265ec8554ce4d7a1d69ce72f25be2ad2c4a2 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 18:23:43 +0100 Subject: [PATCH 38/82] more review --- objects/obj_controller/Step_0.gml | 3 ++- scripts/scr_marine_struct/scr_marine_struct.gml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/objects/obj_controller/Step_0.gml b/objects/obj_controller/Step_0.gml index f1ddbdcbbf..79857d3a42 100644 --- a/objects/obj_controller/Step_0.gml +++ b/objects/obj_controller/Step_0.gml @@ -490,7 +490,8 @@ try { } if (menu == eMENU.DEFAULT && !instances_exist_any([obj_ncombat, obj_fleet_controller])) { - if (role_compare(chapter_master.get_struct(), eROLE.CHAPTERMASTER) && (alarm[7] == -1)) { + var _cm = chapter_master.get_struct(); + if (role_compare(_cm, eROLE.CHAPTERMASTER) && (alarm[7] == -1)) { alarm[7] = 15; } } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index e6bcbe1867..cbbc612a19 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -982,7 +982,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } array_push(epithets, epithet); }; - static name = function(update) { + static name = function() { return unit_name; }; // get marine name From 7e672c5657b6bc1d02c8e79a4c4d9a6ba2892db6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 18:25:51 +0100 Subject: [PATCH 39/82] correct variable syntax --- .../scr_specialist_training.gml | 114 +++++++++--------- .../scr_unit_equip_functions.gml | 6 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index bbac1ca0a3..5d71e1b917 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -139,24 +139,24 @@ function apothecary_training() { return; } /// @type {Struct.TTRPG_stats} - var unit = fetch_unit(random_marine); - if (!is_struct(unit) || unit.name() == "") { + var _unit = fetch_unit(random_marine); + if (!is_struct(_unit) || _unit.name() == "") { return; } apothecary_recruit_points -= 48; - scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); - unit.update_role(_apoth_role.role); - unit.role_tag = [ + scr_alert("green", "recruitment", _unit.name_role() + " has finished training.", 0, 0); + _unit.update_role(_apoth_role.role); + _unit.role_tag = [ 0, 0, 0, 0, ]; - unit.add_exp(10); + _unit.add_exp(10); var _warn = ""; - var _outcome = unit.alter_equipment(_apoth_role, true, true); + var _outcome = _unit.alter_equipment(_apoth_role, true, true); if (!_outcome.success) { scr_alert("red", "recruitment", $"{_outcome.description}!", 0, 0); @@ -175,10 +175,10 @@ function apothecary_training() { // This gets the last open slot for company 0 _unit.move_to_company(0); - unit.update_role(novice_type); - unit.update_gear(""); - unit.update_mobility_item(""); - scr_alert("green", "recruitment", unit.name_role() + " begins training.", 0, 0); + _unit.update_role(novice_type); + _unit.update_gear(""); + _unit.update_mobility_item(""); + scr_alert("green", "recruitment", _unit.name_role() + " begins training.", 0, 0); } else { training_apothecary = 0; @@ -206,21 +206,21 @@ function chaplain_training() { return; } var _chap_role = obj_ini.player_role_data[eROLE.CHAPLAIN]; - var unit = fetch_unit(random_marine); + var _unit = fetch_unit(random_marine); - scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); + scr_alert("green", "recruitment", _unit.name_role() + " has finished training.", 0, 0); chaplain_points -= 48; - unit.update_role(_chap_role.role); - unit.role_tag = [ + _unit.update_role(_chap_role.role); + _unit.role_tag = [ 0, 0, 0, 0, ]; - unit.add_exp(10); + _unit.add_exp(10); chaplain_aspirant = 0; var _warn = ""; - var _outcome = unit.alter_equipment(_chap_role, true, true); + var _outcome = _unit.alter_equipment(_chap_role, true, true); if (!_outcome.success) { scr_alert("red", "recruitment", $"{_outcome.description}!", 0, 0); @@ -240,10 +240,10 @@ function chaplain_training() { _unit.move_to_company(0); chaplain_aspirant = 1; - unit.update_role(novice_type); - unit.update_gear(""); - unit.update_mobility_item(""); - scr_alert("green", "recruitment", $"{unit.name_role()} begins training.", 0, 0); + _unit.update_role(novice_type); + _unit.update_gear(""); + _unit.update_mobility_item(""); + scr_alert("green", "recruitment", $"{_unit.name_role()} begins training.", 0, 0); with (obj_ini) { scr_company_order(marine_company); scr_company_order(0); @@ -276,14 +276,14 @@ function librarian_training() { if (random_marine == "none") { return; } - var unit = fetch_unit(random_marine); + var _unit = fetch_unit(random_marine); psyker_points -= goal; psyker_aspirant = 0; - scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); - unit.update_role("Lexicanum"); - unit.role_tag = [ + scr_alert("green", "recruitment", _unit.name_role() + " has finished training.", 0, 0); + _unit.update_role("Lexicanum"); + _unit.role_tag = [ 0, 0, 0, @@ -303,16 +303,16 @@ function librarian_training() { var _unit = fetch_unit(random_marine); _unit.move_to_company(0); - unit.update_role(novice_type); - unit.update_powers(); + _unit.update_role(novice_type); + _unit.update_powers(); psyker_aspirant = 1; uit.alter_equipment({ gear : "", mobi : "" }) - unit.update_mobility_item(""); - scr_alert("green", "recruitment", unit.name_role() + " begins training.", 0, 0); + _unit.update_mobility_item(""); + scr_alert("green", "recruitment", _unit.name_role() + " begins training.", 0, 0); } } } @@ -350,49 +350,49 @@ function techmarine_training() { if (random_marine == "none") { return; } - var unit = fetch_unit(random_marine); - if (!is_struct(unit) || unit.name() == "") { + var _unit = fetch_unit(random_marine); + if (!is_struct(_unit) || _unit.name() == "") { return; } tech_points -= _threshold; - unit.update_role(_tech_role.role); - unit.role_tag = [ + _unit.update_role(_tech_role.role); + _unit.role_tag = [ 0, 0, 0, 0, ]; - unit.add_exp(30); + _unit.add_exp(30); - unit.religion = "cult_mechanicus"; + _unit.religion = "cult_mechanicus"; if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { - unit.add_trait("mars_trained"); - unit.alter_equipment(_tech_role, false, true); - scr_alert("green", "recruitment", $"{unit.name()} returns from Mars, a {unit.role()}.", 0, 0); + _unit.add_trait("mars_trained"); + _unit.alter_equipment(_tech_role, false, true); + scr_alert("green", "recruitment", $"{_unit.name()} returns from Mars, a {_unit.role()}.", 0, 0); } else { - unit.add_trait("chapter_trained_tech"); - scr_alert("green", "recruitment", $"{unit.name_role()} has finished training.", 0, 0); + _unit.add_trait("chapter_trained_tech"); + scr_alert("green", "recruitment", $"{_unit.name_role()} has finished training.", 0, 0); - var _outcome = unit.alter_equipment(_tech_role, true, true); + var _outcome = _unit.alter_equipment(_tech_role, true, true); if (!_outcome.success) { scr_alert("red", "recruitment", $"{_outcome.description}!", 0, 0); } } - if (unit.location_string == "Terra") { - unit.allocate_unit_to_fresh_spawn("default"); + if (_unit.location_string == "Terra") { + _unit.allocate_unit_to_fresh_spawn("default"); } var extra_bio = 0; - if (global.chapter_name != "Iron Hands" || !unit.has_trait("flesh_is_weak")) { - extra_bio = unit.bionics < 4 ? choose(1, 2, 3) : 1; + if (global.chapter_name != "Iron Hands" || !_unit.has_trait("flesh_is_weak")) { + extra_bio = _unit.bionics < 4 ? choose(1, 2, 3) : 1; } else { extra_bio = choose(4, 5, 6); } repeat (extra_bio) { - unit.add_bionics(); + _unit.add_bionics(); } // 135 ; probably also want to increase the p_player by 1 just because with (obj_ini) { @@ -406,23 +406,23 @@ function techmarine_training() { if (random_marine != "none") { var _unit = fetch_unit(random_marine); - if (!is_struct(unit)){ + if (!is_struct(_unit)){ return; } _unit.move_to_company(0); - unit.update_role(novice_type); + _unit.update_role(novice_type); // Remove from ship if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { - if (unit.ship_location > -1) { - var man_size = unit.get_unit_size(); - obj_ini.ship_carrying[unit.ship_location] -= man_size; + if (_unit.ship_location > -1) { + var man_size = _unit.get_unit_size(); + obj_ini.ship_carrying[_unit.ship_location] -= man_size; } - unit.location_string = "Terra"; - unit.planet_location = 4; - unit.ship_location = -1; + _unit.location_string = "Terra"; + _unit.planet_location = 4; + _unit.ship_location = -1; } - unit.alter_equipment({ + _unit.alter_equipment({ wep1 : "", wep2 : "", armour : "", @@ -431,9 +431,9 @@ function techmarine_training() { }); if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { - scr_alert("green", "recruitment", $"{unit.name_role()} journeys to Mars.", 0, 0); + scr_alert("green", "recruitment", $"{_unit.name_role()} journeys to Mars.", 0, 0); } else { - scr_alert("green", "recruitment", $"{unit.name_role()} begins training.", 0, 0); + scr_alert("green", "recruitment", $"{_unit.name_role()} begins training.", 0, 0); } } else { training_techmarine = 0; diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 7b2c2de7e7..78c5c7268d 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -919,7 +919,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { }; }; - static start_allowable_weapons(slot){ + static start_allowable_weapons = function(slot){ var _allow = true; var _item = equipment[$ slot].name; var _normal_equipment = [ @@ -951,7 +951,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { final_gear[$ slot] = _allow ? _item : default_options[$slot]; } - static start_allowable_mobi(){ + static start_allowable_mobi = function(){ var _allow = true; if (equipment == "Jump Pack" && (veteran_level > 0 || role_id == eROLE.ASSAULT)) { if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { @@ -968,7 +968,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { final_gear.mobi = _allow ? equipment.mobi.name : default_options.mobi; } - static start_allowable_gear(){ + static start_allowable_gear = function(){ var _allow = true; if (veteran_level == 5) { if (role_id == eROLE.CHAPLAIN && equipment == "Rosarius") { From 06291794917ea246afff6d9a73ed82d923a5f2df Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 18:34:50 +0100 Subject: [PATCH 40/82] more minor corrections --- objects/obj_controller/Alarm_5.gml | 2 +- objects/obj_mass_equip/Step_0.gml | 7 +++---- scripts/scr_ChapterTraits/scr_ChapterTraits.gml | 3 ++- scripts/scr_buttons/scr_buttons.gml | 3 ++- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 2 +- .../scr_equipment_struct/scr_equipment_struct.gml | 8 ++++---- .../scr_mechanicus_missions.gml | 4 ++-- .../scr_unit_equip_functions.gml | 13 +++++++------ 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 9d10ceb57f..9c6d644ead 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -583,7 +583,7 @@ try { fest_repeats--; var _cm = chapter_master.get_struct(); - if (fest_sid _cm.ship_location)) { + if (fest_sid == _cm.ship_location) { cm_present = true; } if (fest_wid > 0 && _cm.is_at_location(fest_star, fest_wid)) { diff --git a/objects/obj_mass_equip/Step_0.gml b/objects/obj_mass_equip/Step_0.gml index 95184255bf..8600334074 100644 --- a/objects/obj_mass_equip/Step_0.gml +++ b/objects/obj_mass_equip/Step_0.gml @@ -11,11 +11,10 @@ try { if (role_number[co] > 0) { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var _unit = fetch_unit([co, i]); - if (!role_compare(_unit, role)) { + if (!is_struct(_unit)) { continue; } - var _unit = fetch_unit([co, i]); - if (!is_struct(_unit)) { + if (!role_compare(_unit, role)) { continue; } if (_unit.squad != "none") { @@ -167,7 +166,7 @@ try { _wep_two_found = true; } - var _wep2 = _unit.weapon_two(true); + if (is_struct(_wep2) || _wep2 == req_wep1 && !_wep_two_found){ have_wep2_num++; } diff --git a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml index 016a0db877..2ada1d0316 100644 --- a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml +++ b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml @@ -12,8 +12,9 @@ enum eCHAPTER_DEPARTMENTS { } function get_department_head(head_type = eCHAPTER_DEPARTMENTS.HQ){ + var _unit = undefined; if (head_type < array_length(obj_ini.TTRPG[0])){ - var _unit = fetch_unit([0, head_type]); + _unit = fetch_unit([0, head_type]); } else { return undefined; } diff --git a/scripts/scr_buttons/scr_buttons.gml b/scripts/scr_buttons/scr_buttons.gml index e1ce001259..b56526a2ce 100644 --- a/scripts/scr_buttons/scr_buttons.gml +++ b/scripts/scr_buttons/scr_buttons.gml @@ -1028,12 +1028,13 @@ function MultiSelect(options_array, title_param, data = {}) constructor { array_push(toggles, _next_tog); } - update(data); static update = function(data = {}) { move_data_to_current_scope(data); }; + update(data); + static draw = function(allow_changes_param = true) { changed = false; allow_changes = allow_changes_param; diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index d1ae7559bc..3d8fdac393 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -742,10 +742,10 @@ function scr_enemy_ai_e() { var otm = 0; var master_present = false; - var _is_a_chaos_meeting = _unit.planet_location == floor(chaos_meeting); for (var co = 0; co <= 10 && _is_a_chaos_meeting; co++) { for (var i = 0; i <= array_length(obj_ini.TTRPG[co]); i++) { var _unit = fetch_unit([co, i]); + var _is_a_chaos_meeting = _unit.planet_location == floor(chaos_meeting); if (!is_struct(_unit)) { continue; } diff --git a/scripts/scr_equipment_struct/scr_equipment_struct.gml b/scripts/scr_equipment_struct/scr_equipment_struct.gml index 3d53d62470..b1c6a35011 100644 --- a/scripts/scr_equipment_struct/scr_equipment_struct.gml +++ b/scripts/scr_equipment_struct/scr_equipment_struct.gml @@ -319,10 +319,6 @@ function EquipmentStruct(item_data = undefined, core_type = "", quality_request return item_desc_tooltip; }; - static has_tag = function(tag) { - return array_contains(tags, tag); - }; - static special_value = function(special) { if (is_struct(specials)) { var _specials = struct_get_names(specials); @@ -336,6 +332,10 @@ function EquipmentStruct(item_data = undefined, core_type = "", quality_request } return 0; }; + + static has_tag = function(tag) { + return array_contains(tags, tag); + }; static has_tags = function(search_tags) { var satisfied = false; diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 084e0d83f0..ffab0cfdf7 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -1,4 +1,6 @@ function mechanicus_missions_end_turn(planet) { + + var _pdata = get_planet_data(planet); var raider_planet_slot = has_problem_planet_with_time(planet, "mech_raider"); if (raider_planet_slot > -1) { var _techs = collect_role_group(SPECIALISTS_TECHS, [name, planet, -1]); @@ -15,8 +17,6 @@ function mechanicus_missions_end_turn(planet) { } var bionics_planet_slot = has_problem_planet_with_time(planet, "mech_bionics"); if (bionics_planet_slot > -1) { - var check1 = scr_bionics_count("star", name, planet, "number"); - var _pdata = get_planet_data(planet); var _units = _pdata.collect_planet_group(); var _bionics = _units.tally_attr("bionics"); if (_bionics >= 10) { diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 78c5c7268d..a8eae80e90 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -458,21 +458,22 @@ function alter_unit_equipment(update_equipment, from_armoury = true, to_armoury var equip_areas = struct_get_names(update_equipment); for (var i = 0; i < array_length(equip_areas); i++) { var _item = update_equipment[$ equip_areas[i]]; + var _outcome = ""; switch (equip_areas[i]) { case "wep1": - var _outcome = update_weapon_one(_item, from_armoury, to_armoury, quality); + _outcome = update_weapon_one(_item, from_armoury, to_armoury, quality); break; case "wep2": - var _outcome = update_weapon_two(_item, from_armoury, to_armoury, quality); + _outcome = update_weapon_two(_item, from_armoury, to_armoury, quality); break; case "mobi": - var _outcome = update_mobility_item(_item, from_armoury, to_armoury, quality); + _outcome = update_mobility_item(_item, from_armoury, to_armoury, quality); break; case "armour": - var _outcome = update_armour(_item, from_armoury, to_armoury, quality); + _outcome = update_armour(_item, from_armoury, to_armoury, quality); break; case "gear": - var _outcome = update_gear(_item, from_armoury, to_armoury, quality); + _outcome = update_gear(_item, from_armoury, to_armoury, quality); break; } if (_outcome == "no_items"){ @@ -987,7 +988,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { final_gear.gear = _allow ? equipment.gear.name : default_options.gear; } - static start_allowance(role_id){ + static start_allowance = functione(role_id){ final_gear = {}; veteran_level = 0; default_options = setup_default_gears()[role_id]; From 2754475bb86a1be8d480972195fce25d37f16e8b Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 18:36:50 +0100 Subject: [PATCH 41/82] correct pathways --- scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index a8eae80e90..7649118eb1 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -953,7 +953,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { } static start_allowable_mobi = function(){ - var _allow = true; + var _allow = false; if (equipment == "Jump Pack" && (veteran_level > 0 || role_id == eROLE.ASSAULT)) { if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { _allow = true; @@ -970,7 +970,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { } static start_allowable_gear = function(){ - var _allow = true; + var _allow = false; if (veteran_level == 5) { if (role_id == eROLE.CHAPLAIN && equipment == "Rosarius") { _allow = true; From b2b152b9166f061cee0f5e8f1a5621d2b3f1eebb Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 18:46:58 +0100 Subject: [PATCH 42/82] typo --- objects/obj_p_assra/Alarm_0.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index b13cc016cf..7b1eeef7a6 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -33,7 +33,7 @@ for (o = 0; o < array_length(origin.board_co); o++) { scr_loyalty("Lost Standard", "+"); } - scr_kill__unit(co, i); + scr_kill_unit(co, i); if (obj_fleet.capital + obj_fleet.frigate + obj_fleet.escort > 0) { obj_controller.gene_seed += seed_lost; From c5d43c37fd3947c24e0cc813f26d1a16bc5516a6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 4 Aug 2026 19:30:56 +0100 Subject: [PATCH 43/82] remove old files and a few more fixes --- ChapterMaster.yyp | 3 - objects/obj_controller/Create_0.gml | 2 +- objects/obj_controller/Step_0.gml | 2 +- objects/obj_dropdown_sel/Draw_0.gml | 6 +- objects/obj_ncombat/Alarm_7.gml | 27 +++++---- objects/obj_p_assra/Alarm_0.gml | 4 +- .../scr_ChapterTraits/scr_ChapterTraits.gml | 2 +- .../scr_bionics_count/scr_bionics_count.gml | 0 .../scr_bionics_count/scr_bionics_count.yy | 13 ----- scripts/scr_civil_roster/scr_civil_roster.gml | 2 +- scripts/scr_company_view/scr_company_view.gml | 2 +- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 4 +- scripts/scr_event_gossip/scr_event_gossip.gml | 4 +- .../scr_initialize_custom.gml | 56 +++++++++---------- scripts/scr_kill_unit/scr_kill_unit.gml | 24 +++++--- scripts/scr_librarium/scr_librarium.gml | 2 +- scripts/scr_marine_count/scr_marine_count.gml | 0 scripts/scr_marine_count/scr_marine_count.yy | 13 ----- .../scr_marine_struct/scr_marine_struct.gml | 8 +-- .../scr_popup_functions.gml | 2 +- .../scr_restart_variables.gml | 0 .../scr_restart_variables.yy | 13 ----- scripts/scr_role_setup/scr_role_setup.gml | 12 ++-- .../scr_transfer_marines.gml | 6 +- scripts/scr_ui_advisors/scr_ui_advisors.gml | 6 +- scripts/scr_ui_settings/scr_ui_settings.gml | 2 +- .../scr_unit_equip_functions.gml | 24 ++++---- 27 files changed, 103 insertions(+), 136 deletions(-) delete mode 100644 scripts/scr_bionics_count/scr_bionics_count.gml delete mode 100644 scripts/scr_bionics_count/scr_bionics_count.yy delete mode 100644 scripts/scr_marine_count/scr_marine_count.gml delete mode 100644 scripts/scr_marine_count/scr_marine_count.yy delete mode 100644 scripts/scr_restart_variables/scr_restart_variables.gml delete mode 100644 scripts/scr_restart_variables/scr_restart_variables.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 05851a56b7..1bf8fa2d60 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -753,7 +753,6 @@ {"id":{"name":"scr_autosave","path":"scripts/scr_autosave/scr_autosave.yy",},}, {"id":{"name":"scr_battle_allies","path":"scripts/scr_battle_allies/scr_battle_allies.yy",},}, {"id":{"name":"scr_battle_sort","path":"scripts/scr_battle_sort/scr_battle_sort.yy",},}, - {"id":{"name":"scr_bionics_count","path":"scripts/scr_bionics_count/scr_bionics_count.yy",},}, {"id":{"name":"scr_boarding_actions","path":"scripts/scr_boarding_actions/scr_boarding_actions.yy",},}, {"id":{"name":"scr_bolt","path":"scripts/scr_bolt/scr_bolt.yy",},}, {"id":{"name":"scr_bomb_world","path":"scripts/scr_bomb_world/scr_bomb_world.yy",},}, @@ -857,7 +856,6 @@ {"id":{"name":"scr_manage_task_selector","path":"scripts/scr_manage_task_selector/scr_manage_task_selector.yy",},}, {"id":{"name":"scr_management","path":"scripts/scr_management/scr_management.yy",},}, {"id":{"name":"scr_map_and_warp_functions","path":"scripts/scr_map_and_warp_functions/scr_map_and_warp_functions.yy",},}, - {"id":{"name":"scr_marine_count","path":"scripts/scr_marine_count/scr_marine_count.yy",},}, {"id":{"name":"scr_marine_struct","path":"scripts/scr_marine_struct/scr_marine_struct.yy",},}, {"id":{"name":"scr_max_marine","path":"scripts/scr_max_marine/scr_max_marine.yy",},}, {"id":{"name":"scr_mechanicus_missions","path":"scripts/scr_mechanicus_missions/scr_mechanicus_missions.yy",},}, @@ -892,7 +890,6 @@ {"id":{"name":"scr_recent","path":"scripts/scr_recent/scr_recent.yy",},}, {"id":{"name":"scr_recruit_data","path":"scripts/scr_recruit_data/scr_recruit_data.yy",},}, {"id":{"name":"scr_reequip_units","path":"scripts/scr_reequip_units/scr_reequip_units.yy",},}, - {"id":{"name":"scr_restart_variables","path":"scripts/scr_restart_variables/scr_restart_variables.yy",},}, {"id":{"name":"scr_return_ship","path":"scripts/scr_return_ship/scr_return_ship.yy",},}, {"id":{"name":"scr_role_count","path":"scripts/scr_role_count/scr_role_count.yy",},}, {"id":{"name":"scr_role_setup","path":"scripts/scr_role_setup/scr_role_setup.yy",},}, diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 5c4f2ef569..c3c9426843 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -409,7 +409,7 @@ sel_loading = -1; sel_uid = 0; // ** Sets Chapter events and celebrations ** -fest_sid = 0; +fest_sid = -1; fest_wid = 0; fest_planet = 0; fest_star = ""; diff --git a/objects/obj_controller/Step_0.gml b/objects/obj_controller/Step_0.gml index 79857d3a42..e387a39e50 100644 --- a/objects/obj_controller/Step_0.gml +++ b/objects/obj_controller/Step_0.gml @@ -25,7 +25,7 @@ try { } // TODO change this into a constructor which is in a separated script if ((fest_scheduled == 0) && (fest_sid + fest_wid > 0) && (menu != eMENU.FESTIVAL)) { - fest_sid = 0; + fest_sid = -1; fest_wid = 0; fest_planet = 0; fest_type = ""; diff --git a/objects/obj_dropdown_sel/Draw_0.gml b/objects/obj_dropdown_sel/Draw_0.gml index 676862f8b4..b8b275ae80 100644 --- a/objects/obj_dropdown_sel/Draw_0.gml +++ b/objects/obj_dropdown_sel/Draw_0.gml @@ -119,7 +119,7 @@ if (opened == 1) { if (obj_controller.fest_type == "Triumphal March") { obj_controller.fest_planet = 1; - obj_controller.fest_sid = 0; + obj_controller.fest_sid = -1; obj_controller.fest_wid = 0; with (obj_dropdown_sel) { if (target == "event_loc") { @@ -160,13 +160,13 @@ if (opened == 1) { obj_controller.fest_attend = scr_event_dudes(0, 0, "", option_id[i]); } if (option[i] == "None Selected") { - obj_controller.fest_sid = 0; + obj_controller.fest_sid = -1; obj_controller.fest_attend = ""; } } if (obj_controller.fest_planet == 1) { obj_controller.fest_wid = option_id[i]; - obj_controller.fest_sid = 0; + obj_controller.fest_sid = -1; obj_controller.fest_star = option_star[i]; if (option[i] != "None Selected") { obj_controller.fest_attend = scr_event_dudes(0, 1, option_star[i], option_id[i]); diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 2b3420d511..1e680792fd 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -54,34 +54,33 @@ try { if (name == obj_ncombat.battle_loc) { instance_create(x, y, obj_temp_meeting); var master_present = 0; - var _fetched_chaos = obj_controlle.chapter_master.get_struct(); + var _fetched_chaos = obj_controller.chapter_master.get_struct(); if (!is_struct(_fetched_chaos)) { - LOGGER.error($"fetch_unit guardrail triggered for chapter master [0, {master_index}] in cs_meeting post-battle"); + LOGGER.error($"fetch_unit guardrail triggered for chapter master [0, 0] in cs_meeting post-battle"); exit; } var chaos_meeting = _fetched_chaos.planet_location; for (var co = 0; co <= obj_ini.companies; co++) { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { - var good = 0; var _unit = fetch_unit([co, i]); if (_unit.location_string != name) { continue; } - if (_unit.planet_location == floor(chaos_meeting)) { - good += 1; + if (_unit.planet_location != floor(chaos_meeting)) { + continue; } - good = !_unit.is_dreadnought(); - - if (good >= 3) { - obj_temp_meeting.dudes += 1; - var otm = obj_temp_meeting.dudes; - obj_temp_meeting.present[otm] = 1; - obj_temp_meeting.co[otm] = co; - obj_temp_meeting.ide[otm] = i; - master_present = role_compare(_unit, eROLE.CHAPTERMASTER) + if (_unit.is_dreadnought()){ + continue } + + obj_temp_meeting.dudes += 1; + var otm = obj_temp_meeting.dudes; + obj_temp_meeting.present[otm] = 1; + obj_temp_meeting.co[otm] = co; + obj_temp_meeting.ide[otm] = i; + master_present = role_compare(_unit, eROLE.CHAPTERMASTER) } } } diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index 7b1eeef7a6..a7576c3cd9 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -3,11 +3,11 @@ var co = 0, i = 0, o = 0, _unit; for (o = 0; o < array_length(origin.board_co); o++) { co = origin.board_co[o]; i = origin.board_id[o]; - _unit = fetch__unit([co, i]); + _unit = fetch_unit([co, i]); if (!is_struct(_unit)) { continue; } - if (_unit.hp() <= -15 && _unit.base_group != "astartes") { + if (_unit.hp() <= -15 && _unit.base_group == "astartes") { var seed_lost = 0; if (apothecary <= 0) { if (_unit.IsSpecialist(SPECIALISTS_STANDARD)) { diff --git a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml index 2ada1d0316..63a3e7c895 100644 --- a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml +++ b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml @@ -42,7 +42,7 @@ function get_department_head(head_type = eCHAPTER_DEPARTMENTS.HQ){ } } - return _unnit + return _unit } function selected_chapter_trait(trait) { diff --git a/scripts/scr_bionics_count/scr_bionics_count.gml b/scripts/scr_bionics_count/scr_bionics_count.gml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/scripts/scr_bionics_count/scr_bionics_count.yy b/scripts/scr_bionics_count/scr_bionics_count.yy deleted file mode 100644 index f032f4b9f3..0000000000 --- a/scripts/scr_bionics_count/scr_bionics_count.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_bionics_count", - "isCompatibility":false, - "isDnD":false, - "name":"scr_bionics_count", - "parent":{ - "name":"Interface Help", - "path":"folders/Scripts/Interface Help.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file diff --git a/scripts/scr_civil_roster/scr_civil_roster.gml b/scripts/scr_civil_roster/scr_civil_roster.gml index ca8a7eb250..c236fa3959 100644 --- a/scripts/scr_civil_roster/scr_civil_roster.gml +++ b/scripts/scr_civil_roster/scr_civil_roster.gml @@ -401,7 +401,7 @@ function scr_civil_roster(_unit_location, _target_location, _is_planet) { } // todo find out what more targ.dudes does, relevant to targ.men? - var _armour_data = _unit.get_armour_dsata(); + var _armour_data = _unit.get_armour_data(); if (is_struct(_armour_data)){ targ.dudes_ac += _armour_data.armour_value; arg.dudes_ranged += _armour_data.ranged_mod/100; diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index 36826c9396..be04d38362 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -45,7 +45,7 @@ function find_company_open_slot(target_company) { var good = -1; var _company_length = array_length(obj_ini.TTRPG[target_company]); for (var i = 0; i < _company_length; i++) { - if (is_undefined(obj_ini.TTRPG[target_company])) { + if (is_undefined(obj_ini.TTRPG[target_company][i])) { good = i; break; } diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index 3d8fdac393..6317b69998 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -742,7 +742,7 @@ function scr_enemy_ai_e() { var otm = 0; var master_present = false; - for (var co = 0; co <= 10 && _is_a_chaos_meeting; co++) { + for (var co = 0; co <= obj_ini.companies; co++) { for (var i = 0; i <= array_length(obj_ini.TTRPG[co]); i++) { var _unit = fetch_unit([co, i]); var _is_a_chaos_meeting = _unit.planet_location == floor(chaos_meeting); @@ -762,7 +762,7 @@ function scr_enemy_ai_e() { _meeting.present[otm] = 1; _meeting.co[otm] = co; _meeting.ide[otm] = i; - if (co <= 0) { + if (co <= 0 && i == 0) { master_present = role_compare(_unit, eROLE.CHAPTERMASTER); } } diff --git a/scripts/scr_event_gossip/scr_event_gossip.gml b/scripts/scr_event_gossip/scr_event_gossip.gml index 2b64cf00b4..67b55b0bc1 100644 --- a/scripts/scr_event_gossip/scr_event_gossip.gml +++ b/scripts/scr_event_gossip/scr_event_gossip.gml @@ -178,10 +178,10 @@ function scr_event_gossip(argument0) { var na, ra; var _unit = fetch_unit([attend_co[argument0], attend_id[argument0]]) na = _unit.name(); - ra = _unit.role()(); + ra = _unit.role(); // Getting there - words = string(ra) + " " + string(na) + " "; + words = "{ra} {na}"; if (that_type == "future_battles") { words += choose("recounts", "retells", "tells", "speaks of") + " future glorious battles that the Chapter will partake of, in glory of " + choose("our honor", "The Emperor", "The Imperium", "Primarch") + "."; diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 9d0e8d3770..cf93de7d46 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1475,7 +1475,7 @@ function scr_initialize_custom() { var c_roles = obj_creation.custom_roles; var possible_custom_roles = [ [ - "chapter_master", + "_chapter_master", eROLE.CHAPTERMASTER, ], [ @@ -1568,7 +1568,7 @@ function scr_initialize_custom() { } var roles = { - chapter_master: player_role_data[eROLE.CHAPTERMASTER].role, + _chapter_master: player_role_data[eROLE.CHAPTERMASTER].role, honour_guard: player_role_data[eROLE.HONOURGUARD].role, veteran: player_role_data[eROLE.VETERAN].role, terminator: player_role_data[eROLE.TERMINATOR].role, @@ -1936,38 +1936,38 @@ function scr_initialize_custom() { // This needs work var cm_equip = load_chapter_master_equipment(); - var chapter_master = add_unit_to_company("chapter_master", _company_i, _marine_i, roles.chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); - _forge_master.set_name(obj_creation.chapter_master_name); + var _chapter_master = add_unit_to_company("_chapter_master", _company_i, _marine_i, roles._chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); + _chapter_master.set_name(obj_creation.chapter_master_name); repeat (cm_equip.bionics) { - chapter_master.add_bionics("none", "standard", false); + _chapter_master.add_bionics("none", "standard", false); } - chapter_master.specials = ""; - chapter_master.add_trait("lead_example"); + _chapter_master.specials = ""; + _chapter_master.add_trait("lead_example"); //builds in which of the three chapter master types your CM is // all of this can now be handled in teh struct and no longer neades complex methods switch (obj_creation.chapter_master_specialty) { case 1: - chapter_master.add_exp(550); - chapter_master.specials += "$"; - chapter_master.add_trait("charismatic"); + _chapter_master.add_exp(550); + _chapter_master.specials += "$"; + _chapter_master.add_trait("charismatic"); break; case 2: - chapter_master.add_exp(650); - chapter_master.specials += "@"; - chapter_master.add_trait("paragon"); + _chapter_master.add_exp(650); + _chapter_master.specials += "@"; + _chapter_master.add_trait("paragon"); break; case 3: //TODO phychic powers need a redo but after weapon refactor - chapter_master.add_exp(550); + _chapter_master.add_exp(550); cm_equip.gear = "Psychic Hood"; - chapter_master.add_trait("favoured_by_the_warp"); - chapter_master.psionic = choose(13, 14); - chapter_master.update_powers(); + _chapter_master.add_trait("favoured_by_the_warp"); + _chapter_master.psionic = choose(13, 14); + _chapter_master.update_powers(); } - chapter_master.alter_equipment(cm_equip, false, false, "master_crafted"); - chapter_master.marine_assembling(); + _chapter_master.alter_equipment(cm_equip, false, false, "master_crafted"); + _chapter_master.marine_assembling(); var _hq_armour = "Artificer Armour"; if (scr_has_disadv("Poor Equipment")) { @@ -3114,18 +3114,18 @@ function load_chapter_master_equipment() { } } - if (variable_instance_exists(obj_creation, "chapter_master")) { - if (struct_exists(obj_creation.chapter_master, "gear") && obj_creation.chapter_master.gear != "") { - chapter_master_equip.gear = obj_creation.chapter_master.gear; + if (variable_instance_exists(obj_creation, "_chapter_master")) { + if (struct_exists(obj_creation._chapter_master, "gear") && obj_creation._chapter_master.gear != "") { + chapter_master_equip.gear = obj_creation._chapter_master.gear; } - if (struct_exists(obj_creation.chapter_master, "mobi") && obj_creation.chapter_master.mobi != "") { - chapter_master_equip.mobi = obj_creation.chapter_master.mobi; + if (struct_exists(obj_creation._chapter_master, "mobi") && obj_creation._chapter_master.mobi != "") { + chapter_master_equip.mobi = obj_creation._chapter_master.mobi; } - if (struct_exists(obj_creation.chapter_master, "armour") && obj_creation.chapter_master.armour != "") { - chapter_master_equip.armour = obj_creation.chapter_master.armour; + if (struct_exists(obj_creation._chapter_master, "armour") && obj_creation._chapter_master.armour != "") { + chapter_master_equip.armour = obj_creation._chapter_master.armour; } - if (struct_exists(obj_creation.chapter_master, "bionics") && obj_creation.chapter_master.bionics != "") { - for (var i = 0; i < real(obj_creation.chapter_master.bionics); i++) { + if (struct_exists(obj_creation._chapter_master, "bionics") && obj_creation._chapter_master.bionics != "") { + for (var i = 0; i < real(obj_creation._chapter_master.bionics); i++) { chapter_master_equip.bionics += 1; } } diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 7f15b9f0d7..005956845f 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -1,12 +1,16 @@ /// @self Asset.GMObject.obj_controller function scr_kill_unit(company, unit_slot) { try { - var _unit = fetch_unit([company, unit_slot]) + var _unit = fetch_unit([company, unit_slot]); + if (!is_struct(_unit)){ + LOGGER.debug($"company: {company}, unit_slot: {unit_slot}"); + return; + } if (_unit.role() == "Forge Master") { array_push(obj_ini.previous_forge_masters, _unit.name()); } - if (compare_role(_unit, eROLE.CHAPTERMASTER)) { + if (role_compare(_unit, eROLE.CHAPTERMASTER)) { tek = "c"; alarm[7] = 5; global.defeat = 1; @@ -18,7 +22,7 @@ function scr_kill_unit(company, unit_slot) { } _unit.remove_from_squad(); - // Drop equipped artifacts at the unit's location before the slots are wiped. + // Drop equipped artifacts at the _unit's location before the slots are wiped. var _equipped = _unit.equipped_artifacts(); for (var _e = 0; _e < array_length(_equipped); _e++) { var _art = fetch_artifact(_equipped[_e]); @@ -40,7 +44,7 @@ function scr_wipe_unit(company, unit_slot) { } function kill_and_recover(company, unit_slot, equipment = true, gene_seed_collect = true) { - var unit = obj_ini.TTRPG[company][unit_slot]; + var _unit = obj_ini.TTRPG[company][unit_slot]; if (equipment) { var strip = { "wep1": "", @@ -49,14 +53,16 @@ function kill_and_recover(company, unit_slot, equipment = true, gene_seed_collec "armour": "", "gear": "", }; - unit.alter_equipment(strip, false, true); + _unit.alter_equipment(strip, false, true); } - if (gene_seed_collect && unit.base_group == "astartes") { - obj_controller.gene_seed += unit.recoverable_geneseed(); + var _is_astartes = _unit.base_group == "astartes"; + if (gene_seed_collect && _is_astartes) { + + obj_controller.gene_seed += _unit.recoverable_geneseed(); } - if (obj_ini.base_group == "astartes") { - if (unit.IsSpecialist()) { + if (_is_astartes) { + if (_unit.IsSpecialist()) { obj_controller.command -= 1; } else { obj_controller.marines -= 1; diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index 0f521229cd..e8e7c2707c 100644 --- a/scripts/scr_librarium/scr_librarium.gml +++ b/scripts/scr_librarium/scr_librarium.gml @@ -149,7 +149,7 @@ function scr_librarium() { draw_set_color(c_gray); draw_set_font(fnt_large); draw_text_transformed(xx + 352, yy + 66, "Librarium", 1, 1, 0); - draw_text_transformed(xx + 352, yy + 100, $"Adept {obj_controller.adept_name"}, 0.6, 0.6, 0); + draw_text_transformed(xx + 352, yy + 100, $"Adept {obj_controller.adept_name}", 0.6, 0.6, 0); draw_set_font(fnt_40k_14); } diff --git a/scripts/scr_marine_count/scr_marine_count.gml b/scripts/scr_marine_count/scr_marine_count.gml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/scripts/scr_marine_count/scr_marine_count.yy b/scripts/scr_marine_count/scr_marine_count.yy deleted file mode 100644 index 8b6b0f97f7..0000000000 --- a/scripts/scr_marine_count/scr_marine_count.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_marine_count", - "isCompatibility":false, - "isDnD":false, - "name":"scr_marine_count", - "parent":{ - "name":"Interface Help", - "path":"folders/Scripts/Interface Help.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index cbbc612a19..d39f66d555 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -425,13 +425,13 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} obj_ini.TTRPG[new_company][_slot] = self; company = new_company; marine_number = _slot; - var _old_company_length = array_length(obj_ini.TTRP[_old_loc[0]]); + var _old_company_length = array_length(obj_ini.TTRPG[_old_loc[0]]); for (var i = _old_loc[1] + 1; i < _old_company_length ; i++){ - var _unit = fetch_unit[_old_loc[0] , i]; + var _unit = fetch_unit([_old_loc[0] , i]); _unit.movement_after_math(_old_loc[0] ,i -1, false); _unit.marine_number = i -1; } - array_delete(obj_ini.TTRP[_old_loc[0]] , _old_loc[1] , 1); + array_delete(obj_ini.TTRPG[_old_loc[0]] , _old_loc[1] , 1); } static armour = function(raw = false) { @@ -2077,7 +2077,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static get_role_data = function(){ - for (var i = 0; i < 24; i++) { + for (var i = 0; i < array_legth(obj_ini.player_role_data); i++) { var _role_data = obj_ini.player_role_data[i]; if (_role_data.role == role()) { return _role_data; diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index 5fbf836ec5..ef0a7b6726 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -321,7 +321,7 @@ function calculate_equipment_needs() { req_wep2_num = units; } else { for (var i = 2; i < 20; i++) { - var _role = obj_ini.player_role_data; + var _role = obj_ini.player_role_data[i]; if (_role.role == rall) { req_armour = _role.armour; req_armour_num = units; diff --git a/scripts/scr_restart_variables/scr_restart_variables.gml b/scripts/scr_restart_variables/scr_restart_variables.gml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/scripts/scr_restart_variables/scr_restart_variables.yy b/scripts/scr_restart_variables/scr_restart_variables.yy deleted file mode 100644 index e8eb138c9f..0000000000 --- a/scripts/scr_restart_variables/scr_restart_variables.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_restart_variables", - "isCompatibility":false, - "isDnD":false, - "name":"scr_restart_variables", - "parent":{ - "name":"Scripts", - "path":"folders/Scripts.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index 4477b33377..a10f93af8d 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -45,11 +45,13 @@ function setup_default_gears (){ load_default_gear(eROLE.SERGEANT, "Sergeant", "Chainsword", "Bolt Pistol", STR_ANY_POWER_ARMOUR, "", ""); load_default_gear(eROLE.VETERANSERGEANT, "Veteran Sergeant", "Chainsword", "Plasma Pistol", STR_ANY_POWER_ARMOUR, "", ""); - for (var i = 0; i < array_length(player_role_data); i++) { + for (var i = 0; i < array_length(default_role_data); i++) { if (default_role_data[i] == 0){ default_role_data[i] = role_data_set(); } } + + return default_role_data; } function update_role_data_wth_defaults(){ @@ -60,16 +62,16 @@ function update_role_data_wth_defaults(){ for (var k=0;k 0 || role_id == eROLE.ASSAULT)) { + var _item = equipment.mobi.name; + if (_item == "Jump Pack" && (veteran_level > 0 || role_id == eROLE.ASSAULT)) { if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { _allow = true; } - } else if (equipment == "Bike" && (veteran_level > 0 || role_id == eROLE.ASSAULT)) { + } else if (_item == "Bike" && (veteran_level > 0 || role_id == eROLE.ASSAULT)) { if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { _allow = true; } - } else if (equipment == "Heavy Weapons Pack" && role_id == eROLE.DEVASTATOR) { + } else if (_item == "Heavy Weapons Pack" && role_id == eROLE.DEVASTATOR) { _allow = true; } - final_gear.mobi = _allow ? equipment.mobi.name : default_options.mobi; + final_gear.mobi = _allow ? _item : default_options.mobi; } static start_allowable_gear = function(){ var _allow = false; + var _item = equipment.gear.name; if (veteran_level == 5) { - if (role_id == eROLE.CHAPLAIN && equipment == "Rosarius") { + if (role_id == eROLE.CHAPLAIN && _item == "Rosarius") { _allow = true; } else if (role_id == eROLE.TECHMARINE) { - if (array_contains(["Servo-arm", "Servo-harness"], equipment)) { + if (array_contains(["Servo-arm", "Servo-harness"], _item)) { _allow = true; } - } else if (role_id == eROLE.LIBRARIAN && equipment == "Psychic Hood") { + } else if (role_id == eROLE.LIBRARIAN && _item == "Psychic Hood") { _allow = true; - } else if (role_id == eROLE.APOTHECARY && equipment == "Narthecium") { + } else if (role_id == eROLE.APOTHECARY && _item == "Narthecium") { _allow = true; } } - final_gear.gear = _allow ? equipment.gear.name : default_options.gear; + final_gear.gear = _allow ? _item : default_options.gear; } - static start_allowance = functione(role_id){ + static start_allowance = function(role_id){ final_gear = {}; veteran_level = 0; default_options = setup_default_gears()[role_id]; From 9c2ad96e3bc189a16a09e0bc9185ba5415127cfc Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Wed, 5 Aug 2026 00:27:05 +0100 Subject: [PATCH 44/82] Update scripts/scr_ui_settings/scr_ui_settings.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_ui_settings/scr_ui_settings.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_ui_settings/scr_ui_settings.gml b/scripts/scr_ui_settings/scr_ui_settings.gml index 4161abbd4f..082d4aac7c 100644 --- a/scripts/scr_ui_settings/scr_ui_settings.gml +++ b/scripts/scr_ui_settings/scr_ui_settings.gml @@ -705,7 +705,7 @@ function scr_draw_mass_equip_gui() { draw_set_color(c_gray); draw_rectangle(114, 626, 560, 665, 0); draw_set_color(0); - draw_text(333, 636, $"Requip All {obj_ini.player_role_data[settings].role} With Default Items"); + draw_text(333, 636, $"Requip All {obj_ini.player_role_data[role].role} With Default Items"); if (scr_hit(114, 626, 560, 665) == true) { draw_set_color(c_white); draw_set_alpha(0.2); From bea856bd79e291d1934fbc8db50588a94ae057af Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 13:53:49 +0100 Subject: [PATCH 45/82] correct check val --- scripts/scr_ui_advisors/scr_ui_advisors.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_ui_advisors/scr_ui_advisors.gml b/scripts/scr_ui_advisors/scr_ui_advisors.gml index 08429df5f6..b5c7bb3ad2 100644 --- a/scripts/scr_ui_advisors/scr_ui_advisors.gml +++ b/scripts/scr_ui_advisors/scr_ui_advisors.gml @@ -645,7 +645,7 @@ function scr_ui_advisors() { if (requisition < fest_cost) { doable = false; } - if ((fest_wid == 0) && (fest_sid == 0)) { + if ((fest_wid == 0) && (fest_sid == -1)) { doable = false; } From 35a8698a36a44f271ae54fd6c1dc9a0ea17e3043 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 15:01:34 +0100 Subject: [PATCH 46/82] One final crash --- scripts/scr_initialize_custom/scr_initialize_custom.gml | 2 +- scripts/scr_marine_struct/scr_marine_struct.gml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index cf93de7d46..4bf08cdab9 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -2001,7 +2001,7 @@ function scr_initialize_custom() { // Master of Sanctity (Chaplain) if (chaplains > 0) { var _hchap = add_unit_to_company("marine", _company_i, _marine_i, "Master of Sanctity", eROLE.CHAPLAIN, "default", "Plasma Pistol", "default", "default", _hq_armour); - _hchap.set_name(obj_creation.high_chaplain_name); + _hchap.set_name(high_chaplain_name); _hchap.edit_corruption(-100); if (_hchap.piety < 45) { _hchap.piety = 45; diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index d39f66d555..c9e79d3d34 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -2077,7 +2077,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static get_role_data = function(){ - for (var i = 0; i < array_legth(obj_ini.player_role_data); i++) { + for (var i = 0; i < array_length(obj_ini.player_role_data); i++) { var _role_data = obj_ini.player_role_data[i]; if (_role_data.role == role()) { return _role_data; From 5627b37a88334ed8a606ae980951d1349a2cb4e3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 16:18:17 +0100 Subject: [PATCH 47/82] gameplay issues --- objects/obj_controller/Create_0.gml | 14 +- objects/obj_star_select/Draw_64.gml | 3 +- scripts/SectorHandler/SectorHandler.gml | 2 + .../scr_company_order/scr_company_order.gml | 18 ++ scripts/scr_company_view/scr_company_view.gml | 4 +- .../scr_initialize_custom.gml | 198 +++++------------- scripts/scr_librarium/scr_librarium.gml | 2 +- scripts/scr_random_event/scr_random_event.gml | 2 +- scripts/scr_recruit_data/scr_recruit_data.gml | 2 +- .../scr_unit_quick_find_pane.gml | 4 +- 10 files changed, 92 insertions(+), 157 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index c3c9426843..a722c7ae07 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1317,22 +1317,22 @@ LOGGER.info("set up the UnitQuickFindPanel"); location_viewer = new UnitQuickFindPanel(); // ** Sets up the number of marines per company ** -marines = 0; -marines = obj_ini.specials + obj_ini.firsts + obj_ini.seconds + obj_ini.thirds + obj_ini.fourths + obj_ini.fifths; -marines += obj_ini.sixths + obj_ini.sevenths + obj_ini.eighths + obj_ini.ninths + obj_ini.tenths; -command = 0; -command = obj_ini.commands; +tally_marines(); // Removes the command marines from marine count if (global.load == -1) { marines -= command; } + +LOGGER.info("intro screen data"); // **** INTRO SCREEN **** -#region Intro Scroll +#region Intro Scrolls +LOGGER.info("sector_handle"); temp[30] = obj_ini.sector_handler.date(); // Date temp[31] = string_upper(adept_name); // Adept name -temp[32] = chapter_master.get_struct.name(); // Master name +LOGGER.info("chapter master fetcch"); +temp[32] = cm_obj().get_struct.name(); // Master name temp[33] = string_upper(scr_thought()); // Thought of the day // Game start welcoming message diff --git a/objects/obj_star_select/Draw_64.gml b/objects/obj_star_select/Draw_64.gml index 856b105b1a..7e719d21ae 100644 --- a/objects/obj_star_select/Draw_64.gml +++ b/objects/obj_star_select/Draw_64.gml @@ -301,7 +301,8 @@ try { building.gene_vault = 1; } //is cm at this location - obj_controller.temp[104] = obj_controller.chapter_master.get_struct().is_at_location(target.name, obj_controller.selecting_planet); + var _cm = cm_obj().get_struct(); + obj_controller.temp[104] = _cm.is_at_location(target.name, obj_controller.selecting_planet); obj_controller.menu = 60; with (obj_star_select) { instance_destroy(); diff --git a/scripts/SectorHandler/SectorHandler.gml b/scripts/SectorHandler/SectorHandler.gml index 7ef8a83e15..8f0b6fc070 100644 --- a/scripts/SectorHandler/SectorHandler.gml +++ b/scripts/SectorHandler/SectorHandler.gml @@ -43,4 +43,6 @@ function SectorHandler() constructor{ static get_creation_year = function(age){ return game_year() - age; } + + LOGGER.info("SectorHandler successfully initialised"); } \ No newline at end of file diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 023fd9efaf..302502c308 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -20,6 +20,24 @@ function company_length(company){ return array_length(obj_ini.TTRPG[company]); } +function tally_marines(){ + obj_controller.command = 0; + obj_controller.marines = 0; + for (var co = 0; co <= obj_ini.companies; co++) { + for (var i = 0; i <= commpany_length(co); i++) { + var _unit = fetch_unit([co,i]); + if (_unit.base_group != "astartes"){ + continue; + } + if (!_unit.IsSpecialist()){ + obj_controller.marines++; + } else { + obj_controller.command++; + } + } + } +} + function scr_company_order(company) { try { // company : company number diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index be04d38362..4b0998824e 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -153,9 +153,9 @@ function scr_company_view(company) { sel_uni[1] = "Command"; // Processing marines - var company_length = array_length(obj_ini.TTRPG[company]); + var _company_length = company_length(company); - for (var v = 0; v < company_length; v++) { + for (var v = 0; v < _company_length; v++) { unit = fetch_unit([company, v]); if (is_struct(unit) && unit.name() != "") { diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 4bf08cdab9..b81f71778c 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -801,7 +801,6 @@ function scr_initialize_custom() { flagship_name = obj_creation.flagship_name; obj_creation.restart_flagship_name = flagship_name; sector_name = global.name_generator.GenerateFromSet("sector"); - man_size = 0; psy_powers = obj_creation.discipline; progenitor_disposition = obj_creation.disposition[1]; @@ -1459,11 +1458,6 @@ function scr_initialize_custom() { master_melee = obj_creation.chapter_master_melee; master_ranged = obj_creation.chapter_master_ranged; - TTRPG[0] = array_create(501); - for (var i = 0; i <= 500; i++) { - TTRPG[0][i] = new TTRPG_stats("chapter", 0, i, "blank"); - } - initialized = 500; var _hi_qual_armour = "Artificer Armour"; @@ -1913,7 +1907,6 @@ function scr_initialize_custom() { initialized = 500; // How many array variables have been prepared - var _marine_i = 0; var _vehicle_i = 0; var _company_i = 0; @@ -1923,20 +1916,15 @@ function scr_initialize_custom() { var _game_year = obj_ini.sector_handler.game_year(); #region Chapter HQ - for (var c = 0; c < 11; c++) { - for (var i = 0; i < 501; i++) { - TTRPG[c][i] = new TTRPG_stats("chapter", c, i, "blank"); - var _unit = TTRPG[c][i]; - _unit.born = _game_year - 50; - _unit.marine_ascension = _game_year - 10; - } + for (var c = 0; c < obj_ini.companies; c++) { + TTRPG[c] = []; } // Chapter Master // This needs work var cm_equip = load_chapter_master_equipment(); - var _chapter_master = add_unit_to_company("_chapter_master", _company_i, _marine_i, roles._chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); + var _chapter_master = add_unit_to_company("_chapter_master", _company_i, roles._chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); _chapter_master.set_name(obj_creation.chapter_master_name); repeat (cm_equip.bionics) { _chapter_master.add_bionics("none", "standard", false); @@ -1973,12 +1961,10 @@ function scr_initialize_custom() { if (scr_has_disadv("Poor Equipment")) { _hq_armour = "MK6 Corvus"; } - _marine_i += 1; - commands = 1; // Forge Master - var _forge_master = add_unit_to_company("marine", _company_i, _marine_i, "Forge Master", eROLE.TECHMARINE, "Infernus Pistol", "Omnissian Axe", "default", "Servo-harness", _hq_armour); + var _forge_master = add_unit_to_company("marine", _company_i, "Forge Master", eROLE.TECHMARINE, "Infernus Pistol", "Omnissian Axe", "default", "Servo-harness", _hq_armour); _forge_master.set_name(obj_creation.fmaster); if (_forge_master.technology < 40) { _forge_master.technology = 40; @@ -1995,87 +1981,60 @@ function scr_initialize_custom() { _forge_master.add_bionics("none", "standard", false); } } - _marine_i += 1; - commands += 1; // Master of Sanctity (Chaplain) if (chaplains > 0) { - var _hchap = add_unit_to_company("marine", _company_i, _marine_i, "Master of Sanctity", eROLE.CHAPLAIN, "default", "Plasma Pistol", "default", "default", _hq_armour); + var _hchap = add_unit_to_company("marine", _company_i, "Master of Sanctity", eROLE.CHAPLAIN, "default", "Plasma Pistol", "default", "default", _hq_armour); _hchap.set_name(high_chaplain_name); _hchap.edit_corruption(-100); if (_hchap.piety < 45) { _hchap.piety = 45; } _hchap.add_trait("zealous_faith"); - _marine_i += 1; - commands += 1; } // Maser of the Apothecarion (Apothecary) - var _hapoth = add_unit_to_company("marine", _company_i, _marine_i, "Master of the Apothecarion", eROLE.APOTHECARY, "default", "Plasma Pistol", "default", "default", _hq_armour); + var _hapoth = add_unit_to_company("marine", _company_i, "Master of the Apothecarion", eROLE.APOTHECARY, "default", "Plasma Pistol", "default", "default", _hq_armour); _hapoth.set_name(obj_creation.hapothecary); _hapoth.edit_corruption(0); - _marine_i += 1; - commands += 1; // Chief Librarian if (!scr_has_disadv("Psyker Intolerant")) { - var _clibrarian = add_unit_to_company("marine", _company_i, _marine_i, string("Chief {0}", roles.librarian), eROLE.LIBRARIAN, "default", "Plasma Pistol", "default", "default", _hq_armour); + var _clibrarian = add_unit_to_company("marine", _company_i, string("Chief {0}", roles.librarian), eROLE.LIBRARIAN, "default", "Plasma Pistol", "default", "default", _hq_armour); _clibrarian.set_name(obj_creation.clibrarian); _clibrarian.edit_corruption(0); _clibrarian.psionic = choose(11, 12); _clibrarian.update_powers(); _clibrarian.add_trait("favoured_by_the_warp"); - _marine_i += 1; - commands += 1; } - man_size = _marine_i; // Techmarines in the armoury repeat (techmarines) { - _marine_i += 1; - commands += 1; - man_size += 1; - add_unit_to_company("marine", _company_i, _marine_i, roles.techmarine, eROLE.TECHMARINE, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + add_unit_to_company("marine", _company_i, roles.techmarine, eROLE.TECHMARINE, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Librarians in the librarium repeat (epistolary) { - _marine_i += 1; - commands += 1; - man_size += 1; - var _epi = add_unit_to_company("marine", _company_i, _marine_i, roles.librarian, eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + var _epi = add_unit_to_company("marine", _company_i, roles.librarian, eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Codiciery repeat (codiciery) { - _marine_i += 1; - commands += 1; - man_size += 1; - var _codi = add_unit_to_company("marine", _company_i, _marine_i, "Codiciery", eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + var _codi = add_unit_to_company("marine", _company_i, "Codiciery", eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Lexicanum repeat (lexicanum) { - _marine_i += 1; - commands += 1; - man_size += 1; - var _lexi = add_unit_to_company("marine", _company_i, _marine_i, "Lexicanum", eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + var _lexi = add_unit_to_company("marine", _company_i, "Lexicanum", eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Apothecaries in Apothecarion repeat (apothecary) { - _marine_i += 1; - commands += 1; - man_size += 1; - add_unit_to_company("marine", _company_i, _marine_i, roles.apothecary, eROLE.APOTHECARY, "Chainsword", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + add_unit_to_company("marine", _company_i, roles.apothecary, eROLE.APOTHECARY, "Chainsword", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Chaplains in Reclusium repeat (chaplains) { - _marine_i += 1; - commands += 1; - man_size += 1; - add_unit_to_company("marine", _company_i, _marine_i, roles.chaplain, eROLE.CHAPLAIN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + add_unit_to_company("marine", _company_i, roles.chaplain, eROLE.CHAPLAIN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Honour Guard @@ -2090,13 +2049,9 @@ function scr_initialize_custom() { _honour_guard_count = 3; } for (var i = 0; i < min(_honour_guard_count, 10); i++) { - _marine_i += 1; - commands += 1; - man_size += 1; - add_unit_to_company("marine", _company_i, _marine_i, roles.honour_guard, eROLE.HONOURGUARD); + add_unit_to_company("marine", _company_i, roles.honour_guard, eROLE.HONOURGUARD); } - specials = _marine_i; #endregion #region New Totals Per Company Adjusted @@ -2262,7 +2217,6 @@ function scr_initialize_custom() { for (var _c = 0, _clen = array_length(_coys); _c < _clen; _c++) { var _name = _coys[_c]; var _coy = companies[$ _name]; - _marine_i = 0; _vehicle_i = 0; if (_coy.total <= 0) { continue; @@ -2490,42 +2444,6 @@ function scr_initialize_custom() { // SPECIALISTS case "captains": - var _cap_gen_name = global.name_generator.ChapterMemberNameGeneration() - switch (_coy.coy) { - case 1: - var _new_name = honor_captain_name != "" ? honor_captain_name : _cap_gen_name; - break; - case 2: - var _new_name = watch_master_name != "" ? watch_master_name : _cap_gen_name; - break; - case 3: - var _new_name = arsenal_master_name != "" ? arsenal_master_name : _cap_gen_name; - break; - case 4: - var _new_name = lord_admiral_name != "" ? lord_admiral_name : _cap_gen_name; - break; - case 5: - var _new_name = march_master_name != "" ? march_master_name : _cap_gen_name; - break; - case 6: - var _new_name = rites_master_name != "" ? rites_master_name : _cap_gen_name; - break; - case 7: - var _new_name = chief_victualler_name != "" ? chief_victualler_name : _cap_gen_name; - break; - case 8: - var _new_name = lord_executioner_name != "" ? lord_executioner_name : _cap_gen_name; - break; - case 9: - var _new_name = relic_master_name != "" ? relic_master_name : _cap_gen_name; - break; - case 10: - var _new_name = recruiter_name != "" ? recruiter_name : _cap_gen_name; - break; - } - var _unit = fetch_unit([_coy.coy ,_marine_i]); - _unit.set_name(_new_name); - commands++; _rolename = roles.captain; _erole = eROLE.CAPTAIN; _wep2 = choose_weighted(global.weapon_list_weighted_ranged_pistols); @@ -2539,7 +2457,6 @@ function scr_initialize_custom() { } break; case "chaplains": - commands++; _rolename = roles.chaplain; _erole = eROLE.CHAPLAIN; _wep2 = choose_weighted(global.weapon_list_weighted_ranged_pistols); @@ -2552,7 +2469,6 @@ function scr_initialize_custom() { } break; case "apothecaries": - commands++; _rolename = roles.apothecary; _erole = eROLE.APOTHECARY; if (squad_distribution != 1 && squad_distribution != 3 && _coy.coy == 8) { @@ -2565,7 +2481,6 @@ function scr_initialize_custom() { } break; case "techmarines": - commands++; _rolename = roles.techmarine; _erole = eROLE.TECHMARINE; if (_coy.coy == 1) { @@ -2583,7 +2498,6 @@ function scr_initialize_custom() { } break; case "librarians": - commands++; _rolename = roles.librarian; _erole = eROLE.LIBRARIAN; if (squad_distribution != 1 && squad_distribution != 3 && _coy.coy == 8) { @@ -2725,52 +2639,49 @@ function scr_initialize_custom() { if (_is_vehicle) { if (_vehicle_i < 205) { add_veh_to_company(_rolename, _coy.coy, _vehicle_i, _wep1, _wep2, _wep3, _upgrade, _accessory); - man_size += 10; _vehicle_i++; } } else { - if (_marine_i < 500) { - add_unit_to_company(_unit_type, _coy.coy, _marine_i, _rolename, _erole, _wep1, _wep2, _gear, _mobi, _armour); - _marine_i++; - man_size++; - if (_is_terminator(_armour)) { - man_size++; - } - } + var _unit = add_unit_to_company(_unit_type, _coy.coy , _rolename, _erole, _wep1, _wep2, _gear, _mobi, _armour); } } - switch (_coy.coy) { - case 1: - firsts = _marine_i; - break; - case 2: - seconds = _marine_i; - break; - case 3: - thirds = _marine_i; - break; - case 4: - fourths = _marine_i; - break; - case 5: - fifths = _marine_i; - break; - case 6: - sixths = _marine_i; - break; - case 7: - sevenths = _marine_i; - break; - case 8: - eighths = _marine_i; - break; - case 9: - ninths = _marine_i; - break; - case 10: - tenths = _marine_i; - break; + if (!_is_vehicle && _role == "captains"){ + var _cap_gen_name = global.name_generator.ChapterMemberNameGeneration() + switch (_coy.coy) { + case 1: + var _new_name = honor_captain_name != "" ? honor_captain_name : _cap_gen_name; + break; + case 2: + var _new_name = watch_master_name != "" ? watch_master_name : _cap_gen_name; + break; + case 3: + var _new_name = arsenal_master_name != "" ? arsenal_master_name : _cap_gen_name; + break; + case 4: + var _new_name = lord_admiral_name != "" ? lord_admiral_name : _cap_gen_name; + break; + case 5: + var _new_name = march_master_name != "" ? march_master_name : _cap_gen_name; + break; + case 6: + var _new_name = rites_master_name != "" ? rites_master_name : _cap_gen_name; + break; + case 7: + var _new_name = chief_victualler_name != "" ? chief_victualler_name : _cap_gen_name; + break; + case 8: + var _new_name = lord_executioner_name != "" ? lord_executioner_name : _cap_gen_name; + break; + case 9: + var _new_name = relic_master_name != "" ? relic_master_name : _cap_gen_name; + break; + case 10: + var _new_name = recruiter_name != "" ? recruiter_name : _cap_gen_name; + break; + } + _unit.set_name(_new_name); } + } } @@ -2941,9 +2852,10 @@ function add_veh_to_company(name, company, slot, wep1, wep2, wep3, upgrade, acce /// each item slot can be "" or "default" or a named item. "" will assign items from the available item pool. /// Use "" if you want to set weapons and gear via squad layouts. /// "default" will set it to the value in the default slot for the given role, see `load_default_gear` -function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 = "default", wep2 = "default", gear = "default", mobi = "default", armour = "default") { - obj_ini.TTRPG[company][slot] = new TTRPG_stats("chapter", company, slot, ttrpg_name); - var spawn_unit = fetch_unit([company, slot]); +function add_unit_to_company(ttrpg_name, company , role_name, role_id, wep1 = "default", wep2 = "default", gear = "default", mobi = "default", armour = "default") { + var _slot = find_company_open_slot(company) + obj_ini.TTRPG[company][_slot] = new TTRPG_stats("chapter", company, _slot, ttrpg_name); + var spawn_unit = fetch_unit([company, _slot]); spawn_unit.update_role(role_name) spawn_unit.unit_race = 1; spawn_unit.location_string = obj_ini.home_name; diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index e8e7c2707c..e9d2bda776 100644 --- a/scripts/scr_librarium/scr_librarium.gml +++ b/scripts/scr_librarium/scr_librarium.gml @@ -171,7 +171,7 @@ function scr_librarium() { // Greetings message if (_head_found) { - var _cm = obj_controller.chapter_master.get_struct(); + var _cm = cm_obj().get_struct(); draw_text_ext(xx + 352, yy + 130, string_hash_to_newline($"{_cm.name_role()}, greetings.#I assume you've come for the report? The Chapter currently possesses {temp[36]} Epistolaries, {temp[37]} Codiceries, and {temp[38]} Lexicanum. We are working to identify additional warp-sensitive brothers before they cause harm, and the training is {blurp}.##We could likely speed up the identification and application of appropriate training, but we would need more resources...I don't suppose we can spare some?##Our Chapter has {artif}"), -1, 536); } else { diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 7f39620d77..7edd16e00a 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -708,7 +708,7 @@ function scr_random_event(execute_now) { var _head = get_department_head(eCHAPTER_DEPARTMENTS.LIB); var _has_chief_psyker = is_struct(_head); - var _cm = obj_controller.chapter_master.get_struct(); + var _cm = cm_obj().get_struct(); var _cm_is_psyker = string_count("0", _cm.specials) > 0; if ((!psyker_intolerant) && _has_chief_psyker) { diff --git a/scripts/scr_recruit_data/scr_recruit_data.gml b/scripts/scr_recruit_data/scr_recruit_data.gml index 0bd5c8bda4..18e2d1e1ed 100644 --- a/scripts/scr_recruit_data/scr_recruit_data.gml +++ b/scripts/scr_recruit_data/scr_recruit_data.gml @@ -874,7 +874,7 @@ function scr_draw_recruit_advisor() { draw_set_font(fnt_40k_14); } - var _cm = obj_controller.chapter_master.get_struct(); + var _cm = cm_obj().get_struct(); if (menu_adept == 0) { blurp = $"Hail {_cm.name()}! You asked for a report?\n\n"; } diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index 7ad899655f..24be1bdcf7 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -542,8 +542,10 @@ function UnitQuickFindPanel() constructor { } } pop_draw_return_values(); - } catch (_exception) {} //dangerous to handle wiljustmake game unplayable if crash does occur + } catch (_exception) {} //dangerous to handle will just make game unplayable if crash does occur }; + + LOGGER.info("UnitQuickFindPanel successfully initialised"); } function HoverBox() constructor { From 41d9f365b734a526db65456802931979f65a35e8 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 17:04:34 +0100 Subject: [PATCH 48/82] handful mmore small fixes --- objects/obj_controller/Create_0.gml | 28 +++++++++++-------- objects/obj_controller/Step_0.gml | 2 +- objects/obj_ini/Create_0.gml | 22 ++------------- objects/obj_ncombat/Alarm_7.gml | 2 +- .../scr_chapter_master/scr_chapter_master.gml | 2 +- .../scr_company_order/scr_company_order.gml | 2 +- .../scr_initialize_custom.gml | 12 ++------ scripts/scr_load/scr_load.gml | 2 +- .../scr_specialist_training.gml | 2 +- scripts/scr_start_load/scr_start_load.gml | 2 +- 10 files changed, 28 insertions(+), 48 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index a722c7ae07..d92fed3703 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -736,7 +736,7 @@ if (instance_exists(obj_ini)) { } } -chapter_master = new scr_chapter_master(); +chapter_master = new ChapterMaster(); trade_attempt = false; // ** Sets income ** @@ -1324,15 +1324,12 @@ if (global.load == -1) { marines -= command; } - -LOGGER.info("intro screen data"); // **** INTRO SCREEN **** #region Intro Scrolls LOGGER.info("sector_handle"); temp[30] = obj_ini.sector_handler.date(); // Date temp[31] = string_upper(adept_name); // Adept name -LOGGER.info("chapter master fetcch"); -temp[32] = cm_obj().get_struct.name(); // Master name +temp[32] = cm_obj().get_struct().name(); // Master name temp[33] = string_upper(scr_thought()); // Thought of the day // Game start welcoming message @@ -1347,31 +1344,33 @@ var _build_clause = function(_prefix, _parts) { return $"{_prefix} {string_join_ext(", ", _parts)}."; }; +LOGGER.info("Command staff"); + var _hq_index = collect_company(0).index_roles(); var _command_staff = [ { role: _canon[eROLE.CHAPTERMASTER], - name_slot: 0, + name_slot: eCHAPTER_DEPARTMENTS.HQ, prefix: "your majesty ", }, { role: "Forge Master", - name_slot: 1, + name_slot: eCHAPTER_DEPARTMENTS.FORGE, prefix: "", }, { role: "Master of Sanctity", - name_slot: 2, + name_slot: eCHAPTER_DEPARTMENTS.CHAP, prefix: "", }, { role: "Master of the Apothecarion", - name_slot: 3, + name_slot: eCHAPTER_DEPARTMENTS.APOTH, prefix: "", }, { role: $"Chief {_canon[eROLE.LIBRARIAN]}", - name_slot: 4, + name_slot: eCHAPTER_DEPARTMENTS.LIB, prefix: "and ", }, ]; @@ -1379,8 +1378,13 @@ var _command_staff = [ var _parts = []; for (var i = 0, l = array_length(_command_staff); i < l; i++) { var _officer = _command_staff[i]; - if (_hq_index.has_role(_officer.role)) { - array_push(_parts, $"{_officer.prefix}{_officer.role} {TTRPG[0][_officer.name_slot].name()}"); + var _unit = get_department_head(_officer.name_slot); + if (!is_undefined(_unit)){ + if (_hq_index.has_role(_officer.role)) { + array_push(_parts, $"{_officer.prefix}{_unit.name_role()}"); + } + } else { + array_push(_parts, $"you have no {_officer.role}"); } } temp[34] = _build_clause("Command staff made of", _parts); diff --git a/objects/obj_controller/Step_0.gml b/objects/obj_controller/Step_0.gml index e387a39e50..ead8999cb5 100644 --- a/objects/obj_controller/Step_0.gml +++ b/objects/obj_controller/Step_0.gml @@ -491,7 +491,7 @@ try { if (menu == eMENU.DEFAULT && !instances_exist_any([obj_ncombat, obj_fleet_controller])) { var _cm = chapter_master.get_struct(); - if (role_compare(_cm, eROLE.CHAPTERMASTER) && (alarm[7] == -1)) { + if (!role_compare(_cm, eROLE.CHAPTERMASTER) && (alarm[7] == -1)) { alarm[7] = 15; } } diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 33ff52c012..2c1befd9d8 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -106,24 +106,6 @@ veh_upgrade = array_create_2d(_max_companies, _max_vehicles, ""); veh_acc = array_create_2d(_max_companies, _max_vehicles, ""); // Unit Init -defaults_slot = 100; - -/// @type {Array>} -race = array_create(11, []); -/// @type {Array>} -name = array_create(11, []); -/// @type {Array>} -role = array_create(11, []); -/// @type {Array>} -wep1 = array_create(11, []); -/// @type {Array>} -wep2 = array_create(11, []); -/// @type {Array>} -armour = array_create(11, []); -/// @type {Array>} -gear = array_create(11, []); -/// @type {Array>} -mobi = array_create(11, []); /// @type {Array>} TTRPG = array_create(11, []); @@ -290,8 +272,8 @@ deserialize = function(save_data) { TTRPG[company][marine].load_json_data(struct); } - for (var _coy = 0; _coy <= 10; _coy++) { - for (var _mar = 0; _mar <= 500; _mar++) { + for (var _coy = 0; _coy <= companies; _coy++) { + for (var _mar = 0; _mar <= TTRPG[_coy]; _mar++) { TTRPG[_coy][_mar] = new TTRPG_stats("chapter", _coy, _mar, "blank"); } } diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 1e680792fd..59d19c475b 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -54,7 +54,7 @@ try { if (name == obj_ncombat.battle_loc) { instance_create(x, y, obj_temp_meeting); var master_present = 0; - var _fetched_chaos = obj_controller.chapter_master.get_struct(); + var _fetched_chaos = cm_obj().get_struct(); if (!is_struct(_fetched_chaos)) { LOGGER.error($"fetch_unit guardrail triggered for chapter master [0, 0] in cs_meeting post-battle"); exit; diff --git a/scripts/scr_chapter_master/scr_chapter_master.gml b/scripts/scr_chapter_master/scr_chapter_master.gml index ca08eac641..10db67aff6 100644 --- a/scripts/scr_chapter_master/scr_chapter_master.gml +++ b/scripts/scr_chapter_master/scr_chapter_master.gml @@ -1,4 +1,4 @@ -function scr_chapter_master() constructor { +function ChapterMaster() constructor { favours = { faction_leaders: array_create(15, 0), minor_characters: {}, diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 302502c308..542c546d9e 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -24,7 +24,7 @@ function tally_marines(){ obj_controller.command = 0; obj_controller.marines = 0; for (var co = 0; co <= obj_ini.companies; co++) { - for (var i = 0; i <= commpany_length(co); i++) { + for (var i = 0; i < company_length(co); i++) { var _unit = fetch_unit([co,i]); if (_unit.base_group != "astartes"){ continue; diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index b81f71778c..cea4a652b4 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1916,10 +1916,6 @@ function scr_initialize_custom() { var _game_year = obj_ini.sector_handler.game_year(); #region Chapter HQ - for (var c = 0; c < obj_ini.companies; c++) { - TTRPG[c] = []; - } - // Chapter Master // This needs work var cm_equip = load_chapter_master_equipment(); @@ -1987,9 +1983,7 @@ function scr_initialize_custom() { var _hchap = add_unit_to_company("marine", _company_i, "Master of Sanctity", eROLE.CHAPLAIN, "default", "Plasma Pistol", "default", "default", _hq_armour); _hchap.set_name(high_chaplain_name); _hchap.edit_corruption(-100); - if (_hchap.piety < 45) { - _hchap.piety = 45; - } + _hchap.piety = max(_hchap.piety , 45); _hchap.add_trait("zealous_faith"); } @@ -2854,8 +2848,8 @@ function add_veh_to_company(name, company, slot, wep1, wep2, wep3, upgrade, acce /// "default" will set it to the value in the default slot for the given role, see `load_default_gear` function add_unit_to_company(ttrpg_name, company , role_name, role_id, wep1 = "default", wep2 = "default", gear = "default", mobi = "default", armour = "default") { var _slot = find_company_open_slot(company) - obj_ini.TTRPG[company][_slot] = new TTRPG_stats("chapter", company, _slot, ttrpg_name); - var spawn_unit = fetch_unit([company, _slot]); + var spawn_unit = new TTRPG_stats("chapter", company, _slot, ttrpg_name); + obj_ini.TTRPG[company][_slot] = spawn_unit; spawn_unit.update_role(role_name) spawn_unit.unit_race = 1; spawn_unit.location_string = obj_ini.home_name; diff --git a/scripts/scr_load/scr_load.gml b/scripts/scr_load/scr_load.gml index c8a4e09aa8..3a37222f45 100644 --- a/scripts/scr_load/scr_load.gml +++ b/scripts/scr_load/scr_load.gml @@ -91,7 +91,7 @@ function scr_load(save_part, save_id) { variable_struct_set(specialist_point_handler, prop, variable_struct_get(save_data, prop)); } } - chapter_master = new scr_chapter_master(); + chapter_master = new ChapterMaster(); if (struct_exists(save_data, "chapter_master_data")) { var _data = variable_struct_get(save_data, "chapter_master_data"); with (chapter_master) { diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index 5d71e1b917..b1bdd997f1 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -126,7 +126,7 @@ function apothecary_training() { var training_points_values = global.apothecary_training_tiers; apothecary_recruit_points += training_points_values[training_apothecary]; - var _apoth_role = player_role_data[eROLE.APOTHECARY]; + var _apoth_role = obj_ini.player_role_data[eROLE.APOTHECARY]; var novice_type = string("{0} Aspirant", obj_ini._apoth_role.role); if (training_apothecary > 0) { diff --git a/scripts/scr_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index d5e18d4c75..9373572a07 100644 --- a/scripts/scr_start_load/scr_start_load.gml +++ b/scripts/scr_start_load/scr_start_load.gml @@ -27,7 +27,7 @@ function scr_start_load(fleet, load_from_star, load_options) { var comp_has_units = []; for (var _comp = 0; _comp < 10; _comp++) { comp_has_units[_comp] = false; - for (var _unit = 0; _unit < get_company_length(_comp); _unit++) { + for (var _unit = 0; _unit < company_length(_comp); _unit++) { if (is_struct(fetch_unit([_comp, _unit]))) { comp_has_units[_comp] = true; break; From 8556c52ab390a871e6e36dcf6159a32a5f862bbb Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 17:19:19 +0100 Subject: [PATCH 49/82] two more minor errors --- objects/obj_ini/Create_0.gml | 2 +- scripts/scr_specialist_training/scr_specialist_training.gml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 2c1befd9d8..24f57832ad 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -273,7 +273,7 @@ deserialize = function(save_data) { } for (var _coy = 0; _coy <= companies; _coy++) { - for (var _mar = 0; _mar <= TTRPG[_coy]; _mar++) { + for (var _mar = 0; _mar < company_length(_coy); _mar++) { TTRPG[_coy][_mar] = new TTRPG_stats("chapter", _coy, _mar, "blank"); } } diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index b1bdd997f1..782d94b57a 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -128,7 +128,7 @@ function apothecary_training() { var _apoth_role = obj_ini.player_role_data[eROLE.APOTHECARY]; - var novice_type = string("{0} Aspirant", obj_ini._apoth_role.role); + var novice_type = string("{0} Aspirant", _apoth_role.role); if (training_apothecary > 0) { recruit_count = scr_role_count(novice_type, ""); From afce230aab77a6382b75828fc70b7e3359357e3c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 17:30:04 +0100 Subject: [PATCH 50/82] remove old pllaceholder values --- objects/obj_ini/Create_0.gml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 24f57832ad..1fe8bc0a50 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -194,6 +194,11 @@ serialize = function() { copy_serializable_fields(id, save_data, excluded_from_save); + save_data.company_lengths = []; + for (var _coy = 0; _coy <= companies; _coy++) { + array_push(save_data.company_lengths, company_length(_coy)) + } + return save_data; }; @@ -216,7 +221,8 @@ deserialize = function(save_data) { "artifact_equipped", "artifact_struct", "artifact_list", - "sector_handler" + "sector_handler", + "company_lengths" ]; // skip automatic setting of certain vars, handle explicitly later // Automatic var setting @@ -273,8 +279,8 @@ deserialize = function(save_data) { } for (var _coy = 0; _coy <= companies; _coy++) { - for (var _mar = 0; _mar < company_length(_coy); _mar++) { - TTRPG[_coy][_mar] = new TTRPG_stats("chapter", _coy, _mar, "blank"); + for (var _mar = 0; _mar < save_data.company_lengths[_coy]; _mar++) { + TTRPG[_coy][_mar] = undefined; } } @@ -285,9 +291,6 @@ deserialize = function(save_data) { var _coy = _marine_json.company; var _mar = _marine_json.marine_number; load_marine_struct(_coy, _mar, _marine_json); - if (!is_struct(fetch_unit([_coy, _mar]))) { - TTRPG[_coy][_mar] = new TTRPG_stats("chapter", _coy, _mar, "blank"); - } } } From dccd03158b96fd346724bb25420c28127a6b3873 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Wed, 5 Aug 2026 17:48:07 +0100 Subject: [PATCH 51/82] Update objects/obj_ini/Create_0.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- objects/obj_ini/Create_0.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 1fe8bc0a50..38644b8024 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -279,7 +279,7 @@ deserialize = function(save_data) { } for (var _coy = 0; _coy <= companies; _coy++) { - for (var _mar = 0; _mar < save_data.company_lengths[_coy]; _mar++) { + for (var _mar = 0; _mar < (struct_exists(save_data, "company_lengths") ? save_data.company_lengths[_coy] : 501); _mar++) { TTRPG[_coy][_mar] = undefined; } } From 665844b81f3795aac619136e15c164342af195d7 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 19:02:12 +0100 Subject: [PATCH 52/82] proper tracking of marines in squads --- objects/obj_controller/Alarm_5.gml | 2 +- objects/obj_ini/Create_0.gml | 17 ++++ scripts/scr_UnitGroup/scr_UnitGroup.gml | 47 ++++++++++- .../scr_company_order/scr_company_order.gml | 2 +- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 2 +- .../scr_marine_struct/scr_marine_struct.gml | 37 +++------ scripts/scr_promote/scr_promote.gml | 80 +++---------------- scripts/scr_squads/scr_squads.gml | 15 ++-- scripts/scr_start_load/scr_start_load.gml | 3 +- .../scr_transfer_marines.gml | 75 +++++------------ scripts/scr_ui_advisors/scr_ui_advisors.gml | 9 ++- 11 files changed, 121 insertions(+), 168 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 9c6d644ead..9eab443f1d 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -583,7 +583,7 @@ try { fest_repeats--; var _cm = chapter_master.get_struct(); - if (fest_sid == _cm.ship_location) { + if (fest_sid != -1 & fest_sid == _cm.ship_location) { cm_present = true; } if (fest_wid > 0 && _cm.is_at_location(fest_star, fest_wid)) { diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 1fe8bc0a50..f56a3d5e1d 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -154,6 +154,20 @@ serialize = function() { } + var _squad_copies = variable_clone(squads); + + var _squad_keys = struct_get_names(_squad_copies); + for (var i = 0; i < array_length(_squad_keys); i++) + { + var _squad = _squad_copies[$ _squad_keys[i]]; + + for (var s = 0; s < array_length(_squad.members); s++){ + if (is_struct(_squad.members[i])){ + _squad.members[i] = _squad.members[i].uid; + } + } + } + var save_data = { obj: object_get_name(object_index), x, @@ -304,6 +318,9 @@ deserialize = function(save_data) { var _squad = new UnitSquad(); _squad.load_json_data(_squad_structs[$ _squad_uid]); squads[$ _squad_uid] = _squad; + for (var s = 0; s < array_length(_squad.members); s++){ + _squad.members[i] = fetch_squad_uid(_squad.members[i]); + } } } diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 1ae4c48a78..df73c9b3ab 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -1,4 +1,4 @@ -function UnitGroup(units) constructor { +function UnitGroup(units = []) constructor { self.units = units; static number = function() { @@ -13,6 +13,10 @@ function UnitGroup(units) constructor { return array_pop(units); }; + static push = function(unit) { + array_push(units, unit) + }; + static has_role = function(role) { for (var i = 0; i < array_length(units); i++) { if (units[i].role() == role) { @@ -77,6 +81,45 @@ function UnitGroup(units) constructor { } }; + static duplicate = function(){ + var _new_array = []; + for (var i = 0; i < number(); i++) { + array_push(_new_array, units[i]); + } + return new UnitGroup(_new_array); + } + + static move_to_company = function(company, keep_squads_if_possible = true,original_loop = true){ + if (!keep_squads_if_possible){ + for (var i = 0; i < number(); i++) { + units[i].move_to_company(company,false); + } + } else { + + var _replica = duplicate(); + + var _squadless = _replica.get_from({squadless : true}, true, true); + _squadless.move_to_company(company, false, false); + + var _squads = count_squads("all", true); + + for (var s = 0;s} unit where unit[0] is company and unit[1] is the position returns undefined if member is out of array_bounds +/// @returns {Struct.TTRPG_stats} unit +function fetch_unit_careful(){ + +} + function fetch_unit_uid(uuid) { for (var i = 0; i < obj_ini.companies; i++) { var _comp_length = array_length(obj_ini.TTRPG[i]); diff --git a/scripts/scr_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index aadb2b703f..fcd671504e 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -33,7 +33,8 @@ function setup_promotion_popup() { }); promote_button.bind_method = function() { - var _company_length = company_length(obj_ini.TTRPG[target_comp]); + units_to_move = new UnitGroup([]); + var _company_length = company_length(target_comp); // Gets the number of marines in the target company var unit, squad_mover, moveable; var role_squad_equivilances = {}; //this is the only way to set variables as keys in gml @@ -44,74 +45,17 @@ function setup_promotion_popup() { variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.VETERAN].role, "veteran_squad"); variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.TERMINATOR].role, "terminator_squad"); - for (var i = 0; i < array_length(obj_controller.display_unit) && mahreens < 500; i++) { + + for (var i = 0; i < array_length(obj_controller.display_unit); i++) { if ((obj_controller.man[i] == "man") && (obj_controller.man_sel[i] == 1) && (obj_controller.ma_exp[i] >= min_exp)) { - moveable = true; - unit = obj_controller.display_unit[i]; - if (unit.squad != "none") { - // this evaluates if you are trying promote a whole squad - var move_squad = unit.squad; - squad = fetch_squad(move_squad); - squad.update_fulfilment(); - move_members = squad.members; - if (array_length(move_members) == 1) { - unit.squad = "none"; - moveable = false; - } - for (var mem = 0; mem < array_length(move_members); mem++) { - //check all members have been selected and are in the same company - if (i + mem < array_length(obj_controller.display_unit)) { - if (!is_struct(obj_controller.display_unit[i + mem])) { - continue; - } - if (obj_controller.man_sel[i + mem] != 1 || obj_controller.display_unit[i + mem].squad != move_squad) { - moveable = false; - break; - } - } else { - moveable = false; - break; - } - } - //move squad - if (moveable) { - var mem; - squad.company = target_comp; - for (mem = 0; mem < array_length(move_members); mem++) { - var mem_unit = fetch_unit(move_members[mem]); - if (!is_struct(mem_unit)) { - continue; - } - mem_unit.move_to_company(target_comp); - mem_unit.squad = move_squad; - if (!mem_unit.IsSpecialist(SPECIALISTS_SQUAD_LEADERS)) { - mem_unit.update_role(role_name[target_role]); - mem_unit.alter_equipment({"wep1": req_wep1, "wep2": req_wep2, "mobi": req_mobi, "armour": req_armour, "gear": req_gear}); - } - mahreens++; - } - i += mem - 2; - if (squad.base_company != target_comp) { - squad.base_company = target_comp; - } - if (struct_exists(role_squad_equivilances, role_name[target_role])) { - squad.change_type(role_squad_equivilances[$ role_name[target_role]]); - } - } - } else { - moveable = false; - } - //move individual - if (!moveable) { - if (unit.company != target_comp) { - unit.move_to_company(target_comp); - } - unit.update_role(role_name[target_role]); - unit.alter_equipment({"wep1": req_wep1, "wep2": req_wep2, "mobi": req_mobi, "armour": req_armour, "gear": req_gear}); - mahreens++; - } - } // End that [i] - } // End repeat + var _unit = obj_controller.display_unit[i]; + units_to_move.push(_unit); + } + } + + units_to_move.move_to_company(target_comp); + + var _squads = units_to_move.count_squads("all", true); with (obj_controller) { scr_management(1); diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index fc3e646c91..4b626d80b2 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -300,7 +300,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { var _struct_array = []; for (var i = array_length(members) - 1; i >= 0; i--) { _unit = fetch_unit(members[i]); - if (!is_struct(_unit) || _unit.name() == "") { + if (!is_struct(_unit)) { array_delete(members, i, 1); continue; } else { @@ -401,7 +401,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { if (fill_from != undefined) { while (fill_from.has_role(_wanted_unit_role) && _squad_role_current < _max_role_count) { var _new_member = fill_from.pop_role_member(_wanted_unit_role); - add_member(_new_member.company, _new_member.marine_number); + add_member(_new_member); squad_fulfilment[$ _wanted_unit_role]++; _squad_role_current = squad_fulfilment[$ _wanted_unit_role]; _new_member.squad = uid; @@ -455,19 +455,18 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { }; static fetch_member = function(index) { - return fetch_unit(members[index]); + return members[index]; }; static fetch_members = function() { return collect_role_group("all", "", false, {"company": base_company, "squad": uid, "max_wanted": array_length(members)}); }; - static add_member = function(comp, unit_number) { - if (is_struct(comp)) { - unit_number = comp.marine_number; - comp = comp.company; + static add_member = function(_unit) { + if (!is_struct(_unit)) { + return; } - array_push(members, [comp, unit_number]); + array_push(members, _unit); life_members++; }; diff --git a/scripts/scr_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index 9373572a07..8c45da75da 100644 --- a/scripts/scr_start_load/scr_start_load.gml +++ b/scripts/scr_start_load/scr_start_load.gml @@ -110,8 +110,7 @@ function scr_start_load(fleet, load_from_star, load_options) { var _squad = company_squad_dist[squad]; var _members = _squad.members; for (var squad_member = 0; squad_member < array_length(_members); squad_member++) { - squaddy = _members[squad_member]; - var _marine = fetch_unit(squaddy); + var _marine = _members[squad_member]; if (!is_struct(_marine)) { continue; } diff --git a/scripts/scr_transfer_marines/scr_transfer_marines.gml b/scripts/scr_transfer_marines/scr_transfer_marines.gml index 2b49a785ce..c956d83ed1 100644 --- a/scripts/scr_transfer_marines/scr_transfer_marines.gml +++ b/scripts/scr_transfer_marines/scr_transfer_marines.gml @@ -31,63 +31,21 @@ function transfer_marines() { break; } } - function transfer_unit(array_index){ - var moveable = true; - var unit = obj_controller.display_unit[array_index]; - if (unit.squad != "none") { - // this evaluates if you are tryin to move a whole squad and if so moves teh squad to a new company - var move_squad = unit.squad; - var squad = fetch_squad(move_squad); - var move_members = squad.members; - for (var mem = 0; mem < array_length(move_members); mem++) { - //check all members have been selected and are in the same company - if (array_index + mem < array_length(obj_controller.display_unit)) { - if (!is_struct(obj_controller.display_unit[array_index + mem])) { - continue; - } - if (obj_controller.man_sel[array_index + mem] != 1 || obj_controller.display_unit[array_index + mem].squad != move_squad) { - moveable = false; - break; - } - } else { - moveable = false; - break; - } - } - //move squad - if (moveable) { - for (var mem = 0; mem < array_length(move_members); mem++) { - obj_controller.man_sel[array_index + mem] = 0; - var member_unit = fetch_unit(move_members[mem]); - if (!is_struct(member_unit)) { - continue; - } - member_unit.move_to_company(target_comp, false); - member_unit.squad = move_squad; - squad.members[mem][0] = _unit.company; - squad.members[mem][1] = _unit.marine_number; - } - squad.base_company = target_comp; - } - } else { - moveable = false; - } - //move individual - if (!moveable) { - unit.move_to_company(target_comp) - } - } + + units_to_move = new UnitGroup([]); // The MAHREENS and TARGET/FROM seems to check out for (var w = 0; w < array_length(obj_controller.display_unit); w++) { if (!obj_controller.man_sel[w]) { continue; } - if (obj_controller.man[w] == "man" && is_struct(obj_controller.display_unit[w])) { - transfer_unit(w); - } else if (obj_controller.man[w] == "vehicle" && is_array(obj_controller.display_unit[w])) { + var _unit = obj_controller.display_unit[w]; + + if (obj_controller.man[w] == "man" && is_struct(_unit)) { + units_to_move.push(_unit); + } else if (obj_controller.man[w] == "vehicle" && is_array(_unit)) { // This seems to execute the correct number of times - var veh_data = obj_controller.display_unit[w]; + var veh_data = _unit; // Check if the target company is within the allowed range if ((target_comp >= 1) && (target_comp <= 10)) { obj_ini.veh_race[target_comp][vehi] = obj_ini.veh_race[veh_data[0]][veh_data[1]]; @@ -110,22 +68,25 @@ function transfer_marines() { } } - // Check this + units_to_move.move_to_company(target_comp); - if (obj_controller.managing > 0) { - with (obj_controller) { - scr_management(1); - } - } obj_ini.selected_company = company; obj_ini.temp_target_company = target_comp; with (obj_ini) { - for (var co = 0; co < 11; co++) { + for (var co = 0; co <= obj_ini.companies; co++) { scr_company_order(co); scr_vehicle_order(co); } } + // Check this + + if (obj_controller.managing > 0) { + with (obj_controller) { + scr_management(1); + } + } + with (obj_controller) { // man_current=0; var i = -1; diff --git a/scripts/scr_ui_advisors/scr_ui_advisors.gml b/scripts/scr_ui_advisors/scr_ui_advisors.gml index b5c7bb3ad2..61aebb3285 100644 --- a/scripts/scr_ui_advisors/scr_ui_advisors.gml +++ b/scripts/scr_ui_advisors/scr_ui_advisors.gml @@ -72,21 +72,22 @@ function scr_ui_advisors() { draw_set_color(c_gray); draw_set_font(fnt_40k_30b); draw_text_transformed(xx + 336 + 16, yy + 66, "Reclusium", 1, 1, 0); - draw_text_transformed(xx + 336 + 16, yy + 100, string_hash_to_newline("Adept " + string(obj_controller.adept_name)), 0.6, 0.6, 0); + draw_text_transformed(xx + 336 + 16, yy + 100, $"Adept {obj_controller.adept_name}" , 0.6, 0.6, 0); } draw_set_font(fnt_40k_14); draw_set_alpha(1); draw_set_color(c_gray); var _active_roles = active_roles(); + var _chap_role = _active_roles[eROLE.CHAPLAIN]; if (temp[36] != "0") { - blurp = $"Sir! You requested a report? Currently, we have deployed {temp[36]} {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s to watch over the health of our Battle-Brothers in the field. We have an additional " + string(temp[37]) + " " + string(obj_ini.player_role_data[eROLE.CHAPLAIN].role) + "s who await only your order to carry the word to the troops."; + blurp = $"Sir! You requested a report? Currently, we have deployed {temp[36]} {_chap_role}s to watch over the health of our Battle-Brothers in the field. We have an additional {temp[37]} {_chap_role}s who await only your order to carry the word to the troops."; } if (temp[36] == "0") { - blurp = $"Sir! You requested a report? Currently, we have {temp[37]} {_active_roles[14]}s who await only your order to carry the word to the troops."; + blurp = $"Sir! You requested a report? Currently, we have {temp[37]} {_chap_role}s who await only your order to carry the word to the troops."; } if ((global.chapter_name != "Space Wolves") && (global.chapter_name != "Iron Hands")) { - blurp += $"##Currently, we are training additional {obj_ini.player_role_data[eROLE.CHAPLAIN].role} at a "; + blurp += $"##Currently, we are training additional {_chap_role} at a "; var _recruit_rates = global.recruitment_rates; blurp += _recruit_rates[training_chaplain]; if (training_chaplain > 0 && training_chaplain <= 6) { From 7111c0dd5642fc0b4ada587b2a03377546d1925b Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Wed, 5 Aug 2026 19:09:54 +0100 Subject: [PATCH 53/82] Update objects/obj_ini/Create_0.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- objects/obj_ini/Create_0.gml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 96defae9ed..38df0647ab 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -293,7 +293,9 @@ deserialize = function(save_data) { } for (var _coy = 0; _coy <= companies; _coy++) { - for (var _mar = 0; _mar < (struct_exists(save_data, "company_lengths") ? save_data.company_lengths[_coy] : 501); _mar++) { + var _company_lengths = struct_exists(save_data, "company_lengths") ? save_data.company_lengths : array_create(companies + 1, 501); + for (var _coy = 0; _coy <= companies; _coy++) { + for (var _mar = 0; _mar < _company_lengths[_coy]; _mar++) { TTRPG[_coy][_mar] = undefined; } } From 6dec55d40a5b8302000eb9444d131c1838bde38e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 19:31:47 +0100 Subject: [PATCH 54/82] more tying up loose ends --- objects/obj_ini/Create_0.gml | 4 +-- scripts/ArtifactStruct/ArtifactStruct.gml | 2 +- .../artifact_functions/artifact_functions.gml | 3 ++ scripts/scr_UnitGroup/scr_UnitGroup.gml | 4 --- .../scr_company_order/scr_company_order.gml | 1 - .../scr_company_struct/scr_company_struct.gml | 5 ++- .../scr_draw_management_unit.gml | 2 +- scripts/scr_garrison/scr_garrison.gml | 3 -- .../scr_initialize_custom.gml | 8 ----- scripts/scr_kill_unit/scr_kill_unit.gml | 2 +- .../scr_marine_struct/scr_marine_struct.gml | 18 ----------- .../scr_mechanicus_missions.gml | 2 +- .../scr_mission_functions.gml | 16 +++++----- scripts/scr_powers/scr_powers.gml | 3 -- scripts/scr_roster/scr_roster.gml | 2 +- .../scr_specialist_training.gml | 4 +-- scripts/scr_squads/scr_squads.gml | 32 ++++--------------- scripts/scr_start_load/scr_start_load.gml | 7 ++-- .../scr_unit_equip_functions.gml | 25 +++------------ 19 files changed, 36 insertions(+), 107 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 96defae9ed..48b3d28f75 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -162,8 +162,8 @@ serialize = function() { var _squad = _squad_copies[$ _squad_keys[i]]; for (var s = 0; s < array_length(_squad.members); s++){ - if (is_struct(_squad.members[i])){ - _squad.members[i] = _squad.members[i].uid; + if (is_struct(_squad.members[s])){ + _squad.members[i] = _squad.members[s].uid; } } } diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index b26bb052de..0dbdc8fc52 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -186,7 +186,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, __identification_timer = data.identification_timer ?? 0; __location_name = data.location_name ?? ""; __ship_id = data.ship_id ?? -1; - __bearer = data.bearer ?? undefined; + __bearer = data.bearer.uid ?? undefined; __custom_name = data.custom_name ?? ""; __custom_description = data.custom_description ?? ""; diff --git a/scripts/artifact_functions/artifact_functions.gml b/scripts/artifact_functions/artifact_functions.gml index 1cc248d169..4fcb630eb2 100644 --- a/scripts/artifact_functions/artifact_functions.gml +++ b/scripts/artifact_functions/artifact_functions.gml @@ -329,6 +329,9 @@ function load_artifact_list(artifact_list) { if (arti.artifact_id > max_id) { max_id = arti.artifact_id; } + if (!is_undefined(arti.bearer)){ + arti.bearer = fetch_unit_uid(arti.bearer); + } } static_get(ArtifactStruct).__next_id = max_id + 1; diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index df73c9b3ab..0892aeb766 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -917,10 +917,6 @@ function collect_by_religeon(religion, sub_cult = "", location = "") { if (!is_struct(_unit)) { continue; } - if (_unit.name() == "") { - LOGGER.error($"Empty name! Unit:\n{_unit}"); - continue; - } if (_unit.religion == religion) { if (sub_cult != "") { if (_unit.religion_sub_cult != "sub_cult") { diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 4442a77dc5..c4f3d73ec1 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -148,7 +148,6 @@ function scr_company_order(company) { var _squad = _struc.get_squad(); _squad.add_member(_struc) } - _struc.movement_after_math(co, i, false); } } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); diff --git a/scripts/scr_company_struct/scr_company_struct.gml b/scripts/scr_company_struct/scr_company_struct.gml index 00e28a4778..38b1e18b5a 100644 --- a/scripts/scr_company_struct/scr_company_struct.gml +++ b/scripts/scr_company_struct/scr_company_struct.gml @@ -457,9 +457,8 @@ function CompanyStruct(comp) constructor { }; static default_member = function() { - var _member = company_squads[0].members[0]; - var _fetched = fetch_unit(_member); - if (is_struct(_fetched)) { + var _member = company_squads[0].fetch_member(0); + if (is_struct(_member)) { obj_controller.unit_focus = _fetched; } selected_unit = obj_controller.unit_focus; diff --git a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml index b055d0e970..e3e9582491 100644 --- a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml +++ b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml @@ -15,7 +15,7 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l if (man[selected] == "man" && is_struct(display_unit[selected])) { is_man = true; _unit = display_unit[selected]; - if (_unit.name() == "" || _unit.base_group == "none") { + if ( _unit.base_group == "none") { return "continue"; } var _active_tags = array_length(manage_tags); diff --git a/scripts/scr_garrison/scr_garrison.gml b/scripts/scr_garrison/scr_garrison.gml index 37135c0123..56b700f7e4 100644 --- a/scripts/scr_garrison/scr_garrison.gml +++ b/scripts/scr_garrison/scr_garrison.gml @@ -55,9 +55,6 @@ function GarrisonForce(system, planet, type = "garrison") constructor { if (!is_struct(_unit)) { continue; } - if (_unit.name() == "") { - continue; - } array_push(members, _unit); if (_unit.hp() > 0) { viable_garrison++; diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index cea4a652b4..c6828785d7 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -2978,10 +2978,6 @@ function load_chapter_master_equipment() { arti = new ArtifactStruct(obj_creation.artifact.base_weapon_type, [], 0, "", -1); arti.set_custom_name(obj_creation.artifact.name); arti.set_custom_description(obj_creation.artifact.description); - arti.set_bearer([ - 0, - 1, - ]); arti.set_identification_timer(0); obj_ini.artifact_map[$ string(arti.artifact_id)] = arti; chapter_master_equip.wep1 = arti.artifact_id; @@ -2990,10 +2986,6 @@ function load_chapter_master_equipment() { arti = new ArtifactStruct(obj_creation.artifact[a].base_weapon_type, [], 0, "", -1); arti.set_custom_name(obj_creation.artifact[a].name); arti.set_custom_description(obj_creation.artifact[a].description); - arti.set_bearer([ - 0, - 1, - ]); arti.set_identification_timer(0); obj_ini.artifact_map[$ string(arti.artifact_id)] = arti; switch (obj_creation.artifact[a].slot) { diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 005956845f..7218369f59 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -32,7 +32,7 @@ function scr_kill_unit(company, unit_slot) { } } - scr_wipe_unit(company, unit_slot); + array_delete(obj_ini.TTRPG[company], unit_slot, 1); } catch (ex) { LOGGER.error($"company: {company}, unit_slot: {unit_slot}"); ERROR_HANDLER.handle_exception(ex); diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 6cfc219790..c49d24cc4d 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -421,7 +421,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static move_to_company = function(new_company, keep_squad = true){ var _slot = find_company_open_slot(new_company); var _old_loc = [company, marine_number]; - movement_after_math(new_company , _slot); obj_ini.TTRPG[new_company][_slot] = self; company = new_company; marine_number = _slot; @@ -429,11 +428,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} remove_from_squad(); } var _old_company_length = array_length(obj_ini.TTRPG[_old_loc[0]]); - for (var i = _old_loc[1] + 1; i < _old_company_length ; i++){ - var _unit = fetch_unit([_old_loc[0] , i]); - _unit.movement_after_math(_old_loc[0] ,i -1, false); - _unit.marine_number = i -1; - } array_delete(obj_ini.TTRPG[_old_loc[0]] , _old_loc[1] , 1); } @@ -2258,18 +2252,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } }; - static movement_after_math = function(end_company = company, end_slot = marine_number, check_squads = true) { - - var artifact_list = equipped_artifacts(); - for (var i = 0; i < array_length(artifact_list); i++) { - var arti = fetch_artifact(artifact_list[i]); - arti.set_bearer([ - end_company, - end_slot, - ]); - } - }; - static is_dreadnought = function() { var _arm_data = get_armour_data(); if (is_struct(_arm_data)) { diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index ffab0cfdf7..288811535e 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -383,7 +383,7 @@ function mechanicus_mars_mission_target_time_elapsed(planet) { for (com = 0; com <= 10; com++) { for (ide = 0; ide < array_length(obj_ini.TTRPG[com]); ide++) { _unit = fetch_unit([com, ide]); - if (!is_struct(_unit) || _unit.name() == "") { + if (!is_struct(_unit)) { continue; } if (_unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 423176ba1e..d9c161ed6b 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -225,14 +225,14 @@ function problem_end_turn_checks() { for (var co = 0; co <= obj_ini.companies; co++) { me = 0; for (me = 0; me < array_length(obj_ini.TTRPG[co]); me++) { - if (obj_ini.base_group == "astartes") { - _unit = fetch_unit([co, me]); - if (!is_struct(_unit)) { - continue; - } - _unit.edit_corruption(irandom_range(3, 6)); - _unit.alter_loyalty(-10); + var _unit = fetch_unit([co, me]); + if (_unit.base_group != "astartes") { + continue } + _unit = fetch_unit([co, me]); + _unit.edit_corruption(irandom_range(3, 6)); + _unit.alter_loyalty(-10); + } } } @@ -391,7 +391,7 @@ function role_compare(unit, role) { } function init_protect_raider_mission(squad) { - var _squad_units = squad.get_squad_structs(); + var _squad_units = squad.members; var _squad_wisdom = stat_average(_squad_units, "wisdom"); var _squad_dex = stat_average(_squad_units, "dexterity"); var _tester = global.character_tester; diff --git a/scripts/scr_powers/scr_powers.gml b/scripts/scr_powers/scr_powers.gml index 41b6c4761e..9b873feadd 100644 --- a/scripts/scr_powers/scr_powers.gml +++ b/scripts/scr_powers/scr_powers.gml @@ -69,9 +69,6 @@ function scr_powers(caster_id, _psy_log = undefined) { if (!is_struct(_unit)) { exit; } - if (_unit.name() == "") { - exit; - } if (!instance_exists(obj_enunit)) { exit; } diff --git a/scripts/scr_roster/scr_roster.gml b/scripts/scr_roster/scr_roster.gml index c4ec70d87a..d2cf384ed9 100644 --- a/scripts/scr_roster/scr_roster.gml +++ b/scripts/scr_roster/scr_roster.gml @@ -276,7 +276,7 @@ function Roster() constructor { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var _allow = false; var _unit = fetch_unit([co, i]); - if (!is_struct(_unit) || _unit.name() == "" || _unit.role() == "") { + if (!is_struct(_unit) ) { continue; } if (_unit.hp() <= 0 || _unit.in_jail()) { diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index 782d94b57a..c618e18ae0 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -140,7 +140,7 @@ function apothecary_training() { } /// @type {Struct.TTRPG_stats} var _unit = fetch_unit(random_marine); - if (!is_struct(_unit) || _unit.name() == "") { + if (!is_struct(_unit)) { return; } @@ -351,7 +351,7 @@ function techmarine_training() { return; } var _unit = fetch_unit(random_marine); - if (!is_struct(_unit) || _unit.name() == "") { + if (!is_struct(_unit)) { return; } tech_points -= _threshold; diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index 4b626d80b2..6b339030fe 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -296,20 +296,6 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { return squad_unit_types; }; - static get_squad_structs = function(as_UnitGroup) { - var _struct_array = []; - for (var i = array_length(members) - 1; i >= 0; i--) { - _unit = fetch_unit(members[i]); - if (!is_struct(_unit)) { - array_delete(members, i, 1); - continue; - } else { - array_push(_struct_array, _unit); - } - } - return _struct_array; - }; - // for creating a new sergeant from existing squad members static new_sergeant = function(veteran = false) { var exp_unit = ""; @@ -317,8 +303,8 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { var highest_exp = 0; var member_length = array_length(members); for (var i = 0; i < member_length; i++) { - _unit = fetch_unit(members[i]); - if (!is_struct(_unit) || _unit.name() == "") { + _unit = members[i]; + if (!is_struct(_unit)) { array_delete(members, i, 1); member_length--; i--; @@ -347,7 +333,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { static kill_members = function() { for (var i = 0; i < array_length(members); i++) { - scr_kill_unit(members[i][0], members[i][1]); + scr_kill_unit(members[i].company, members[i].marine_number); } members = []; }; @@ -377,10 +363,6 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { for (var i = member_length - 1; i >= 0; i--) { //checks squad member is still valid _unit = fetch_member(i); - if (_unit.name() == "") { - array_delete(members, i, 1); - continue; - } if (struct_exists(squad_fulfilment, _unit.role())) { squad_fulfilment[$ _unit.role()]++; } else { @@ -514,8 +496,8 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { var planet_side = false; var exact_loc = false; for (var i = 0; i < member_length; i++) { - _unit = fetch_unit(members[i]); - if (!is_struct(_unit) || _unit.name() == "") { + _unit = members[i]; + if (!is_struct(_unit)) { array_delete(members, i, 1); member_length--; i--; @@ -590,7 +572,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { var highest_exp = 0; for (var i = 0; i < member_length; i++) { var _unit = fetch_unit(members[i]); - if (!is_struct(_unit) || _unit.name() == "") { + if (!is_struct(_unit)) { array_delete(members, i, 1); member_length--; i--; @@ -671,7 +653,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { member_length = array_length(members); for (var i = 0; i < member_length; i++) { var _unit = fetch_unit(members[i]); - if (!is_struct(_unit) || _unit.name() == "") { + if (!is_struct(_unit)) { array_delete(members, i, 1); member_length--; i--; diff --git a/scripts/scr_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index 8c45da75da..ed2d67ced5 100644 --- a/scripts/scr_start_load/scr_start_load.gml +++ b/scripts/scr_start_load/scr_start_load.gml @@ -93,10 +93,10 @@ function scr_start_load(fleet, load_from_star, load_options) { var company_vehicle = []; //array of companies vehicles var ship_fit = true; - for (var _unit = 0; _unit < (array_length(obj_ini.TTRPG[_comp]) - 1); _unit++) { + for (var _unit = 0; _unit < company_length(_comp); _unit++) { var _marine = fetch_unit([_comp, _unit]); // check if marine exists - if (is_struct(_marine) && _marine.name() != "") { + if (is_struct(_marine)) { //calculate marine space var marine_size = _marine.get_unit_size(); _company_size += marine_size; @@ -111,9 +111,6 @@ function scr_start_load(fleet, load_from_star, load_options) { var _members = _squad.members; for (var squad_member = 0; squad_member < array_length(_members); squad_member++) { var _marine = _members[squad_member]; - if (!is_struct(_marine)) { - continue; - } var marine_size = _marine.get_unit_size(); _company_size += marine_size; array_push(company_loader, _marine); diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index b3e019e7e9..ece0ea7e99 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -101,10 +101,7 @@ function scr_update_unit_armour(new_armour, from_armoury = true, to_armoury = tr if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) armour_quality = "artifact"; } else { armour_quality = quality; @@ -208,10 +205,7 @@ function scr_update_unit_weapon_one(new_weapon, from_armoury = true, to_armoury if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) weapon_one_quality = "artifact"; } else { weapon_one_quality = quality; @@ -266,10 +260,7 @@ function scr_update_unit_weapon_two(new_weapon, from_armoury = true, to_armoury if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) weapon_two_quality = "artifact"; } else { weapon_two_quality = quality; @@ -332,10 +323,7 @@ function scr_update_unit_gear(new_gear, from_armoury = true, to_armoury = true, if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) gear_quality = "artifact"; } else { gear_quality = quality; @@ -431,10 +419,7 @@ function scr_update_unit_mobility_item(new_mobility_item, from_armoury = true, t if (is_artifact) { var arti_struct = fetch_artifact(artifact_id); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) mobility_item_quality = "artifact"; } else { mobility_item_quality = quality; From 6bd0d7eb1e0538162169d92d715c229a49985068 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 19:34:53 +0100 Subject: [PATCH 55/82] think we might be there --- objects/obj_ini/Create_0.gml | 1 - 1 file changed, 1 deletion(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index e3674be070..35ff27324a 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -292,7 +292,6 @@ deserialize = function(save_data) { TTRPG[company][marine].load_json_data(struct); } - for (var _coy = 0; _coy <= companies; _coy++) { var _company_lengths = struct_exists(save_data, "company_lengths") ? save_data.company_lengths : array_create(companies + 1, 501); for (var _coy = 0; _coy <= companies; _coy++) { for (var _mar = 0; _mar < _company_lengths[_coy]; _mar++) { From 38f42f810c994d1c05c8a08258dcd66d7614f9d8 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 21:42:47 +0100 Subject: [PATCH 56/82] more tests --- objects/obj_ini/Create_0.gml | 2 +- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 2 +- scripts/scr_ui_manage/scr_ui_manage.gml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 35ff27324a..c540baf97e 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -320,7 +320,7 @@ deserialize = function(save_data) { _squad.load_json_data(_squad_structs[$ _squad_uid]); squads[$ _squad_uid] = _squad; for (var s = 0; s < array_length(_squad.members); s++){ - _squad.members[i] = fetch_squad_uid(_squad.members[i]); + _squad.members[i] = fetch_unit_uid(_squad.members[i]); } } } diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index f7477d6056..5637a9a1a0 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -743,7 +743,7 @@ function scr_enemy_ai_e() { var otm = 0; var master_present = false; for (var co = 0; co <= obj_ini.companies; co++) { - for (var i = 0; i <= array_length(obj_ini.TTRPG[co]); i++) { + for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var _unit = fetch_unit([co, i]); var _is_a_chaos_meeting = _unit.planet_location == floor(chaos_meeting); if (!is_struct(_unit)) { diff --git a/scripts/scr_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index 5019c6fd5d..9166f36161 100644 --- a/scripts/scr_ui_manage/scr_ui_manage.gml +++ b/scripts/scr_ui_manage/scr_ui_manage.gml @@ -1051,7 +1051,7 @@ function scr_ui_manage() { break; } - while ((sel <= array_length(display_unit) - 1) && (man[sel] == "hide" || (man_sel[sel] != 1 && _only_display_selected))) { + while ((sel < array_length(display_unit)) && (man[sel] == "hide" || (man_sel[sel] != 1 && _only_display_selected))) { sel += 1; } if (sel >= array_length(display_unit)) { From a20e67bf5e227babcfa47f56e4ff9078c2cd89f7 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 21:51:14 +0100 Subject: [PATCH 57/82] fix promoring changing role --- scripts/scr_promote/scr_promote.gml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/scr_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index fcd671504e..c76eaa8314 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -34,9 +34,7 @@ function setup_promotion_popup() { promote_button.bind_method = function() { units_to_move = new UnitGroup([]); - var _company_length = company_length(target_comp); // Gets the number of marines in the target company - var unit, squad_mover, moveable; var role_squad_equivilances = {}; //this is the only way to set variables as keys in gml variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.TACTICAL].role, "tactical_squad"); variable_struct_set(role_squad_equivilances, obj_ini.player_role_data[eROLE.DEVASTATOR].role, "devastator_squad"); @@ -50,13 +48,20 @@ function setup_promotion_popup() { if ((obj_controller.man[i] == "man") && (obj_controller.man_sel[i] == 1) && (obj_controller.ma_exp[i] >= min_exp)) { var _unit = obj_controller.display_unit[i]; units_to_move.push(_unit); - } + } } units_to_move.move_to_company(target_comp); - var _squads = units_to_move.count_squads("all", true); + var _target_role = role_name[target_role] + var _squads = units_to_move.count_squads("all", true); + for (var i = 0; i < units_to_move.number(); i++){ + var _unit = units_to_move.units[i]; + _unit.update_role(_target_role); + _unit.alter_equipment({"wep1": req_wep1, "wep2": req_wep2, "mobi": req_mobi, "armour": req_armour, "gear": req_gear}); + } + with (obj_controller) { scr_management(1); } From 565fe93497ec9a7d12c04cb4cf5254b78483d251 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 21:58:50 +0100 Subject: [PATCH 58/82] fixes to squad view --- .../scr_company_struct/scr_company_struct.gml | 5 ++- scripts/scr_garrison/scr_garrison.gml | 3 +- .../scr_mission_functions.gml | 2 +- scripts/scr_squads/scr_squads.gml | 36 +++++++------------ 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/scripts/scr_company_struct/scr_company_struct.gml b/scripts/scr_company_struct/scr_company_struct.gml index 38b1e18b5a..c73c34e601 100644 --- a/scripts/scr_company_struct/scr_company_struct.gml +++ b/scripts/scr_company_struct/scr_company_struct.gml @@ -550,9 +550,8 @@ function CompanyStruct(comp) constructor { draw_set_halign(fa_left); //should be moved elsewhere for efficiency squad_leader = _cur_squad.determine_leader(); - if (squad_leader != "none") { - var _fetched = fetch_unit(squad_leader); - var leader_text = is_struct(_fetched) ? $"Squad Leader : {_fetched.name_role()}" : "Squad Leader : Unknown"; + if (is_struct(squad_leader)) { + var leader_text = is_struct(squad_leader) ? $"Squad Leader : {squad_leader.name_role()}" : "Squad Leader : Unknown"; draw_text_transformed(xx + bound_width[0] + 5, yy + bound_height[0] + 50, leader_text, 1, 1, 0); } squad_loc = _cur_squad.squad_loci(); diff --git a/scripts/scr_garrison/scr_garrison.gml b/scripts/scr_garrison/scr_garrison.gml index 56b700f7e4..bcaed498eb 100644 --- a/scripts/scr_garrison/scr_garrison.gml +++ b/scripts/scr_garrison/scr_garrison.gml @@ -141,8 +141,7 @@ function GarrisonForce(system, planet, type = "garrison") constructor { var _unit; for (var _squad = 0; _squad < array_length(garrison_squads); _squad++) { var _leader = garrison_squads[_squad].determine_leader(); - _unit = fetch_unit(_leader); - if (!is_struct(_unit)) { + if (!is_struct(_leader)) { continue; } if (garrison_leader == false) { diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index d9c161ed6b..de2e0dc789 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -402,7 +402,7 @@ function init_protect_raider_mission(squad) { _mod += 10; } - var _leader = fetch_unit(squad.determine_leader()); + var _leader = squad.determine_leader(); if (!is_struct(_leader)) { return; } diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index 6b339030fe..7a743ee39a 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -570,12 +570,10 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { var leader_hier_pos = array_length(hierarchy); var leader = "none"; var highest_exp = 0; - for (var i = 0; i < member_length; i++) { + for (var i = member_length - 1; i >= 0; i++) { var _unit = fetch_unit(members[i]); if (!is_struct(_unit)) { array_delete(members, i, 1); - member_length--; - i--; continue; } else { if (leader == "none") { @@ -592,19 +590,13 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { } else if (leader_hier_pos < array_length(hierarchy) && hierarchy[leader_hier_pos] == _unit.role()) { var _leader = fetch_unit(leader); if (is_struct(_leader) && _leader.experience < _unit.experience) { - leader = [ - _unit.company, - _unit.marine_number, - ]; + leader = _leader; } } else { for (var r = 0; r < leader_hier_pos; r++) { if (hierarchy[r] == _unit.role()) { leader_hier_pos = r; - leader = [ - _unit.company, - _unit.marine_number, - ]; + leader = _unit; break; } } @@ -616,21 +608,17 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { }; static change_sgt = function(new_sgt) { - sgt = determine_leader(); - var remove_sgt; - if (sgt != "none") { - remove_sgt = fetch_unit(sgt); - if (is_struct(remove_sgt)) { - if (remove_sgt.IsSpecialist(SPECIALISTS_SQUAD_LEADERS)) { - var replace_role = remove_sgt.role(); - remove_sgt.update_role(new_sgt.role()); - //TODO centralise loyalty changes for role changes in the update_role method - remove_sgt.alter_loyalty(-10); - new_sgt.update_role(replace_role); - new_sgt.alter_loyalty(10); - } + var _remove_sgt = determine_leader(); + if (is_struct(_remove_sgt)) { + if (remove_sgt.IsSpecialist(SPECIALISTS_SQUAD_LEADERS)) { + var replace_role = remove_sgt.role(); + remove_sgt.update_role(new_sgt.role()); + //TODO centralise loyalty changes for role changes in the update_role method + remove_sgt.alter_loyalty(-10); } } + new_sgt.update_role(replace_role); + new_sgt.alter_loyalty(10); }; static set_location = function(loc, lid, wid) { From 0078dadac986f85b594a5644f33ccf67e21b3ef3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 5 Aug 2026 22:17:42 +0100 Subject: [PATCH 59/82] more legacy fetches --- .../scr_company_struct/scr_company_struct.gml | 8 ++--- scripts/scr_garrison/scr_garrison.gml | 2 +- scripts/scr_squads/scr_squads.gml | 33 ++++++++----------- scripts/scr_ui_manage/scr_ui_manage.gml | 2 +- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/scripts/scr_company_struct/scr_company_struct.gml b/scripts/scr_company_struct/scr_company_struct.gml index c73c34e601..5ce7b9ddd0 100644 --- a/scripts/scr_company_struct/scr_company_struct.gml +++ b/scripts/scr_company_struct/scr_company_struct.gml @@ -380,7 +380,7 @@ function CompanyStruct(comp) constructor { current_squad = (current_squad - 1 < 0) ? array_length(company_squads) - 1 : current_squad - 1; } var _member = grab_current_squad().members[0]; - var _fetched = fetch_unit(_member); + var _fetched = _member; if (is_struct(_fetched)) { obj_controller.unit_focus = _fetched; } @@ -549,9 +549,9 @@ function CompanyStruct(comp) constructor { draw_set_halign(fa_left); //should be moved elsewhere for efficiency - squad_leader = _cur_squad.determine_leader(); - if (is_struct(squad_leader)) { - var leader_text = is_struct(squad_leader) ? $"Squad Leader : {squad_leader.name_role()}" : "Squad Leader : Unknown"; + var _squad_leader = _cur_squad.determine_leader(); + if (is_struct(_squad_leader)) { + var leader_text = $"Squad Leader : {_squad_leader.name_role()}"; draw_text_transformed(xx + bound_width[0] + 5, yy + bound_height[0] + 50, leader_text, 1, 1, 0); } squad_loc = _cur_squad.squad_loci(); diff --git a/scripts/scr_garrison/scr_garrison.gml b/scripts/scr_garrison/scr_garrison.gml index bcaed498eb..8c176096e7 100644 --- a/scripts/scr_garrison/scr_garrison.gml +++ b/scripts/scr_garrison/scr_garrison.gml @@ -289,7 +289,7 @@ function GarrisonForce(system, planet, type = "garrison") constructor { for (var s = 0; s < array_length(garrison_squads); s++) { //loop squads in the garrison _squad = garrison_squads[s]; - _leader = fetch_unit(_squad.squad_leader); + _leader = _squad.squad_leader; if (!is_struct(_leader)) { continue; } diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index 7a743ee39a..a43eb77887 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -225,7 +225,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { nickname = ""; assignment = "none"; class = []; - squad_leader = ""; + squad_leader = undefined; type_data = {}; base = "tactical"; formation_place = ""; @@ -300,7 +300,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { static new_sergeant = function(veteran = false) { var exp_unit = ""; var _unit; - var highest_exp = 0; + var _highest_exp = 0; var member_length = array_length(members); for (var i = 0; i < member_length; i++) { _unit = members[i]; @@ -310,8 +310,8 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { i--; continue; } - if (_unit.experience > highest_exp) { - highest_exp = _unit.experience; + if (_unit.experience > _highest_exp) { + _highest_exp = _unit.experience; exp_unit = _unit; } } @@ -568,19 +568,15 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { var member_length = array_length(members); var hierarchy = role_hierarchy(); var leader_hier_pos = array_length(hierarchy); - var leader = "none"; - var highest_exp = 0; - for (var i = member_length - 1; i >= 0; i++) { - var _unit = fetch_unit(members[i]); + var _leader = undefined; + for (var i = member_length - 1; i >= 0; i--) { + var _unit = members[i] if (!is_struct(_unit)) { array_delete(members, i, 1); continue; } else { - if (leader == "none") { - leader = [ - _unit.company, - _unit.marine_number, - ]; + if (!is_struct(_leader)) { + _leader = _unit; for (var r = 0; r < array_length(hierarchy); r++) { if (hierarchy[r] == _unit.role()) { leader_hier_pos = r; @@ -588,23 +584,22 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { } } } else if (leader_hier_pos < array_length(hierarchy) && hierarchy[leader_hier_pos] == _unit.role()) { - var _leader = fetch_unit(leader); - if (is_struct(_leader) && _leader.experience < _unit.experience) { - leader = _leader; + if (_leader.experience < _unit.experience) { + _leader = _unit; } } else { for (var r = 0; r < leader_hier_pos; r++) { if (hierarchy[r] == _unit.role()) { leader_hier_pos = r; - leader = _unit; + _leader = _unit; break; } } } } } - squad_leader = leader; - return leader; + squad_leader = _leader; + return _leader; }; static change_sgt = function(new_sgt) { diff --git a/scripts/scr_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index 9166f36161..b5ab2bc524 100644 --- a/scripts/scr_ui_manage/scr_ui_manage.gml +++ b/scripts/scr_ui_manage/scr_ui_manage.gml @@ -672,7 +672,7 @@ function draw_sprite_and_unit_equip_data() { if (company_data.current_squad != -1) { var cur_squad = company_data.grab_current_squad(); var sgt_possible = cur_squad.type != "command_squad" && !selected_unit.IsSpecialist(SPECIALISTS_SQUAD_LEADERS); - if (selected_unit != cur_squad.squad_leader) { + if (selected_unit.uid != cur_squad.squad_leader.uid) { if (point_and_click(draw_unit_buttons([xx + 200 + 50, yy + 329], "Make Sgt", [1, 1], #50a076,,, sgt_possible ? 1 : 0.5)) && sgt_possible) { cur_squad.change_sgt(selected_unit); } From d7baf2241cfa17ffd6458a9cc5eb5b4ac3ec0904 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Wed, 5 Aug 2026 22:26:43 +0100 Subject: [PATCH 60/82] Update scripts/scr_ui_manage/scr_ui_manage.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_ui_manage/scr_ui_manage.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index b5ab2bc524..304c2eed6b 100644 --- a/scripts/scr_ui_manage/scr_ui_manage.gml +++ b/scripts/scr_ui_manage/scr_ui_manage.gml @@ -672,7 +672,7 @@ function draw_sprite_and_unit_equip_data() { if (company_data.current_squad != -1) { var cur_squad = company_data.grab_current_squad(); var sgt_possible = cur_squad.type != "command_squad" && !selected_unit.IsSpecialist(SPECIALISTS_SQUAD_LEADERS); - if (selected_unit.uid != cur_squad.squad_leader.uid) { +if (!is_struct(cur_squad.squad_leader) || selected_unit.uid != cur_squad.squad_leader.uid) { if (point_and_click(draw_unit_buttons([xx + 200 + 50, yy + 329], "Make Sgt", [1, 1], #50a076,,, sgt_possible ? 1 : 0.5)) && sgt_possible) { cur_squad.change_sgt(selected_unit); } From f1caeed6082fcdee8d8cd27dddf22ae4873b1b83 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 01:05:25 +0100 Subject: [PATCH 61/82] various other changes --- objects/obj_controller/Step_0.gml | 3 --- objects/obj_ini/Create_0.gml | 2 +- objects/obj_ncombat/Alarm_7.gml | 6 +++--- objects/obj_p_assra/Alarm_0.gml | 4 ++-- .../scr_apothecary_ground.gml | 4 ++-- .../scr_chapter_managent_events.gml | 1 + scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 18 +++++++++------- scripts/scr_event_gossip/scr_event_gossip.gml | 2 +- scripts/scr_garrison/scr_garrison.gml | 21 +++++++++---------- .../scr_initialize_custom.gml | 20 +++++++++--------- .../scr_mission_functions.gml | 5 +---- scripts/scr_ship_battle/scr_ship_battle.gml | 2 +- scripts/scr_squads/scr_squads.gml | 16 +++++++------- scripts/scr_ui_manage/scr_ui_manage.gml | 2 +- .../scr_unit_quick_find_pane.gml | 1 - 15 files changed, 52 insertions(+), 55 deletions(-) diff --git a/objects/obj_controller/Step_0.gml b/objects/obj_controller/Step_0.gml index ead8999cb5..70d844ece9 100644 --- a/objects/obj_controller/Step_0.gml +++ b/objects/obj_controller/Step_0.gml @@ -442,12 +442,9 @@ try { if (unit.name() == "") { continue; } - var unit_id = unit.marine_number; - var company = unit.company; unit.location_string = obj_ini.ship_location[b]; unit.ship_location = -1; unit.planet_location = unload; - obj_ini.uid[company][unit_id] = 0; ma_loc[q] = obj_ini.ship_location[b]; ma_lid[q] = -1; diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index c540baf97e..09b3113378 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -320,7 +320,7 @@ deserialize = function(save_data) { _squad.load_json_data(_squad_structs[$ _squad_uid]); squads[$ _squad_uid] = _squad; for (var s = 0; s < array_length(_squad.members); s++){ - _squad.members[i] = fetch_unit_uid(_squad.members[i]); + _squad.members[s] = fetch_unit_uid(_squad.members[s]); } } } diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 59d19c475b..cb6507a694 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -59,7 +59,7 @@ try { LOGGER.error($"fetch_unit guardrail triggered for chapter master [0, 0] in cs_meeting post-battle"); exit; } - var chaos_meeting = _fetched_chaos.planet_location; + var _chaos_meeting = _fetched_chaos.planet_location; for (var co = 0; co <= obj_ini.companies; co++) { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { @@ -67,11 +67,11 @@ try { if (_unit.location_string != name) { continue; } - if (_unit.planet_location != floor(chaos_meeting)) { + if (_unit.planet_location != floor(_chaos_meeting)) { continue; } - if (_unit.is_dreadnought()){ + if (_unit.is_dreadnought() && !(role_compare(_unit, eROLE.CHAPTERMASTER))){ continue } diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index a7576c3cd9..120fb275d2 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -17,8 +17,8 @@ for (o = 0; o < array_length(origin.board_co); o++) { } if (apothecary_had > 0) { - if (unit.base_group == "astartes") { - seed_lost = unit.recoverable_geneseed(); + if (_unit.base_group == "astartes") { + seed_lost = _unit.recoverable_geneseed(); } } diff --git a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml index cdb6536e2f..aea868906c 100644 --- a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml +++ b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml @@ -24,8 +24,8 @@ function calculate_full_chapter_spread() { var _apoth_spread = {}; var _unit_spread = {}; for (var company = 0; company < 11; company++) { - var _marine_len = array_length(obj_ini.TTRPG[company]) - 1; - var _veh_len = array_length(obj_ini.veh_hp[company]) - 1; + var _marine_len = array_length(obj_ini.TTRPG[company]); + var _veh_len = array_length(obj_ini.veh_hp[company]); var _company_length = max(_marine_len, _veh_len); for (var v = 0; v < _company_length; v++) { diff --git a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index 8e3aedcdf2..6f9eb3d9a7 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -274,5 +274,6 @@ function new_forge_master_chosen(pick) { if (pick.company > 0) { pick.move_to_company(0); } + scr_company_order(0); } } diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index 5637a9a1a0..61f6a63c6d 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -745,7 +745,7 @@ function scr_enemy_ai_e() { for (var co = 0; co <= obj_ini.companies; co++) { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var _unit = fetch_unit([co, i]); - var _is_a_chaos_meeting = _unit.planet_location == floor(chaos_meeting); + var _is_at_chaos_meeting = _unit.planet_location == floor(chaos_meeting); if (!is_struct(_unit)) { continue; } @@ -757,13 +757,15 @@ function scr_enemy_ai_e() { } - _meeting.dudes += 1; - otm = _meeting.dudes; - _meeting.present[otm] = 1; - _meeting.co[otm] = co; - _meeting.ide[otm] = i; - if (co == 0 && i == 0) { - master_present = role_compare(_unit, eROLE.CHAPTERMASTER); + if (_is_at_chaos_meeting){ + _meeting.dudes += 1; + otm = _meeting.dudes; + _meeting.present[otm] = 1; + _meeting.co[otm] = co; + _meeting.ide[otm] = i; + if (co == 0 && i == 0) { + master_present = role_compare(_unit, eROLE.CHAPTERMASTER); + } } } } diff --git a/scripts/scr_event_gossip/scr_event_gossip.gml b/scripts/scr_event_gossip/scr_event_gossip.gml index 67b55b0bc1..a14ae1ba3f 100644 --- a/scripts/scr_event_gossip/scr_event_gossip.gml +++ b/scripts/scr_event_gossip/scr_event_gossip.gml @@ -181,7 +181,7 @@ function scr_event_gossip(argument0) { ra = _unit.role(); // Getting there - words = "{ra} {na}"; + words = $"{ra} {na}"; if (that_type == "future_battles") { words += choose("recounts", "retells", "tells", "speaks of") + " future glorious battles that the Chapter will partake of, in glory of " + choose("our honor", "The Emperor", "The Imperium", "Primarch") + "."; diff --git a/scripts/scr_garrison/scr_garrison.gml b/scripts/scr_garrison/scr_garrison.gml index 8c176096e7..0df93cdc4a 100644 --- a/scripts/scr_garrison/scr_garrison.gml +++ b/scripts/scr_garrison/scr_garrison.gml @@ -135,32 +135,31 @@ function GarrisonForce(system, planet, type = "garrison") constructor { static find_leader = function() { //find leader of garrison by finding most senior squad leader - garrison_leader = false; + garrison_leader = undefined; var hierarchy = role_hierarchy(); var leader_hier_pos = array_length(hierarchy); - var _unit; for (var _squad = 0; _squad < array_length(garrison_squads); _squad++) { var _leader = garrison_squads[_squad].determine_leader(); if (!is_struct(_leader)) { continue; } - if (garrison_leader == false) { - garrison_leader = _unit; + if (!is_Struct(garrison_leader)) { + garrison_leader = _leader; for (var r = 0; r < array_length(hierarchy); r++) { - if (hierarchy[r] == _unit.role()) { + if (hierarchy[r] == _leader.role()) { leader_hier_pos = r; break; } } - } else if (hierarchy[leader_hier_pos] == _unit.role()) { - if (garrison_leader.experience < _unit.experience) { - garrison_leader = _unit; + } else if (hierarchy[leader_hier_pos] == _leader.role()) { + if (garrison_leader.experience < _leader.experience) { + garrison_leader = _leader; } } else { for (var r = 0; r < leader_hier_pos; r++) { - if (hierarchy[r] == _unit.role()) { + if (hierarchy[r] == _leader.role()) { leader_hier_pos = r; - garrison_leader = _unit; + garrison_leader = _leader; break; } } @@ -174,7 +173,7 @@ function GarrisonForce(system, planet, type = "garrison") constructor { for (var s = 0; s < array_length(garrison_squads); s++) { _squad = garrison_squads[s]; for (m = 0; m < array_length(_squad.members); m++) { - _unit = fetch_unit(_squad.members[m]); + _unit = _squad.members[m]; } } }; diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index c6828785d7..9b9efb2591 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1920,7 +1920,7 @@ function scr_initialize_custom() { // This needs work var cm_equip = load_chapter_master_equipment(); - var _chapter_master = add_unit_to_company("_chapter_master", _company_i, roles._chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); + var _chapter_master = add_unit_to_company("_chapter_master", _company_i, roles.chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); _chapter_master.set_name(obj_creation.chapter_master_name); repeat (cm_equip.bionics) { _chapter_master.add_bionics("none", "standard", false); @@ -3012,18 +3012,18 @@ function load_chapter_master_equipment() { } } - if (variable_instance_exists(obj_creation, "_chapter_master")) { - if (struct_exists(obj_creation._chapter_master, "gear") && obj_creation._chapter_master.gear != "") { - chapter_master_equip.gear = obj_creation._chapter_master.gear; + if (variable_instance_exists(obj_creation, "chapter_master")) { + if (struct_exists(obj_creation.chapter_master, "gear") && obj_creation.chapter_master.gear != "") { + chapter_master_equip.gear = obj_creation.chapter_master.gear; } - if (struct_exists(obj_creation._chapter_master, "mobi") && obj_creation._chapter_master.mobi != "") { - chapter_master_equip.mobi = obj_creation._chapter_master.mobi; + if (struct_exists(obj_creation.chapter_master, "mobi") && obj_creation.chapter_master.mobi != "") { + chapter_master_equip.mobi = obj_creation.chapter_master.mobi; } - if (struct_exists(obj_creation._chapter_master, "armour") && obj_creation._chapter_master.armour != "") { - chapter_master_equip.armour = obj_creation._chapter_master.armour; + if (struct_exists(obj_creation.chapter_master, "armour") && obj_creation.chapter_master.armour != "") { + chapter_master_equip.armour = obj_creation.chapter_master.armour; } - if (struct_exists(obj_creation._chapter_master, "bionics") && obj_creation._chapter_master.bionics != "") { - for (var i = 0; i < real(obj_creation._chapter_master.bionics); i++) { + if (struct_exists(obj_creation.chapter_master, "bionics") && obj_creation.chapter_master.bionics != "") { + for (var i = 0; i < real(obj_creation.chapter_master.bionics); i++) { chapter_master_equip.bionics += 1; } } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index de2e0dc789..9e867c7121 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -221,15 +221,12 @@ function problem_end_turn_checks() { var _unit; if (irandom(100) > 33) { // Give all marines +3d6 corruption and reduce loyalty by 20*/ - var me = 0; for (var co = 0; co <= obj_ini.companies; co++) { - me = 0; - for (me = 0; me < array_length(obj_ini.TTRPG[co]); me++) { + for (var me = 0; me < array_length(obj_ini.TTRPG[co]); me++) { var _unit = fetch_unit([co, me]); if (_unit.base_group != "astartes") { continue } - _unit = fetch_unit([co, me]); _unit.edit_corruption(irandom_range(3, 6)); _unit.alter_loyalty(-10); diff --git a/scripts/scr_ship_battle/scr_ship_battle.gml b/scripts/scr_ship_battle/scr_ship_battle.gml index be87642413..54235476ee 100644 --- a/scripts/scr_ship_battle/scr_ship_battle.gml +++ b/scripts/scr_ship_battle/scr_ship_battle.gml @@ -168,7 +168,7 @@ function scr_ship_battle(target_ship_id, cooridor_width) { if (co == 10) { col = obj_controller.bat_scout_column; } - if (_unit.mobility_item == "Jump Pack") { + if (_unit.mobility_item() == "Jump Pack") { col = obj_controller.bat_assault_column; } } diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index a43eb77887..1e909710b1 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -604,14 +604,16 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { static change_sgt = function(new_sgt) { var _remove_sgt = determine_leader(); - if (is_struct(_remove_sgt)) { - if (remove_sgt.IsSpecialist(SPECIALISTS_SQUAD_LEADERS)) { - var replace_role = remove_sgt.role(); - remove_sgt.update_role(new_sgt.role()); - //TODO centralise loyalty changes for role changes in the update_role method - remove_sgt.alter_loyalty(-10); - } + if (!is_struct(_remove_sgt)) { + return; + } + var replace_role = _remove_sgt.role(); + if (_remove_sgt.IsSpecialist(SPECIALISTS_SQUAD_LEADERS)) { + _remove_sgt.update_role(new_sgt.role()); + //TODO centralise loyalty changes for role changes in the update_role method + _remove_sgt.alter_loyalty(-10); } + new_sgt.update_role(replace_role); new_sgt.alter_loyalty(10); }; diff --git a/scripts/scr_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index b5ab2bc524..734e6d6a54 100644 --- a/scripts/scr_ui_manage/scr_ui_manage.gml +++ b/scripts/scr_ui_manage/scr_ui_manage.gml @@ -672,7 +672,7 @@ function draw_sprite_and_unit_equip_data() { if (company_data.current_squad != -1) { var cur_squad = company_data.grab_current_squad(); var sgt_possible = cur_squad.type != "command_squad" && !selected_unit.IsSpecialist(SPECIALISTS_SQUAD_LEADERS); - if (selected_unit.uid != cur_squad.squad_leader.uid) { + if (!is_struct(cur_squad.squad_leader) || selected_unit.uid != cur_squad.squad_leader.uid) { if (point_and_click(draw_unit_buttons([xx + 200 + 50, yy + 329], "Make Sgt", [1, 1], #50a076,,, sgt_possible ? 1 : 0.5)) && sgt_possible) { cur_squad.change_sgt(selected_unit); } diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index 24be1bdcf7..d182a87845 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -629,7 +629,6 @@ function toggle_selection_borders() { if ((man_sel[p] == 1) && (man[p] == "man")) { if (is_struct(display_unit[p])) { var _unit = display_unit[p]; - var mar_id = _unit.marine_number; if ((_unit.ship_location > -1) && _unit.controllable()) { _unit.is_boarder = !_unit.is_boarder; } From 82fbda2658476713f379498d024bab5767cdc6e8 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 01:57:38 +0100 Subject: [PATCH 62/82] cleanup from new kill method --- objects/obj_ncombat/Alarm_7.gml | 2 +- scripts/scr_ChapterTraits/scr_ChapterTraits.gml | 5 +++++ scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 3 --- scripts/scr_initialize_custom/scr_initialize_custom.gml | 4 ++-- scripts/scr_kill_unit/scr_kill_unit.gml | 2 +- scripts/scr_promote/scr_promote.gml | 2 +- scripts/scr_specialist_training/scr_specialist_training.gml | 2 +- .../scr_unit_equip_functions/scr_unit_equip_functions.gml | 2 ++ 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 3cf40ce1db..ddb5fd844d 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -29,7 +29,7 @@ try { obj_controller.marines -= 1; } - obj_ncombat.world_size += scr_unit_size(_unit.armour(), _unit.role(), true, _unit.mobility_item()); + obj_ncombat.world_size += _unit.get_unit_size(); var recover = !obj_ncombat.defeat; _unit.kill(recover, recover); diff --git a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml index 63a3e7c895..8596767765 100644 --- a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml +++ b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml @@ -24,22 +24,27 @@ function get_department_head(head_type = eCHAPTER_DEPARTMENTS.HQ){ if (!role_compare(_unit, eROLE.CHAPTERMASTER)){ return undefined; } + break case eCHAPTER_DEPARTMENTS.FORGE: if (_unit.role() != "Forge Master"){ return undefined; } + break case eCHAPTER_DEPARTMENTS.CHAP: if (_unit.role() != "Master of Sanctity"){ return undefined; } + break case eCHAPTER_DEPARTMENTS.APOTH: if (_unit.role() != "Master of the Apothecarion"){ return undefined; } + break case eCHAPTER_DEPARTMENTS.LIB: if (_unit.role() != $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role}"){ return undefined; } + break } return _unit diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index 61f6a63c6d..633128f09a 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -746,9 +746,6 @@ function scr_enemy_ai_e() { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var _unit = fetch_unit([co, i]); var _is_at_chaos_meeting = _unit.planet_location == floor(chaos_meeting); - if (!is_struct(_unit)) { - continue; - } if (_unit.is_dreadnought() && !role_compare(_unit, eROLE.CHAPTERMASTER)){ continue; } diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 9b9efb2591..d1de943c27 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1469,7 +1469,7 @@ function scr_initialize_custom() { var c_roles = obj_creation.custom_roles; var possible_custom_roles = [ [ - "_chapter_master", + "chapter_master", eROLE.CHAPTERMASTER, ], [ @@ -1920,7 +1920,7 @@ function scr_initialize_custom() { // This needs work var cm_equip = load_chapter_master_equipment(); - var _chapter_master = add_unit_to_company("_chapter_master", _company_i, roles.chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); + var _chapter_master = add_unit_to_company("chapter_master", _company_i, roles.chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); _chapter_master.set_name(obj_creation.chapter_master_name); repeat (cm_equip.bionics) { _chapter_master.add_bionics("none", "standard", false); diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 443b97b661..cc0d5ea517 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -27,7 +27,7 @@ function scr_kill_unit() { } array_delete(obj_ini.TTRPG[company], marine_number, 1); var _len = company_length(company); - for (var i = marine_number; i < company_length; i++){ + for (var i = marine_number; i < _len; i++){ obj_ini.TTRPG[company][i].marine_number = i; } diff --git a/scripts/scr_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index c76eaa8314..4cee0efd68 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -268,6 +268,6 @@ function draw_popup_promotion() { instance_destroy(); } - promote_button.draw(all_good); + promote_button.draw(all_good && target_role > 0); pop_draw_return_values(); } diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index c618e18ae0..844a6f95dd 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -307,7 +307,7 @@ function librarian_training() { _unit.update_powers(); psyker_aspirant = 1; - uit.alter_equipment({ + _unit.alter_equipment({ gear : "", mobi : "" }) diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index ece0ea7e99..f21f4c0d8d 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -472,6 +472,8 @@ function alter_unit_equipment(update_equipment, from_armoury = true, to_armoury } var _final_outcome = {success : _success,description :_outcome_desc}; + return _final_outcome; + } /// @self Struct.TTRPG_stats From cfcb68ff5de59a07da1145f63fb7cd2e6931b05e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 02:13:06 +0100 Subject: [PATCH 63/82] cm variable name --- scripts/scr_initialize_custom/scr_initialize_custom.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index d1de943c27..801d4a411a 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1562,7 +1562,7 @@ function scr_initialize_custom() { } var roles = { - _chapter_master: player_role_data[eROLE.CHAPTERMASTER].role, + chapter_master: player_role_data[eROLE.CHAPTERMASTER].role, honour_guard: player_role_data[eROLE.HONOURGUARD].role, veteran: player_role_data[eROLE.VETERAN].role, terminator: player_role_data[eROLE.TERMINATOR].role, From fb7b8d736fd7d902696228702e734b14b62cddff Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 14:07:03 +0100 Subject: [PATCH 64/82] remove redundant order steps --- .../scr_company_order/scr_company_order.gml | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index c4f3d73ec1..d166b55e66 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -124,30 +124,10 @@ function scr_company_order(company) { _company_marines.order_by_rank(); - var _squads = _company_marines.count_squads("all", true); + TTRPG[co] = _company_marines.units; - for (var i = 0; i < array_length(_squads); i++) { - var _squad = fetch_squad(_squads[i]); - _squad.members = []; - } - - var _temps = []; - for (var i = 0; i < array_length(_company_marines.units); i++) { - var _unit = _company_marines.units[i]; - array_push(_temps, {unit: _unit}); - } - - var _new_length = array_length(_temps); - TTRPG[co] = array_create(_new_length, 0); - for (var i = 0; i < array_length(_temps); i++) { - var _unit = _temps[i]; - var _struc = _unit.unit; - TTRPG[co][i] = _struc; - _struc.marine_number = i; - if (_struc.squad != "none") { - var _squad = _struc.get_squad(); - _squad.add_member(_struc) - } + for (var i = 0; i < array_length(TTRPG[co]); i++) { + TTRPG[co][i].marine_number = i; } } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); From f2553eccffbc71974580de43ecca71b6e15e87a4 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 14:18:46 +0100 Subject: [PATCH 65/82] replace borders logic with precise struct referencec --- objects/obj_p_assra/Alarm_0.gml | 6 ++---- objects/obj_p_assra/Step_0.gml | 15 ++++----------- objects/obj_p_ship/Alarm_0.gml | 3 +-- objects/obj_p_ship/Create_0.gml | 3 +-- objects/obj_p_ship/KeyPress_66.gml | 1 - scripts/scr_ChapterTraits/scr_ChapterTraits.gml | 10 +++++----- .../scr_boarding_actions/scr_boarding_actions.gml | 4 ++-- scripts/scr_kill_unit/scr_kill_unit.gml | 15 +++++++-------- .../scr_mission_functions.gml | 3 +-- .../scr_player_fleet_combat_functions.gml | 3 +-- 10 files changed, 24 insertions(+), 39 deletions(-) diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index 0b4e64dde7..534ad39fe2 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -1,9 +1,7 @@ var co = 0, i = 0, o = 0, _unit; -for (o = 0; o < array_length(origin.board_co); o++) { - co = origin.board_co[o]; - i = origin.board_id[o]; - _unit = fetch_unit([co, i]); +for (o = 0; o < array_length(origin.board_marine); o++) { + _unit = board_marine[o] if (!is_struct(_unit)) { continue; } diff --git a/objects/obj_p_assra/Step_0.gml b/objects/obj_p_assra/Step_0.gml index 85a09c87cf..3de8bd42ae 100644 --- a/objects/obj_p_assra/Step_0.gml +++ b/objects/obj_p_assra/Step_0.gml @@ -110,16 +110,14 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in ac = 0; dr = 1; - for (var o = 0; o < array_length(origin.board_co); o++) { + for (var o = 0; o < array_length(origin.board_marine); o++) { if (!instance_exists(target)) { exit; } - co = origin.board_co[o]; - i = origin.board_id[o]; ac = 0; dr = 1; - unit = fetch_unit([co, i]); + unit = board_marine[o]; if (!is_struct(unit)) { continue; } @@ -571,13 +569,8 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in if (experience > 0) { var new_exp, unit_exp, exp_roll; - for (var o = 0; o < array_length(origin.board_co); o++) { - co = origin.board_co[o]; - i = origin.board_id[o]; - unit = fetch_unit([co, i]); - if (!is_struct(unit)) { - continue; - } + for (var o = 0; o < array_length(origin.board_marine); o++) { + unit = board_marine[o]; unit_exp = unit.experience; exp_roll = irandom(150 + unit_exp) + 1; if (exp_roll >= unit_exp) { diff --git a/objects/obj_p_ship/Alarm_0.gml b/objects/obj_p_ship/Alarm_0.gml index 9df24b9a44..a4a1bfde82 100644 --- a/objects/obj_p_ship/Alarm_0.gml +++ b/objects/obj_p_ship/Alarm_0.gml @@ -192,8 +192,7 @@ for (var co = 0; co <= obj_ini.companies; co++) { } if (unit.ship_location == ship_id) { if (unit.is_boarder && unit.hp() > (unit.max_health() / 10)) { - array_push(board_co, co); - array_push(board_id, i); + array_push(board_marine,unit); array_push(board_location, 0); array_push(board_raft, 0); boarders += 1; diff --git a/objects/obj_p_ship/Create_0.gml b/objects/obj_p_ship/Create_0.gml index 28f8dc34da..cdf26687b0 100644 --- a/objects/obj_p_ship/Create_0.gml +++ b/objects/obj_p_ship/Create_0.gml @@ -57,8 +57,7 @@ weapon_ammo = array_create(SHIP_WEAPON_SLOTS, 0); weapon_range = array_create(SHIP_WEAPON_SLOTS, 0); weapon_minrange = array_create(SHIP_WEAPON_SLOTS, 0); -board_co = []; -board_id = []; +board_marine = []; board_location = []; board_raft = []; //alarm_set(0, 1); diff --git a/objects/obj_p_ship/KeyPress_66.gml b/objects/obj_p_ship/KeyPress_66.gml index 4dc1912204..d27e729b5c 100644 --- a/objects/obj_p_ship/KeyPress_66.gml +++ b/objects/obj_p_ship/KeyPress_66.gml @@ -22,4 +22,3 @@ if ((selected == 1) && (boarders > 0) && (board_cooldown <= 0) && (point_distanc create_boarding_craft(tar_final); } -// board_co[i]=0;board_id[i]=0;board_location[i]=0; diff --git a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml index 8596767765..f115079ba1 100644 --- a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml +++ b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml @@ -24,27 +24,27 @@ function get_department_head(head_type = eCHAPTER_DEPARTMENTS.HQ){ if (!role_compare(_unit, eROLE.CHAPTERMASTER)){ return undefined; } - break + break; case eCHAPTER_DEPARTMENTS.FORGE: if (_unit.role() != "Forge Master"){ return undefined; } - break + break; case eCHAPTER_DEPARTMENTS.CHAP: if (_unit.role() != "Master of Sanctity"){ return undefined; } - break + break; case eCHAPTER_DEPARTMENTS.APOTH: if (_unit.role() != "Master of the Apothecarion"){ return undefined; } - break + break; case eCHAPTER_DEPARTMENTS.LIB: if (_unit.role() != $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role}"){ return undefined; } - break + break; } return _unit diff --git a/scripts/scr_boarding_actions/scr_boarding_actions.gml b/scripts/scr_boarding_actions/scr_boarding_actions.gml index e8c716d424..ea618fd02c 100644 --- a/scripts/scr_boarding_actions/scr_boarding_actions.gml +++ b/scripts/scr_boarding_actions/scr_boarding_actions.gml @@ -13,13 +13,13 @@ function create_boarding_craft(target_ship) { var bear = instance_create(x, y, obj_p_assra); bear.apothecary = 0; - for (var o = 0; o < array_length(board_id); o++) { + for (var o = 0; o < array_length(board_marine); o++) { if ((board_id[o] != 0) && (board_location[o] == 0)) { board_raft[o] = bear; board_location[o] = -1; boarders -= 1; bear.boarders += 1; - unit = fetch_unit([board_co[o], board_id[o]]); + unit = board_marine[o]; if (!is_struct(unit)) { continue; } diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index cc0d5ea517..ecb9396f58 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -30,7 +30,13 @@ function scr_kill_unit() { for (var i = marine_number; i < _len; i++){ obj_ini.TTRPG[company][i].marine_number = i; } - + if (_is_astartes) { + if (IsSpecialist()) { + obj_controller.command -= 1; + } else { + obj_controller.marines -= 1; + } + } } catch (ex) { LOGGER.error($"company: {company}, unit_slot: {marine_number}"); ERROR_HANDLER.handle_exception(ex); @@ -58,12 +64,5 @@ function kill_and_recover(recover_equipment = true, gene_seed_collect = true) { obj_controller.gene_seed += recoverable_geneseed(); } - if (_is_astartes) { - if (IsSpecialist()) { - obj_controller.command -= 1; - } else { - obj_controller.marines -= 1; - } - } scr_kill_unit(); } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 801383abdf..bb342f8e1a 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -218,11 +218,10 @@ function problem_end_turn_checks() { return; } var alert_text = ""; - var _unit; if (irandom(100) > 33) { // Give all marines +3d6 corruption and reduce loyalty by 20*/ for (var co = 0; co <= obj_ini.companies; co++) { - for (var me = 0; me < array_length(obj_ini.TTRPG[co]); me++) { + for (var me = 0; me < company_length(co); me++) { var _unit = fetch_unit([co, me]); if (_unit.base_group != "astartes") { continue diff --git a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml index 1c411786a9..5e954e6f92 100644 --- a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml +++ b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml @@ -353,8 +353,7 @@ function setup_player_combat_ship() { } if (unit.ship_location == ship_id) { if (unit.is_boarder && unit.hp() > (unit.max_health() / 10)) { - array_push(board_co, co); - array_push(board_id, i); + array_push(board_marine, unit); array_push(board_location, 0); array_push(board_raft, 0); boarders += 1; From 3d5dda56dc8ddebd3885c8730973111b11f3aecb Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 16:40:48 +0100 Subject: [PATCH 66/82] elegently pass boarders between ship and assault craft --- objects/obj_p_assra/Create_0.gml | 1 + objects/obj_p_assra/Step_0.gml | 4 +- objects/obj_p_ship/Alarm_0.gml | 2 - objects/obj_p_ship/Create_0.gml | 2 - .../scr_boarding_actions.gml | 94 +++++++++++++------ .../scr_player_fleet_combat_functions.gml | 2 - 6 files changed, 67 insertions(+), 38 deletions(-) diff --git a/objects/obj_p_assra/Create_0.gml b/objects/obj_p_assra/Create_0.gml index a727206bef..632bfee016 100644 --- a/objects/obj_p_assra/Create_0.gml +++ b/objects/obj_p_assra/Create_0.gml @@ -13,6 +13,7 @@ firstest = 0; apothecary = 0; apothecary_had = 0; experience = 0; +occupants = []; action = "goto"; diff --git a/objects/obj_p_assra/Step_0.gml b/objects/obj_p_assra/Step_0.gml index 3de8bd42ae..6213be128f 100644 --- a/objects/obj_p_assra/Step_0.gml +++ b/objects/obj_p_assra/Step_0.gml @@ -110,7 +110,7 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in ac = 0; dr = 1; - for (var o = 0; o < array_length(origin.board_marine); o++) { + for (var o = 0; o < array_length(board_marine); o++) { if (!instance_exists(target)) { exit; } @@ -569,7 +569,7 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in if (experience > 0) { var new_exp, unit_exp, exp_roll; - for (var o = 0; o < array_length(origin.board_marine); o++) { + for (var o = 0; o < array_length(board_marine); o++) { unit = board_marine[o]; unit_exp = unit.experience; exp_roll = irandom(150 + unit_exp) + 1; diff --git a/objects/obj_p_ship/Alarm_0.gml b/objects/obj_p_ship/Alarm_0.gml index a4a1bfde82..6ec34e52bd 100644 --- a/objects/obj_p_ship/Alarm_0.gml +++ b/objects/obj_p_ship/Alarm_0.gml @@ -193,8 +193,6 @@ for (var co = 0; co <= obj_ini.companies; co++) { if (unit.ship_location == ship_id) { if (unit.is_boarder && unit.hp() > (unit.max_health() / 10)) { array_push(board_marine,unit); - array_push(board_location, 0); - array_push(board_raft, 0); boarders += 1; } // Loc 0: on origin ship diff --git a/objects/obj_p_ship/Create_0.gml b/objects/obj_p_ship/Create_0.gml index cdf26687b0..c388231432 100644 --- a/objects/obj_p_ship/Create_0.gml +++ b/objects/obj_p_ship/Create_0.gml @@ -58,6 +58,4 @@ weapon_range = array_create(SHIP_WEAPON_SLOTS, 0); weapon_minrange = array_create(SHIP_WEAPON_SLOTS, 0); board_marine = []; -board_location = []; -board_raft = []; //alarm_set(0, 1); diff --git a/scripts/scr_boarding_actions/scr_boarding_actions.gml b/scripts/scr_boarding_actions/scr_boarding_actions.gml index ea618fd02c..36018ca6c2 100644 --- a/scripts/scr_boarding_actions/scr_boarding_actions.gml +++ b/scripts/scr_boarding_actions/scr_boarding_actions.gml @@ -1,48 +1,82 @@ function create_boarding_craft(target_ship) { - var first = 0; - - for (var o = 0; o < array_length(board_id); o++) { - if ((board_id[o] != 0) && (board_location[o] == 0)) { - first = o; - break; - } - } board_cooldown = 45; - var bear = instance_create(x, y, obj_p_assra); - bear.apothecary = 0; + var _boarding_craft = instance_create(x, y, obj_p_assra); + _boarding_craft.apothecary = 0; for (var o = 0; o < array_length(board_marine); o++) { - if ((board_id[o] != 0) && (board_location[o] == 0)) { - board_raft[o] = bear; - board_location[o] = -1; - boarders -= 1; - bear.boarders += 1; - unit = board_marine[o]; - if (!is_struct(unit)) { - continue; - } - if (unit.IsSpecialist(SPECIALISTS_APOTHECARIES)) { - if ((unit.gear() == "Narthecium") && (unit.hp() >= 10)) { - bear.apothecary += 1; - } + + boarders--; + _boarding_craft.boarders++; + unit = board_marine[o]; + if (!is_struct(unit)) { + continue; + } + if (unit.IsSpecialist(SPECIALISTS_APOTHECARIES)) { + if ((unit.gear() == "Narthecium") && (unit.hp() >= 10)) { + _boarding_craft.apothecary += 1; } } - if (bear.boarders >= 20) { + array_push(_boarding_craft.board_marine unit); + if (_boarding_craft.boarders >= 20) { break; } } - bear.apothecary_had = bear.apothecary; + array_delete(board_marine,0, _boarding_craft.boarders); + _boarding_craft.apothecary_had = _boarding_craft.apothecary; - bear.target = target_ship; - bear.direction = direction; - bear.origin = self.id; - bear.speed = 4; - bear.firstest = first; + _boarding_craft.target = target_ship; + _boarding_craft.direction = direction; + _boarding_craft.origin = self.id; + _boarding_craft.speed = 4; + _boarding_craft.firstest = first; if (boarders <= 0) { obj_cursor.board = 0; } } + +function destroy_boarding_craft(){ + for (var o = 0; o < array_length(origin.board_marine); o++) { + var _unit = board_marine[o]; + if (!is_struct(_unit)) { + continue; + } + var _recover_gene = obj_fleet.capital + obj_fleet.frigate + obj_fleet.escort > 0; + if (_unit.hp() <= -15 && _unit.base_group == "astartes") { + var seed_lost = 0; + if (apothecary <= 0) { + if (_unit.IsSpecialist(SPECIALISTS_STANDARD)) { + obj_fleet.fallen_command += 1; + } else { + obj_fleet.fallen += 1; + } + + if (apothecary_had > 0) { + if (_unit.base_group == "astartes") { + seed_lost = _unit.recoverable_geneseed(); + } + } + + // obj_fleet.marines_lost+=1; + if (role_compare(_unit, eROLE.CHAPTERMASTER)) { + obj_controller.alarm[7] = 1; + if (global.defeat <= 1) { + global.defeat = 1; + } + } + if (_unit.weapon_one() == "Company Standard" || _unit.weapon_two() == "Company Standard") { + scr_loyalty("Lost Standard", "+"); + } + + _unit.kill(false, _recover_gene); + + } else if (apothecary > 0) { + _unit.add_or_sub_health(irandom_range(9, 14)); + apothecary -= 0.5; + } + } + } +} \ No newline at end of file diff --git a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml index 5e954e6f92..5fc48549c2 100644 --- a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml +++ b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml @@ -354,8 +354,6 @@ function setup_player_combat_ship() { if (unit.ship_location == ship_id) { if (unit.is_boarder && unit.hp() > (unit.max_health() / 10)) { array_push(board_marine, unit); - array_push(board_location, 0); - array_push(board_raft, 0); boarders += 1; } // Loc 0: on origin ship From 623fcd67520ba8f162108acf6c10529a799dd439 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 16:42:42 +0100 Subject: [PATCH 67/82] isssing variable declaration --- scripts/scr_kill_unit/scr_kill_unit.gml | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index ecb9396f58..5c58d3d1f2 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -30,6 +30,7 @@ function scr_kill_unit() { for (var i = marine_number; i < _len; i++){ obj_ini.TTRPG[company][i].marine_number = i; } + var _is_astartes = base_group == "astartes"; if (_is_astartes) { if (IsSpecialist()) { obj_controller.command -= 1; From 568d6f9b7627e1e00c3a26e9764f3353104b222e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 16:46:41 +0100 Subject: [PATCH 68/82] reove duplicated marine kill logic --- objects/obj_p_assra/Alarm_0.gml | 46 +------------------ .../scr_boarding_actions.gml | 27 +---------- 2 files changed, 2 insertions(+), 71 deletions(-) diff --git a/objects/obj_p_assra/Alarm_0.gml b/objects/obj_p_assra/Alarm_0.gml index 534ad39fe2..9afbac9bc3 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -1,45 +1 @@ -var co = 0, i = 0, o = 0, _unit; - -for (o = 0; o < array_length(origin.board_marine); o++) { - _unit = board_marine[o] - if (!is_struct(_unit)) { - continue; - } - var _recover_gene = obj_fleet.capital + obj_fleet.frigate + obj_fleet.escort > 0; - if (_unit.hp() <= -15 && _unit.base_group == "astartes") { - var seed_lost = 0; - if (apothecary <= 0) { - if (_unit.IsSpecialist(SPECIALISTS_STANDARD)) { - obj_fleet.fallen_command += 1; - } else { - obj_fleet.fallen += 1; - } - - if (apothecary_had > 0) { - if (_unit.base_group == "astartes") { - seed_lost = _unit.recoverable_geneseed(); - } - } - - // obj_fleet.marines_lost+=1; - if (role_compare(_unit, eROLE.CHAPTERMASTER)) { - obj_controller.alarm[7] = 1; - if (global.defeat <= 1) { - global.defeat = 1; - } - } - if (_unit.weapon_one() == "Company Standard" || _unit.weapon_two() == "Company Standard") { - scr_loyalty("Lost Standard", "+"); - } - - _unit.kill(false, _recover_gene); - - } else if (apothecary > 0) { - _unit.add_or_sub_health(irandom_range(9, 14)); - apothecary -= 0.5; - } - } -} - -/* */ -/* */ +destroy_boarding_craft(); \ No newline at end of file diff --git a/scripts/scr_boarding_actions/scr_boarding_actions.gml b/scripts/scr_boarding_actions/scr_boarding_actions.gml index 36018ca6c2..0d4cf11775 100644 --- a/scripts/scr_boarding_actions/scr_boarding_actions.gml +++ b/scripts/scr_boarding_actions/scr_boarding_actions.gml @@ -39,38 +39,13 @@ function create_boarding_craft(target_ship) { } function destroy_boarding_craft(){ - for (var o = 0; o < array_length(origin.board_marine); o++) { + for (var o = 0; o < array_length(board_marine); o++) { var _unit = board_marine[o]; if (!is_struct(_unit)) { continue; } var _recover_gene = obj_fleet.capital + obj_fleet.frigate + obj_fleet.escort > 0; if (_unit.hp() <= -15 && _unit.base_group == "astartes") { - var seed_lost = 0; - if (apothecary <= 0) { - if (_unit.IsSpecialist(SPECIALISTS_STANDARD)) { - obj_fleet.fallen_command += 1; - } else { - obj_fleet.fallen += 1; - } - - if (apothecary_had > 0) { - if (_unit.base_group == "astartes") { - seed_lost = _unit.recoverable_geneseed(); - } - } - - // obj_fleet.marines_lost+=1; - if (role_compare(_unit, eROLE.CHAPTERMASTER)) { - obj_controller.alarm[7] = 1; - if (global.defeat <= 1) { - global.defeat = 1; - } - } - if (_unit.weapon_one() == "Company Standard" || _unit.weapon_two() == "Company Standard") { - scr_loyalty("Lost Standard", "+"); - } - _unit.kill(false, _recover_gene); } else if (apothecary > 0) { From 699e7f66dc99eb47260875ad9b8d9ec4e74b235a Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 16:49:52 +0100 Subject: [PATCH 69/82] use occupannts, easier to read variable --- objects/obj_p_assra/Step_0.gml | 11 ++++------- scripts/scr_boarding_actions/scr_boarding_actions.gml | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/objects/obj_p_assra/Step_0.gml b/objects/obj_p_assra/Step_0.gml index 6213be128f..650b53240d 100644 --- a/objects/obj_p_assra/Step_0.gml +++ b/objects/obj_p_assra/Step_0.gml @@ -110,17 +110,14 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in ac = 0; dr = 1; - for (var o = 0; o < array_length(board_marine); o++) { + for (var o = 0; o < array_length(occupants); o++) { if (!instance_exists(target)) { exit; } ac = 0; dr = 1; - unit = board_marine[o]; - if (!is_struct(unit)) { - continue; - } + unit = occupants[o]; gear_bonus = 0; marine_bonus = 0; boarding_odds = 50; @@ -569,8 +566,8 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in if (experience > 0) { var new_exp, unit_exp, exp_roll; - for (var o = 0; o < array_length(board_marine); o++) { - unit = board_marine[o]; + for (var o = 0; o < array_length(occupants); o++) { + unit = occupants[o]; unit_exp = unit.experience; exp_roll = irandom(150 + unit_exp) + 1; if (exp_roll >= unit_exp) { diff --git a/scripts/scr_boarding_actions/scr_boarding_actions.gml b/scripts/scr_boarding_actions/scr_boarding_actions.gml index 0d4cf11775..a259348e52 100644 --- a/scripts/scr_boarding_actions/scr_boarding_actions.gml +++ b/scripts/scr_boarding_actions/scr_boarding_actions.gml @@ -18,7 +18,7 @@ function create_boarding_craft(target_ship) { _boarding_craft.apothecary += 1; } } - array_push(_boarding_craft.board_marine unit); + array_push(_boarding_craft.occupants unit); if (_boarding_craft.boarders >= 20) { break; } @@ -39,8 +39,8 @@ function create_boarding_craft(target_ship) { } function destroy_boarding_craft(){ - for (var o = 0; o < array_length(board_marine); o++) { - var _unit = board_marine[o]; + for (var o = 0; o < array_length(occupants); o++) { + var _unit = occupants[o]; if (!is_struct(_unit)) { continue; } From 13d2a1107aea5495d07d6ed27ba18c343df93f4f Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 16:56:11 +0100 Subject: [PATCH 70/82] final clean up on boarding --- scripts/scr_boarding_actions/scr_boarding_actions.gml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/scr_boarding_actions/scr_boarding_actions.gml b/scripts/scr_boarding_actions/scr_boarding_actions.gml index a259348e52..91c5c43885 100644 --- a/scripts/scr_boarding_actions/scr_boarding_actions.gml +++ b/scripts/scr_boarding_actions/scr_boarding_actions.gml @@ -9,7 +9,7 @@ function create_boarding_craft(target_ship) { boarders--; _boarding_craft.boarders++; - unit = board_marine[o]; + var unit = board_marine[o]; if (!is_struct(unit)) { continue; } @@ -18,7 +18,7 @@ function create_boarding_craft(target_ship) { _boarding_craft.apothecary += 1; } } - array_push(_boarding_craft.occupants unit); + array_push(_boarding_craft.occupants, unit); if (_boarding_craft.boarders >= 20) { break; } @@ -46,12 +46,12 @@ function destroy_boarding_craft(){ } var _recover_gene = obj_fleet.capital + obj_fleet.frigate + obj_fleet.escort > 0; if (_unit.hp() <= -15 && _unit.base_group == "astartes") { - _unit.kill(false, _recover_gene); + _unit.kill(false, _recover_gene); - } else if (apothecary > 0) { + if (apothecary > 0) { _unit.add_or_sub_health(irandom_range(9, 14)); apothecary -= 0.5; } - } + } } } \ No newline at end of file From 0ea6a2362868335158f6b1bff066d8f1c46d87ff Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 6 Aug 2026 17:17:02 +0100 Subject: [PATCH 71/82] remove legacy firstest variable --- objects/obj_p_assra/Create_0.gml | 1 - scripts/scr_boarding_actions/scr_boarding_actions.gml | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/objects/obj_p_assra/Create_0.gml b/objects/obj_p_assra/Create_0.gml index 632bfee016..14dc637b92 100644 --- a/objects/obj_p_assra/Create_0.gml +++ b/objects/obj_p_assra/Create_0.gml @@ -9,7 +9,6 @@ hp = 9999; boarders = 0; boarders_dead = 0; boarding = false; -firstest = 0; apothecary = 0; apothecary_had = 0; experience = 0; diff --git a/scripts/scr_boarding_actions/scr_boarding_actions.gml b/scripts/scr_boarding_actions/scr_boarding_actions.gml index 91c5c43885..32dad14f82 100644 --- a/scripts/scr_boarding_actions/scr_boarding_actions.gml +++ b/scripts/scr_boarding_actions/scr_boarding_actions.gml @@ -31,7 +31,6 @@ function create_boarding_craft(target_ship) { _boarding_craft.direction = direction; _boarding_craft.origin = self.id; _boarding_craft.speed = 4; - _boarding_craft.firstest = first; if (boarders <= 0) { obj_cursor.board = 0; @@ -46,11 +45,11 @@ function destroy_boarding_craft(){ } var _recover_gene = obj_fleet.capital + obj_fleet.frigate + obj_fleet.escort > 0; if (_unit.hp() <= -15 && _unit.base_group == "astartes") { - _unit.kill(false, _recover_gene); - if (apothecary > 0) { _unit.add_or_sub_health(irandom_range(9, 14)); apothecary -= 0.5; + } else { + _unit.kill(false, _recover_gene); } } } From e678d223f0522b5f65dab48a630481c2f1815b41 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 13:05:05 +0100 Subject: [PATCH 72/82] saving all hunky dory --- objects/obj_ini/Create_0.gml | 23 ++++++++++++------- scripts/ArtifactStruct/ArtifactStruct.gml | 4 ++-- .../artifact_functions/artifact_functions.gml | 3 --- .../scr_marine_struct/scr_marine_struct.gml | 2 +- .../scr_unit_quick_find_pane.gml | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 09b3113378..530c2a441e 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -173,17 +173,18 @@ serialize = function() { x, y, custom_advisors, - full_liveries: full_liveries, - company_liveries: company_liveries, - complex_livery_data: complex_livery_data, - squad_types: squad_types, + full_liveries, + company_liveries, + complex_livery_data, + squad_types, artifact_list: _artifact_list, marine_structs: _marines, squad_structs: squads, - equipment: equipment, - gene_slaves: gene_slaves, // squads // marines, - chapter_data: chapter_data, - chapter_squad_arrangement: chapter_squad_arrangement, + equipment, + gene_slaves, // squads // marines, + chapter_data, + chapter_squad_arrangement, + player_role_data, }; if (variable_instance_exists(self, "last_ship")) { @@ -322,6 +323,12 @@ deserialize = function(save_data) { for (var s = 0; s < array_length(_squad.members); s++){ _squad.members[s] = fetch_unit_uid(_squad.members[s]); } + + for (var s = array_length(_squad.members) - 1; s >= 0; s--){ + if (!is_struct(_squad.members[s])){ + array_delete(_squad.members, s, 1); + } + } } } diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index 0dbdc8fc52..1e5e507959 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -169,7 +169,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, identification_timer: __identification_timer, location_name: __location_name, ship_id: __ship_id, - bearer: __bearer, + bearer: is_struct(__bearer) ? __bearer.uid : "", custom_name: __custom_name, custom_description: __custom_description, }; @@ -186,7 +186,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, __identification_timer = data.identification_timer ?? 0; __location_name = data.location_name ?? ""; __ship_id = data.ship_id ?? -1; - __bearer = data.bearer.uid ?? undefined; + __bearer = data.bearer == "" ? undefined : fetch_unit_uid(data.bearer) ; __custom_name = data.custom_name ?? ""; __custom_description = data.custom_description ?? ""; diff --git a/scripts/artifact_functions/artifact_functions.gml b/scripts/artifact_functions/artifact_functions.gml index 4fcb630eb2..1cc248d169 100644 --- a/scripts/artifact_functions/artifact_functions.gml +++ b/scripts/artifact_functions/artifact_functions.gml @@ -329,9 +329,6 @@ function load_artifact_list(artifact_list) { if (arti.artifact_id > max_id) { max_id = arti.artifact_id; } - if (!is_undefined(arti.bearer)){ - arti.bearer = fetch_unit_uid(arti.bearer); - } } static_get(ArtifactStruct).__next_id = max_id + 1; diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 2f42186934..4007083a06 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -2387,5 +2387,5 @@ function fetch_unit_uid(uuid) { } } - return "none"; + return undefined; } diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index d182a87845..424298d4bf 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -319,7 +319,7 @@ function UnitQuickFindPanel() constructor { _mission_data.click_right = method(_mission_data, function() { var _unit = fetch_unit_uid(important_person); - if (_unit != "none") { + if (is_struct(_unit)) { var _unit_l = [_unit]; group_selection(_unit_l); } From 40c8ade3b10191312d9df450a1a19d0ddf329473 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 13:07:42 +0100 Subject: [PATCH 73/82] missinng reference --- scripts/scr_crusade/scr_crusade.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 36b3c89eee..b528455b8f 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -57,7 +57,7 @@ function scr_crusade() { var death_data = death_sets[$ type]; - for (co = 0; co <= companies; co++) { + for (co = 0; co <= obj_ini.companies; co++) { clean[co] = 0; } var total_ship_id = array_concat(capital_num, frigate_num, escort_num); From 92a1ab317c05b852eda1dc8110cbda445d08f052 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 13:10:54 +0100 Subject: [PATCH 74/82] remove legacy name checks --- scripts/scr_UnitGroup/scr_UnitGroup.gml | 7 ++----- scripts/scr_company_view/scr_company_view.gml | 2 +- scripts/scr_count_forces/scr_count_forces.gml | 2 +- scripts/scr_squads/scr_squads.gml | 20 +++++++++---------- scripts/scr_ui_manage/scr_ui_manage.gml | 2 +- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index e21895be1c..367c814358 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -831,11 +831,8 @@ function SearchConditions(data) constructor { static evaluate = function(unit) { self.unit = unit; - if (!is_struct(unit) || unit.name() == "") { - if (is_struct(unit)) { - unit.base_group = "none"; - // LOGGER.error($"Empty name! Unit:\n{unit}"); - } + if (!is_struct(unit)) { + LOGGER.error($"Not Real Unit! Unit:\n{unit}"); return false; } diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index 4b0998824e..fc2f068374 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -158,7 +158,7 @@ function scr_company_view(company) { for (var v = 0; v < _company_length; v++) { unit = fetch_unit([company, v]); - if (is_struct(unit) && unit.name() != "") { + if (is_struct(unit)) { unit_loc = unit.marine_location(); // Check if unit is on a lost ship diff --git a/scripts/scr_count_forces/scr_count_forces.gml b/scripts/scr_count_forces/scr_count_forces.gml index 36e1cd6bab..b8046ee983 100644 --- a/scripts/scr_count_forces/scr_count_forces.gml +++ b/scripts/scr_count_forces/scr_count_forces.gml @@ -15,7 +15,7 @@ function scr_count_forces(_unit_location, _target_location, _is_planet, _return_ for (var i = 0; i < array_length(obj_ini.TTRPG[_company]); i++) { var _unit = fetch_unit([_company, i]); - var _marine_exists = is_struct(_unit) && _unit.name() != ""; + var _marine_exists = is_struct(_unit); var _vehicle_exists = i < _veh_len; if (!_marine_exists && !_vehicle_exists) { diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index fe61156038..88cbd4c236 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -316,17 +316,15 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { } } if ((array_length(members) > 0) && is_struct(exp_unit)) { - if (exp_unit.name() != "") { - var new_role; - if (veteran == true) { - new_role = obj_ini.player_role_data[eROLE.VETERANSERGEANT].role; - } else { - new_role = obj_ini.player_role_data[eROLE.SERGEANT].role; - } - exp_unit.update_role(new_role); - if (irandom(1) == 0) { - exp_unit.add_trait("lead_example"); - } + var new_role; + if (veteran == true) { + new_role = obj_ini.player_role_data[eROLE.VETERANSERGEANT].role; + } else { + new_role = obj_ini.player_role_data[eROLE.SERGEANT].role; + } + exp_unit.update_role(new_role); + if (irandom(1) == 0) { + exp_unit.add_trait("lead_example"); } } }; diff --git a/scripts/scr_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index 734e6d6a54..4c4f0f641c 100644 --- a/scripts/scr_ui_manage/scr_ui_manage.gml +++ b/scripts/scr_ui_manage/scr_ui_manage.gml @@ -1117,7 +1117,7 @@ function scr_ui_manage() { } if (instance_exists(obj_controller) && is_struct(obj_controller.unit_focus)) { var selected_unit = obj_controller.unit_focus; - if ((selected_unit.name() != "") && (selected_unit.race() != 0)) { + if (selected_unit.race() != 0) { draw_set_alpha(1); if (obj_controller.unit_profile && !instance_exists(obj_popup)) { stats_displayed = true; From c8c0581191fe3dcdc03486b34d17c068b3c7748e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 13:23:42 +0100 Subject: [PATCH 75/82] uid search error --- scripts/scr_marine_struct/scr_marine_struct.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 4007083a06..09ed146813 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -2374,7 +2374,7 @@ function fetch_unit_careful(){ } function fetch_unit_uid(uuid) { - for (var i = 0; i < obj_ini.companies; i++) { + for (var i = 0; i <= obj_ini.companies; i++) { var _comp_length = array_length(obj_ini.TTRPG[i]); for (var s = 0; s < _comp_length; s++) { var _unit = fetch_unit([i, s]); From d89a62175aa694e7e5207cb8463b41f35c102aa7 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 14:44:53 +0100 Subject: [PATCH 76/82] update arti strucct --- scripts/ArtifactStruct/ArtifactStruct.gml | 85 ++++++++++++----------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index 1e5e507959..a4079c4f89 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -230,37 +230,41 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, var _type = get_type(); - var _unit = fetch_unit(__bearer); - if (is_struct(_unit)) { - switch (_type) { - case "weapon": - if (_unit.weapon_one(true) == artifact_id) { - _unit.update_weapon_one("", false, true); - } else if (_unit.weapon_two(true) == artifact_id) { - _unit.update_weapon_two("", false, true); - } - - break; - case "gear": - if (_unit.gear(true) == artifact_id) { - _unit.update_gear("", false, true); - } - - break; - case "armour": - if (_unit.armour(true) == artifact_id) { - _unit.update_armour("", false, true); - } - - break; - case "mobility": - if (_unit.mobility_item(true) == artifact_id) { - _unit.update_mobility_item("", false, true); - } - - break; - } + var _unit = __bearer; + if (!is_struct(_unit)) { + __bearer = undefined; + return; } + + switch (_type) { + case "weapon": + if (_unit.weapon_one(true) == artifact_id) { + _unit.update_weapon_one("", false, true); + } else if (_unit.weapon_two(true) == artifact_id) { + _unit.update_weapon_two("", false, true); + } + + break; + case "gear": + if (_unit.gear(true) == artifact_id) { + _unit.update_gear("", false, true); + } + + break; + case "armour": + if (_unit.armour(true) == artifact_id) { + _unit.update_armour("", false5, true); + } + + break; + case "mobility": + if (_unit.mobility_item(true) == artifact_id) { + _unit.update_mobility_item("", false, true); + } + + break; + } + }; /// @desc Equips this artifact on a unit; daemonic/chaos artifacts also apply corruption. @@ -383,7 +387,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, /// Derived from the bearer field (single source of truth). /// @returns {Bool} true if bearer is a valid unit reference array. static is_equipped = function() { - return is_array(__bearer); + return is_Struct(__bearer); }; // ###### Getters ###### @@ -443,9 +447,8 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, /// @returns {String} The bearer possession text, or empty string if not equipped. static get_bearer_text = function() { if (is_equipped()) { - var _unit = fetch_unit(__bearer); - if (is_struct(_unit)) { - return $"It is currently in the possession of {_unit.name_role()}."; + if (is_struct(__bearer)) { + return $"It is currently in the possession of {__bearer.name_role()}."; } } @@ -583,22 +586,22 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, if (!is_equipped()) { return undefined; } - - var _unit = fetch_unit(__bearer); - if (!is_struct(_unit)) { + if (!is_struct(__bearer)) { return undefined; } - if ((_unit.ship_location > -1) && (_unit.ship_location < array_length(obj_ini.ship))) { + //TODO unpgrade to use marine_location method of unit struct + + if ((__bearer.ship_location > -1) && (__bearer.ship_location < array_length(obj_ini.ship))) { return { - ship_id: _unit.ship_location, - location_name: obj_ini.ship[_unit.ship_location], + ship_id: __bearer.ship_location, + location_name: obj_ini.ship[__bearer.ship_location], }; } return { ship_id: -1, - location_name: _unit.location_string ?? "", + location_name: __bearer.location_string ?? "", }; }; From 0607012c33fd9e3a5338e01bde5496cede8bb617 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 14:48:23 +0100 Subject: [PATCH 77/82] typo --- scripts/ArtifactStruct/ArtifactStruct.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index a4079c4f89..3db94b8b32 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -387,7 +387,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, /// Derived from the bearer field (single source of truth). /// @returns {Bool} true if bearer is a valid unit reference array. static is_equipped = function() { - return is_Struct(__bearer); + return is_struct(__bearer); }; // ###### Getters ###### From f9caf93a8eb30be5a6f84ec64601e031031c7e14 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 14:55:19 +0100 Subject: [PATCH 78/82] easily kill_unit within unitgroup --- scripts/scr_UnitGroup/scr_UnitGroup.gml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 367c814358..c1e787453c 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -1,5 +1,6 @@ function UnitGroup(units = []) constructor { self.units = units; + killed = []; static number = function() { return array_length(units); @@ -166,19 +167,26 @@ function UnitGroup(units = []) constructor { return _exp_unit; }; + static kill_unit = function(index, equipment = true, gene_seed_collect = true){ + var _unit = units[index]; + _unit.kill(equipment, gene_seed_collect); + array_push(killed, _unit); + array_delete(units, index ,1); + } + static kill_percent = function(kill_percent, equipment = true, gene_seed_collect = true) { var _kill_numb = floor((kill_percent / 100) * number()); var _killed = 0; - var i = 0; - while (_killed < _kill_numb && i < number()) { + var i = number() - 1; + while (_killed < _kill_numb && i >= 0) { var _unit = units[i]; if (kill_percent < 100 && _unit.role() == active_roles()[eROLE.CHAPTERMASTER]) { i++; continue; } - _unit.kill(equipment, gene_seed_collect); + kill_unit(i, equipment, gene_seed_collect) _killed++; - i++; + i--; } }; From bf06db3e2f6b2712715840e75fb1e99fd33449e5 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 14:58:35 +0100 Subject: [PATCH 79/82] remove legcay checks --- scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index 424298d4bf..1b5e0b365e 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -73,7 +73,7 @@ function UnitQuickFindPanel() constructor { }; static evaluate_unit_for_garrison_log = function(unit) { - if (!is_struct(unit) || unit.name() == "" || !unit.controllable()) { + if (!unit.controllable()) { return; } var unit_location = unit.marine_location(); @@ -132,7 +132,7 @@ function UnitQuickFindPanel() constructor { obj_controller.specialist_point_handler.calculate_research_points(false); ship_count = array_length(obj_ini.ship_carrying); for (var co = 0; co <= obj_ini.companies; co++) { - for (var u = 0; u < array_length(obj_ini.TTRPG[co]); u++) { + for (var u = 0; u < company_length(co); u++) { /// @type {Struct.TTRPG_stats} var _unit = fetch_unit([co, u]); if (!is_struct(_unit)) { From fcc708915f157b1ea30d2c2579046a37da3587be Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 7 Aug 2026 15:00:35 +0100 Subject: [PATCH 80/82] indexing error --- scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml index 26cfcfebba..470e231e2d 100644 --- a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml +++ b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml @@ -77,7 +77,7 @@ function setup_complex_livery_shader(setup_role, unit = "none") { data_set = _full_liveries[eROLE.CHAPLAIN]; } } else { - for (var i = 0; i <= 20; i++) { + for (var i = 0; i < array_length(_roles); i++) { if (_roles[i] == setup_role) { data_set = _full_liveries[i]; break; From 373db0d504f2c34c4d5516ab747ad5b7ca266083 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:26:14 +0100 Subject: [PATCH 81/82] Update scripts/ArtifactStruct/ArtifactStruct.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/ArtifactStruct/ArtifactStruct.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index 3db94b8b32..23add858c4 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -253,7 +253,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, break; case "armour": if (_unit.armour(true) == artifact_id) { - _unit.update_armour("", false5, true); + _unit.update_armour("", false, true); } break; From cbc2c0552e56ce9102d738692d104ce3ef3faa8e Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:26:36 +0100 Subject: [PATCH 82/82] Update scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml index 470e231e2d..fe6742cba7 100644 --- a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml +++ b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml @@ -77,7 +77,7 @@ function setup_complex_livery_shader(setup_role, unit = "none") { data_set = _full_liveries[eROLE.CHAPLAIN]; } } else { - for (var i = 0; i < array_length(_roles); i++) { + for (var i = 0; i < array_length(_roles) && i < array_length(_full_liveries); i++) { if (_roles[i] == setup_role) { data_set = _full_liveries[i]; break;