Skip to content
2,264 changes: 1,857 additions & 407 deletions datafiles/main/chapters/1.JSON

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion datafiles/main/squads/base_squads.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"devastator",
"scout",
"tactical"
]
],
"base" : "command"
}
},

Expand Down
2 changes: 1 addition & 1 deletion scripts/scr_UnitGroup/scr_UnitGroup.gml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function UnitGroup(units) constructor {
_squad = _unit.get_squad();

if (!struct_exists(_squad_index, _squad.type)) {
_squad_index[_squad.type] = [];
_squad_index[$ _squad.type] = [];
}
array_push(_squad_index[$ _squad.type], _unit.squad);
}
Expand Down
8 changes: 8 additions & 0 deletions scripts/scr_chapter_new/scr_chapter_new.gml
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,18 @@ function scr_chapter_new(chapter_identifier) {
obj_creation.custom_squads = chapter_object.custom_squads;
}

if (struct_exists(chapter_object, "squad_builder")) {
obj_creation.squad_builder = chapter_object.squad_builder;
}
Comment thread
OH296 marked this conversation as resolved.

if (struct_exists(chapter_object, "custom_advisors")) {
obj_creation.custom_advisors = chapter_object.custom_advisors;
}

if (struct_exists(chapter_object, "companies")) {
Comment thread
OH296 marked this conversation as resolved.
obj_creation.companies = chapter_object.companies;
}

// Validate and clamp trait values to sane ranges (defaulting if missing/invalid)
obj_creation.strength = clamp(is_real(chapter_object.strength) ? chapter_object.strength : 5, 1, 10);
obj_creation.purity = clamp(is_real(chapter_object.purity) ? chapter_object.purity : 5, 1, 10);
Expand Down
4 changes: 2 additions & 2 deletions scripts/scr_company_order/scr_company_order.gml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function scr_company_order(company) {

_squad.update_fulfilment(_squadless_index);

if (!_squad.fulfilled && _squad.type != "command_squad") {
if (!_squad.fulfilled && _squad.base != "command") {
Comment thread
OH296 marked this conversation as resolved.
_squad.empty_squad_to_index(_squadless_index);
}
}
Expand All @@ -58,7 +58,7 @@ function scr_company_order(company) {
for (var i = 0; i < array_length(_empty_squads); i++) {
var _squad = _empty_squads[i];
_squad.update_fulfilment(_squadless_index);
if (!_squad.fulfilled && _squad.type != "command_squad") {
if (!_squad.fulfilled && _squad.base != "command") {
_squad.empty_squad_to_index(_squadless_index);
} else {
_squad.base_company = co;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l
if (_unit.IsSpecialist(SPECIALISTS_COMMAND)) {
changed = true;
} else if (_unit.squad != "none") {
if (fetch_squad(_unit.squad).type == "command_squad") {
if (fetch_squad(_unit.squad).base == "command") {
Comment thread
OH296 marked this conversation as resolved.
changed = true;
}
}
Expand Down
56 changes: 39 additions & 17 deletions scripts/scr_initialize_custom/scr_initialize_custom.gml
Original file line number Diff line number Diff line change
Expand Up @@ -1697,26 +1697,25 @@ function scr_initialize_custom() {
// LOGGER.debug($"squads object for chapter {chapter_name}");
// LOGGER.debug($"{custom_squads}");

if (struct_exists(obj_creation, "custom_squads")) {
var custom_squads = obj_creation.custom_squads;
// LOGGER.debug($"custom roles {custom_squads}");
if (array_length(struct_get_names(custom_squads)) != 0) {
var names = struct_get_names(custom_squads);
// LOGGER.debug($"names {names}");
for (var n = 0; n < array_length(names); n++) {
var _squad_name = names[n];
// LOGGER.debug($"matched squad name name {_squad_name}");

if (struct_exists(custom_squads, _squad_name)) {
var custom_squad = struct_get(custom_squads, _squad_name);
// LOGGER.debug($"overwriting squad layout for {_squad_name}");
// LOGGER.debug($"{custom_squad}")
variable_struct_set(custom_squads, _squad_name, custom_squad);
if (struct_exists(obj_creation, "squad_builder")){
Comment thread
OH296 marked this conversation as resolved.
for (var s=0; s<array_length(obj_creation.squad_builder);s++){
var _custom_build = obj_creation.squad_builder[s];
for (var i=0;i<array_length(obj_ini.chapter_squad_arrangement.companies);i++){
var _default_build = obj_ini.chapter_squad_arrangement.companies[i];
if (_custom_build.company == _default_build.company){
obj_ini.chapter_squad_arrangement.companies[i] = _custom_build;
}
}
}
}

if (struct_exists(obj_creation, "custom_squads")) {
var _customs = obj_creation.custom_squads;
with (squad_types){
move_data_to_current_scope(_customs);
}
}

// LOGGER.debug($"roles object for chapter {chapter_name} after setting from obj");
// LOGGER.debug($"{custom_squads}");

Expand Down Expand Up @@ -2360,10 +2359,33 @@ function scr_initialize_custom() {
LOGGER.info($"New Company Totals: eq specialists: {equal_specialists}: scout coy {scout_company_behaviour} equal_scouts: {equal_scouts}");
// LOGGER.info($"Company {_coy.coy}: {json_stringify(_coy, true)}");

var attrs = struct_get_names(_coy);

var _set_company_makeup = function(old_values, new_values){
var _override_keys = struct_get_names(new_values);
var _override_keys_count = array_length(_override_keys);
for (var j = 0; j < _override_keys_count; j++) {
var _okey_hash = _override_keys[j];
var _okey_ins = new_values[$ _okey_hash];
LOGGER.info($"{_okey_hash}<{_okey_ins}<{old_values}")
old_values[$ _okey_hash] = _okey_ins;
}
return old_values;
}
if (struct_exists(obj_creation, "companies")) {
var _company_keys = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"];
var _company_keys_count = array_length(_company_keys);
for (var i = 0; i < _company_keys_count; i++) {
var _company_string = _company_keys[i]
if (struct_exists(obj_creation.companies, _company_string) && struct_exists(companies, _company_string)) {
var _ckey_ins = obj_creation.companies[$ _company_string];
var _ckey_var = companies[$ _company_string];
companies[$ _company_string] = _set_company_makeup(_ckey_var, _ckey_ins);
}
}
}
// LOGGER.info($"attrs {attrs}");
Comment thread
OH296 marked this conversation as resolved.

var attrs = struct_get_names(_coy);

for (var _a = 0, _alen = array_length(attrs); _a < _alen; _a++) {
var _is_vehicle = false;
var _rolename;
Expand Down
6 changes: 6 additions & 0 deletions scripts/scr_squads/scr_squads.gml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor {
class = [];
squad_leader = "";
type_data = {};
base = "tactical";
formation_place = "";
formation_options = [];
uid = scr_uuid_generate();
Expand Down Expand Up @@ -223,6 +224,11 @@ function UnitSquad(squad_type = undefined, company = 0) constructor {
if (struct_exists(type_data, "class")) {
class = type_data.class;
}
if (struct_exists(type_data, "base")) {
base = type_data.base;
} else {
base = "tactical";
}
if (struct_exists(type_data, "formation_options")) {
formation_options = type_data.formation_options;
formation_place = formation_options[0];
Expand Down
Loading