diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 5e78d5f4c2..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,15 +856,12 @@ {"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_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",},}, {"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",},}, @@ -894,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",},}, @@ -921,7 +916,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",},}, @@ -957,8 +951,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/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/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/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 4c28d71f51..9eab443f1d 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; @@ -476,12 +477,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", "+"); } @@ -580,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 != -1 & 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/Alarm_6.gml b/objects/obj_controller/Alarm_6.gml index 1c8b3d7a04..fdfb119493 100644 --- a/objects/obj_controller/Alarm_6.gml +++ b/objects/obj_controller/Alarm_6.gml @@ -32,45 +32,45 @@ 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]) { + } 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.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]) { + } 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.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]) { + } else if (unit.role() == obj_ini.player_role_data[eROLE.SERGEANT].role) { 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,35 +100,35 @@ 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"; } 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"; } 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"; } 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,21 +149,21 @@ 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"; } 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"; } 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"; } @@ -177,56 +177,56 @@ 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"; } 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"; } 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"; } 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"; } 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/Create_0.gml b/objects/obj_controller/Create_0.gml index 0d748405d8..d92fed3703 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; @@ -449,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 = ""; @@ -776,7 +736,7 @@ if (instance_exists(obj_ini)) { } } -chapter_master = new scr_chapter_master(); +chapter_master = new ChapterMaster(); trade_attempt = false; // ** Sets income ** @@ -1357,11 +1317,7 @@ 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) { @@ -1369,16 +1325,17 @@ if (global.load == -1) { } // **** 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] = string_upper(obj_ini.name[0][0]); // 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 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) { @@ -1387,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 ", }, ]; @@ -1419,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} {obj_ini.name[0][_officer.name_slot]}"); + 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/Mouse_50.gml b/objects/obj_controller/Mouse_50.gml index 27d51eaff8..79a3bac536 100644 --- a/objects/obj_controller/Mouse_50.gml +++ b/objects/obj_controller/Mouse_50.gml @@ -15,12 +15,13 @@ 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]) { + var _unit = fetch_unit([c,e]); + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { alarm[7] = 5; global.defeat = 3; } // TODO Needs to be based on role - kill_and_recover(c, e); + _unit.kill(); diplo_char = c; with (obj_ini) { scr_company_order(obj_controller.diplo_char); @@ -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 b6d84a16b7..70d844ece9 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 = ""; @@ -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; @@ -490,7 +487,8 @@ 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)) { + var _cm = chapter_master.get_struct(); + if (!role_compare(_cm, 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 4f53d1ace1..ec4aec314f 100644 --- a/objects/obj_creation/Create_0.gml +++ b/objects/obj_creation/Create_0.gml @@ -542,28 +542,9 @@ 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] = ""; - } -} - -defaults_slot = 100; +player_role_data = []; +setup_default_gears(); +player_role_data = variable_clone(default_role_data) /// @description /// @param {Real} _role_id @@ -573,34 +554,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", "", ""); -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, "", ""); 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_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index b28c015ee4..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); @@ -163,15 +164,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 +228,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 +259,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/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_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_dropdown_sel/Step_0.gml b/objects/obj_dropdown_sel/Step_0.gml index e0410f2c7d..b9b66dee76 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_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_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_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index ecb5427e5f..530c2a441e 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; @@ -104,36 +106,9 @@ 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, []); -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; -}; company_spawn_buffs = []; role_spawn_buffs = {}; @@ -164,10 +139,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); } } @@ -181,22 +154,37 @@ 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[s])){ + _squad.members[i] = _squad.members[s].uid; + } + } + } + var save_data = { obj: object_get_name(object_index), 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")) { @@ -207,7 +195,6 @@ serialize = function() { "temp", "serialize", "deserialize", - "load_default_gear", "role_spawn_buffs", "TTRPG", "squads", @@ -222,6 +209,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; }; @@ -244,7 +236,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 @@ -300,9 +293,10 @@ 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++) { - TTRPG[_coy][_mar] = new TTRPG_stats("chapter", _coy, _mar, "blank"); + 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; } } @@ -313,9 +307,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"); - } } } @@ -329,6 +320,15 @@ 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[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/objects/obj_mass_equip/Step_0.gml b/objects/obj_mass_equip/Step_0.gml index b5872660b0..8600334074 100644 --- a/objects/obj_mass_equip/Step_0.gml +++ b/objects/obj_mass_equip/Step_0.gml @@ -9,88 +9,89 @@ 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 (!is_struct(_unit)) { + continue; + } + if (!role_compare(_unit, role)) { + 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 ** } @@ -129,96 +130,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 (is_struct(_wep2) || _wep2 == req_wep1 && !_wep_two_found){ + have_wep2_num++; + } - if (string_count("&", obj_ini.armour[co][i]) > 0) { + 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("&", _armour) > 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]); + } + } } } @@ -254,7 +256,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_1.gml b/objects/obj_ncombat/Alarm_1.gml index c2a3b31708..56bfaf50c5 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -163,39 +163,39 @@ 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)) { 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, "; } } 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,62 +210,62 @@ 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)) { 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) { @@ -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_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 358c008487..ddb5fd844d 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -19,7 +19,7 @@ try { var nco = dude_co[q]; var nid = dude_id[q]; cleann[nco] = true; - var _unit = obj_ini.TTRPG[nco][nid]; + var _unit = fetch_unit([nco,nid]); commandy = _unit.IsSpecialist(); if (commandy == true) { @@ -29,10 +29,10 @@ 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; - kill_and_recover(nco, nid, recover, recover); + _unit.kill(recover, recover); } } } @@ -54,42 +54,33 @@ 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.role[100][eROLE.CHAPTERMASTER]); - var _fetched_chaos = fetch_unit([0, master_index]); + var _fetched_chaos = cm_obj().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; + 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.role[100][6]) && (obj_ini.role[co][i] != "Venerable " + string(obj_ini.role[100][6]))) { - good += 1; - } - if ((string_count("Dread", _unit.armour()) == 0) || (obj_ini.role[co][i] == obj_ini.role[100][eROLE.CHAPTERMASTER])) { - good += 1; + if (_unit.planet_location != floor(_chaos_meeting)) { + continue; } - 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; - if (obj_ini.role[co][i] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { - master_present = 1; - } + if (_unit.is_dreadnought() && !(role_compare(_unit, eROLE.CHAPTERMASTER))){ + 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 36b035da7b..9afbac9bc3 100644 --- a/objects/obj_p_assra/Alarm_0.gml +++ b/objects/obj_p_assra/Alarm_0.gml @@ -1,49 +1 @@ -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)) { - continue; - } - if (unit.hp() <= -15 && obj_ini.race[co][i] == 1) { - 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 (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") { - scr_loyalty("Lost Standard", "+"); - } - - 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)); - apothecary -= 0.5; - } - } -} - -/* */ -/* */ +destroy_boarding_craft(); \ No newline at end of file diff --git a/objects/obj_p_assra/Create_0.gml b/objects/obj_p_assra/Create_0.gml index a727206bef..14dc637b92 100644 --- a/objects/obj_p_assra/Create_0.gml +++ b/objects/obj_p_assra/Create_0.gml @@ -9,10 +9,10 @@ hp = 9999; boarders = 0; boarders_dead = 0; boarding = false; -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 87aa539672..650b53240d 100644 --- a/objects/obj_p_assra/Step_0.gml +++ b/objects/obj_p_assra/Step_0.gml @@ -110,19 +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(occupants); 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]); - if (!is_struct(unit)) { - continue; - } + unit = occupants[o]; gear_bonus = 0; marine_bonus = 0; boarding_odds = 50; @@ -199,7 +194,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 +206,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); } } @@ -571,13 +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(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(occupants); o++) { + unit = occupants[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 39392fdeee..6ec34e52bd 100644 --- a/objects/obj_p_ship/Alarm_0.gml +++ b/objects/obj_p_ship/Alarm_0.gml @@ -185,27 +185,21 @@ 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++) { - 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; } 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_location, 0); - array_push(board_raft, 0); + array_push(board_marine,unit); boarders += 1; } // Loc 0: on origin 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/objects/obj_p_ship/Create_0.gml b/objects/obj_p_ship/Create_0.gml index 28f8dc34da..c388231432 100644 --- a/objects/obj_p_ship/Create_0.gml +++ b/objects/obj_p_ship/Create_0.gml @@ -57,8 +57,5 @@ 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_location = []; -board_raft = []; +board_marine = []; //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/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_pnunit/Alarm_6.gml b/objects/obj_pnunit/Alarm_6.gml index 62ac8b4e7f..dad1ebdbf4 100644 --- a/objects/obj_pnunit/Alarm_6.gml +++ b/objects/obj_pnunit/Alarm_6.gml @@ -21,7 +21,7 @@ for (var i = 0; i < array_length(unit_struct); i++) { if (unit.ship_location > -1) { obj_ini.ship_carrying[unit.ship_location] -= man_size; } - scr_kill_unit(unit.company, unit.marine_number); + unit.kill(false, false); } } diff --git a/objects/obj_popup/Create_0.gml b/objects/obj_popup/Create_0.gml index eedec39c70..e5c57e89ad 100644 --- a/objects/obj_popup/Create_0.gml +++ b/objects/obj_popup/Create_0.gml @@ -129,66 +129,66 @@ 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.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") { + } 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; } 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) { + 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; - 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; } 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; @@ -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,38 +230,38 @@ 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 { 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; - 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/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..7e719d21ae 100644 --- a/objects/obj_star_select/Draw_64.gml +++ b/objects/obj_star_select/Draw_64.gml @@ -300,7 +300,9 @@ 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 + 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/Armamentarium/Armamentarium.gml b/scripts/Armamentarium/Armamentarium.gml index fefa1964ef..2d3a495ca6 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; @@ -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); }; @@ -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/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index 8a063ddd32..23add858c4 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 ?? undefined; + __bearer = data.bearer == "" ? undefined : fetch_unit_uid(data.bearer) ; __custom_name = data.custom_name ?? ""; __custom_description = data.custom_description ?? ""; @@ -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("", false, 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. @@ -290,7 +294,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"; @@ -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 ?? "", }; }; 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/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/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_ChapterTraits/scr_ChapterTraits.gml b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml index 2cabf3746f..f115079ba1 100644 --- a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml +++ b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml @@ -3,6 +3,53 @@ 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){ + var _unit = undefined; + if (head_type < array_length(obj_ini.TTRPG[0])){ + _unit = fetch_unit([0, head_type]); + } else { + return undefined; + } + + switch(head_type){ + case 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 +} + 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_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 38cd93048a..c1e787453c 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -1,5 +1,6 @@ -function UnitGroup(units) constructor { +function UnitGroup(units = []) constructor { self.units = units; + killed = []; static number = function() { return array_length(units); @@ -13,6 +14,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) { @@ -41,6 +46,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); @@ -69,6 +82,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= 0) { var _unit = units[i]; if (kill_percent < 100 && _unit.role() == active_roles()[eROLE.CHAPTERMASTER]) { i++; continue; } - kill_and_recover(_unit.company, _unit.marine_number, equipment, gene_seed_collect); + kill_unit(i, equipment, gene_seed_collect) _killed++; - i++; + i--; } }; @@ -270,13 +329,13 @@ function UnitGroup(units) constructor { if (squad_fulfilment[$ _unit.role()] < _max) { //if sergeants not required squad_fulfilment[$ _unit.role()]++; - squad.add_member(_unit.company, _unit.marine_number); + squad.add_member(_unit); } } //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.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; @@ -780,11 +839,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; } @@ -866,10 +922,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_add_corruption/scr_add_corruption.gml b/scripts/scr_add_corruption/scr_add_corruption.gml index 878da9acc2..5f34031328 100644 --- a/scripts/scr_add_corruption/scr_add_corruption.gml +++ b/scripts/scr_add_corruption/scr_add_corruption.gml @@ -22,10 +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++) { - if (obj_ini.name[co][i] == "") { - continue; - } + 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_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index 1f32fb66b8..fd18b44884 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -26,44 +26,36 @@ 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"); 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) @@ -73,41 +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)) { - 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], - }; + if (man_role == obj_ini.player_role_data[eROLE.SCOUT].role) { + _gear = obj_ini.player_role_data[eROLE.SCOUT]; } _unit = new TTRPG_stats("chapter", target_company, _company_slot, "scout", other_data); @@ -117,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_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index a6e551dc0a..073ca03531 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; @@ -354,7 +354,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_apothecarium/scr_apothecarium.gml b/scripts/scr_apothecarium/scr_apothecarium.gml index d46e4d8bad..544105a0c7 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); @@ -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); @@ -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_apothecary_ground/scr_apothecary_ground.gml b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml index e12474d8d7..aea868906c 100644 --- a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml +++ b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml @@ -24,83 +24,83 @@ 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 _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++) { 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_bionics_count/scr_bionics_count.gml b/scripts/scr_bionics_count/scr_bionics_count.gml deleted file mode 100644 index 61776799dc..0000000000 --- a/scripts/scr_bionics_count/scr_bionics_count.gml +++ /dev/null @@ -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_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_boarding_actions/scr_boarding_actions.gml b/scripts/scr_boarding_actions/scr_boarding_actions.gml index e8c716d424..32dad14f82 100644 --- a/scripts/scr_boarding_actions/scr_boarding_actions.gml +++ b/scripts/scr_boarding_actions/scr_boarding_actions.gml @@ -1,48 +1,56 @@ 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; - - for (var o = 0; o < array_length(board_id); 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]]); - if (!is_struct(unit)) { - continue; - } - if (unit.IsSpecialist(SPECIALISTS_APOTHECARIES)) { - if ((unit.gear() == "Narthecium") && (unit.hp() >= 10)) { - bear.apothecary += 1; - } + var _boarding_craft = instance_create(x, y, obj_p_assra); + _boarding_craft.apothecary = 0; + + for (var o = 0; o < array_length(board_marine); o++) { + + boarders--; + _boarding_craft.boarders++; + var 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.occupants, 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; if (boarders <= 0) { obj_cursor.board = 0; } } + +function destroy_boarding_craft(){ + for (var o = 0; o < array_length(occupants); o++) { + var _unit = occupants[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") { + if (apothecary > 0) { + _unit.add_or_sub_health(irandom_range(9, 14)); + apothecary -= 0.5; + } else { + _unit.kill(false, _recover_gene); + } + } + } +} \ No newline at end of file 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_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index e390360f0b..ae84f28819 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -74,7 +74,7 @@ function tech_uprising_event_aftermath() { } if (purge_target != noone) { for (var tal = 0; tal < array_length(purge_target); tal++) { - kill_and_recover(purge_target[tal].company, purge_target[tal].marine_number); + purge_target[tal].kill(); } } } @@ -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); } } @@ -272,8 +272,8 @@ 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); } + scr_company_order(0); } } 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_chapter_new/scr_chapter_new.gml b/scripts/scr_chapter_new/scr_chapter_new.gml index 38def22277..54ea349d1e 100644 --- a/scripts/scr_chapter_new/scr_chapter_new.gml +++ b/scripts/scr_chapter_new/scr_chapter_new.gml @@ -210,36 +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; - } - }; - - 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(); + 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_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..c236fa3959 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 @@ -43,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; @@ -105,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; } } @@ -140,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.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) { @@ -163,71 +162,71 @@ 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; } - 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() == 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 (_unit.mobility_item() == "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; @@ -268,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; } @@ -280,27 +279,27 @@ 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; } 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; } } @@ -310,27 +309,27 @@ 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 (_unit.mobility_item() == "Jump Pack") { col = 22 - obj_controller.bat_assault_column; } } - 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(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) { @@ -362,15 +361,15 @@ 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_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_hp[targ.men] = _unit.hp(); + targ.dudes_exp[targ.men] = _unit.experience; + 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] = _unit.gear(); + targ.dudges_mobi[targ.men] = _unit.mobility_item(); new_combat.enemy_forces += 1; new_combat.enemy_max += 1; @@ -392,101 +391,55 @@ 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) { - 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 (deploying_unit.armour[co][v] == "Scout Armour") { - targ.dudes_ac[targ.men] = 8; - } - if (deploying_unit.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") { - 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") { - 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") { - targ.dudes_ac[targ.men] = 18; - targ.dudes_ranged[targ.men] += 0.1; - } - if (deploying_unit.armour[co][v] == "MK7 Aquila") { - targ.dudes_ac[targ.men] = 18; - } - if (deploying_unit.armour[co][v] == "MK8 Errant") { - targ.dudes_ac[targ.men] = 19; - } - if (deploying_unit.armour[co][v] == "Power Armour") { - targ.dudes_ac[targ.men] = 19; - } - if (deploying_unit.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") { - 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") { - 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") { - targ.dudes_ac[targ.men] = 40; - } - if (deploying_unit.armour[co][v] == "Ork Armour") { - targ.dudes_ac[targ.men] = 15; + 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; + arg.dudes_attack += _armour_data.melee_mod/100; } - if (deploying_unit.wep1[co][v] == "Boarding Shield") { + if (_unit.weapon_one() == "Boarding Shield") { targ.dudes_ac[targ.men] += 4; } - if (deploying_unit.wep2[co][v] == "Boarding Shield") { + if (_unit.weapon_two() == "Boarding Shield") { targ.dudes_ac[targ.men] += 4; } - if (deploying_unit.wep1[co][v] == "Storm Shield") { + if (_unit.weapon_one() == "Storm Shield") { targ.dudes_ac[targ.men] += 8; } - if (deploying_unit.wep2[co][v] == "Storm Shield") { + if (_unit.weapon_two() == "Storm Shield") { targ.dudes_ac[targ.men] += 8; } - if (string_count("&", deploying_unit.armour[co][v]) > 0) { + if (string_count("&", _unit.armour()) > 0) { // Artifact armour - if (string_count("Power", deploying_unit.armour[co][v]) > 0) { + if (string_count("Power", _unit.armour()) > 0) { targ.dudes_ac[targ.men] = 30; } - if (string_count("Artificer", deploying_unit.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", deploying_unit.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", deploying_unit.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) { @@ -507,26 +460,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 (_unit.mobility_item() == "Bike") { targ.dudes_hp[targ.men] += 25; } - if (deploying_unit.wep1[cooh][va] == "Boarding Shield") { + if (_unit.weapon_one() == "Boarding Shield") { targ.dudes_hp[targ.men] += 20; } - if (deploying_unit.wep2[cooh][va] == "Boarding Shield") { + if (_unit.weapon_two() == "Boarding Shield") { targ.dudes_hp[targ.men] += 20; } - if (deploying_unit.wep1[cooh][va] == "Storm Shield") { + if (_unit.weapon_one() == "Storm Shield") { targ.dudes_hp[targ.men] += 30; } - if (deploying_unit.wep2[cooh][va] == "Storm Shield") { + if (_unit.weapon_two() == "Storm Shield") { targ.dudes_hp[targ.men] += 30; } - if (deploying_unit.wep2[cooh][va] == "Iron Halo") { + if (_unit.weapon_two() == "Iron Halo") { targ.dudes_hp[targ.men] += 20; } @@ -544,71 +497,71 @@ 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; } - 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() == 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 +574,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 (_unit.mobility_item() == "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; @@ -649,10 +602,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; } @@ -661,27 +614,27 @@ 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; } 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; } } @@ -691,37 +644,37 @@ 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 (_unit.mobility_item() == "Jump Pack") { col = obj_controller.bat_assault_column; } } - 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; - 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(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) { @@ -736,27 +689,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_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 2204338406..d166b55e66 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 < company_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 @@ -106,48 +124,10 @@ function scr_company_order(company) { _company_marines.order_by_rank(); - var _squads = _company_marines.count_squads("all", true); - - 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, 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] = _company_marines.units; - 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(); - array_push(_squad.members, [co, i]); - } - _struc.movement_after_math(co, i, false); + for (var i = 0; i < array_length(TTRPG[co]); i++) { + TTRPG[co][i].marine_number = i; } } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); @@ -155,7 +135,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 5582a14eb7..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; } @@ -424,7 +424,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]; @@ -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; @@ -550,10 +549,9 @@ 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"; + 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_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index f4c25b1e27..fc2f068374 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -43,24 +43,16 @@ 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.TTRPG[target_company]); + for (var i = 0; i < _company_length; i++) { + if (is_undefined(obj_ini.TTRPG[target_company][i])) { 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; + good = _company_length; } return good; } @@ -161,12 +153,12 @@ 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() != "") { + if (is_struct(unit)) { unit_loc = unit.marine_location(); // Check if unit is on a lost ship @@ -263,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) { @@ -326,15 +318,15 @@ 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])) { + } 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_complex_colour_kit/scr_complex_colour_kit.gml b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml index e67c0e8b57..fe6742cba7 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]; @@ -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 < array_length(_full_liveries); i++) { if (_roles[i] == setup_role) { data_set = _full_liveries[i]; break; diff --git a/scripts/scr_controller_helpers/scr_controller_helpers.gml b/scripts/scr_controller_helpers/scr_controller_helpers.gml index a24d49d345..417d7d5a21 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,12 +258,12 @@ 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) { menu = eMENU.LIBRARIUM; - 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_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_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_creation/scr_creation.gml b/scripts/scr_creation/scr_creation.gml index a5002329ec..a717bc17bb 100644 --- a/scripts/scr_creation/scr_creation.gml +++ b/scripts/scr_creation/scr_creation.gml @@ -64,11 +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++) { - if (race[100][i] != 0 && role[100][i] != "") { - array_push(_role_data, {str1: role[100][i], font: fnt_40k_14b, role_id: 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_choice_array, {str1: _role_data.role, font: fnt_40k_14b, role_id: i}); } } @@ -78,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; } @@ -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_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 1ba2035635..b528455b8f 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; @@ -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); @@ -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.role[100][5]) { - 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.role[100][11] || unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + } 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--; @@ -119,18 +119,17 @@ function scr_crusade() { clean[co] = 1; marines_lost++; - scr_kill_unit(co, i); - seed += 2; + unit.kill(false, true); } 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())); } } } @@ -182,10 +181,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..b826c5d24d 100644 --- a/scripts/scr_culture_visuals/scr_culture_visuals.gml +++ b/scripts/scr_culture_visuals/scr_culture_visuals.gml @@ -2206,20 +2206,22 @@ function DummyMarine() constructor { return "jeff"; }; + 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 role[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; - } else { - return role[100][eROLE.TACTICAL]; - } + + 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 wep1[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; - } + return obj_creation.player_role_data[role_index()].wep1; }; static race = function() { @@ -2227,9 +2229,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 obj_creation.player_role_data[role_index()].wep2; }; last_armour = "MK7 Aquila"; @@ -2238,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 = armour[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; - 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; @@ -2263,19 +2263,15 @@ function DummyMarine() constructor { }; static gear = function() { - with (obj_creation) { - return gear[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; - } + return obj_creation.player_role_data[role_index()].gear; }; static mobility_item = function() { - with (obj_creation) { - return mobi[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; - } + 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_destroy_planet/scr_destroy_planet.gml b/scripts/scr_destroy_planet/scr_destroy_planet.gml index 2acc46780f..2a67d8c8c1 100644 --- a/scripts/scr_destroy_planet/scr_destroy_planet.gml +++ b/scripts/scr_destroy_planet/scr_destroy_planet.gml @@ -41,20 +41,20 @@ 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; } 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) { @@ -65,7 +65,7 @@ function scr_destroy_planet(destruction_method) { } } - scr_kill_unit(cah, ed); + unit.kill(false, false); } if (ed < 200) { if ((obj_ini.veh_loc[cah][ed] == you.name) && (obj_ini.veh_wid[cah][ed] == baid)) { diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index 8d6a709ffb..ee894c4e08 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; } } @@ -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"; @@ -180,7 +182,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; } } @@ -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|"; } @@ -346,12 +350,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.role[100][eROLE.CHAPTERMASTER]) { - 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_diplomacy_helpers/scr_diplomacy_helpers.gml b/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml index cf80eacfdb..35fbf2faa2 100644 --- a/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml +++ b/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml @@ -277,7 +277,7 @@ function scr_emmisary_diplomacy_routes() { pop_up.text = $"You summon {dead_lib.name_role()} to your personal chambers. Darting from the shadows you deftly strike his head from his shoulders. With the flesh removed from his skull you place the skull upon a hastily erected shrine."; pop_up.type = 98; pop_up.image = "chaos"; - kill_and_recover(lib[0], lib[1]); + dead_lib.kill(); chapter_master.add_trait("blood_for_blood"); chapter_master.edit_corruption(20); } else { @@ -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"); @@ -301,7 +301,7 @@ function scr_emmisary_diplomacy_routes() { pop_up.text = $"You summon {dead_champ.name_role()} to your personal chambers. Darting from the shadows towards {dead_champ.name()} who is a cunning warrior and reacts with precision to your attack, however eventually you prevail and strike him down. With the flesh removed from his skull you place it upon a hastily erected shrine."; pop_up.type = 98; pop_up.image = "chaos"; - kill_and_recover(champ[0], champ[1]); + dead_champ.kill(); } else { diplomacy_pathway = "daemon_scorn"; } 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_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 d6880545f9..748b7d7e55 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -156,17 +156,19 @@ 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."); + 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) { 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..633128f09a 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -742,26 +742,26 @@ 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++) { + 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]); - if (!is_struct(_unit)) { + var _is_at_chaos_meeting = _unit.planet_location == floor(chaos_meeting); + if (_unit.is_dreadnought() && !role_compare(_unit, eROLE.CHAPTERMASTER)){ 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.role[100][6]; - var _unit_is_not_venerable = _unit.role() != "Venerable " + string(obj_ini.role[100][6]); - 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]; - 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)) { + if (_unit.location_string != name){ + continue; + } + + + if (_is_at_chaos_meeting){ _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]) { - master_present = true; + if (co == 0 && i == 0) { + master_present = role_compare(_unit, eROLE.CHAPTERMASTER); } } } 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_event_code/scr_event_code.gml b/scripts/scr_event_code/scr_event_code.gml index e1f35ae27a..2386994d3c 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 {fetch_artifact(_last_artifact).get_type_name()} 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,11 +203,11 @@ 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 - scr_kill_unit(comp, marine_num); + _unit.kill(false, false); with (obj_ini) { scr_company_order(0); } @@ -217,7 +217,8 @@ function event_end_turn_action() { { str1: "Execute the heretic", choice_func: function() { - scr_kill_unit(pop_data.company, pop_data.marine_number); + var _unit = fetch_unit([pop_data.company, pop_data.marine_number]); + _unit.kill(false, false); var company_to_order = pop_data.company; with (obj_ini) { scr_company_order(company_to_order); diff --git a/scripts/scr_event_dudes/scr_event_dudes.gml b/scripts/scr_event_dudes/scr_event_dudes.gml index a82c2e2a78..db53deadd9 100644 --- a/scripts/scr_event_dudes/scr_event_dudes.gml +++ b/scripts/scr_event_dudes/scr_event_dudes.gml @@ -27,54 +27,31 @@ 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; - repeat (300) { - 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; - if (obj_ini.name[coh][ide] == "") { - continue; - } - unit = fetch_unit([coh, ide]); - if (!is_struct(unit)) { - continue; - } + var _unit = fetch_unit([coh, ide]); + - if ((is_planet == 0) && (unit.ship_location == location_id)) { - if ((obj_ini.race[coh][ide] == 1) || (obj_ini.race[coh][ide] == 5)) { + 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)) { - if ((obj_ini.race[coh][ide] == 1) || (obj_ini.race[coh][ide] == 5)) { + } 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.role[100][6]) { - adding = false; - } - if (obj_ini.role[coh][ide] == "Venerable " + string(obj_ini.role[100][6])) { - adding = false; - } - if (string_count("Dread", obj_ini.armour[coh][ide]) > 0) { + if (_unit.is_dreadnought()) { adding = false; } @@ -85,7 +62,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; } @@ -93,7 +70,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; } @@ -102,15 +79,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; } @@ -123,9 +100,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; } @@ -133,7 +111,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 @@ -147,13 +125,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 0f28932384..a14ae1ba3f 100644 --- a/scripts/scr_event_gossip/scr_event_gossip.gml +++ b/scripts/scr_event_gossip/scr_event_gossip.gml @@ -25,24 +25,28 @@ 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"; } @@ -172,11 +176,12 @@ 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) + " "; + 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") + "."; @@ -502,7 +507,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 +517,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 +527,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_garrison/scr_garrison.gml b/scripts/scr_garrison/scr_garrison.gml index 37135c0123..51495b5f18 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++; @@ -117,7 +114,7 @@ function GarrisonForce(system, planet, type = "garrison") constructor { } if (_unit.hp() < 0) { if (_unit.calculate_death()) { - kill_and_recover(_unit.company, _unit.marine_number); + _unit.kill(); members_lost++; array_delete(members, i, 1); } @@ -126,7 +123,7 @@ function GarrisonForce(system, planet, type = "garrison") constructor { _unit.add_or_sub_health(-50); if (_unit.hp() < 0) { if (_unit.calculate_death()) { - kill_and_recover(_unit.company, _unit.marine_number); + _unit.kill(); array_delete(members, i, 1); members_lost++; } @@ -138,33 +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(); - _unit = fetch_unit(_leader); - if (!is_struct(_unit)) { + 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; } } @@ -178,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]; } } }; @@ -293,7 +288,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_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_ini_ship_cleanup/scr_ini_ship_cleanup.gml b/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml index f992b7aaa3..71a269edfb 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; @@ -12,7 +12,7 @@ function scr_kill_ship(index) { if (_unit.ship_location > -1) { if (_unit.ship_location == index) { if (!(irandom(_unit.luck) - 3)) { - scr_kill_unit(_unit.company, _unit.marine_number); + _unit.kill(false, false); } else { array_push(_units_on_ship, _unit); } @@ -148,7 +148,7 @@ function scr_kill_ship(index) { } else { _unit.location_string = ""; } - scr_kill_unit(_unit.company, _unit.marine_number); + unit.kill(false, false); } } } catch (_exception) { diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index b1ac55e869..801d4a411a 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]; @@ -828,6 +827,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 = []; @@ -1456,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"; @@ -1468,28 +1465,6 @@ 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; - } if (variable_instance_exists(obj_creation, "custom_roles")) { var c_roles = obj_creation.custom_roles; var possible_custom_roles = [ @@ -1566,18 +1541,10 @@ 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 - * 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])) { @@ -1587,26 +1554,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; } } } @@ -1614,24 +1562,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 @@ -1742,18 +1690,19 @@ function scr_initialize_custom() { "{squad_name}": _squad_name, }, ]; - var _roles_player = obj_ini.role[100]; - var _default_player = obj_ini.role[101]; - for (var i = 1; i < 20; i++) { - if (_roles_player[i] == "") { + + var _roles_player = player_role_data; + var _default_player = default_role_data; + for (var i = 0; i < 20; 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); } @@ -1761,13 +1710,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); } @@ -1797,11 +1746,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, ], }, @@ -1871,7 +1820,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", @@ -1944,25 +1893,20 @@ 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]); + for (var i = 0; i < array_length(player_role_data); i++) { + if (player_role_data[i].role == "") { + continue; } - if (role[defaults_slot][i] != "") { - scr_start_allow(i, "gear", gear[defaults_slot][i]); + 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); } // check for allowable starting equipment here } initialized = 500; // How many array variables have been prepared - var _marine_i = 0; var _vehicle_i = 0; var _company_i = 0; @@ -1972,70 +1916,52 @@ 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++) { - 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"); - var _unit = TTRPG[c][i]; - _unit.born = _game_year - 50; - _unit.marine_ascension = _game_year - 10; - } - } - // 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); + 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); + _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")) { _hq_armour = "MK6 Corvus"; } - _marine_i += 1; - 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); + + 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; } @@ -2051,87 +1977,58 @@ function scr_initialize_custom() { _forge_master.add_bionics("none", "standard", false); } } - _marine_i += 1; - commands += 1; // 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); + 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"); - _marine_i += 1; - commands += 1; } // 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); + 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")) { - 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); + 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 @@ -2146,13 +2043,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 @@ -2318,7 +2211,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; @@ -2507,7 +2399,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; @@ -2546,39 +2438,6 @@ function scr_initialize_custom() { // SPECIALISTS case "captains": - switch (_coy.coy) { - case 1: - name[_coy.coy][_marine_i] = honor_captain_name != "" ? honor_captain_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 2: - name[_coy.coy][_marine_i] = watch_master_name != "" ? watch_master_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 3: - name[_coy.coy][_marine_i] = arsenal_master_name != "" ? arsenal_master_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 4: - name[_coy.coy][_marine_i] = lord_admiral_name != "" ? lord_admiral_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 5: - name[_coy.coy][_marine_i] = march_master_name != "" ? march_master_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 6: - name[_coy.coy][_marine_i] = rites_master_name != "" ? rites_master_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 7: - name[_coy.coy][_marine_i] = chief_victualler_name != "" ? chief_victualler_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 8: - name[_coy.coy][_marine_i] = lord_executioner_name != "" ? lord_executioner_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 9: - name[_coy.coy][_marine_i] = relic_master_name != "" ? relic_master_name : global.name_generator.ChapterMemberNameGeneration(); - break; - case 10: - name[_coy.coy][_marine_i] = recruiter_name != "" ? recruiter_name : global.name_generator.ChapterMemberNameGeneration(); - break; - } - commands++; _rolename = roles.captain; _erole = eROLE.CAPTAIN; _wep2 = choose_weighted(global.weapon_list_weighted_ranged_pistols); @@ -2592,7 +2451,6 @@ function scr_initialize_custom() { } break; case "chaplains": - commands++; _rolename = roles.chaplain; _erole = eROLE.CHAPLAIN; _wep2 = choose_weighted(global.weapon_list_weighted_ranged_pistols); @@ -2601,11 +2459,10 @@ 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": - commands++; _rolename = roles.apothecary; _erole = eROLE.APOTHECARY; if (squad_distribution != 1 && squad_distribution != 3 && _coy.coy == 8) { @@ -2613,18 +2470,17 @@ 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": - commands++; _rolename = roles.techmarine; _erole = eROLE.TECHMARINE; 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")) { @@ -2636,7 +2492,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) { @@ -2644,7 +2499,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": @@ -2653,7 +2508,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 = ""; @@ -2665,7 +2520,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; @@ -2778,74 +2633,61 @@ 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); } + } } #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); 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); @@ -2868,8 +2710,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); @@ -3004,52 +2846,21 @@ 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]); - obj_ini.race[company][slot] = 1; +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) + 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; - obj_ini.role[company][slot] = 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 { @@ -3072,12 +2883,12 @@ 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); 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); @@ -3085,7 +2896,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(); } @@ -3167,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; @@ -3179,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_inquisition_inspection/scr_inquisition_inspection.gml b/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml index b1d065a1df..9c3081be1b 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) { @@ -574,7 +563,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 2b803d79a8..5c58d3d1f2 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -1,56 +1,55 @@ /// @self Asset.GMObject.obj_controller -function scr_kill_unit(company, unit_slot) { +function scr_kill_unit() { try { - if (obj_ini.role[company][unit_slot] == "Forge Master") { - array_push(obj_ini.previous_forge_masters, obj_ini.name[company][unit_slot]); + if (role() == "Forge Master") { + array_push(obj_ini.previous_forge_masters, name()); } - if (obj_ini.role[company][unit_slot] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { + if (role_compare(self, 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", "+"); - } - _unit.remove_from_squad(); + if (weapon_one() == "Company Standard" || weapon_two() == "Company Standard") { + scr_loyalty("Lost Standard", "+"); + } + remove_from_squad(); - // 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]); - if (is_struct(_art)) { - _art.clear_bearer(); - } + // Drop equipped artifacts at the self's location before the slots are wiped. + var _equipped = equipped_artifacts(); + for (var _e = 0; _e < array_length(_equipped); _e++) { + var _art = fetch_artifact(_equipped[_e]); + if (is_struct(_art)) { + _art.clear_bearer(); + } + } + array_delete(obj_ini.TTRPG[company], marine_number, 1); + var _len = company_length(company); + 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; + } else { + obj_controller.marines -= 1; } } - - scr_wipe_unit(company, unit_slot); } catch (ex) { - LOGGER.error($"company: {company}, unit_slot: {unit_slot}"); + LOGGER.error($"company: {company}, unit_slot: {marine_number}"); ERROR_HANDLER.handle_exception(ex); } } 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); } -function kill_and_recover(company, unit_slot, equipment = true, gene_seed_collect = true) { - var unit = obj_ini.TTRPG[company][unit_slot]; - if (equipment) { +function kill_and_recover(recover_equipment = true, gene_seed_collect = true) { + if (recover_equipment) { var strip = { "wep1": "", "wep2": "", @@ -58,18 +57,13 @@ function kill_and_recover(company, unit_slot, equipment = true, gene_seed_collec "armour": "", "gear": "", }; - unit.alter_equipment(strip, false, true); + alter_equipment(strip, false, true); } - if (gene_seed_collect && unit.base_group == "astartes") { - obj_controller.gene_seed += unit.recoverable_geneseed(); - } - if (obj_ini.race[company][unit_slot] == 1) { - if (is_specialist(obj_ini.role[company][unit_slot])) { - obj_controller.command -= 1; - } else { - obj_controller.marines -= 1; - } + var _is_astartes = base_group == "astartes"; + if (gene_seed_collect && _is_astartes) { + + obj_controller.gene_seed += recoverable_geneseed(); } - scr_kill_unit(company, unit_slot); + scr_kill_unit(); } diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index 05ffcd738f..e9d2bda776 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.role[100][17]) + " " + 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,11 +170,12 @@ 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 = 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); } - 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); + 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); } draw_set_color(#5F730D); 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_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index 8ef146a584..ef4b8727b8 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -73,21 +73,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"; - 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": - _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) { @@ -98,7 +91,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) { @@ -109,54 +102,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_count/scr_marine_count.gml b/scripts/scr_marine_count/scr_marine_count.gml deleted file mode 100644 index 091d55b4d6..0000000000 --- a/scripts/scr_marine_count/scr_marine_count.gml +++ /dev/null @@ -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_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 11cb59165c..09ed146813 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -156,6 +156,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; @@ -167,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"; @@ -176,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; @@ -196,7 +205,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 = [ @@ -234,7 +243,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); @@ -259,7 +268,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 @@ -361,7 +370,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_compare(self, eROLE.CHAPLAIN)) { _cloak_chance += 25; } else if (IsSpecialist(SPECIALISTS_LIBRARIANS)) { _cloak_chance += 75; @@ -409,17 +418,30 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static handle_stat_growth = unit_stat_growth; + static move_to_company = function(new_company, keep_squad = true){ + 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; + if (!keep_squad){ + remove_from_squad(); + } + var _old_company_length = array_length(obj_ini.TTRPG[_old_loc[0]]); + array_delete(obj_ini.TTRPG[_old_loc[0]] , _old_loc[1] , 1); + } + static armour = function(raw = false) { - var wep = obj_ini.armour[company][marine_number]; - 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(); }; static role = function() { - return obj_ini.role[company][marine_number]; + return role1; }; static squad_role = function() { @@ -444,31 +466,34 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (role() == new_role) { return "no change"; } - if (base_group == "astartes") { - if (role() == obj_ini.role[100][12] && new_role != obj_ini.role[100][12]) { + 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; - } - } } - obj_ini.role[company][marine_number] = new_role; + 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.role[100][5]) { + if (new_role == obj_ini.player_role_data[eROLE.CAPTAIN].role) { if (company == 2) { obj_ini.watch_master_name = name(); } @@ -497,11 +522,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", @@ -523,11 +548,11 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static mobility_item = function(raw = false) { - var wep = obj_ini.mobi[company][marine_number]; - 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(); }; @@ -589,7 +614,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; @@ -797,7 +822,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) { @@ -955,29 +980,27 @@ 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]; + return unit_name; }; // get marine name - static set_name = function(new_name) { - obj_ini.name[company][marine_number] = new_name; - return new_name; - }; + static set_name = function(val){ + unit_name = val; + } static gear = function(raw = false) { - var wep = obj_ini.gear[company][marine_number]; - 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(); }; - static weapon_one = function(raw = false) { - var wep = obj_ini.wep1[company][marine_number]; - 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(); }; @@ -1040,7 +1063,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"; } @@ -1052,11 +1075,11 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static weapon_two = function(raw = false) { - var wep = obj_ini.wep2[company][marine_number]; - if (is_string(wep) || raw) { - return wep; + var _wep = wep2; + if (is_string(_wep) || raw) { + return _wep; } - var arti = fetch_artifact(wep); + var arti = fetch_artifact(_wep); return arti.get_type_name(); }; @@ -1167,7 +1190,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); } }; @@ -1776,8 +1799,9 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} for (var r = 0; r < array_length(_squad.members); r++) { squad_member = _squad.members[r]; - if ((squad_member[0] == company) && (squad_member[1] == marine_number)) { + if (squad_member.uid == uid) { array_delete(_squad.members, r, 1); + break; } } @@ -1804,7 +1828,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } squad = new_squad; var _squad = get_squad(); - _squad.add_member(company, marine_number); + _squad.add_member(self); }; static marine_location = function() { @@ -2050,17 +2074,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; - for (var i = 0; i < 24; i++) { - if (obj_ini.role[100][i] == role()) { - role_match = i; - break; + static get_role_data = function(){ + 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; } } - 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() { @@ -2221,39 +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) { - if (squad != "none" && check_squads) { - var squad_data = get_squad(); - var squad_member; - - for (var r = 0; r < array_length(squad_data.members); r++) { - squad_member = squad_data.members[r]; - if (squad_member[0] == company && squad_member[1] == marine_number) { - if (squad_data.base_company != end_company) { - array_delete(squad_data.members, r, 1); - squad = "none"; - // if unit will no longer be same company as squad remove unit from squad - } else { - squad_data.members[r] = [ - end_company, - end_slot, - ]; - } - break; - } - } - } - - 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)) { @@ -2335,6 +2333,8 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } } }; + + static kill = kill_and_recover; } function jsonify_marine_struct(company, marine, stringify = true) { @@ -2367,8 +2367,14 @@ function fetch_unit(unit) { } } +/// @param {Array} 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++) { + 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]); @@ -2381,5 +2387,5 @@ function fetch_unit_uid(uuid) { } } - return "none"; + return undefined; } 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 fee148dc62..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.role[100][eROLE.CHAPTERMASTER]) { - 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_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index ebd77afd93..288811535e 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,9 @@ 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 _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); @@ -146,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"); } } @@ -188,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", @@ -214,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", @@ -308,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"); } @@ -357,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"); } @@ -380,10 +383,10 @@ 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.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(); @@ -421,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_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 56f4aae9e1..bb342f8e1a 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -218,21 +218,17 @@ 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*/ - 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++) { - if ((obj_ini.race[co][me] == 1) && (obj_ini.role[co][me] != "")) { - _unit = fetch_unit([co, me]); - if (!is_struct(_unit)) { - continue; - } - _unit.edit_corruption(irandom_range(3, 6)); - _unit.alter_loyalty(-10); + for (var me = 0; me < company_length(co); me++) { + var _unit = fetch_unit([co, me]); + if (_unit.base_group != "astartes") { + continue } + _unit.edit_corruption(irandom_range(3, 6)); + _unit.alter_loyalty(-10); + } } } @@ -387,11 +383,11 @@ 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) { - 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; @@ -402,7 +398,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; } @@ -470,7 +466,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++) { @@ -729,7 +725,7 @@ function complete_beast_hunt_mission(targ_planet, problem_index) { if (!_tough_check[0]) { if (_tough_check[1] < -10) { _unit_report_string += $"{_unit.name_role()} Was mauled to death\n"; - scr_kill_unit(_unit.company, _unit.marine_number); + _unit.kill(true, false); _deaths++; } else if (_tough_check[1] >= -10) { if (irandom(100) < _unit.luck) { diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml index be982d132e..c673ffb77d 100644 --- a/scripts/scr_mission_reward/scr_mission_reward.gml +++ b/scripts/scr_mission_reward/scr_mission_reward.gml @@ -25,7 +25,7 @@ function scr_mission_reward(mission, star, planet) { var _tech_roll = global.character_tester.standard_test(_tech, "technology", -10)[1]; var _wep_test = global.character_tester.standard_test(_tech, "weapon_skill", 10); if (!_wep_test[0]) { - kill_and_recover(_tech.company, _tech.marine_number, true, false); + _tech.kill(true, false); techs_lost++; cleanup[_tech.company] = true; } else { @@ -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_move_unit_info/scr_move_unit_info.gml b/scripts/scr_move_unit_info/scr_move_unit_info.gml deleted file mode 100644 index 810e1bad12..0000000000 --- a/scripts/scr_move_unit_info/scr_move_unit_info.gml +++ /dev/null @@ -1,41 +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.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]); - - 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_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_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_planetary_feature/scr_planetary_feature.gml b/scripts/scr_planetary_feature/scr_planetary_feature.gml index d460a43899..e11f8fea42 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_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..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 @@ -346,27 +346,21 @@ 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++) { - if (obj_ini.name[co][i] == "") { - continue; - } + for (i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { var unit = fetch_unit([co, i]); if (!is_struct(unit)) { continue; } 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_location, 0); - array_push(board_raft, 0); + array_push(board_marine, unit); boarders += 1; } // Loc 0: on origin 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_player_fleet_functions/scr_player_fleet_functions.gml b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml index 6d70b22ca8..b432dced29 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_player_ship_functions/scr_player_ship_functions.gml b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml index 16d2386fb4..831be96c1f 100644 --- a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml +++ b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml @@ -209,10 +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++) { - if (obj_ini.name[company][marine] == "") { - continue; - } + for (var marine = 0; marine < array_length(obj_ini.TTRPG[company]); marine++) { unit = fetch_unit([company, marine]); if (!is_struct(unit)) { continue; diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index 8cca473cbf..ef0a7b6726 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,38 +314,40 @@ 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"; 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[i]; + 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_post_battle_events/scr_post_battle_events.gml b/scripts/scr_post_battle_events/scr_post_battle_events.gml index d2c03dbad0..ee1e8ffd31 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_powers/scr_powers.gml b/scripts/scr_powers/scr_powers.gml index ebd8f94b50..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; } @@ -521,7 +518,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_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index f193b203d9..4cee0efd68 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -32,108 +32,36 @@ 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; - } - } + + units_to_move = new UnitGroup([]); // 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.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.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"); + - 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; - 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.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) { - scr_move_unit_info(unit.company, target_comp, unit.marine_number, mahreens); - unit = fetch_unit([target_comp, mahreens]); - if (!is_struct(unit)) { - continue; - } - } - 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 _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); } @@ -340,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_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index df38fdefd1..7edd16e00a 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.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,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.role[100][17]), "") >= 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.role[100][eROLE.CHAPTERMASTER] && 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 = cm_obj().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.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", ""); - } 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_random_marine/scr_random_marine.gml b/scripts/scr_random_marine/scr_random_marine.gml index 85c8f38df7..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 = []; @@ -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_recruit_data/scr_recruit_data.gml b/scripts/scr_recruit_data/scr_recruit_data.gml index 9de06bec2b..18e2d1e1ed 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", @@ -874,8 +874,9 @@ function scr_draw_recruit_advisor() { draw_set_font(fnt_40k_14); } + var _cm = cm_obj().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_restart_variables/scr_restart_variables.gml b/scripts/scr_restart_variables/scr_restart_variables.gml deleted file mode 100644 index b214d2b847..0000000000 --- a/scripts/scr_restart_variables/scr_restart_variables.gml +++ /dev/null @@ -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_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 1aae33d420..a10f93af8d 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -1,3 +1,82 @@ + + +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, + wep1 : _wep1, + wep2 : _wep2, + armour : _armour, + mobi : _mobi, + gear : _gear, + 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", "", ""); + 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, "", ""); + + 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(){ + 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 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) && (_unit.is_dreadnought())) { okay = 0; } if (string_count("spyrer", obj_ncombat.battle_special) > 0) { @@ -49,7 +46,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 +59,68 @@ 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; } - 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; } - 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; } - 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; } - 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.role[100][16]) { + 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.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; } - 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; @@ -131,10 +128,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 +139,26 @@ 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.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; } 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 +168,32 @@ 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; } } - 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; } - 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.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) { @@ -204,7 +201,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 +212,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_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; diff --git a/scripts/scr_special_view/scr_special_view.gml b/scripts/scr_special_view/scr_special_view.gml index 34a590e8e5..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; @@ -159,16 +156,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") { @@ -180,7 +177,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 +187,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 +206,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_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 fa6175ac82..844a6f95dd 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"), ]; @@ -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]; @@ -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, ); @@ -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 = obj_ini.player_role_data[eROLE.APOTHECARY]; + + var novice_type = string("{0} Aspirant", _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)) { + 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.player_role_data[eROLE.APOTHECARY].role} training", 0, 0); } } } @@ -212,76 +195,63 @@ 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, ""); 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(_chap_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); + scr_alert("red", "recruitment", $"No remaining {obj_ini.player_role_data[eROLE.CHAPLAIN].role} applicant marines for training", 0, 0); } } } @@ -296,33 +266,30 @@ 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, ""); 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; + + _unit.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)) { + 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_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index a7b7f3708e..88cbd4c236 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 = ""; @@ -296,58 +296,42 @@ 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) || _unit.name() == "") { - 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 = ""; 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 = 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--; continue; } - if (_unit.experience > highest_exp) { - highest_exp = _unit.experience; + if (_unit.experience > _highest_exp) { + _highest_exp = _unit.experience; exp_unit = _unit; } } if ((array_length(members) > 0) && is_struct(exp_unit)) { - if (exp_unit.name() != "") { - var new_role; - if (veteran == true) { - new_role = obj_ini.role[100][19]; - } else { - new_role = obj_ini.role[100][18]; - } - 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"); } } }; - static kill_members = function() { + static kill_members = function(recover_equipment = true, recover_gene = true) { for (var i = 0; i < array_length(members); i++) { - scr_kill_unit(members[i][0], members[i][1]); + members[i].kill(recover_equipment, recover_gene); } members = []; }; @@ -377,10 +361,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 { @@ -401,7 +381,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; @@ -418,7 +398,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 +406,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); @@ -455,19 +435,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++; }; @@ -515,8 +494,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--; @@ -587,21 +566,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 = 0; i < member_length; i++) { - var _unit = fetch_unit(members[i]); - if (!is_struct(_unit) || _unit.name() == "") { + 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); - member_length--; - i--; 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; @@ -609,47 +582,38 @@ 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, - ]; + 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.company, - _unit.marine_number, - ]; + _leader = _unit; break; } } } } } - squad_leader = leader; - return leader; + squad_leader = _leader; + return _leader; }; 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)) { + 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); }; static set_location = function(loc, lid, wid) { @@ -672,7 +636,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_allow/scr_start_allow.gml b/scripts/scr_start_allow/scr_start_allow.gml deleted file mode 100644 index f9d9586e2c..0000000000 --- a/scripts/scr_start_allow/scr_start_allow.gml +++ /dev/null @@ -1,75 +0,0 @@ -function scr_start_allow(role_id, equip_area, equipment) { - var _allow = false; - var _veteran_level = 0; - - if (role_id == eROLE.DREADNOUGHT) { - equip_area[101][role_id] = 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) { - equip_area[101][role_id] = equipment; - } - 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_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index 3e9d9ac1e5..ed2d67ced5 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 < company_length(_comp); _unit++) { + if (is_struct(fetch_unit([_comp, _unit]))) { comp_has_units[_comp] = true; break; } @@ -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.role[_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; @@ -110,11 +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); - if (!is_struct(_marine)) { - continue; - } + var _marine = _members[squad_member]; var marine_size = _marine.get_unit_size(); _company_size += marine_size; array_push(company_loader, _marine); 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; diff --git a/scripts/scr_transfer_marines/scr_transfer_marines.gml b/scripts/scr_transfer_marines/scr_transfer_marines.gml index 9494051a26..c956d83ed1 100644 --- a/scripts/scr_transfer_marines/scr_transfer_marines.gml +++ b/scripts/scr_transfer_marines/scr_transfer_marines.gml @@ -32,104 +32,61 @@ function transfer_marines() { } } + 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] == 1) { - if (obj_controller.man[w] == "man" && is_struct(obj_controller.display_unit[w])) { - var moveable = true; - var unit = obj_controller.display_unit[w]; - 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 (w + mem < array_length(obj_controller.display_unit)) { - if (!is_struct(obj_controller.display_unit[w + mem])) { - continue; - } - if (obj_controller.man_sel[w + mem] != 1 || obj_controller.display_unit[w + 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[w + mem] = 0; - var member_unit = fetch_unit(move_members[mem]); - if (!is_struct(member_unit)) { - continue; - } - 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; - mahreens++; - } - squad.base_company = target_comp; - } - } else { - moveable = false; - } - //move individual - if (!moveable) { - scr_move_unit_info(unit.company, target_comp, unit.marine_number, mahreens, true); - mahreens++; - } - var check = 0; - } else if (obj_controller.man[w] == "vehicle" && is_array(obj_controller.display_unit[w])) { - // This seems to execute the correct number of times - var check = 0; - 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++; - } + if (!obj_controller.man_sel[w]) { + continue; + } + 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 = _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]]; + 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++; } } } - // 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 bdb61d5af6..61aebb3285 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,28 +64,30 @@ 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); 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.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]} {_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]} {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]} {_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 " + string(obj_ini.role[100][14]) + " 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) { @@ -91,7 +96,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."; @@ -136,15 +141,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 +170,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 = ""; @@ -201,8 +206,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 @@ -281,13 +287,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") { @@ -383,7 +389,7 @@ function scr_ui_advisors() { if ((onceh == 0) && (fest_planet == 0)) { onceh = 1; fest_planet = 1; - fest_sid = 0; + fest_sid = -1; fest_wid = 0; fest_star = ""; with (obj_dropdown_sel) { @@ -419,7 +425,7 @@ function scr_ui_advisors() { if ((onceh == 0) && (fest_planet == 1) && (fest_type != "Triumphal March")) { onceh = 1; fest_planet = 0; - fest_sid = 0; + fest_sid = -1; fest_wid = 0; fest_star = ""; with (obj_dropdown_sel) { @@ -640,7 +646,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; } @@ -696,7 +702,7 @@ function scr_ui_advisors() { draw_rectangle(xx + 1132, yy + 780, xx + 1253, yy + 805, 0); if (mouse_button_clicked()) { fest_type = ""; - fest_sid = 0; + fest_sid = -1; fest_wid = 0; fest_planet = 0; fest_star = ""; @@ -743,7 +749,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_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index 5019c6fd5d..4c4f0f641c 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 (!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); } @@ -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)) { @@ -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; diff --git a/scripts/scr_ui_settings/scr_ui_settings.gml b/scripts/scr_ui_settings/scr_ui_settings.gml index f26f87d193..082d4aac7c 100644 --- a/scripts/scr_ui_settings/scr_ui_settings.gml +++ b/scripts/scr_ui_settings/scr_ui_settings.gml @@ -74,17 +74,18 @@ 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 _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; @@ -626,11 +627,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 +643,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 +654,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 +665,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 +676,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, @@ -703,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].role} With Default Items"); if (scr_hit(114, 626, 560, 665) == true) { draw_set_color(c_white); draw_set_alpha(0.2); @@ -860,6 +862,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; @@ -882,29 +886,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) { @@ -951,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")) { 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 ea5ee130b1..812fbedb01 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.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.role[100][eROLE.CHAPTERMASTER]; + 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) { 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 1cd1207eea..f21f4c0d8d 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -97,14 +97,11 @@ 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); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) armour_quality = "artifact"; } else { armour_quality = quality; @@ -121,7 +118,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(""); } @@ -204,14 +201,11 @@ 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); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) weapon_one_quality = "artifact"; } else { weapon_one_quality = quality; @@ -262,14 +256,11 @@ 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); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) weapon_two_quality = "artifact"; } else { weapon_two_quality = quality; @@ -328,14 +319,11 @@ 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); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) gear_quality = "artifact"; } else { gear_quality = quality; @@ -427,14 +415,11 @@ 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); - arti_struct.set_bearer([ - company, - marine_number, - ]); + arti_struct.set_bearer(self) mobility_item_quality = "artifact"; } else { mobility_item_quality = quality; @@ -448,29 +433,47 @@ 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]]; + var _outcome = ""; switch (equip_areas[i]) { case "wep1": - update_weapon_one(update_equipment[$ equip_areas[i]], from_armoury, to_armoury, quality); + _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); + _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); + _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); + _outcome = update_armour(_item, from_armoury, to_armoury, quality); break; case "gear": - update_gear(update_equipment[$ equip_areas[i]], from_armoury, to_armoury, quality); + _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 : _success,description :_outcome_desc}; + + return _final_outcome; + } /// @self Struct.TTRPG_stats @@ -573,21 +576,25 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { } } - items = [ - equipment.wep1, - equipment.wep2, - equipment.armour, - equipment.gear, - equipment.mobi, - ]; + 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, + ]; + } - item_names = [ - equipment.wep1.name, - equipment.wep2.name, - equipment.armour.name, - equipment.gear.name, - equipment.mobi.name, - ]; + update_arrays(); present_items = []; @@ -603,6 +610,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; @@ -887,4 +904,98 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { equipment_found_and_valid, }; }; + + static start_allowable_weapons = function(slot){ + var _allow = true; + var _item = equipment[$ slot].name; + var _normal_equipment = [ + "Combat Knife", + "Chainsword", + "Chainaxe", + "Boarding Shield", + "Bolt Pistol", + "Bolter", + "Flamer", + "Sniper Rifle", + ]; + _allow = array_contains(_normal_equipment, _item); + + if (veteran_level > 0 && !_allow) { + var _special_equipment = [ + "Storm Bolter", + "Meltagun", + "Power Fist", + "Power Sword", + "Power Axe", + ]; + _allow = array_contains(_special_equipment, _item); + } + + if (!_allow){ + final_gear[$ slot] = default_options[$slot]; + } + final_gear[$ slot] = _allow ? _item : default_options[$slot]; + } + + static start_allowable_mobi = function(){ + var _allow = false; + 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 (_item == "Bike" && (veteran_level > 0 || role_id == eROLE.ASSAULT)) { + if (!array_contains([eROLE.TERMINATOR, eROLE.DREADNOUGHT], role_id)) { + _allow = true; + } + } else if (_item == "Heavy Weapons Pack" && role_id == eROLE.DEVASTATOR) { + _allow = true; + } + + 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 && _item == "Rosarius") { + _allow = true; + } else if (role_id == eROLE.TECHMARINE) { + if (array_contains(["Servo-arm", "Servo-harness"], _item)) { + _allow = true; + } + } else if (role_id == eROLE.LIBRARIAN && _item == "Psychic Hood") { + _allow = true; + } else if (role_id == eROLE.APOTHECARY && _item == "Narthecium") { + _allow = true; + } + } + + final_gear.gear = _allow ? _item : default_options.gear; + } + + static start_allowance = function(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; + } } 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..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)) { @@ -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); } @@ -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 { @@ -627,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; } 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 a8bd3c283a..fb79201545 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; @@ -259,13 +259,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 @@ -274,31 +274,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) { @@ -311,7 +311,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")) { @@ -324,7 +324,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; } @@ -346,7 +346,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 { @@ -371,7 +371,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); @@ -385,7 +385,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 { @@ -398,12 +398,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"); @@ -412,7 +412,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) { @@ -462,10 +462,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); @@ -486,7 +486,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) { @@ -495,7 +495,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 {