From fd20c2d4f8f4fc88c0f7607893df10b97c66caa4 Mon Sep 17 00:00:00 2001 From: Nyx <80511023+The-Real-Nyx@users.noreply.github.com> Date: Fri, 28 Aug 2026 20:00:38 -0400 Subject: [PATCH] fix: Repair demon summon ship battle The roster scan probed slots 1 through 300 for each of 11 companies regardless of the company's bounds. After #1414 removed the obj_ini.name sentinel, probes past the end of a roster reached fetch_unit and reported an index-out-of-bounds error for every invalid slot. The scan now iterates each stored company over its valid zero-based bounds, which also lets the first marine in each company join the battle. The summon branch also skipped the normal combat-scene handoff, so map instances remained active over the battle and the shared formation columns could retain the previous battle's values. It now performs the scene handoff before creating combat, applies its configured formation before building the roster, and closes the Librarium once the battle is built. --- scripts/ArtifactStruct/ArtifactStruct.gml | 8 +++++ scripts/scr_ship_battle/scr_ship_battle.gml | 38 +++++++-------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/scripts/ArtifactStruct/ArtifactStruct.gml b/scripts/ArtifactStruct/ArtifactStruct.gml index 0fb479a1bc..a584cd8fd7 100644 --- a/scripts/ArtifactStruct/ArtifactStruct.gml +++ b/scripts/ArtifactStruct/ArtifactStruct.gml @@ -203,6 +203,7 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, }; /// @desc Destroys the artifact. Daemonic artifacts destroyed while on a ship may trigger a demon summoning battle. + /// @returns {Undefined} static destroy_artifact = function() { if (has_tag("daemonic")) { var _resolved = __resolve_location(); @@ -210,13 +211,20 @@ function ArtifactStruct(_type_name = "", _tags = [], _identification_timer = 0, var demonSummonChance = roll_dice_chapter(1, 100, "high"); if ((demonSummonChance <= DEMON_SUMMON_THRESHOLD) && (obj_ini.ship_carrying[_resolved.ship_id] > 0)) { + instance_deactivate_all_safe(); + instance_activate_object(obj_star); + /// @type {Asset.GMObject.obj_ncombat} var _combat = instance_create_depth(0, 0, 0, obj_ncombat); _combat.battle_special = "ship_demon"; _combat.formation_set = 1; _combat.enemy = DEMON_SUMMON_ENEMIES; _combat.battle_id = _resolved.ship_id; + + instance_deactivate_object(obj_star); + setup_battle_formations(); scr_ship_battle(_resolved.ship_id, 999); + main_map_defaults(); } } } diff --git a/scripts/scr_ship_battle/scr_ship_battle.gml b/scripts/scr_ship_battle/scr_ship_battle.gml index 14f126aaff..5ea6960c0a 100644 --- a/scripts/scr_ship_battle/scr_ship_battle.gml +++ b/scripts/scr_ship_battle/scr_ship_battle.gml @@ -1,3 +1,7 @@ +/// @desc Builds the player roster for a boarding battle aboard the target ship. +/// @param {Real} target_ship_id Index into obj_ini.ship of the ship the battle is fought over. +/// @param {Real} cooridor_width Second ship index whose occupants also count as present. +/// @returns {Undefined} function scr_ship_battle(target_ship_id, cooridor_width) { // determine occupants // determine who is fighting @@ -5,32 +9,17 @@ function scr_ship_battle(target_ship_id, cooridor_width) { // set battle special // if (argument2=true){ - var co, v, stop, okay, sofar, _unit; - co = 0; - v = 0; - stop = 0; - okay = 0; - sofar = 0; - - repeat (3600) { - if (co < 11) { - v += 1; - okay = 0; - - if (v > 300) { - co += 1; - v = 1; - } + var sofar = 0; - if (co > 10) { - stop = 1; - } + for (var co = 0; co < array_length(obj_ini.TTRPG); co++) { + var _company_length = company_length(co); - if (stop == 0) { - _unit = fetch_unit([co, v]); - if (!is_struct(_unit)) { - continue; - } + for (var v = 0; v < _company_length; v++) { + var okay = 0; + var _unit = fetch_unit([co, v]); + if (!is_struct(_unit)) { + continue; + } if ((_unit.ship_location == target_ship_id) && _unit.hp()) { okay = 1; } @@ -213,7 +202,6 @@ 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); - } } } }