From 0db92db56eb400ab39c1f943d82f8980bb0b6b05 Mon Sep 17 00:00:00 2001 From: UltiNaruto Date: Wed, 23 Oct 2024 19:12:46 +0200 Subject: [PATCH] Add an option in game config to start with Great Tree Hall bars opened --- schema/randomprime.schema.json | 5 +++++ src/patch_config.rs | 6 ++++++ src/patches.rs | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/schema/randomprime.schema.json b/schema/randomprime.schema.json index 6fa54ccd..48054522 100644 --- a/schema/randomprime.schema.json +++ b/schema/randomprime.schema.json @@ -813,6 +813,11 @@ "type": "boolean", "default": false }, + "greatTreeHallBarsOpened": { + "description": "Bars in Tallon Overworld - Great Tree Hall are pre-opened.", + "type": "boolean", + "default": false + }, "incineratorDroneConfig": { "description": "Replace the 'random add' timer values us in the Incinerator Drone miniboss fight with constants.", "type": "object", diff --git a/src/patch_config.rs b/src/patch_config.rs index 74ba023f..004f425c 100644 --- a/src/patch_config.rs +++ b/src/patch_config.rs @@ -1394,6 +1394,7 @@ pub struct PatchConfig { pub remove_mine_security_station_locks: bool, pub remove_hive_mecha: bool, pub power_bomb_arboretum_sandstone: bool, + pub great_tree_hall_bars_opened: bool, pub visible_bounding_box: bool, pub door_destination_scans: bool, pub no_hud: bool, @@ -1554,6 +1555,7 @@ struct GameConfig { remove_mine_security_station_locks: Option, remove_hive_mecha: Option, power_bomb_arboretum_sandstone: Option, + great_tree_hall_bars_opened: Option, incinerator_drone_config: Option, maze_seeds: Option>, @@ -2644,6 +2646,10 @@ impl PatchConfigPrivate { .game_config .power_bomb_arboretum_sandstone .unwrap_or(false), + great_tree_hall_bars_opened: self + .game_config + .great_tree_hall_bars_opened + .unwrap_or(false), incinerator_drone_config: self.game_config.incinerator_drone_config.clone(), maze_seeds: self.game_config.maze_seeds.clone(), diff --git a/src/patches.rs b/src/patches.rs index a28e2647..e7bf5222 100644 --- a/src/patches.rs +++ b/src/patches.rs @@ -15657,6 +15657,37 @@ fn patch_arboretum_sandstone(patcher: &mut PrimePatcher<'_, '_>) { }); } +fn make_great_tree_hall_bars_opened(patcher: &mut PrimePatcher<'_, '_>) +{ + patcher.add_scly_patch(resource_info!("04_over_tree.MREA").into(), |_ps, area| { + let (gate_solved_layer_idx, gate_unsolved_layer_idx) = ( + area.get_layer_id_from_name("Gate Solved"), + area.get_layer_id_from_name("Gate Unsolved"), + ); + let flags = &mut area.layer_flags.flags; + *flags |= 1 << gate_solved_layer_idx; // Turn on "Gate Solved" + *flags &= !(1 << gate_unsolved_layer_idx); // Turn off "Gate Unsolved" + + // disable scan point for closed bars + area.set_memory_relay_active(0x002402c8, 1); + + let scly = area.mrea().scly_section_mut(); + + // activate solved bars + let obj = scly.layers + .as_mut_vec()[0] + .objects + .iter_mut() + .find(|obj| obj.instance_id & 0xffff == 0x1F6) + .and_then(|obj| obj.property_data.as_platform_mut()) + .unwrap(); + + obj.active = 1; + + Ok(()) + }); +} + pub fn patch_iso(config: PatchConfig, mut pn: T) -> Result<(), String> where T: structs::ProgressNotifier, @@ -17946,6 +17977,10 @@ fn build_and_run_patches<'r>( patch_arboretum_sandstone(&mut patcher); } + if config.great_tree_hall_bars_opened { + make_great_tree_hall_bars_opened(&mut patcher); + } + if let Some(bomb_slot_covers) = config.hall_of_the_elders_bomb_slot_covers { patch_hall_of_the_elders_bomb_slot_covers(&mut patcher, bomb_slot_covers) }